diff options
| author | Aiden Cline <[email protected]> | 2025-07-30 11:43:34 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-30 11:43:34 -0500 |
| commit | 09074dc6394c910f22ca690e24336be6ebb2fc6d (patch) | |
| tree | 9dd6badbed780788d307b7f8035f14d9c819a982 /packages/tui/internal/components/chat/message.go | |
| parent | 1b3d58e7919714dbeefc571c278ec65b90154c7d (diff) | |
| download | opencode-09074dc6394c910f22ca690e24336be6ebb2fc6d.tar.gz opencode-09074dc6394c910f22ca690e24336be6ebb2fc6d.zip | |
fix: attachment highlighting (#1427)
Diffstat (limited to 'packages/tui/internal/components/chat/message.go')
| -rw-r--r-- | packages/tui/internal/components/chat/message.go | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/packages/tui/internal/components/chat/message.go b/packages/tui/internal/components/chat/message.go index ff361e76e..5c92dee5c 100644 --- a/packages/tui/internal/components/chat/message.go +++ b/packages/tui/internal/components/chat/message.go @@ -182,6 +182,7 @@ func renderText( showToolDetails bool, width int, extra string, + fileParts []opencode.FilePart, toolCalls ...opencode.ToolPart, ) string { t := theme.CurrentTheme() @@ -197,19 +198,15 @@ func renderText( ts = time.UnixMilli(int64(casted.Time.Created)) base := styles.NewStyle().Foreground(t.Text()).Background(backgroundColor) text = ansi.WordwrapWc(text, width-6, " -") - lines := strings.Split(text, "\n") - for i, line := range lines { - words := strings.Fields(line) - for i, word := range words { - if strings.HasPrefix(word, "@") { - words[i] = base.Foreground(t.Secondary()).Render(word + " ") - } else { - words[i] = base.Render(word + " ") - } - } - lines[i] = strings.Join(words, "") + + // Build list of attachment filenames for highlighting + for _, filePart := range fileParts { + atFilename := "@" + filePart.Filename + // Find and highlight complete @filename references + highlightStyle := base.Foreground(t.Secondary()) + text = strings.ReplaceAll(text, atFilename, highlightStyle.Render(atFilename)) } - text = strings.Join(lines, "\n") + content = base.Width(width - 6).Render(text) } |
