on main help sign in
Merge remote-tracking branch 'origin/main' into onboarding
e9e938aKujtim Hoxha
cmd/root.go+2
@@ -118,6 +118,8 @@ to assist developers in writing, debugging, and understanding code directly from
118 tea.WithAltScreen(),
118 tea.WithAltScreen(),
119 tea.WithKeyReleases(),
119 tea.WithKeyReleases(),
120 tea.WithUniformKeyLayout(),
120 tea.WithUniformKeyLayout(),
121+ tea.WithMouseCellMotion(), // Use cell motion instead of all motion to reduce event flooding
122+ tea.WithFilter(tui.MouseEventFilter), // Filter mouse events based on focus state
121 )
123 )
122
124
123 go app.Subscribe(program)
125 go app.Subscribe(program)
internal/tui/components/chat/editor/editor.go+1
@@ -265,6 +265,7 @@ func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
265 }
265 }
266 }
266 }
267 }
267 }
268+
268 m.textarea, cmd = m.textarea.Update(msg)
269 m.textarea, cmd = m.textarea.Update(msg)
269 cmds = append(cmds, cmd)
270 cmds = append(cmds, cmd)
270 return m, tea.Batch(cmds...)
271 return m, tea.Batch(cmds...)
internal/tui/page/chat/chat.go+5
@@ -68,6 +68,7 @@ const (
68type ChatPage interface {
68type ChatPage interface {
69 util.Model
69 util.Model
70 layout.Help
70 layout.Help
71+ IsChatFocused() bool
71}
72}
72
73
73// cancelTimerCmd creates a command that expires the cancel timer
74// cancelTimerCmd creates a command that expires the cancel timer
@@ -557,3 +558,7 @@ func (p *chatPage) Bindings() []key.Binding {
557
558
558 return bindings
559 return bindings
559}
560}
561+
562+func (p *chatPage) IsChatFocused() bool {
563+ return p.focusedPane == PanelTypeChat
564+}
internal/tui/tui.go+23
@@ -30,6 +30,29 @@ import (
30 "github.com/charmbracelet/lipgloss/v2"
30 "github.com/charmbracelet/lipgloss/v2"
31)
31)
32
32
33+// MouseEventFilter filters mouse events based on the current focus state
34+// This is used with tea.WithFilter to prevent mouse scroll events from
35+// interfering with typing performance in the editor
36+func MouseEventFilter(m tea.Model, msg tea.Msg) tea.Msg {
37+ // Only filter mouse events
38+ switch msg.(type) {
39+ case tea.MouseWheelMsg, tea.MouseMotionMsg:
40+ // Check if we have an appModel and if editor is focused
41+ if appModel, ok := m.(*appModel); ok {
42+ if appModel.currentPage == chat.ChatPageID {
43+ if chatPage, ok := appModel.pages[appModel.currentPage].(chat.ChatPage); ok {
44+ // If editor is focused (not chatFocused), filter out mouse wheel/motion events
45+ if !chatPage.IsChatFocused() {
46+ return nil // Filter out the event
47+ }
48+ }
49+ }
50+ }
51+ }
52+ // Allow all other events to pass through
53+ return msg
54+}
55+
33// appModel represents the main application model that manages pages, dialogs, and UI state.
56// appModel represents the main application model that manages pages, dialogs, and UI state.
34type appModel struct {
57type appModel struct {
35 wWidth, wHeight int // Window dimensions
58 wWidth, wHeight int // Window dimensions