xonecas.io
62159
Sy

symb / commit 7446a4b

feat: cleanup of the conversation pane

xonecas2026-02-17 7446a4b021fb4be74902de28a4d5d855c47b146a parent 0ce88c4

6 files changed

internal/tui/conv.go+50−28
@@ -119,39 +119,44 @@ func formatTokens(n int) string {
119119 return fmt.Sprintf("%.1fk", float64(n)/1000)
120120 }
121121
122-// makeSeparator builds a right-aligned timestamp/token separator line.
123-func (m Model) makeSeparator(dur string, ts string, tokIn, tokOut, totalTok, ctxTok int) string {
122+// makeSeparator builds a timestamp/token separator label.
123+// Centering is applied at render time so it adapts to resizes.
124+func makeSeparator(sty Styles, dur, ts string, tokIn, tokOut, totalTok, ctxTok int) string {
124125 var label string
125126 if tokIn > 0 || tokOut > 0 {
126- label = fmt.Sprintf("%s %s ↓ %s ↑ %s Σ %s ◔ %s", dur, ts, formatTokens(tokIn), formatTokens(tokOut), formatTokens(totalTok), formatTokens(ctxTok))
127+ label = fmt.Sprintf("%s %s ↓%s ↑%s Σ%s ◔%s", ts, dur, formatTokens(tokIn), formatTokens(tokOut), formatTokens(totalTok), formatTokens(ctxTok))
127128 } else {
128- label = dur + " " + ts
129+ label = ts + " " + dur
129130 }
130- w := m.convWidth()
131- pad := w - lipgloss.Width(label)
132- if pad < 0 {
133- pad = 0
134- }
135- return m.styles.Dim.Render(strings.Repeat(" ", pad) + label)
131+ return sty.Dim.Render(label)
136132 }
137133
138134 // makeUndoEntry creates convEntries for the undo control: the separator line
139-// plus a right-aligned "undo" line below it.
135+// plus a centered [undo] button below it. Centering is applied at render time.
140136 // sepDisplay is the styled separator text to restore if the undo entry is demoted.
141137 func (m Model) makeUndoEntry(sepDisplay string) []convEntry {
142- undoLabel := "undo"
143- w := m.convWidth()
144- pad := w - lipgloss.Width(undoLabel)
145- if pad < 0 {
146- pad = 0
147- }
148- undoLine := m.styles.Dim.Render(strings.Repeat(" ", pad) + undoLabel)
149138 return []convEntry{
150139 {display: sepDisplay, kind: entrySeparator, full: sepDisplay},
151- {display: undoLine, kind: entryUndo, full: sepDisplay},
140+ {display: m.styles.Clickable.Render("undo"), kind: entryUndo, full: sepDisplay},
152141 }
153142 }
154143
144+// isCentered returns true if the wrapped line at lineIdx belongs to a
145+// separator or undo entry that should be centered in the conversation pane.
146+// Caller must ensure convLineSource is fresh (call wrappedConvLines first).
147+func (m Model) isCentered(lineIdx int) bool {
148+ src := m.convLineSource
149+ if lineIdx < 0 || lineIdx >= len(src) {
150+ return false
151+ }
152+ entryIdx := src[lineIdx]
153+ if entryIdx < 0 || entryIdx >= len(m.convEntries) {
154+ return false
155+ }
156+ k := m.convEntries[entryIdx].kind
157+ return k == entrySeparator || k == entryUndo
158+}
159+
155160 // visibleStartLine returns the index of the first visible wrapped conversation line.
156161 func (m *Model) visibleStartLine() int {
157162 lines := m.wrappedConvLines()
@@ -168,8 +173,7 @@ func (m *Model) visibleStartLine() int {
168173 }
169174
170175 // historyConvEntries rebuilds conversation display entries from loaded history.
171-func historyConvEntries(msgs []provider.Message) []convEntry {
172- sty := DefaultStyles()
176+func historyConvEntries(msgs []provider.Message, sty Styles) []convEntry {
173177 var entries []convEntry
174178 for _, msg := range msgs {
175179 switch msg.Role {
@@ -179,24 +183,42 @@ func historyConvEntries(msgs []provider.Message) []convEntry {
179183 if msg.Content == "" {
180184 continue
181185 }
186+ entries = append(entries, convEntry{display: "", kind: entryText})
182187 entries = append(entries, textEntries(highlightMarkdown(msg.Content, sty.Text)...)...)
188+ entries = append(entries, convEntry{display: "", kind: entryText})
183189 case roleAssistant:
190+ if msg.Reasoning != "" {
191+ entries = append(entries, textEntries(styledLines(msg.Reasoning, sty.Muted)...)...)
192+ entries = append(entries, convEntry{display: "", kind: entryText})
193+ }
184194 if msg.Content != "" {
185195 entries = append(entries, textEntries(highlightMarkdown(msg.Content, sty.Text)...)...)
196+ entries = append(entries, convEntry{display: "", kind: entryText})
186197 }
187198 for _, tc := range msg.ToolCalls {
188- line := formatToolCall(tc)
189- entries = append(entries, convEntry{display: line, kind: entryToolResult, full: line})
199+ display := sty.ToolArrow.Render("→") + " " + sty.ToolCall.Render(formatToolCall(tc))
200+ entries = append(entries, convEntry{display: display, kind: entryToolCall})
190201 }
191202 case "tool":
192- // tool results stored as content; show abbreviated
193203 if msg.Content != "" {
194204 lines := strings.SplitN(msg.Content, "\n", 2)
195- display := lines[0]
196- if len(display) > 200 {
197- display = display[:200] + "…"
205+ body := lines[0]
206+ if len(body) > 200 {
207+ body = body[:200] + "…"
208+ }
209+ arrow := sty.ToolArrow.Render("←") + " "
210+ display := arrow + sty.Dim.Render(body) + " " + sty.Clickable.Render("view")
211+
212+ var filePath string
213+ if sm := toolResultFileRe.FindStringSubmatch(msg.Content); sm != nil {
214+ filePath = sm[1]
198215 }
199- entries = append(entries, convEntry{display: display, kind: entryToolResult, full: msg.Content})
216+ entries = append(entries, convEntry{
217+ display: display,
218+ kind: entryToolResult,
219+ filePath: filePath,
220+ full: msg.Content,
221+ })
200222 }
201223 }
202224 }
internal/tui/mouse.go+134−59
@@ -8,6 +8,7 @@ import (
88 "time"
99
1010 tea "charm.land/bubbletea/v2"
11+ "charm.land/lipgloss/v2"
1112 "github.com/charmbracelet/x/ansi"
1213 "github.com/xonecas/symb/internal/highlight"
1314 )
@@ -156,9 +157,15 @@ func (m *Model) handleConvMotion(x, y, totalLines int) {
156157 func (m *Model) handleConvRelease(x, y, totalLines int) tea.Cmd {
157158 m.convDragging = false
158159 if m.convSel != nil && m.convSel.empty() {
159- clickedLine := m.convPosFromScreen(x, y, totalLines).line
160+ cp := m.convPosFromScreen(x, y, totalLines)
160161 m.convSel = nil
161- return m.handleConvClick(clickedLine)
162+ // Ignore clicks on empty space past the last wrapped line.
163+ startLine := m.visibleStartLine()
164+ screenLine := startLine + (y - m.layout.conv.Min.Y)
165+ if screenLine >= totalLines {
166+ return nil
167+ }
168+ return m.handleConvClick(cp.line, cp.col)
162169 }
163170 return nil
164171 }
@@ -216,8 +223,10 @@ func (m Model) translateMouse(msg tea.MouseMsg, offX, offY int) tea.Msg {
216223 return msg
217224 }
218225
219-// isClickableLine returns true if the wrapped line at lineIdx is clickable
220-// (tool result entry or contains a file path reference).
226+// isClickableLine returns true if the wrapped line at lineIdx is clickable.
227+// Tool result entries (first line only, which has the [view] button) and undo
228+// entries are always clickable. Plain text lines are clickable only if they
229+// contain a file path reference.
221230 func (m *Model) isClickableLine(lineIdx int) bool {
222231 lines := m.wrappedConvLines() // ensures convLineSource is also fresh
223232 src := m.convLineSource
@@ -228,35 +237,31 @@ func (m *Model) isClickableLine(lineIdx int) bool {
228237 if entryIdx < 0 || entryIdx >= len(m.convEntries) {
229238 return false
230239 }
231- if m.convEntries[entryIdx].kind == entryToolResult {
232- // Entries with a file path (Read/Edit/Create) are always clickable.
233- if m.convEntries[entryIdx].filePath != "" {
234- return true
235- }
236- // Others (Grep/Shell) only if the line itself contains a file path.
237- if lineIdx < len(lines) {
238- return filePathRe.MatchString(ansi.Strip(lines[lineIdx]))
240+ entry := m.convEntries[entryIdx]
241+ switch entry.kind {
242+ case entryToolResult:
243+ // Only the first wrapped line (containing [view]) is clickable.
244+ if lineIdx > 0 && src[lineIdx-1] == entryIdx {
245+ return false
239246 }
240- return false
241- }
242- if m.convEntries[entryIdx].kind == entryToolDiag {
243- return false
244- }
245- if m.convEntries[entryIdx].kind == entryUndo {
246247 return true
247- }
248- if lineIdx >= len(lines) {
248+ case entryUndo:
249+ return true
250+ case entryToolDiag, entryToolCall, entrySeparator:
249251 return false
252+ default:
253+ // Plain text: clickable if it contains a file path.
254+ if lineIdx >= len(lines) {
255+ return false
256+ }
257+ return filePathRe.MatchString(ansi.Strip(lines[lineIdx]))
250258 }
251- plain := ansi.Strip(lines[lineIdx])
252- return filePathRe.MatchString(plain)
253259 }
254260
255261 // handleConvClick resolves a click on a wrapped conversation line.
256-// If the line belongs to a tool result entry, the full content is opened in
257-// the editor. Otherwise, if the line contains a file path reference
258-// (path/to/file.go:123), that file is opened in the editor.
259-func (m *Model) handleConvClick(wrappedLine int) tea.Cmd {
262+// Tool result [view] buttons open the relevant content in the editor.
263+// Undo buttons trigger an undo. Plain text file paths open the file.
264+func (m *Model) handleConvClick(wrappedLine, col int) tea.Cmd {
260265 m.wrappedConvLines() // ensure convLineSource is fresh
261266 src := m.convLineSource
262267 if wrappedLine < 0 || wrappedLine >= len(src) {
@@ -267,50 +272,120 @@ func (m *Model) handleConvClick(wrappedLine int) tea.Cmd {
267272 return nil
268273 }
269274 entry := m.convEntries[entryIdx]
270- if entry.kind == entryToolDiag {
275+
276+ switch entry.kind {
277+ case entryUndo:
278+ if m.isClickOnCenteredLabel(entry.display, col) {
279+ return func() tea.Msg { return undoMsg{} }
280+ }
281+ return nil
282+
283+ case entryToolResult:
284+ // Only trigger on the [view] label at the end of the line.
285+ if m.isClickOnViewLabel(entry.display, col) {
286+ return m.handleToolResultView(entry)
287+ }
271288 return nil
289+
290+ case entryToolDiag, entryToolCall, entrySeparator:
291+ return nil
292+
293+ default:
294+ // Plain text: try to open a file path reference.
295+ lines := m.wrappedConvLines()
296+ if wrappedLine >= len(lines) {
297+ return nil
298+ }
299+ return m.tryOpenFilePath(ansi.Strip(lines[wrappedLine]))
272300 }
301+}
273302
274- // Undo control: emit undoMsg
275- if entry.kind == entryUndo {
276- return func() tea.Msg { return undoMsg{} }
303+// isClickOnCenteredLabel checks whether a column falls within a centered
304+// label's visible text area in the conversation pane.
305+func (m *Model) isClickOnCenteredLabel(display string, col int) bool {
306+ rw := m.convWidth()
307+ lw := lipgloss.Width(display)
308+ pad := (rw - lw) / 2
309+ if pad < 0 {
310+ pad = 0
277311 }
312+ return col >= pad && col < pad+lw
313+}
278314
279- // Tool result: open the source file or fall back to raw content
280- if entry.kind == entryToolResult {
315+// isClickOnViewLabel checks whether a column falls on the "view" label
316+// at the end of a tool result line.
317+func (m *Model) isClickOnViewLabel(display string, col int) bool {
318+ const viewLabel = "view"
319+ lw := lipgloss.Width(display)
320+ viewStart := lw - len(viewLabel)
321+ if viewStart < 0 {
322+ viewStart = 0
323+ }
324+ return col >= viewStart && col < lw
325+}
326+
327+// handleToolResultView opens the appropriate content in the editor for a
328+// tool result [view] click, based on the tool type.
329+func (m *Model) handleToolResultView(entry convEntry) tea.Cmd {
330+ switch entry.toolName {
331+ case "Read":
332+ // Open file with cursor in the middle of the read range.
281333 if entry.filePath != "" {
282- absPath, _ := filepath.Abs(entry.filePath)
283- if content, err := os.ReadFile(entry.filePath); err == nil {
284- m.editor.SetValue(string(content))
285- m.editor.Language = highlight.DetectLanguage(entry.filePath)
286- m.editor.SetGutterMarkers(GitFileMarkers(m.ctx, entry.filePath))
287- m.editor.DiagnosticLines = nil
288- m.editorFilePath = absPath
289- m.lspErrors = 0
290- m.lspWarnings = 0
291- if entry.line > 0 {
292- m.editor.GotoLine(entry.line)
293- }
294- m.setFocus(focusEditor)
295- return nil
296- }
334+ return m.openFileAtCenter(entry.filePath, entry.line, entry.full)
297335 }
298- // No file path on entry (e.g. Grep/Shell): try to extract a
299- // file:line reference from the clicked line itself.
300- lines := m.wrappedConvLines()
301- if wrappedLine < len(lines) {
302- plain := ansi.Strip(lines[wrappedLine])
303- return m.tryOpenFilePath(plain)
336+ case "Edit":
337+ // Open file with cursor at the end of the changes.
338+ if entry.filePath != "" {
339+ return m.openFile(entry.filePath, entry.line)
304340 }
341+ case "Shell":
342+ // Show the command output in the editor as plain text.
343+ m.showRawContent(entry.full, "text")
344+ return nil
345+ case "WebFetch", "WebSearch":
346+ // Show search/fetch results as markdown.
347+ m.showRawContent(entry.full, "markdown")
348+ return nil
349+ case "SubAgent":
350+ // Show the subagent's response as markdown.
351+ m.showRawContent(entry.full, "markdown")
352+ return nil
353+ default:
354+ // Fallback: try file path, then show raw content.
355+ if entry.filePath != "" {
356+ return m.openFile(entry.filePath, entry.line)
357+ }
358+ m.showRawContent(entry.full, "text")
359+ return nil
305360 }
361+ // Fallback for tools with no file path.
362+ m.showRawContent(entry.full, "text")
363+ return nil
364+}
306365
307- // Try to extract a file path from the clicked line's plain text
308- lines := m.wrappedConvLines()
309- if wrappedLine >= len(lines) {
310- return nil
366+// openFileAtCenter opens a file and positions the cursor in the middle of the
367+// read range (for Read tool results).
368+func (m *Model) openFileAtCenter(path string, startLine int, content string) tea.Cmd {
369+ if sm := toolResultRangeRe.FindStringSubmatch(content); sm != nil {
370+ start, _ := strconv.Atoi(sm[1])
371+ end, _ := strconv.Atoi(sm[2])
372+ if start > 0 && end >= start {
373+ return m.openFile(path, (start+end)/2)
374+ }
311375 }
312- plain := ansi.Strip(lines[wrappedLine])
313- return m.tryOpenFilePath(plain)
376+ return m.openFile(path, startLine)
377+}
378+
379+// showRawContent loads raw text content into the editor for viewing.
380+func (m *Model) showRawContent(content, language string) {
381+ m.editor.SetValue(content)
382+ m.editor.Language = language
383+ m.editor.SetGutterMarkers(nil)
384+ m.editor.DiagnosticLines = nil
385+ m.editorFilePath = ""
386+ m.lspErrors = 0
387+ m.lspWarnings = 0
388+ m.setFocus(focusEditor)
314389 }
315390
316391 // tryOpenFilePath looks for a file:line reference in text and opens it in the editor.
internal/tui/selection.go+12−28
@@ -60,8 +60,10 @@ func (m *Model) selectedConvText() string {
6060 return sb.String()
6161 }
6262
63-// applyClickableStyle styles the first line of a clickable entry only.
64-func (m Model) applyClickableStyle(line string, lineIdx int, bgFill lipgloss.Style) string {
63+// applyClickableStyle returns the line as-is for entries that are already
64+// pre-styled (undo, tool results with [view]). For plain text lines
65+// containing file path references, it applies the clickable highlight.
66+func (m Model) applyClickableStyle(line string, lineIdx int, _ lipgloss.Style) string {
6567 if !m.isClickableLine(lineIdx) {
6668 return line
6769 }
@@ -74,39 +76,21 @@ func (m Model) applyClickableStyle(line string, lineIdx int, bgFill lipgloss.Sty
7476 if entryIdx < 0 || entryIdx >= len(m.convEntries) {
7577 return line
7678 }
77- if lineIdx > 0 && src[lineIdx-1] == entryIdx {
78- return line
79- }
8079 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-}
87-
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))
80+ // Undo and tool results are pre-styled with clickable elements.
81+ if entry.kind == entryUndo || entry.kind == entryToolResult {
82+ return line
9983 }
100- sb.WriteString(clickable.Render(undoLabel))
101- if after != "" {
102- sb.WriteString(bgFill.Render(after))
84+ // Plain text with file path reference — highlight the whole line.
85+ if lineIdx > 0 && src[lineIdx-1] == entryIdx {
86+ return line
10387 }
104- return sb.String()
88+ return m.styles.Clickable.Render(ansi.Strip(line))
10589 }
10690
10791 // renderConvLine renders a single conversation line with optional selection highlight.
10892 // Returns the styled line. Padding is handled by the caller.
109-func (m Model) renderConvLine(line string, lineIdx, _ int, bgFill lipgloss.Style) string {
93+func (m Model) renderConvLine(line string, lineIdx int, bgFill lipgloss.Style) string {
11094 if m.convSel == nil || m.convSel.empty() {
11195 return m.applyClickableStyle(line, lineIdx, bgFill)
11296 }
internal/tui/tui.go+11−6
@@ -112,11 +112,12 @@ func (m *Model) setFocus(f focus) {
112112 type entryKind int
113113
114114 const (
115- entryText entryKind = iota // Plain text (user, assistant, separator)
116- entryToolResult // Tool result — clickable to view full content in editor
115+ entryText entryKind = iota // Plain text (user, assistant, reasoning)
116+ entryToolCall // Tool call arrow line (→ ToolName(...))
117+ entryToolResult // Tool result summary (← summary [view])
117118 entryToolDiag // Tool diagnostics — non-clickable
118- entryUndo // Undo control — clickable to undo last turn
119- entrySeparator // Demoted undo — a turn-end separator that can be re-promoted
119+ entryUndo // Undo button — small clickable label
120+ entrySeparator // Turn-end separator (timestamp + tokens)
120121 )
121122
122123 // convEntry is a single logical entry in the conversation pane.
@@ -124,8 +125,9 @@ type convEntry struct {
124125 display string // Styled text for rendering (may be truncated for tool results)
125126 kind entryKind // Entry type
126127 filePath string // Source file path (for tool results that reference a file)
127- full string // Fallback raw content (when no file path, e.g. Grep results)
128+ full string // Full raw content (for editor viewing or undo separator restore)
128129 line int // Target line (1-indexed) for cursor positioning on click (0 = none)
130+ toolName string // Tool name for view button context (Read, Edit, Shell, etc.)
129131 }
130132
131133 // toolResultFileRe extracts the file path from "Read path ..." / "Edited path ..." / "Created path ..." headers.
@@ -134,6 +136,9 @@ var toolResultFileRe = regexp.MustCompile(`^(?:Read|Edited|Created)\s+(\S+)`)
134136 // toolResultLineRe extracts the start line from "(lines N-M)" in tool result headers.
135137 var toolResultLineRe = regexp.MustCompile(`\(lines\s+(\d+)-\d+\)`)
136138
139+// toolResultRangeRe extracts both start and end lines from "(lines N-M)".
140+var toolResultRangeRe = regexp.MustCompile(`\(lines\s+(\d+)-(\d+)\)`)
141+
137142 // filePathRe matches file references like "path/to/file.go:123" or just "path/to/file.go".
138143 // Requires a '/' to avoid matching version numbers like "v1.0".
139144 var filePathRe = regexp.MustCompile(`(?:^|[\s(])([a-zA-Z0-9_./-]*[/][a-zA-Z0-9_.-]+\.[a-zA-Z]\w*)(?::(\d+))?`)
@@ -319,7 +324,7 @@ func New(prov provider.Provider, proxy *mcp.Proxy, tools []mcp.Tool, modelID str
319324
320325 var entries []convEntry
321326 if resumeHistory != nil {
322- entries = historyConvEntries(resumeHistory)
327+ entries = historyConvEntries(resumeHistory, sty)
323328 } else {
324329 systemPrompt := llm.BuildSystemPrompt(modelID, idx)
325330 systemMsg := provider.Message{Role: "system", Content: systemPrompt, CreatedAt: time.Now()}
internal/tui/update.go+24−8
@@ -292,11 +292,9 @@ func (m *Model) handleUserMsg(msg llmUserMsg) Model {
292292 outputTokens: m.totalOutputTokens,
293293 })
294294
295- m.appendText(highlightMarkdown(msg.content, m.styles.Text)...)
296- m.appendText("")
297- sep := m.makeSeparator("0s", now.Format("15:04:05"), 0, 0, 0, 0)
298- wasBottom := m.appendText(sep)
299295 m.appendText("")
296+ m.appendText(highlightMarkdown(msg.content, m.styles.Text)...)
297+ wasBottom := m.appendText("")
300298 m.turnInputTokens = 0
301299 m.turnOutputTokens = 0
302300 m.turnContextTokens = 0
@@ -363,7 +361,7 @@ func (m Model) handleLLMBatch(batch llmBatchMsg) (tea.Model, tea.Cmd) {
363361 m.demoteOldUndo()
364362 m.appendText("")
365363 m.turnContextTokens = msg.contextTokens
366- sep := m.makeSeparator(msg.duration.Round(time.Second).String(), msg.timestamp,
364+ sep := makeSeparator(m.styles, msg.duration.Round(time.Second).String(), msg.timestamp,
367365 msg.inputTokens, msg.outputTokens, m.totalInputTokens+m.totalOutputTokens, m.turnContextTokens)
368366 m.appendConv(m.makeUndoEntry(sep)...)
369367 m.trimOldTurns()
@@ -492,8 +490,8 @@ func (m *Model) applyAssistantMsg(msg llmAssistantMsg) {
492490 m.pendingToolCalls = make(map[string]provider.ToolCall)
493491 }
494492 m.pendingToolCalls[tc.ID] = tc
495- entry := m.styles.ToolArrow.Render("→") + " " + m.styles.ToolCall.Render(formatToolCall(tc))
496- wasBottom := m.appendText(entry)
493+ display := m.styles.ToolArrow.Render("→") + " " + m.styles.ToolCall.Render(formatToolCall(tc))
494+ wasBottom := m.appendConv(convEntry{display: display, kind: entryToolCall})
497495 if wasBottom {
498496 m.scrollOffset = 0
499497 }
@@ -539,6 +537,12 @@ func (m *Model) applyToolResultMsg(msg llmToolResultMsg) {
539537 filePath = sm[1]
540538 }
541539
540+ // Resolve the tool name from the pending call.
541+ var toolName string
542+ if tc, ok := m.pendingToolCalls[msg.toolCallID]; ok {
543+ toolName = tc.Name
544+ }
545+
542546 // Extract target line for cursor positioning.
543547 // Read results: from "(lines N-M)". Edit results: from the tool call arguments.
544548 var startLine int
@@ -556,8 +560,20 @@ func (m *Model) applyToolResultMsg(msg llmToolResultMsg) {
556560 body = body[:idx]
557561 }
558562
563+ // Build display: "← summary [view]"
559564 arrow := m.styles.ToolArrow.Render("←") + " "
560- entry := convEntry{display: arrow + m.styleToolResultLine(body), kind: entryToolResult, filePath: filePath, full: msg.content, line: startLine}
565+ summary := arrow + m.styleToolResultLine(body)
566+ viewBtn := " " + m.styles.Clickable.Render("view")
567+ display := summary + viewBtn
568+
569+ entry := convEntry{
570+ display: display,
571+ kind: entryToolResult,
572+ filePath: filePath,
573+ full: msg.content,
574+ line: startLine,
575+ toolName: toolName,
576+ }
561577 wasBottom := m.appendConv(entry)
562578 for _, dl := range diagLines {
563579 m.appendConv(convEntry{display: m.styleToolResultLine(dl), kind: entryToolDiag, full: msg.content})
internal/tui/view.go+16−1
@@ -92,8 +92,23 @@ func (m Model) renderConvRow(b *strings.Builder, convLines []string, lineIdx, rw
9292 b.WriteString(bgFill.Render(strings.Repeat(" ", rw)))
9393 return
9494 }
95- line := m.renderConvLine(convLines[lineIdx], lineIdx, rw, bgFill)
95+ line := m.renderConvLine(convLines[lineIdx], lineIdx, bgFill)
9696 lw := lipgloss.Width(line)
97+
98+ // Center separator and undo entries.
99+ if m.isCentered(lineIdx) {
100+ pad := (rw - lw) / 2
101+ if pad > 0 {
102+ b.WriteString(bgFill.Render(strings.Repeat(" ", pad)))
103+ b.WriteString(line)
104+ trail := rw - pad - lw
105+ if trail > 0 {
106+ b.WriteString(bgFill.Render(strings.Repeat(" ", trail)))
107+ }
108+ return
109+ }
110+ }
111+
97112 b.WriteString(line)
98113 if lw < rw {
99114 b.WriteString(bgFill.Render(strings.Repeat(" ", rw-lw)))