fix QoL and Ai integration

This commit is contained in:
2026-07-29 09:13:16 +02:00
parent 07e8bc2f5b
commit a82f5e7e9f
13 changed files with 472 additions and 84 deletions

View File

@@ -342,7 +342,7 @@ func (m App) updateAI(msg tea.Msg) (tea.Model, tea.Cmd, bool) {
}
default:
if key.Type == tea.KeyRunes || key.Type == tea.KeySpace {
m.aiInput += string(key.Runes)
m.aiInput += textInputKeyValue(key)
}
}
m.scroll = m.detailMaxScroll()
@@ -391,7 +391,8 @@ func withoutLocalAI(pr PRDetails) PRDetails {
func slicesDeleteLocalAIComments(comments []ReviewComment) []ReviewComment {
result := comments[:0]
for _, comment := range comments {
if comment.Origin != reviewOriginLocalAI {
if comment.Origin != reviewOriginLocalAI &&
comment.Origin != reviewOriginLocalAIUser {
result = append(result, comment)
}
}
@@ -441,10 +442,9 @@ func (m App) viewAI() string {
case aiDiscussion:
lines = append(lines, titleStyle.Render("Local AI discussion"), "",
dimStyle.Render("This message stays local; only the configured model receives it."), "")
draft := m.aiInput + "│"
for _, source := range strings.Split(draft, "\n") {
lines = append(lines, strings.Split(ansi.Wordwrap(source, width-2, ""), "\n")...)
}
lines = append(lines, renderTextInput(
m.aiInput, width-2, m.cursorOutput != nil,
)...)
if m.err != nil {
lines = append(lines, "", badStyle.Render(m.err.Error()))
}
@@ -587,10 +587,14 @@ func renderAIProgressBar(width int, progress AIRunProgress, spinner int) string
}
func localAICommentBadge(comment ReviewComment) string {
if comment.Origin != reviewOriginLocalAI {
switch comment.Origin {
case reviewOriginLocalAI:
return " " + warnStyle.Render("[LOCAL AI · LOCAL ONLY]")
case reviewOriginLocalAIUser:
return " " + warnStyle.Render("[LOCAL ONLY]")
default:
return ""
}
return " " + warnStyle.Render("[LOCAL AI · LOCAL ONLY]")
}
func (m App) inlineAIDiscussionLines(width int) []detailLine {
@@ -603,17 +607,13 @@ func (m App) inlineAIDiscussionLines(width int) []detailLine {
warnStyle.Render("[LOCAL ONLY]"),
},
}
draft := m.aiInput + "│"
textWidth := max(1, width-4)
textWidth := max(1, width-5)
lineIndex := 0
for _, sourceLine := range strings.Split(draft, "\n") {
wrapped := ansi.Hardwrap(ansi.Wordwrap(sourceLine, textWidth, ""), textWidth, false)
for _, part := range strings.Split(wrapped, "\n") {
lines = append(lines, detailLine{
rail: rail, anchor: fmt.Sprintf("ai-discussion:body:%d", lineIndex), text: part,
})
lineIndex++
}
for _, part := range renderTextInput(m.aiInput, textWidth, m.cursorOutput != nil) {
lines = append(lines, detailLine{
rail: rail, anchor: fmt.Sprintf("ai-discussion:body:%d", lineIndex), text: part,
})
lineIndex++
}
if m.err != nil {
lines = append(lines, detailLine{rail: rail, text: badStyle.Render(m.err.Error())})