xonecas.io
62159
Sy

symb / commit 0071d95

fix: conversation log improvements

xonecas2026-02-16 0071d95a218d07166e2063a7d0f88c3fa8ceb422 parent 49f7f53

8 files changed

cmd/symb/main.go+0−4
@@ -111,10 +111,6 @@ func main() {
111111 svc.lspManager.SetCallback(func(absPath string, lines map[int]int) {
112112 p.Send(tui.LSPDiagnosticsMsg{FilePath: absPath, Lines: lines})
113113 })
114- // Wire shell output streaming to TUI.
115- svc.shellHandler.OnOutput = func(chunk string) {
116- p.Send(tui.ShellOutputMsg{Content: chunk})
117- }
118114
119115 if _, err := p.Run(); err != nil {
120116 fmt.Printf("Error running symb: %v\n", err)
internal/tui/messages.go+0−4
@@ -53,10 +53,6 @@ type llmErrorMsg struct{ err error }
5353 type llmContentDeltaMsg struct{ content string }
5454 type llmReasoningDeltaMsg struct{ content string }
5555
56-// ShellOutputMsg carries incremental shell output for real-time display.
57-// Exported so main.go can send it via program.Send from the shell handler callback.
58-type ShellOutputMsg struct{ Content string }
59-
6056 // tickMsg drives the 60fps frame loop (~16ms). Rendering work (highlight,
6157 // wrap) is deferred to this tick so streaming deltas don't cause per-batch
6258 // rebuilds.
internal/tui/mouse.go+7−13
@@ -54,11 +54,6 @@ func (m Model) handleMouse(msg tea.MouseMsg) (tea.Model, tea.Cmd) {
5454 // --- Focus switching on click -------------------------------------------
5555 m.handleFocusClick(msg, x, y)
5656
57- // --- Hover: clear when outside conv area --------------------------------
58- if _, isMotion := msg.(tea.MouseMotionMsg); isMotion && !inRect(x, y, m.layout.conv) {
59- m.hoverConvLine = -1
60- }
61-
6257 // --- Editor: forward with original coords (left pane starts at 0) -------
6358 if inRect(x, y, m.layout.editor) {
6459 var cmd tea.Cmd
@@ -155,14 +150,7 @@ func (m *Model) handleConvMotion(x, y, totalLines int) {
155150 } else if !m.convDragging && m.convSel != nil {
156151 m.convSel = nil
157152 }
158- if totalLines > 0 {
159- lineIdx := m.visibleStartLine() + (y - m.layout.conv.Min.Y)
160- if lineIdx >= 0 && lineIdx < totalLines && m.isClickableLine(lineIdx) {
161- m.hoverConvLine = lineIdx
162- } else {
163- m.hoverConvLine = -1
164- }
165- }
153+
166154 }
167155
168156 func (m *Model) handleConvRelease(x, y, totalLines int) tea.Cmd {
@@ -251,6 +239,9 @@ func (m *Model) isClickableLine(lineIdx int) bool {
251239 }
252240 return false
253241 }
242+ if m.convEntries[entryIdx].kind == entryToolDiag {
243+ return false
244+ }
254245 if m.convEntries[entryIdx].kind == entryUndo {
255246 return true
256247 }
@@ -276,6 +267,9 @@ func (m *Model) handleConvClick(wrappedLine int) tea.Cmd {
276267 return nil
277268 }
278269 entry := m.convEntries[entryIdx]
270+ if entry.kind == entryToolDiag {
271+ return nil
272+ }
279273
280274 // Undo control: emit undoMsg
281275 if entry.kind == entryUndo {
internal/tui/selection.go+48−8
@@ -60,18 +60,58 @@ func (m *Model) selectedConvText() string {
6060 return sb.String()
6161 }
6262
63-// renderConvLine renders a single conversation line with optional hover or selection highlight.
64-// Returns the styled line. Padding is handled by the caller.
65-func (m Model) renderConvLine(line string, lineIdx, _ int, bgFill lipgloss.Style) string {
66- // Hover highlight (selection takes priority below)
67- if m.hoverConvLine == lineIdx && (m.convSel == nil || m.convSel.empty()) {
68- plain := ansi.Strip(line)
69- return m.styles.Hover.Render(plain)
63+// applyClickableStyle styles the first line of a clickable entry only.
64+func (m Model) applyClickableStyle(line string, lineIdx int, bgFill lipgloss.Style) string {
65+ if !m.isClickableLine(lineIdx) {
66+ return line
67+ }
68+ m.wrappedConvLines()
69+ src := m.convLineSource
70+ if lineIdx < 0 || lineIdx >= len(src) {
71+ return line
72+ }
73+ entryIdx := src[lineIdx]
74+ if entryIdx < 0 || entryIdx >= len(m.convEntries) {
75+ return line
7076 }
77+ if lineIdx > 0 && src[lineIdx-1] == entryIdx {
78+ return line
79+ }
80+ entry := m.convEntries[entryIdx]
81+ plain := ansi.Strip(line)
82+ if entry.kind == entryUndo {
83+ return styleUndoLine(plain, bgFill, m.styles.Clickable)
84+ }
85+ return m.styles.Clickable.Render(plain)
86+}
7187
88+func styleUndoLine(plain string, bgFill, clickable lipgloss.Style) string {
89+ const undoLabel = "undo"
90+ idx := strings.LastIndex(plain, undoLabel)
91+ if idx == -1 {
92+ return clickable.Render(plain)
93+ }
94+ before := plain[:idx]
95+ after := plain[idx+len(undoLabel):]
96+ var sb strings.Builder
97+ if before != "" {
98+ sb.WriteString(bgFill.Render(before))
99+ }
100+ sb.WriteString(clickable.Render(undoLabel))
101+ if after != "" {
102+ sb.WriteString(bgFill.Render(after))
103+ }
104+ return sb.String()
105+}
106+
107+// renderConvLine renders a single conversation line with optional selection highlight.
108+// Returns the styled line. Padding is handled by the caller.
109+func (m Model) renderConvLine(line string, lineIdx, _ int, bgFill lipgloss.Style) string {
72110 if m.convSel == nil || m.convSel.empty() {
73- return line
111+ return m.applyClickableStyle(line, lineIdx, bgFill)
74112 }
113+ line = m.applyClickableStyle(line, lineIdx, bgFill)
114+
75115 s, e := m.convSel.ordered()
76116 if lineIdx < s.line || lineIdx > e.line {
77117 return line
internal/tui/styles.go+3−3
@@ -42,8 +42,8 @@ type Styles struct {
4242 Selection lipgloss.Style // Mouse text selection highlight
4343 BgFill lipgloss.Style // Background fill for empty areas
4444
45- // Hover
46- Hover lipgloss.Style // Highlight text on subtle dark bg for clickable hover
45+ // Clickable
46+ Clickable lipgloss.Style // Clickable text background/foreground
4747
4848 // Status bar
4949 StatusText lipgloss.Style // Status bar text
@@ -65,7 +65,7 @@ func DefaultStyles() Styles {
6565 Selection: lipgloss.NewStyle().Background(ColorSurface).Foreground(ColorBg),
6666 BgFill: bg,
6767
68- Hover: lipgloss.NewStyle().Background(ColorLinkBg).Foreground(ColorHighlight),
68+ Clickable: lipgloss.NewStyle().Background(ColorLinkBg).Foreground(ColorHighlight),
6969
7070 StatusText: bg.Foreground(ColorDim),
7171 }
internal/tui/tui.go+1−4
@@ -113,6 +113,7 @@ type entryKind int
113113 const (
114114 entryText entryKind = iota // Plain text (user, assistant, separator)
115115 entryToolResult // Tool result — clickable to view full content in editor
116+ entryToolDiag // Tool diagnostics — non-clickable
116117 entryUndo // Undo control — clickable to undo last turn
117118 entrySeparator // Demoted undo — a turn-end separator that can be re-promoted
118119 )
@@ -251,9 +252,6 @@ type Model struct {
251252 convSel *convSelection
252253 convDragging bool
253254
254- // Hover state: wrapped line index under cursor (-1 = none)
255- hoverConvLine int
256-
257255 // Frame loop
258256 streamDirty bool // New streaming content arrived since last rebuild
259257 frameLines []string // Per-frame cache of wrapped conv lines (cleared each Update)
@@ -346,7 +344,6 @@ func New(prov provider.Provider, proxy *mcp.Proxy, tools []mcp.Tool, modelID str
346344 searcher: newSearcherOrNil("."),
347345
348346 streamEntryStart: -1,
349- hoverConvLine: -1,
350347
351348 providerConfigName: providerConfigName,
352349 }
internal/tui/update.go+38−11
@@ -12,6 +12,7 @@ import (
1212 tea "charm.land/bubbletea/v2"
1313 "github.com/rs/zerolog/log"
1414 "github.com/xonecas/symb/internal/filesearch"
15+ "github.com/xonecas/symb/internal/hashline"
1516 "github.com/xonecas/symb/internal/provider"
1617 "github.com/xonecas/symb/internal/tui/modal"
1718 )
@@ -68,12 +69,6 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
6869 m.mcpTools = msg.Tools
6970 return m, nil
7071
71- case ShellOutputMsg:
72- m.ensureStreaming()
73- m.streamingContent += msg.Content
74- m.streamDirty = true
75- return m, nil
76-
7772 case undoMsg:
7873 return m.handleUndo(), nil
7974
@@ -467,8 +462,7 @@ func (m *Model) clearStreaming() {
467462 }
468463
469464 // applyToolResultMsg appends tool result display entries.
470-// It also clears any active streaming state (e.g. from ShellOutputMsg)
471-// so the next applyAssistantMsg doesn't truncate the tool result entries.
465+// It also clears any active streaming state so the next applyAssistantMsg doesn't truncate the tool result entries.
472466 func (m *Model) applyToolResultMsg(msg llmToolResultMsg) {
473467 m.clearStreaming()
474468
@@ -485,6 +479,9 @@ func (m *Model) applyToolResultMsg(msg llmToolResultMsg) {
485479 } else if tc, ok := m.pendingToolCalls[msg.toolCallID]; ok && tc.Name == "Edit" {
486480 startLine = toolCallEditLine(tc.Arguments)
487481 }
482+ if startLine == 0 && filePath != "" {
483+ startLine = toolResultHashlineStart(msg.content, filePath)
484+ }
488485
489486 body, diagLines := extractDiagLines(msg.content)
490487 if idx := strings.Index(body, "\n"); idx >= 0 {
@@ -495,7 +492,7 @@ func (m *Model) applyToolResultMsg(msg llmToolResultMsg) {
495492 entry := convEntry{display: arrow + m.styleToolResultLine(body), kind: entryToolResult, filePath: filePath, full: msg.content, line: startLine}
496493 wasBottom := m.appendConv(entry)
497494 for _, dl := range diagLines {
498- m.appendConv(convEntry{display: m.styleToolResultLine(dl), kind: entryToolResult, filePath: filePath, full: msg.content, line: startLine})
495+ m.appendConv(convEntry{display: m.styleToolResultLine(dl), kind: entryToolDiag, full: msg.content})
499496 }
500497 if wasBottom {
501498 m.scrollOffset = 0
@@ -517,8 +514,6 @@ func extractDiagLines(content string) (body string, diags []string) {
517514 return content[:idx], diags
518515 }
519516
520-
521-
522517 // styleToolResultLine applies semantic styling to a tool result line.
523518 // Diagnostic lines (ERROR/WARNING) get colored; everything else is dim.
524519 func (m *Model) styleToolResultLine(line string) string {
@@ -566,6 +561,38 @@ func toolCallEditLine(args json.RawMessage) int {
566561 return 0
567562 }
568563
564+// toolResultHashlineStart scans a tool result body for the first hashline and
565+// returns its line number if it matches the provided file path.
566+func toolResultHashlineStart(content, filePath string) int {
567+ prefix := "Read " + filePath + " "
568+ if !strings.HasPrefix(content, prefix) {
569+ prefix = "Edited " + filePath + " "
570+ if !strings.HasPrefix(content, prefix) {
571+ prefix = "Created " + filePath + " "
572+ if !strings.HasPrefix(content, prefix) {
573+ return 0
574+ }
575+ }
576+ }
577+ lines := strings.Split(content, "\n")
578+ for _, line := range lines {
579+ if line == "" {
580+ continue
581+ }
582+ idx := strings.IndexByte(line, '|')
583+ if idx <= 0 {
584+ continue
585+ }
586+ anchor := line[:idx]
587+ parsed, err := hashline.ParseAnchor(anchor)
588+ if err != nil {
589+ continue
590+ }
591+ return parsed.Num
592+ }
593+ return 0
594+}
595+
569596 // formatToolCall renders a tool call as Name(key="val", key2="val2").
570597 // Long values are truncated. Falls back to Name(...) on parse errors.
571598 func formatToolCall(tc provider.ToolCall) string {
internal/tui/view.go+2−6
@@ -86,21 +86,17 @@ func (m Model) renderRightPaneRow(b *strings.Builder, convLines, inputLines []st
8686 }
8787 }
8888
89-// renderConvRow writes one conversation line with selection/hover highlight.
89+// renderConvRow writes one conversation line with selection highlight.
9090 func (m Model) renderConvRow(b *strings.Builder, convLines []string, lineIdx, rw int, bgFill lipgloss.Style) {
9191 if lineIdx >= len(convLines) {
9292 b.WriteString(bgFill.Render(strings.Repeat(" ", rw)))
9393 return
9494 }
9595 line := m.renderConvLine(convLines[lineIdx], lineIdx, rw, bgFill)
96- padFill := bgFill
97- if m.hoverConvLine == lineIdx && (m.convSel == nil || m.convSel.empty()) {
98- padFill = m.styles.Hover
99- }
10096 lw := lipgloss.Width(line)
10197 b.WriteString(line)
10298 if lw < rw {
103- b.WriteString(padFill.Render(strings.Repeat(" ", rw-lw)))
99+ b.WriteString(bgFill.Render(strings.Repeat(" ", rw-lw)))
104100 }
105101 }