xonecas.io
62159
Sy

symb / commit e5da8c4

fix: can click grep results? maybe

xonecas2026-02-14 e5da8c40d08f0d48a24ee72b6f2a42c9470e4339 parent dbbea61

2 files changed

internal/tui/mouse.go+6−9
@@ -289,15 +289,12 @@ func (m *Model) handleConvClick(wrappedLine int) tea.Cmd {
289289 return nil
290290 }
291291 }
292- // Fallback: show raw tool result text
293- if entry.full != "" {
294- m.editor.SetValue(entry.full)
295- m.editor.Language = "text"
296- m.editor.SetGutterMarkers(nil)
297- m.editor.DiagnosticLines = nil
298- m.editorFilePath = ""
299- m.setFocus(focusEditor)
300- return nil
292+ // No file path on entry (e.g. Grep/Shell): try to extract a
293+ // file:line reference from the clicked line itself.
294+ lines := m.wrappedConvLines()
295+ if wrappedLine < len(lines) {
296+ plain := ansi.Strip(lines[wrappedLine])
297+ return m.tryOpenFilePath(plain)
301298 }
302299 }
303300
internal/tui/update.go+28−21
@@ -268,16 +268,7 @@ func (m *Model) flushRebuild(needed bool) bool {
268268 // applyAssistantMsg finalizes streaming state and appends the assistant's
269269 // response entries. Extracted so handleLLMBatch can reuse the logic.
270270 func (m *Model) applyAssistantMsg(msg llmAssistantMsg) {
271- if m.streaming {
272- m.streaming = false
273- if m.streamEntryStart >= 0 && m.streamEntryStart <= len(m.convEntries) {
274- m.convEntries = m.convEntries[:m.streamEntryStart]
275- }
276- m.streamEntryStart = -1
277- m.streamingReasoning = ""
278- m.streamingContent = ""
279- m.convLines = nil
280- }
271+ m.clearStreaming()
281272 if msg.reasoning != "" {
282273 wasBottom := m.appendText(styledLines(msg.reasoning, m.styles.Muted)...)
283274 m.appendText("")
@@ -305,20 +296,27 @@ func (m *Model) applyAssistantMsg(msg llmAssistantMsg) {
305296 }
306297 }
307298
299+// clearStreaming resets active streaming state.
300+func (m *Model) clearStreaming() {
301+ if !m.streaming {
302+ return
303+ }
304+ m.streaming = false
305+ if m.streamEntryStart >= 0 && m.streamEntryStart <= len(m.convEntries) {
306+ m.convEntries = m.convEntries[:m.streamEntryStart]
307+ }
308+ m.streamEntryStart = -1
309+ m.streamingReasoning = ""
310+ m.streamingContent = ""
311+ m.convLines = nil
312+}
313+
308314 // applyToolResultMsg appends tool result display entries.
309315 // It also clears any active streaming state (e.g. from ShellOutputMsg)
310316 // so the next applyAssistantMsg doesn't truncate the tool result entries.
311317 func (m *Model) applyToolResultMsg(msg llmToolResultMsg) {
312- if m.streaming {
313- m.streaming = false
314- if m.streamEntryStart >= 0 && m.streamEntryStart <= len(m.convEntries) {
315- m.convEntries = m.convEntries[:m.streamEntryStart]
316- }
317- m.streamEntryStart = -1
318- m.streamingReasoning = ""
319- m.streamingContent = ""
320- m.convLines = nil
321- }
318+ m.clearStreaming()
319+
322320 var filePath string
323321 if sm := toolResultFileRe.FindStringSubmatch(msg.content); sm != nil {
324322 filePath = sm[1]
@@ -333,10 +331,19 @@ func (m *Model) applyToolResultMsg(msg llmToolResultMsg) {
333331 startLine = toolCallEditLine(tc.Arguments)
334332 }
335333
334+ // Determine the tool name for display decisions.
335+ var toolName string
336+ if tc, ok := m.pendingToolCalls[msg.toolCallID]; ok {
337+ toolName = tc.Name
338+ }
339+
340+ // Grep and Shell show all lines (each clickable); others truncate.
341+ showFull := toolName == "Grep" || toolName == "Shell"
342+
336343 lines := strings.Split(msg.content, "\n")
337344 preview := lines
338345 truncated := false
339- if len(lines) > maxPreviewLines {
346+ if !showFull && len(lines) > maxPreviewLines {
340347 preview = lines[:maxPreviewLines]
341348 truncated = true
342349 }