xonecas.io
62159
Sy

symb / commit e16dc68

fix: selection and copy paste. v2 of charm libs

xonecas2026-02-13 e16dc68aec2f160dab56003d687f57d953de1699 parent 91fe4cb

22 files changed

This diff is too big to show in full. The first 1000 lines are below, and every file is listed with its counts.

cmd/symb/main.go+1−3
@@ -7,7 +7,7 @@ import (
77 "path/filepath"
88 "time"
99
10- tea "github.com/charmbracelet/bubbletea"
10+ tea "charm.land/bubbletea/v2"
1111 "github.com/rs/zerolog"
1212 "github.com/rs/zerolog/log"
1313 "github.com/xonecas/symb/internal/config"
@@ -143,8 +143,6 @@ func main() {
143143 // Create the BubbleTea program with model-specific prompt
144144 p := tea.NewProgram(
145145 tui.New(prov, proxy, tools, providerCfg.Model),
146- tea.WithAltScreen(),
147- tea.WithMouseCellMotion(),
148146 tea.WithFilter(tui.MouseEventFilter),
149147 )
150148
docs/mouse-selection-tui.md+0−363
@@ -1,363 +0,0 @@
1-# Mouse & Selection in Bubbletea TUIs
2-
3-Reference document based on patterns from Charm's Crush (production TUI using
4-Bubbletea v2 + Lipgloss v2). Applies directly to our stack.
5-
6----
7-
8-## 1. Mouse Modes
9-
10-Bubbletea supports two mouse tracking modes:
11-
12-- **CellMotion** (`tea.WithMouseCellMotion()` / `MouseModeCellMotion`): reports
13- presses, releases, and motion *while a button is held* (i.e. drags). This is
14- what you want for selection. Does NOT report hover.
15-- **AllMotion** (`tea.WithMouseAllMotion()` / `MouseModeAllMotion`): also
16- reports motion with no button held. Expensive — avoid unless hover is needed.
17-
18-Crush uses CellMotion. So do we.
19-
20-## 2. Mouse Message Types (Bubbletea v2)
21-
22-Bubbletea v2 splits the old `tea.MouseMsg` into distinct types:
23-
24-| Type | When fired |
25-|---------------------|----------------------------------|
26-| `tea.MouseClickMsg` | Button pressed |
27-| `tea.MouseMotionMsg`| Motion while button held (drag) |
28-| `tea.MouseReleaseMsg`| Button released |
29-| `tea.MouseWheelMsg` | Scroll wheel |
30-
31-Bubbletea v1 (what we use) has a single `tea.MouseMsg` with `.Action` field:
32-
33-| `msg.Action` | Equivalent v2 type |
34-|---------------------------|-----------------------|
35-| `tea.MouseActionPress` | `tea.MouseClickMsg` |
36-| `tea.MouseActionMotion` | `tea.MouseMotionMsg` |
37-| `tea.MouseActionRelease` | `tea.MouseReleaseMsg` |
38-
39-And `msg.Button` for wheel: `tea.MouseButtonWheelUp`, `tea.MouseButtonWheelDown`.
40-
41-## 3. Event Throttling
42-
43-Trackpads and high-refresh mice flood the event queue. Use `tea.WithFilter` to
44-throttle motion and wheel events at the program level:
45-
46-```go
47-var lastMouseEvent time.Time
48-
49-func MouseEventFilter(_ tea.Model, msg tea.Msg) tea.Msg {
50- switch msg.(type) {
51- case tea.MouseWheelMsg, tea.MouseMotionMsg:
52- now := time.Now()
53- if now.Sub(lastMouseEvent) < 15*time.Millisecond {
54- return nil // drop event
55- }
56- lastMouseEvent = now
57- }
58- return msg
59-}
60-```
61-
62-For v1 (our code), switch on `tea.MouseMsg` and check `msg.Action`/`msg.Button`
63-instead. **Never drop click or release events** — only motion and wheel.
64-
65-Register at program creation:
66-
67-```go
68-p := tea.NewProgram(model, tea.WithMouseCellMotion(), tea.WithFilter(filter))
69-```
70-
71-## 4. Mouse Event Routing
72-
73-### 4.1 Layout Rects (Not Zones)
74-
75-Both Crush and our codebase use `image.Rectangle` structs for layout regions.
76-Hit testing is `image.Pt(msg.X, msg.Y).In(rect)`. This is simpler and more
77-predictable than lipgloss zone-based routing.
78-
79-### 4.2 Coordinate Translation
80-
81-Mouse coordinates are screen-absolute. Child components expect local
82-coordinates. Subtract the layout rect origin before forwarding:
83-
84-```go
85-localX := msg.X - layout.pane.Min.X
86-localY := msg.Y - layout.pane.Min.Y
87-```
88-
89-### 4.3 Routing Priority
90-
91-Process mouse events in this order:
92-
93-1. **Dialogs/overlays** — if open, they consume all mouse events
94-2. **Divider drag** — if resizing, motion goes to resize logic
95-3. **Focus switching** — click sets focus to the clicked region
96-4. **Component dispatch** — forward (with coord translation) to the hit region
97-
98-This matches both Crush and our current approach.
99-
100-## 5. Selection Data Model
101-
102-### 5.1 Anchor + Active Pattern
103-
104-Selection is defined by two points:
105-
106-- **Anchor**: where the selection started (mouse down, or cursor position when
107- shift was first held)
108-- **Active**: where the selection currently extends to (mouse drag position, or
109- current cursor position while shift is held)
110-
111-The anchor is fixed; the active point moves. This lets backward selection
112-(dragging up/left) work naturally.
113-
114-```go
115-type selPos struct{ row, col int }
116-
117-type selection struct {
118- anchor selPos
119- active selPos
120-}
121-```
122-
123-To get the ordered range:
124-
125-```go
126-func (s selection) ordered() (start, end selPos) {
127- if s.anchor.row > s.active.row ||
128- (s.anchor.row == s.active.row && s.anchor.col > s.active.col) {
129- return s.active, s.anchor
130- }
131- return s.anchor, s.active
132-}
133-```
134-
135-### 5.2 Valid Selection Check
136-
137-A selection is "empty" when anchor == active. Only render highlight and allow
138-copy when they differ.
139-
140-### 5.3 Clearing Selection
141-
142-Clear on:
143-- Any non-shift cursor movement (arrows, home, end, pgup, pgdown)
144-- Click (press) without drag
145-- Edit operations (typing, backspace, delete, paste)
146-- Explicit copy (Ctrl+Shift+C) — optional, some editors keep it
147-
148-Do NOT clear on:
149-- Mouse motion during drag
150-- Shift+movement keys
151-- Scroll (wheel)
152-
153-## 6. Mouse Selection Flow
154-
155-### 6.1 Press → Drag → Release
156-
157-```
158-Press: Set anchor = active = screenToPos(x, y). Set mouseDown = true.
159-Motion: If mouseDown, update active = screenToPos(x, y).
160-Release: Set mouseDown = false. Keep selection visible.
161-```
162-
163-Crush does NOT auto-copy on release. It waits for an explicit copy action
164-(keyboard shortcut or delayed auto-copy after double-click timeout). This
165-prevents accidental clipboard overwrites during casual clicking.
166-
167-### 6.2 Click Detection (No Drag)
168-
169-If press and release happen at the same position (anchor == active after
170-release), treat it as a click, not a selection. Clear any existing selection
171-and handle the click action (e.g., position cursor, open file link).
172-
173-### 6.3 Double-Click / Triple-Click
174-
175-Crush implements multi-click via timing + spatial tolerance:
176-
177-```go
178-const (
179- doubleClickThreshold = 400 * time.Millisecond
180- clickTolerance = 2 // pixels
181-)
182-```
183-
184-On click, check if the previous click was within threshold and tolerance:
185-- **Double-click**: select word at cursor (using Unicode word boundaries)
186-- **Triple-click**: select entire line
187-
188-Track `lastClickTime`, `lastClickX`, `lastClickY`, `clickCount`.
189-
190-### 6.4 Delayed Single-Click
191-
192-Problem: a single click should position the cursor, but the first click of a
193-double-click should NOT trigger single-click behavior.
194-
195-Solution: on single click, schedule a delayed action after `doubleClickThreshold`.
196-Increment a `pendingClickID`. If a double-click arrives before the delay fires,
197-the ID won't match and the pending action is discarded.
198-
199-### 6.5 Auto-Scroll During Drag
200-
201-When dragging near viewport edges, scroll the content:
202-
203-```go
204-case tea.MouseActionMotion:
205- if msg.Y <= 0 {
206- scrollUp(1)
207- } else if msg.Y >= viewportHeight-1 {
208- scrollDown(1)
209- }
210-```
211-
212-This lets the user drag-select beyond the visible area.
213-
214-## 7. Keyboard Selection (Editors)
215-
216-Keyboard selection uses the same anchor+active model:
217-
218-- **Start selection**: On any shift+movement key, if no selection exists, set
219- anchor = current cursor position. Then move cursor. Set active = new cursor.
220-- **Extend selection**: On shift+movement with existing selection, just move
221- cursor and update active. Anchor stays put.
222-- **Clear selection**: On any non-shift movement or edit, clear the selection.
223-
224-Supported shift+key combinations:
225-
226-| Key | Action |
227-|-----------------|---------------------------|
228-| `shift+left` | Extend selection left 1 |
229-| `shift+right` | Extend selection right 1 |
230-| `shift+up` | Extend selection up 1 row |
231-| `shift+down` | Extend selection down 1 |
232-| `shift+home` | Extend to line start |
233-| `shift+end` | Extend to line end |
234-| `shift+pgup` | Extend up by page |
235-| `shift+pgdown` | Extend down by page |
236-
237-## 8. Clipboard
238-
239-### 8.1 Dual Write for Compatibility
240-
241-Use both OSC 52 and native clipboard for writes:
242-
243-```go
244-func CopyToClipboard(text string) tea.Cmd {
245- return tea.Sequence(
246- tea.SetClipboard(text), // OSC 52 (works through SSH/tmux)
247- func() tea.Msg {
248- _ = clipboard.WriteAll(text) // Native OS clipboard
249- return nil
250- },
251- )
252-}
253-```
254-
255-`tea.SetClipboard()` sends an OSC 52 escape sequence. Many terminals support
256-it, and it works through SSH tunnels and tmux (if configured). The native
257-clipboard call (`github.com/atotto/clipboard`) covers local-only terminals.
258-
259-### 8.2 Copy Trigger
260-
261-Ctrl+Shift+C (not Ctrl+C, which should remain quit/cancel). The top-level
262-handler checks which component has a selection and copies from it.
263-
264-### 8.3 Paste Trigger
265-
266-Ctrl+Shift+V. Read from native clipboard and insert at cursor.
267-
268-## 9. Highlight Rendering
269-
270-### 9.1 Cell-Level Approach (Crush)
271-
272-Crush uses `ultraviolet.ScreenBuffer` — a cell grid where each cell has content,
273-foreground, background, and attributes. Highlighting replaces cell styles in the
274-selected range. This gives perfect per-character accuracy but requires the UV
275-library.
276-
277-### 9.2 ANSI String Approach (Our Stack)
278-
279-Without UV, we work with ANSI-styled strings. To highlight a region within a
280-rendered line:
281-
282-1. Determine which characters fall within the selection range
283-2. Split the line into before / selected / after segments
284-3. Strip existing background from the selected segment
285-4. Apply the selection background style
286-5. Reassemble
287-
288-For syntax-highlighted content, use `ansi.Cut(hlString, start, end)` to extract
289-ANSI substrings at character boundaries, then wrap the selected portion in the
290-highlight style.
291-
292-### 9.3 Selection Style
293-
294-Define a visible but not jarring selection background:
295-
296-```go
297-Selection: lipgloss.NewStyle().Background(lipgloss.Color("#264f78"))
298-```
299-
300-Dark blue (#264f78) is the VS Code default and works well on dark backgrounds.
301-The current `#111111` is too subtle — almost invisible.
302-
303-### 9.4 Per-Row Intersection
304-
305-For each visual row during render, compute the intersection with the selection
306-range:
307-
308-```go
309-// selStart, selEnd are in buffer coordinates (row, col)
310-// vr.bufRow is this visual row's buffer line
311-// vr.segStart, vr.segEnd are the rune range of this segment
312-
313-if vr.bufRow < selStart.row || vr.bufRow > selEnd.row {
314- // No selection on this row
315-} else {
316- colStart := 0
317- if vr.bufRow == selStart.row { colStart = selStart.col - vr.segStart }
318- colEnd := segLen
319- if vr.bufRow == selEnd.row { colEnd = selEnd.col - vr.segStart }
320- // Clamp to segment bounds, then render highlight
321-}
322-```
323-
324-## 10. Cross-Component Selection
325-
326-Our app has 3 selectable regions: editor, conversation, input. Only one can
327-have an active selection at a time. When a mouse press or shift+key starts a
328-selection in one region, clear any selection in the others.
329-
330-The top-level model owns this coordination:
331-
332-```go
333-func (m *Model) clearAllSelections() {
334- m.editor.ClearSelection()
335- m.agentInput.ClearSelection()
336- m.convSelection = nil
337-}
338-```
339-
340-On Ctrl+Shift+C, check each component in priority order and copy from the
341-first one with an active selection.
342-
343-## 11. Common Pitfalls
344-
345-1. **Auto-copy on mouse release**: Don't. It overwrites the clipboard on every
346- casual click-drag. Copy should be explicit (Ctrl+Shift+C) or delayed.
347-
348-2. **Clearing selection on release**: Don't. The user expects to see what they
349- selected, then press a key to copy. Only clear on next click or edit.
350-
351-3. **Not translating coordinates**: Mouse events use screen-absolute positions.
352- Always subtract the component's layout origin before forwarding.
353-
354-4. **Selection during scroll**: Mouse wheel should NOT affect selection state.
355- The selection anchors are in buffer coordinates, not screen coordinates, so
356- they survive scrolling.
357-
358-5. **Forgetting to clamp**: Selection endpoints must be clamped to valid buffer
359- ranges. Off-by-one errors here cause panics or garbled rendering.
360-
361-6. **Highlight on trailing whitespace**: Crush explicitly avoids highlighting
362- trailing whitespace on each line. Track `lastContentX` and only highlight
363- up to that point. This looks much cleaner.
go.mod+8−11
@@ -3,12 +3,11 @@ module github.com/xonecas/symb
33 go 1.25.6
44
55 require (
6+ charm.land/bubbles/v2 v2.0.0-rc.1
7+ charm.land/bubbletea/v2 v2.0.0-rc.2
8+ charm.land/lipgloss/v2 v2.0.0-beta.3.0.20251106192539-4b304240aab7
69 github.com/BurntSushi/toml v1.6.0
710 github.com/alecthomas/chroma/v2 v2.23.1
8- github.com/atotto/clipboard v0.1.4
9- github.com/charmbracelet/bubbles v1.0.0
10- github.com/charmbracelet/bubbletea v1.3.10
11- github.com/charmbracelet/lipgloss v1.1.0
1211 github.com/charmbracelet/x/ansi v0.11.6
1312 github.com/charmbracelet/x/exp/golden v0.0.0-20260209194814-eeb2896ac759
1413 github.com/rs/zerolog v1.34.0
@@ -18,33 +17,31 @@ require (
1817 )
1918
2019 require (
21- github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
2220 github.com/aymanbagabas/go-udiff v0.3.1 // indirect
2321 github.com/charmbracelet/colorprofile v0.4.1 // indirect
24- github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
22+ github.com/charmbracelet/ultraviolet v0.0.0-20251116181749-377898bcce38 // indirect
2523 github.com/charmbracelet/x/term v0.2.2 // indirect
24+ github.com/charmbracelet/x/termios v0.1.1 // indirect
25+ github.com/charmbracelet/x/windows v0.2.2 // indirect
2626 github.com/clipperhouse/displaywidth v0.9.0 // indirect
2727 github.com/clipperhouse/stringish v0.1.1 // indirect
2828 github.com/clipperhouse/uax29/v2 v2.5.0 // indirect
2929 github.com/dlclark/regexp2 v1.11.5 // indirect
3030 github.com/dustin/go-humanize v1.0.1 // indirect
31- github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
3231 github.com/google/uuid v1.6.0 // indirect
3332 github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
3433 github.com/mattn/go-colorable v0.1.13 // indirect
3534 github.com/mattn/go-isatty v0.0.20 // indirect
36- github.com/mattn/go-localereader v0.0.1 // indirect
3735 github.com/mattn/go-runewidth v0.0.19 // indirect
38- github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
3936 github.com/muesli/cancelreader v0.2.2 // indirect
40- github.com/muesli/termenv v0.16.0 // indirect
4137 github.com/ncruces/go-strftime v1.0.0 // indirect
4238 github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
4339 github.com/rivo/uniseg v0.4.7 // indirect
4440 github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
4541 golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 // indirect
42+ golang.org/x/sync v0.19.0 // indirect
4643 golang.org/x/sys v0.41.0 // indirect
47- golang.org/x/text v0.34.0 // indirect
44+ golang.org/x/tools v0.41.0 // indirect
4845 modernc.org/libc v1.67.6 // indirect
4946 modernc.org/mathutil v1.7.1 // indirect
5047 modernc.org/memory v1.11.0 // indirect
go.sum+12−23
@@ -1,3 +1,9 @@
1+charm.land/bubbles/v2 v2.0.0-rc.1 h1:EiIFVAc3Zi/yY86td+79mPhHR7AqZ1OxF+6ztpOCRaM=
2+charm.land/bubbles/v2 v2.0.0-rc.1/go.mod h1:5AbN6cEd/47gkEf8TgiQ2O3RZ5QxMS14l9W+7F9fPC4=
3+charm.land/bubbletea/v2 v2.0.0-rc.2 h1:TdTbUOFzbufDJmSz/3gomL6q+fR6HwfY+P13hXQzD7k=
4+charm.land/bubbletea/v2 v2.0.0-rc.2/go.mod h1:IXFmnCnMLTWw/KQ9rEatSYqbAPAYi8kA3Yqwa1SFnLk=
5+charm.land/lipgloss/v2 v2.0.0-beta.3.0.20251106192539-4b304240aab7 h1:059k1h5vvZ4ASinki9nmBguxu9Rq0UDDSa6q8LOUphk=
6+charm.land/lipgloss/v2 v2.0.0-beta.3.0.20251106192539-4b304240aab7/go.mod h1:1qZyvvVCenJO2M1ac2mX0yyiIZJoZmDM4DG4s0udJkU=
17 github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
28 github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
39 github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
@@ -6,28 +12,22 @@ github.com/alecthomas/chroma/v2 v2.23.1 h1:nv2AVZdTyClGbVQkIzlDm/rnhk1E9bU9nXwmZ
612 github.com/alecthomas/chroma/v2 v2.23.1/go.mod h1:NqVhfBR0lte5Ouh3DcthuUCTUpDC9cxBOfyMbMQPs3o=
713 github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs=
814 github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
9-github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
10-github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
11-github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
12-github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
1315 github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3vj1nolY=
1416 github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E=
15-github.com/charmbracelet/bubbles v1.0.0 h1:12J8/ak/uCZEMQ6KU7pcfwceyjLlWsDLAxB5fXonfvc=
16-github.com/charmbracelet/bubbles v1.0.0/go.mod h1:9d/Zd5GdnauMI5ivUIVisuEm3ave1XwXtD1ckyV6r3E=
17-github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw=
18-github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4=
1917 github.com/charmbracelet/colorprofile v0.4.1 h1:a1lO03qTrSIRaK8c3JRxJDZOvhvIeSco3ej+ngLk1kk=
2018 github.com/charmbracelet/colorprofile v0.4.1/go.mod h1:U1d9Dljmdf9DLegaJ0nGZNJvoXAhayhmidOdcBwAvKk=
21-github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
22-github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
19+github.com/charmbracelet/ultraviolet v0.0.0-20251116181749-377898bcce38 h1:7Rs87fbKJoIIxsQS8YKJYGYa0tlsDwwb0twQjV1KB+g=
20+github.com/charmbracelet/ultraviolet v0.0.0-20251116181749-377898bcce38/go.mod h1:6lfcr3MNP+kZR25sF1nQwJFuQnNYBlFy3PGX5rvslXc=
2321 github.com/charmbracelet/x/ansi v0.11.6 h1:GhV21SiDz/45W9AnV2R61xZMRri5NlLnl6CVF7ihZW8=
2422 github.com/charmbracelet/x/ansi v0.11.6/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ=
25-github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI=
26-github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q=
2723 github.com/charmbracelet/x/exp/golden v0.0.0-20260209194814-eeb2896ac759 h1:wQKrpioYyZbkqq2V5o9x7D2dDnqZeTgFshM7G2/vmu0=
2824 github.com/charmbracelet/x/exp/golden v0.0.0-20260209194814-eeb2896ac759/go.mod h1:V8n/g3qVKNxr2FR37Y+otCsMySvZr601T0C7coEP0bw=
2925 github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk=
3026 github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI=
27+github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY=
28+github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo=
29+github.com/charmbracelet/x/windows v0.2.2 h1:IofanmuvaxnKHuV04sC0eBy/smG6kIKrWG2/jYn2GuM=
30+github.com/charmbracelet/x/windows v0.2.2/go.mod h1:/8XtdKZzedat74NQFn0NGlGL4soHB0YQZrETF96h75k=
3131 github.com/clipperhouse/displaywidth v0.9.0 h1:Qb4KOhYwRiN3viMv1v/3cTBlz3AcAZX3+y9OLhMtAtA=
3232 github.com/clipperhouse/displaywidth v0.9.0/go.mod h1:aCAAqTlh4GIVkhQnJpbL0T/WfcrJXHcj8C0yjYcjOZA=
3333 github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs=
@@ -39,8 +39,6 @@ github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZ
3939 github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
4040 github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
4141 github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
42-github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
43-github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
4442 github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
4543 github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
4644 github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
@@ -58,16 +56,10 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/
5856 github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
5957 github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
6058 github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
61-github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
62-github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
6359 github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw=
6460 github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
65-github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
66-github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
6761 github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
6862 github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
69-github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
70-github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
7163 github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
7264 github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
7365 github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
@@ -90,14 +82,11 @@ golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60=
9082 golang.org/x/net v0.50.0/go.mod h1:UgoSli3F/pBgdJBHCTc+tp3gmrU4XswgGRgtnwWTfyM=
9183 golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
9284 golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
93-golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
9485 golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
9586 golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
9687 golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
9788 golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
9889 golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
99-golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk=
100-golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA=
10190 golang.org/x/tools v0.41.0 h1:a9b8iMweWG+S0OBnlU36rzLp20z1Rp10w+IY2czHTQc=
10291 golang.org/x/tools v0.41.0/go.mod h1:XSY6eDqxVNiYgezAVqqCeihT4j1U2CCsqvH3WhQpnlg=
10392 modernc.org/cc/v4 v4.27.1 h1:9W30zRlYrefrDV2JE2O8VDtJ1yPGownxciz5rrbQZis=
internal/mcp_tools/edit.go+1−1
@@ -8,7 +8,7 @@ import (
88 "path/filepath"
99 "strings"
1010
11- tea "github.com/charmbracelet/bubbletea"
11+ tea "charm.land/bubbletea/v2"
1212 "github.com/xonecas/symb/internal/hashline"
1313 "github.com/xonecas/symb/internal/mcp"
1414 )
internal/mcp_tools/open.go+1−1
@@ -8,7 +8,7 @@ import (
88 "path/filepath"
99 "strings"
1010
11- tea "github.com/charmbracelet/bubbletea"
11+ tea "charm.land/bubbletea/v2"
1212 "github.com/xonecas/symb/internal/hashline"
1313 "github.com/xonecas/symb/internal/mcp"
1414 )
internal/tui/conv.go+118−0
@@ -0,0 +1,118 @@
1+package tui
2+
3+import (
4+ "strings"
5+
6+ "charm.land/lipgloss/v2"
7+)
8+
9+// ---------------------------------------------------------------------------
10+// Conversation entry helpers
11+// ---------------------------------------------------------------------------
12+
13+// convWidth returns the usable width of the conversation pane.
14+func (m Model) convWidth() int { return m.layout.conv.Dx() }
15+
16+// styledLines applies a lipgloss style to each line in a multi-line text.
17+// No wrapping — lines are stored raw for later wrapping at render time.
18+func styledLines(text string, style lipgloss.Style) []string {
19+ raw := strings.Split(text, "\n")
20+ out := make([]string, len(raw))
21+ for i, l := range raw {
22+ out[i] = style.Render(l)
23+ }
24+ return out
25+}
26+
27+// textEntries converts styled display strings into plain convEntry values.
28+func textEntries(lines ...string) []convEntry {
29+ out := make([]convEntry, len(lines))
30+ for i, l := range lines {
31+ out[i] = convEntry{display: l, kind: entryText}
32+ }
33+ return out
34+}
35+
36+// appendConv appends entries and returns whether we were at bottom
37+// (for sticky scroll). Invalidates the wrapped-lines cache.
38+func (m *Model) appendConv(entries ...convEntry) bool {
39+ atBottom := m.scrollOffset == 0
40+ m.convEntries = append(m.convEntries, entries...)
41+ m.convLines = nil // invalidate cache
42+ return atBottom
43+}
44+
45+// appendText is a convenience to append plain text entries.
46+func (m *Model) appendText(lines ...string) bool {
47+ return m.appendConv(textEntries(lines...)...)
48+}
49+
50+// rebuildStreamEntries replaces any existing streaming entries with fresh
51+// styled entries from the current streamingReasoning and streamingContent.
52+// Called on each delta to reflect incremental updates.
53+func (m *Model) rebuildStreamEntries() {
54+ // Remove old streaming entries
55+ if m.streamEntryStart >= 0 && m.streamEntryStart <= len(m.convEntries) {
56+ m.convEntries = m.convEntries[:m.streamEntryStart]
57+ }
58+
59+ if m.streamingReasoning != "" {
60+ m.convEntries = append(m.convEntries, textEntries(styledLines(m.streamingReasoning, m.styles.Muted)...)...)
61+ }
62+ if m.streamingContent != "" {
63+ m.convEntries = append(m.convEntries, textEntries(styledLines(m.streamingContent, m.styles.Text)...)...)
64+ }
65+ m.convLines = nil // invalidate cache
66+}
67+
68+// wrappedConvLines returns the conversation wrapped to the current convWidth.
69+// Cached — only recomputed when entries change (nil) or width changes.
70+func (m *Model) wrappedConvLines() []string {
71+ w := m.convWidth()
72+ if m.convLines != nil && m.convCachedW == w {
73+ return m.convLines
74+ }
75+ m.convCachedW = w
76+ lines := make([]string, 0, len(m.convEntries))
77+ source := make([]int, 0, len(m.convEntries))
78+ for i, entry := range m.convEntries {
79+ if entry.display == "" {
80+ lines = append(lines, "")
81+ source = append(source, i)
82+ } else {
83+ wrapped := wrapANSI(entry.display, w)
84+ for range wrapped {
85+ source = append(source, i)
86+ }
87+ lines = append(lines, wrapped...)
88+ }
89+ }
90+ m.convLines = lines
91+ m.convLineSource = source
92+ return m.convLines
93+}
94+
95+// makeSeparator builds a timestamp separator line.
96+func (m Model) makeSeparator(dur string, ts string) string {
97+ label := dur + " " + ts + " "
98+ fill := m.convWidth() - lipgloss.Width(label)
99+ if fill < 0 {
100+ fill = 0
101+ }
102+ return m.styles.Dim.Render(label + strings.Repeat("─", fill))
103+}
104+
105+// visibleStartLine returns the index of the first visible wrapped conversation line.
106+func (m *Model) visibleStartLine() int {
107+ lines := m.wrappedConvLines()
108+ total := len(lines)
109+ visible := m.layout.conv.Dy()
110+ if total <= visible {
111+ return 0
112+ }
113+ start := total - visible - m.scrollOffset
114+ if start < 0 {
115+ return 0
116+ }
117+ return start
118+}
internal/tui/editor/editor.go+66−49
@@ -5,16 +5,17 @@ package editor
55
66 import (
77 "fmt"
8+ "image/color"
89 "strings"
910 "sync"
1011
12+ "charm.land/bubbles/v2/cursor"
13+ tea "charm.land/bubbletea/v2"
14+ "charm.land/lipgloss/v2"
1115 "github.com/alecthomas/chroma/v2"
1216 "github.com/alecthomas/chroma/v2/formatters"
1317 "github.com/alecthomas/chroma/v2/lexers"
1418 "github.com/alecthomas/chroma/v2/styles"
15- "github.com/charmbracelet/bubbles/cursor"
16- tea "github.com/charmbracelet/bubbletea"
17- "github.com/charmbracelet/lipgloss"
1819 "github.com/charmbracelet/x/ansi"
1920 )
2021
@@ -130,7 +131,7 @@ type Model struct {
130131 SelectionStyle lipgloss.Style // Background for selected text
131132 LineNumStyle lipgloss.Style // Line number gutter
132133 PlaceholderSty lipgloss.Style // Placeholder text
133- BgColor lipgloss.Color // Fallback bg when no syntax theme
134+ BgColor color.Color // Fallback bg when no syntax theme
134135
135136 // Internal state
136137 lines [][]rune // Backing store, one entry per line
@@ -590,20 +591,29 @@ func (m *Model) bufferColToExpandedCol(bufRow, bufCol int) int {
590591 return len([]rune(prefix))
591592 }
592593
593-// bgHexForRender returns the background hex color. Prefers the syntax theme
594-// background, falls back to BgColor.
595-func (m *Model) bgHexForRender() string {
594+// bgForRender returns the background as a lipgloss style. Prefers the syntax
595+// theme background, falls back to BgColor.
596+func (m *Model) bgForRender() lipgloss.Style {
596597 if m.Language != "" && m.SyntaxTheme != "" {
597598 if hex := themeBg(m.SyntaxTheme); hex != "" {
598- return hex
599+ return lipgloss.NewStyle().Background(lipgloss.Color(hex))
599600 }
600601 }
601- return string(m.BgColor)
602+ return lipgloss.NewStyle().Background(m.BgColor)
602603 }
603604
604-// bgForRender returns the background as a lipgloss style.
605-func (m *Model) bgForRender() lipgloss.Style {
606- return lipgloss.NewStyle().Background(lipgloss.Color(m.bgHexForRender()))
605+// bgHexForHighlight returns the bg hex string for syntax highlighting.
606+func (m *Model) bgHexForHighlight() string {
607+ if m.Language != "" && m.SyntaxTheme != "" {
608+ if hex := themeBg(m.SyntaxTheme); hex != "" {
609+ return hex
610+ }
611+ }
612+ if m.BgColor != nil {
613+ r, g, b, _ := m.BgColor.RGBA()
614+ return fmt.Sprintf("#%02x%02x%02x", r>>8, g>>8, b>>8)
615+ }
616+ return "#000000"
607617 }
608618
609619 // ---------------------------------------------------------------------------
@@ -744,12 +754,12 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
744754 var cmds []tea.Cmd
745755
746756 switch msg := msg.(type) {
747- case tea.KeyMsg:
757+ case tea.KeyPressMsg:
748758 if !m.focus {
749759 break
750760 }
751761 moved := true
752- key := msg.String()
762+ key := msg.Keystroke()
753763
754764 switch key {
755765 // --- Shift+navigation: extend selection ---
@@ -870,9 +880,9 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
870880
871881 default:
872882 moved = false
873- if !m.ReadOnly && len(msg.Runes) > 0 {
883+ if !m.ReadOnly && msg.Text != "" {
874884 m.DeleteSelection()
875- for _, r := range msg.Runes {
885+ for _, r := range msg.Text {
876886 m.insertRune(r)
877887 }
878888 moved = true
@@ -882,43 +892,51 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
882892 if moved {
883893 m.clampCursor()
884894 m.clampScroll()
885- m.cursor.Blink = false
886- cmds = append(cmds, m.cursor.BlinkCmd())
895+ cmds = append(cmds, m.cursor.Blink())
887896 }
888897
889- case tea.MouseMsg:
898+ case tea.MouseClickMsg:
890899 if !m.focus {
891900 break
892901 }
893- switch msg.Button {
894- case tea.MouseButtonLeft:
895- switch msg.Action {
896- case tea.MouseActionPress:
897- p := m.screenToPos(msg.X, msg.Y)
898- m.dragging = true
899- m.sel = &selection{anchor: p, active: p}
900- m.row = p.row
901- m.col = p.col
902- m.clampCursor()
903- case tea.MouseActionMotion:
904- if m.dragging {
905- p := m.screenToPos(msg.X, msg.Y)
906- m.sel.active = p
907- m.row = p.row
908- m.col = p.col
909- m.clampCursor()
910- }
911- case tea.MouseActionRelease:
912- m.dragging = false
913- // If no actual drag distance, treat as click: clear selection
914- if m.sel != nil && m.sel.empty() {
915- m.ClearSelection()
916- }
917- }
918- case tea.MouseButtonWheelUp:
902+ if msg.Button == tea.MouseLeft {
903+ p := m.screenToPos(msg.X, msg.Y)
904+ m.dragging = true
905+ m.sel = &selection{anchor: p, active: p}
906+ m.row = p.row
907+ m.col = p.col
908+ m.clampCursor()
909+ }
910+
911+ case tea.MouseMotionMsg:
912+ if !m.focus {
913+ break
914+ }
915+ if m.dragging {
916+ p := m.screenToPos(msg.X, msg.Y)
917+ m.sel.active = p
918+ m.row = p.row
919+ m.col = p.col
920+ m.clampCursor()
921+ }
922+
923+ case tea.MouseReleaseMsg:
924+ if !m.focus {
925+ break
926+ }
927+ m.dragging = false
928+ if m.sel != nil && m.sel.empty() {
929+ m.ClearSelection()
930+ }
931+
932+ case tea.MouseWheelMsg:
933+ if !m.focus {
934+ break
935+ }
936+ if msg.Button == tea.MouseWheelUp {
919937 m.scroll -= 3
920938 m.clampScrollBounds()
921- case tea.MouseButtonWheelDown:
939+ } else if msg.Button == tea.MouseWheelDown {
922940 m.scroll += 3
923941 m.clampScrollBounds()
924942 }
@@ -947,8 +965,7 @@ func (m Model) View() string {
947965 }
948966
949967 tw := m.textWidth()
950- bgHex := m.bgHexForRender()
951- bg := lipgloss.NewStyle().Background(lipgloss.Color(bgHex))
968+ bg := m.bgForRender()
952969 lineNumSty := m.LineNumStyle.Background(bg.GetBackground())
953970
954971 // Build a flat list of visual rows from visible buffer lines.
@@ -981,7 +998,7 @@ func (m Model) View() string {
981998 // Highlight the full line once for all its segments.
982999 var fullHL string
9831000 if hasSyntax {
984- fullHL = cachedHighlight(lineStr, m.Language, m.SyntaxTheme, bgHex)
1001+ fullHL = cachedHighlight(lineStr, m.Language, m.SyntaxTheme, m.bgHexForHighlight())
9851002 }
9861003
9871004 firstSub := 0
internal/tui/editor/editor_test.go+1−1
@@ -5,7 +5,7 @@ import (
55 "strings"
66 "testing"
77
8- "github.com/charmbracelet/lipgloss"
8+ "charm.land/lipgloss/v2"
99 )
1010
1111 func TestLineWidthWithTabs(t *testing.T) {
internal/tui/golden_test.go+2−2
@@ -4,7 +4,7 @@ import (
44 "regexp"
55 "testing"
66
7- tea "github.com/charmbracelet/bubbletea"
7+ tea "charm.land/bubbletea/v2"
88 "github.com/charmbracelet/x/exp/golden"
99 )
1010
@@ -30,7 +30,7 @@ func TestLayout(t *testing.T) {
3030 updated, _ := m.Update(tea.WindowSizeMsg{Width: tt.width, Height: tt.height})
3131 m = updated.(Model)
3232
33- output := m.View()
33+ output := m.renderContent()
3434
3535 t.Run("ANSI", func(t *testing.T) {
3636 golden.RequireEqual(t, []byte(output))
internal/tui/messages.go+111−0
@@ -0,0 +1,111 @@
1+package tui
2+
3+import (
4+ "time"
5+
6+ tea "charm.land/bubbletea/v2"
7+ "github.com/xonecas/symb/internal/llm"
8+ "github.com/xonecas/symb/internal/mcp"
9+ "github.com/xonecas/symb/internal/provider"
10+)
11+
12+// ---------------------------------------------------------------------------
13+// ELM messages
14+// ---------------------------------------------------------------------------
15+
16+type llmUserMsg struct{ content string }
17+
18+type llmAssistantMsg struct {
19+ reasoning string
20+ content string
21+ toolCalls []provider.ToolCall
22+}
23+
24+type llmToolResultMsg struct {
25+ toolCallID string
26+ content string
27+}
28+
29+type llmDoneMsg struct {
30+ duration time.Duration
31+ timestamp string
32+}
33+
34+type llmHistoryMsg struct{ msg provider.Message }
35+type llmErrorMsg struct{ err error }
36+
37+// Streaming delta messages
38+type llmContentDeltaMsg struct{ content string }
39+type llmReasoningDeltaMsg struct{ content string }
40+
41+// UpdateToolsMsg is exported so main.go can send it via program.Send.
42+type UpdateToolsMsg struct{ Tools []mcp.Tool }
43+
44+// ---------------------------------------------------------------------------
45+// ELM commands
46+// ---------------------------------------------------------------------------
47+
48+func (m Model) sendToLLM(userInput string) tea.Cmd {
49+ return func() tea.Msg { return llmUserMsg{content: userInput} }
50+}
51+
52+func (m Model) waitForLLMUpdate() tea.Cmd {
53+ return func() tea.Msg { return <-m.updateChan }
54+}
55+
56+func (m Model) processLLM() tea.Cmd {
57+ prov := m.provider
58+ proxy := m.mcpProxy
59+ tools := make([]mcp.Tool, len(m.mcpTools))
60+ copy(tools, m.mcpTools)
61+ history := make([]provider.Message, len(m.history))
62+ copy(history, m.history)
63+ ch := m.updateChan
64+ ctx := m.ctx
65+
66+ return func() tea.Msg {
67+ go func() {
68+ start := time.Now()
69+ err := llm.ProcessTurn(ctx, llm.ProcessTurnOptions{
70+ Provider: prov,
71+ Proxy: proxy,
72+ Tools: tools,
73+ History: history,
74+ MaxToolRounds: 20,
75+ OnDelta: func(evt provider.StreamEvent) {
76+ switch evt.Type {
77+ case provider.EventContentDelta:
78+ ch <- llmContentDeltaMsg{content: evt.Content}
79+ case provider.EventReasoningDelta:
80+ ch <- llmReasoningDeltaMsg{content: evt.Content}
81+ }
82+ },
83+ OnMessage: func(msg provider.Message) {
84+ ch <- llmHistoryMsg{msg: msg}
85+ switch msg.Role {
86+ case "assistant":
87+ ch <- llmAssistantMsg{
88+ reasoning: msg.Reasoning,
89+ content: msg.Content,
90+ toolCalls: msg.ToolCalls,
91+ }
92+ case "tool":
93+ ch <- llmToolResultMsg{
94+ toolCallID: msg.ToolCallID,
95+ content: msg.Content,
96+ }
97+ }
98+ },
99+ })
100+ if err != nil {
101+ ch <- llmErrorMsg{err: err}
102+ return
103+ }
104+ ch <- llmDoneMsg{
105+ duration: time.Since(start),
106+ timestamp: start.Format("15:04"),
107+ }
108+ }()
109+ return nil
110+ }
111+}
internal/tui/mouse.go+274−0
@@ -0,0 +1,274 @@
1+package tui
2+
3+import (
4+ "os"
Cut short: this commit's diff is over 1000 lines.
internal/tui/selection.go+113−0
Cut short: this commit's diff is over 1000 lines.
internal/tui/styles.go+1−1
Cut short: this commit's diff is over 1000 lines.
internal/tui/testdata/TestLayout/120x40/ANSI.golden+40−40
Cut short: this commit's diff is over 1000 lines.
internal/tui/testdata/TestLayout/120x40/Stripped.golden+1−1
Cut short: this commit's diff is over 1000 lines.
internal/tui/testdata/TestLayout/80x24/ANSI.golden+24−24
Cut short: this commit's diff is over 1000 lines.
internal/tui/testdata/TestLayout/80x24/Stripped.golden+1−1
Cut short: this commit's diff is over 1000 lines.
internal/tui/tui.go+46−952
Cut short: this commit's diff is over 1000 lines.
internal/tui/update.go+251−0
Cut short: this commit's diff is over 1000 lines.
internal/tui/view.go+135−0
Cut short: this commit's diff is over 1000 lines.
selection-refactor.md+0−69
Cut short: this commit's diff is over 1000 lines.