xonecas.io
62159
Sy

symb / commit b8e15b3

feat: filesearch modal

xonecas2026-02-15 b8e15b39ba434fab85823f7a8c5bf08d9a91536c parent 5b0ba40

7 files changed

internal/tui/modal/modal.go+302−0
@@ -0,0 +1,302 @@
1+package modal
2+
3+import (
4+ "strings"
5+ "time"
6+
7+ tea "charm.land/bubbletea/v2"
8+ "charm.land/lipgloss/v2"
9+)
10+
11+// Action is the result of handling a message. nil means no action.
12+type Action any
13+
14+// ActionClose signals the modal should be dismissed.
15+type ActionClose struct{}
16+
17+// ActionSelect signals an item was chosen.
18+type ActionSelect struct{ Item Item }
19+
20+// Item is a single entry in the list.
21+type Item struct {
22+ Name string
23+ Desc string
24+}
25+
26+// SearchFunc is called with the current query to produce results.
27+type SearchFunc func(query string) []Item
28+
29+const (
30+ debounceDelay = 250 * time.Millisecond
31+
32+ colorDim = "#666666"
33+ colorSelFg = "#ffffff"
34+ colorSelBg = "#444444"
35+ colorBorder = "#555555"
36+
37+ keyDown = "down"
38+ keyBackspace = "backspace"
39+)
40+
41+// debounceMsg is sent after the debounce timer fires.
42+type debounceMsg struct{ seq int }
43+
44+// Model is a generic input+list modal.
45+type Model struct {
46+ input []rune
47+ cursor int
48+ items []Item
49+ selected int
50+ inList bool // true = list focused, false = input focused
51+
52+ searchFn SearchFunc
53+ seq int // debounce sequence counter
54+
55+ // Prompt shown before the input text.
56+ Prompt string
57+}
58+
59+// New creates a modal with the given search function.
60+func New(searchFn SearchFunc, prompt string) Model {
61+ m := Model{
62+ searchFn: searchFn,
63+ Prompt: prompt,
64+ }
65+ // Initial search with empty query.
66+ m.items = searchFn("")
67+ return m
68+}
69+
70+// DebounceCmd returns a tea.Cmd that fires after the debounce delay.
71+func (m *Model) DebounceCmd() tea.Cmd {
72+ seq := m.seq
73+ return tea.Tick(debounceDelay, func(time.Time) tea.Msg {
74+ return debounceMsg{seq: seq}
75+ })
76+}
77+
78+// HandleMsg processes a tea.Msg and returns an optional Action.
79+// The second return is a tea.Cmd the parent must dispatch (for debounce).
80+func (m *Model) HandleMsg(msg tea.Msg) (Action, tea.Cmd) {
81+ switch msg := msg.(type) {
82+ case tea.KeyPressMsg:
83+ return m.handleKey(msg)
84+ case debounceMsg:
85+ if msg.seq == m.seq {
86+ m.items = m.searchFn(string(m.input))
87+ m.selected = 0
88+ m.inList = false
89+ }
90+ return nil, nil
91+ }
92+ return nil, nil
93+}
94+
95+func (m *Model) handleKey(msg tea.KeyPressMsg) (Action, tea.Cmd) {
96+ switch msg.Keystroke() {
97+ case "esc":
98+ return ActionClose{}, nil
99+ case "enter":
100+ return m.handleEnter()
101+ case "up", keyDown:
102+ m.handleNav(msg.Keystroke())
103+ return nil, nil
104+ case keyBackspace, "delete", "ctrl+u", "ctrl+k":
105+ return nil, m.handleDelete(msg.Keystroke())
106+ case "left", "right", "home", "end", "ctrl+a", "ctrl+e":
107+ m.handleCursor(msg.Keystroke())
108+ return nil, nil
109+ }
110+
111+ // Rune input.
112+ if !m.inList && msg.Text != "" {
113+ for _, r := range msg.Text {
114+ m.input = append(m.input[:m.cursor], append([]rune{r}, m.input[m.cursor:]...)...)
115+ m.cursor++
116+ }
117+ m.seq++
118+ return nil, m.DebounceCmd()
119+ }
120+
121+ return nil, nil
122+}
123+
124+func (m *Model) handleEnter() (Action, tea.Cmd) {
125+ if len(m.items) == 0 {
126+ return nil, nil
127+ }
128+ idx := m.selected
129+ if idx >= len(m.items) {
130+ idx = 0
131+ }
132+ return ActionSelect{Item: m.items[idx]}, nil
133+}
134+
135+func (m *Model) handleNav(key string) {
136+ switch key {
137+ case "up":
138+ if m.inList {
139+ if m.selected > 0 {
140+ m.selected--
141+ } else {
142+ m.inList = false
143+ }
144+ }
145+ case keyDown:
146+ if !m.inList {
147+ if len(m.items) > 0 {
148+ m.inList = true
149+ m.selected = 0
150+ }
151+ } else if m.selected < len(m.items)-1 {
152+ m.selected++
153+ }
154+ }
155+}
156+
157+func (m *Model) handleDelete(key string) tea.Cmd {
158+ switch key {
159+ case keyBackspace:
160+ if m.cursor > 0 {
161+ m.input = append(m.input[:m.cursor-1], m.input[m.cursor:]...)
162+ m.cursor--
163+ m.seq++
164+ return m.DebounceCmd()
165+ }
166+ case "delete":
167+ if m.cursor < len(m.input) {
168+ m.input = append(m.input[:m.cursor], m.input[m.cursor+1:]...)
169+ m.seq++
170+ return m.DebounceCmd()
171+ }
172+ case "ctrl+u":
173+ m.input = m.input[m.cursor:]
174+ m.cursor = 0
175+ m.seq++
176+ return m.DebounceCmd()
177+ case "ctrl+k":
178+ m.input = m.input[:m.cursor]
179+ m.seq++
180+ return m.DebounceCmd()
181+ }
182+ return nil
183+}
184+
185+func (m *Model) handleCursor(key string) {
186+ if m.inList {
187+ return
188+ }
189+ switch key {
190+ case "left":
191+ if m.cursor > 0 {
192+ m.cursor--
193+ }
194+ case "right":
195+ if m.cursor < len(m.input) {
196+ m.cursor++
197+ }
198+ case "home", "ctrl+a":
199+ m.cursor = 0
200+ case "end", "ctrl+e":
201+ m.cursor = len(m.input)
202+ }
203+}
204+
205+// View renders the modal at the given app width and height.
206+func (m *Model) View(appWidth, appHeight int) string {
207+ w := appWidth * 80 / 100
208+ h := appHeight * 80 / 100
209+ if w < 30 {
210+ w = 30
211+ }
212+ if h < 8 {
213+ h = 8
214+ }
215+
216+ innerW := w - 6 // border + padding
217+ if innerW < 10 {
218+ innerW = 10
219+ }
220+
221+ prompt := m.Prompt
222+ if prompt == "" {
223+ prompt = "> "
224+ }
225+
226+ inputLine := m.renderInput(prompt)
227+ listHeight := h - 4 // border top/bottom + input + divider
228+ if listHeight < 1 {
229+ listHeight = 1
230+ }
231+
232+ dimStyle := lipgloss.NewStyle().Foreground(lipgloss.Color(colorDim))
233+ divider := dimStyle.Render(strings.Repeat("\u2500", innerW))
234+ listLines := m.renderList(innerW, listHeight)
235+
236+ content := inputLine + "\n" + divider
237+ for _, l := range listLines {
238+ content += "\n" + l
239+ }
240+
241+ box := lipgloss.NewStyle().
242+ Border(lipgloss.RoundedBorder()).
243+ BorderForeground(lipgloss.Color(colorBorder)).
244+ Padding(0, 1).
245+ Width(w - 2).
246+ Render(content)
247+
248+ return lipgloss.Place(appWidth, appHeight, lipgloss.Center, lipgloss.Center, box)
249+}
250+
251+func (m *Model) renderInput(prompt string) string {
252+ if m.inList {
253+ return prompt + string(m.input)
254+ }
255+ before := string(m.input[:m.cursor])
256+ cursorStyle := lipgloss.NewStyle().Reverse(true)
257+ cursorChar := " "
258+ after := ""
259+ if m.cursor < len(m.input) {
260+ cursorChar = string(m.input[m.cursor])
261+ after = string(m.input[m.cursor+1:])
262+ }
263+ return prompt + before + cursorStyle.Render(cursorChar) + after
264+}
265+
266+func (m *Model) renderList(innerW, listHeight int) []string {
267+ scrollOff := 0
268+ if m.selected >= listHeight {
269+ scrollOff = m.selected - listHeight + 1
270+ }
271+
272+ dimStyle := lipgloss.NewStyle().Foreground(lipgloss.Color(colorDim))
273+ selStyle := lipgloss.NewStyle().
274+ Foreground(lipgloss.Color(colorSelFg)).
275+ Background(lipgloss.Color(colorSelBg))
276+
277+ var lines []string
278+ for i := scrollOff; i < len(m.items) && len(lines) < listHeight; i++ {
279+ item := m.items[i]
280+ if i == m.selected && m.inList {
281+ lines = append(lines, selStyle.Render(padRight(item.Name, innerW)))
282+ } else {
283+ line := item.Name
284+ if item.Desc != "" {
285+ line += dimStyle.Render(" " + item.Desc)
286+ }
287+ lines = append(lines, padRight(line, innerW))
288+ }
289+ }
290+
291+ for len(lines) < listHeight {
292+ lines = append(lines, strings.Repeat(" ", innerW))
293+ }
294+ return lines
295+}
296+
297+func padRight(s string, w int) string {
298+ if len(s) >= w {
299+ return s
300+ }
301+ return s + strings.Repeat(" ", w-len(s))
302+}
internal/tui/modal/modal_test.go+173−0
@@ -0,0 +1,173 @@
1+package modal
2+
3+import (
4+ "testing"
5+
6+ tea "charm.land/bubbletea/v2"
7+)
8+
9+func fruits(query string) []Item {
10+ all := []Item{
11+ {Name: "apple"},
12+ {Name: "banana"},
13+ {Name: "cherry"},
14+ }
15+ if query == "" {
16+ return all
17+ }
18+ var out []Item
19+ for _, it := range all {
20+ for _, r := range query {
21+ for _, c := range it.Name {
22+ if r == c {
23+ out = append(out, it)
24+ goto next
25+ }
26+ }
27+ }
28+ next:
29+ }
30+ return out
31+}
32+
33+func key(ch rune) tea.KeyPressMsg {
34+ return tea.KeyPressMsg{Code: ch, Text: string(ch)}
35+}
36+
37+func special(name string) tea.KeyPressMsg {
38+ switch name {
39+ case "enter":
40+ return tea.KeyPressMsg{Code: tea.KeyEnter}
41+ case "esc":
42+ return tea.KeyPressMsg{Code: tea.KeyEscape}
43+ case "up":
44+ return tea.KeyPressMsg{Code: tea.KeyUp}
45+ case "down":
46+ return tea.KeyPressMsg{Code: tea.KeyDown}
47+ case "backspace":
48+ return tea.KeyPressMsg{Code: tea.KeyBackspace}
49+ default:
50+ return tea.KeyPressMsg{}
51+ }
52+}
53+
54+func TestEscapeCloses(t *testing.T) {
55+ m := New(fruits, "> ")
56+ a, _ := m.HandleMsg(special("esc"))
57+ if _, ok := a.(ActionClose); !ok {
58+ t.Fatalf("expected ActionClose, got %T", a)
59+ }
60+}
61+
62+func TestEnterSelectsFirst(t *testing.T) {
63+ m := New(fruits, "> ")
64+ a, _ := m.HandleMsg(special("enter"))
65+ sel, ok := a.(ActionSelect)
66+ if !ok {
67+ t.Fatalf("expected ActionSelect, got %T", a)
68+ }
69+ if sel.Item.Name != "apple" {
70+ t.Fatalf("expected apple, got %s", sel.Item.Name)
71+ }
72+}
73+
74+func TestDownThenEnterSelectsHighlighted(t *testing.T) {
75+ m := New(fruits, "> ")
76+ m.HandleMsg(special("down")) // enter list, selected=0
77+ m.HandleMsg(special("down")) // selected=1
78+ a, _ := m.HandleMsg(special("enter"))
79+ sel, ok := a.(ActionSelect)
80+ if !ok {
81+ t.Fatalf("expected ActionSelect, got %T", a)
82+ }
83+ if sel.Item.Name != "banana" {
84+ t.Fatalf("expected banana, got %s", sel.Item.Name)
85+ }
86+}
87+
88+func TestUpFromTopReturnsFocusToInput(t *testing.T) {
89+ m := New(fruits, "> ")
90+ m.HandleMsg(special("down")) // enter list
91+ if !m.inList {
92+ t.Fatal("expected inList=true")
93+ }
94+ m.HandleMsg(special("up")) // back to input
95+ if m.inList {
96+ t.Fatal("expected inList=false")
97+ }
98+}
99+
100+func TestTypingProducesDebounceCmd(t *testing.T) {
101+ m := New(fruits, "> ")
102+ _, cmd := m.HandleMsg(key('a'))
103+ if cmd == nil {
104+ t.Fatal("expected debounce cmd")
105+ }
106+ if string(m.input) != "a" {
107+ t.Fatalf("expected input 'a', got %q", string(m.input))
108+ }
109+}
110+
111+func TestDebounceFiresSearch(t *testing.T) {
112+ called := false
113+ searchFn := func(q string) []Item {
114+ if q == "x" {
115+ called = true
116+ }
117+ return nil
118+ }
119+ m := New(searchFn, "> ")
120+ // Type 'x'.
121+ m.HandleMsg(key('x'))
122+ seq := m.seq
123+ // Fire matching debounce.
124+ m.HandleMsg(debounceMsg{seq: seq})
125+ if !called {
126+ t.Fatal("expected search to be called")
127+ }
128+}
129+
130+func TestStaleDebounceIgnored(t *testing.T) {
131+ callCount := 0
132+ searchFn := func(q string) []Item {
133+ if q != "" {
134+ callCount++
135+ }
136+ return nil
137+ }
138+ m := New(searchFn, "> ")
139+ m.HandleMsg(key('a'))
140+ staleSeq := m.seq
141+ m.HandleMsg(key('b')) // bumps seq
142+ // Fire stale debounce — should be ignored.
143+ m.HandleMsg(debounceMsg{seq: staleSeq})
144+ if callCount != 0 {
145+ t.Fatalf("expected 0 search calls for stale debounce, got %d", callCount)
146+ }
147+}
148+
149+func TestBackspaceRemovesChar(t *testing.T) {
150+ m := New(fruits, "> ")
151+ m.HandleMsg(key('a'))
152+ m.HandleMsg(key('b'))
153+ m.HandleMsg(special("backspace"))
154+ if string(m.input) != "a" {
155+ t.Fatalf("expected 'a', got %q", string(m.input))
156+ }
157+}
158+
159+func TestViewRenders(t *testing.T) {
160+ m := New(fruits, "> ")
161+ v := m.View(100, 40)
162+ if v == "" {
163+ t.Fatal("expected non-empty view")
164+ }
165+}
166+
167+func TestEmptyResultsEnterNoAction(t *testing.T) {
168+ m := New(func(string) []Item { return nil }, "> ")
169+ a, _ := m.HandleMsg(special("enter"))
170+ if a != nil {
171+ t.Fatalf("expected nil action, got %T", a)
172+ }
173+}
internal/tui/testdata/TestLayout/120x40/ANSI.golden+40−40
@@ -1,40 +1,40 @@
1- 1   │ 
2- │ 
3- │ 
4- │ 
5- │ 
6- │ 
7- │ 
8- │ 
9- │ 
10- │ 
11- │ 
12- │ 
13- │ 
14- │ 
15- │ 
16- │ 
17- │ 
18- │ 
19- │ 
20- │ 
21- │ 
22- │ 
23- │ 
24- │ 
25- │ 
26- │ 
27- │ 
28- │ 
29- │ 
30- │ 
31- │ 
32- │ 
33- │ 
34- │ 
35- │───────────────────────────────────────────────────────────
36- │Type a message...  
37- │  
38- │  
39-────────────────────────────────────────────────────────────┴───────────────────────────────────────────────────────────
40- test-provider ⠋ 
1+ 1   │ 
2+ │ 
3+ │ 
4+ │ 
5+ │ 
6+ │ 
7+ │ 
8+ │ 
9+ │ 
10+ │ 
11+ │ 
12+ │ 
13+ │ 
14+ │ 
15+ │ 
16+ │ 
17+ │ 
18+ │ 
19+ │ 
20+ │ 
21+ │ 
22+ │ 
23+ │ 
24+ │ 
25+ │ 
26+ │ 
27+ │ 
28+ │ 
29+ │ 
30+ │ 
31+ │ 
32+ │ 
33+ │ 
34+ │ 
35+ │───────────────────────────────────────────────────────────
36+ │Type a message...  
37+ │  
38+ │  
39+────────────────────────────────────────────────────────────┴───────────────────────────────────────────────────────────
40+ test-provider ⠋ 
internal/tui/testdata/TestLayout/80x24/ANSI.golden+24−24
@@ -1,24 +1,24 @@
1- 1   │ 
2- │ 
3- │ 
4- │ 
5- │ 
6- │ 
7- │ 
8- │ 
9- │ 
10- │ 
11- │ 
12- │ 
13- │ 
14- │ 
15- │ 
16- │ 
17- │ 
18- │ 
19- │───────────────────────────────────────
20- │Type a message...  
21- │  
22- │  
23-────────────────────────────────────────┴───────────────────────────────────────
24- test-provider ⠋ 
1+ 1   │ 
2+ │ 
3+ │ 
4+ │ 
5+ │ 
6+ │ 
7+ │ 
8+ │ 
9+ │ 
10+ │ 
11+ │ 
12+ │ 
13+ │ 
14+ │ 
15+ │ 
16+ │ 
17+ │ 
18+ │ 
19+ │───────────────────────────────────────
20+ │Type a message...  
21+ │  
22+ │  
23+────────────────────────────────────────┴───────────────────────────────────────
24+ test-provider ⠋ 
internal/tui/tui.go+15−0
@@ -10,12 +10,14 @@ import (
1010 "charm.land/lipgloss/v2"
1111 "github.com/xonecas/symb/internal/constants"
1212 "github.com/xonecas/symb/internal/delta"
13+ "github.com/xonecas/symb/internal/filesearch"
1314 "github.com/xonecas/symb/internal/llm"
1415 "github.com/xonecas/symb/internal/mcp"
1516 "github.com/xonecas/symb/internal/provider"
1617 "github.com/xonecas/symb/internal/store"
1718 "github.com/xonecas/symb/internal/treesitter"
1819 "github.com/xonecas/symb/internal/tui/editor"
20+ "github.com/xonecas/symb/internal/tui/modal"
1921 )
2022
2123 // ---------------------------------------------------------------------------
@@ -233,6 +235,9 @@ type Model struct {
233235 // Editor state
234236 editorFilePath string // absolute path of the file currently shown in the editor
235237
238+ // File finder modal
239+ fileModal *modal.Model
240+ searcher *filesearch.Searcher
236241 // Pending tool calls: maps tool call ID → arguments for line extraction
237242 pendingToolCalls map[string]provider.ToolCall
238243
@@ -329,6 +334,8 @@ func New(prov provider.Provider, proxy *mcp.Proxy, tools []mcp.Tool, modelID str
329334 fileTracker: ft,
330335 tsIndex: idx,
331336
337+ searcher: newSearcherOrNil("."),
338+
332339 streamEntryStart: -1,
333340 hoverConvLine: -1,
334341
@@ -336,6 +343,14 @@ func New(prov provider.Provider, proxy *mcp.Proxy, tools []mcp.Tool, modelID str
336343 }
337344 }
338345
346+func newSearcherOrNil(root string) *filesearch.Searcher {
347+ s, err := filesearch.NewSearcher(root)
348+ if err != nil {
349+ return nil
350+ }
351+ return s
352+}
353+
339354 // Init starts cursor blink, the 60fps frame loop, and periodic git branch polling.
340355 func (m Model) Init() tea.Cmd {
341356 return tea.Batch(func() tea.Msg { return editor.Blink() }, frameTick(), gitBranchCmd())
internal/tui/update.go+87−12
@@ -11,7 +11,9 @@ import (
1111
1212 tea "charm.land/bubbletea/v2"
1313 "github.com/rs/zerolog/log"
14+ "github.com/xonecas/symb/internal/filesearch"
1415 "github.com/xonecas/symb/internal/provider"
16+ "github.com/xonecas/symb/internal/tui/modal"
1517 )
1618
1719 // ---------------------------------------------------------------------------
@@ -21,6 +23,11 @@ import (
2123 func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
2224 m.frameLines = nil // invalidate per-frame wrap cache
2325
26+ // File finder modal intercepts all input when open.
27+ if mdl, cmd, handled := m.updateFileModal(msg); handled {
28+ return mdl, cmd
29+ }
30+
2431 switch msg := msg.(type) {
2532
2633 // -- Window resize -------------------------------------------------------
@@ -28,12 +35,8 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
2835 m.handleResize(msg)
2936
3037 // -- Paste (clipboard read or bracketed paste) ---------------------------
31- case tea.ClipboardMsg:
32- m.insertPaste(msg.String())
33- return m, nil
34- case tea.PasteMsg:
35- m.insertPaste(msg.Content)
36- return m, nil
38+ case tea.ClipboardMsg, tea.PasteMsg:
39+ return m.handlePaste(msg)
3740
3841 // -- Mouse ---------------------------------------------------------------
3942 case tea.MouseMsg:
@@ -57,12 +60,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
5760
5861 // -- LLM user message (sent before streaming begins) ---------------------
5962 case llmUserMsg:
60- m.llmInFlight = true
61- turnCtx, turnCancel := context.WithCancel(m.ctx)
62- m.turnCancel = turnCancel
63- m.turnCtx = turnCtx
64- mdl := m.handleUserMsg(msg)
65- return mdl, tea.Batch(mdl.processLLM(), mdl.waitForLLMUpdate())
63+ return m.handleLLMUser(msg)
6664
6765 case LSPDiagnosticsMsg:
6866 return m.handleLSPDiag(msg), nil
@@ -98,6 +96,30 @@ func (m Model) forwardToSubModels(msg tea.Msg) (tea.Model, tea.Cmd) {
9896 return m, tea.Batch(cmds...)
9997 }
10098
99+func (m Model) handlePaste(msg tea.Msg) (tea.Model, tea.Cmd) {
100+ var text string
101+ switch v := msg.(type) {
102+ case tea.ClipboardMsg:
103+ text = v.Content
104+ case tea.PasteMsg:
105+ text = v.Content
106+ }
107+ if text != "" {
108+ m.insertPaste(text)
109+ }
110+ return m, nil
111+}
112+
113+func (m Model) handleLLMUser(msg llmUserMsg) (tea.Model, tea.Cmd) {
114+ m = m.handleUserMsg(msg)
115+ if m.provider == nil {
116+ return m, nil
117+ }
118+ m.llmInFlight = true
119+ m.turnCtx, m.turnCancel = context.WithCancel(context.Background())
120+ return m, tea.Batch(m.processLLM(), m.waitForLLMUpdate())
121+}
122+
101123 // handleLSPDiag applies LSP diagnostic markers when the file matches the editor.
102124 func (m *Model) handleLSPDiag(msg LSPDiagnosticsMsg) Model {
103125 if msg.FilePath == m.editorFilePath {
@@ -186,6 +208,11 @@ func (m *Model) handleKeyPress(msg tea.KeyPressMsg) (Model, tea.Cmd, bool) {
186208 m.agentInput.Reset()
187209 return *m, m.sendToLLM(userMsg), true
188210 }
211+ case "ctrl+f":
212+ if m.searcher != nil {
213+ m.openFileModal()
214+ return *m, nil, true
215+ }
189216 }
190217 return Model{}, nil, false
191218 }
@@ -694,3 +721,51 @@ func (m *Model) handleUndo() Model {
694721
695722 return *m
696723 }
724+
725+func (m *Model) openFileModal() {
726+ searchFn := func(query string) []modal.Item {
727+ if query == "" {
728+ return nil
729+ }
730+ results, err := m.searcher.Search(context.Background(), filesearch.Options{
731+ Pattern: query,
732+ ContentSearch: false,
733+ MaxResults: 50,
734+ })
735+ if err != nil {
736+ return nil
737+ }
738+ items := make([]modal.Item, len(results))
739+ for i, r := range results {
740+ items[i] = modal.Item{Name: r.Path}
741+ }
742+ return items
743+ }
744+ md := modal.New(searchFn, "Open: ")
745+ m.fileModal = &md
746+}
747+
748+func (m *Model) updateFileModal(msg tea.Msg) (Model, tea.Cmd, bool) {
749+ if m.fileModal == nil {
750+ return *m, nil, false
751+ }
752+ action, cmd := m.fileModal.HandleMsg(msg)
753+ switch a := action.(type) {
754+ case modal.ActionClose:
755+ m.fileModal = nil
756+ return *m, nil, true
757+ case modal.ActionSelect:
758+ m.fileModal = nil
759+ openCmd := m.tryOpenFilePath(a.Item.Name)
760+ return *m, openCmd, true
761+ }
762+ if cmd != nil {
763+ return *m, cmd, true
764+ }
765+ // Modal is open — absorb key/mouse events, pass through others.
766+ switch msg.(type) {
767+ case tea.KeyPressMsg, tea.MouseMsg:
768+ return *m, nil, true
769+ }
770+ return *m, nil, false
771+}
internal/tui/view.go+5−1
@@ -14,7 +14,11 @@ import (
1414 // ---------------------------------------------------------------------------
1515
1616 func (m Model) View() tea.View {
17- v := tea.NewView(m.renderContent())
17+ content := m.renderContent()
18+ if m.fileModal != nil {
19+ content = m.fileModal.View(m.width, m.height)
20+ }
21+ v := tea.NewView(content)
1822 v.AltScreen = true
1923 v.MouseMode = tea.MouseModeAllMotion
2024 // Keyboard enhancements are automatically enabled in v2 (Kitty protocol).