on main help sign in
Merge remote-tracking branch 'origin/main' into onboarding
commite9e938a9b9a20ad223ad78080bdfbc35881ba4b8 authorKujtim Hoxha <kujtimii.h@gmail.com> dateWed 9 Jul 2025, 11:19 (1 year ago) parentdc2230b55a3756
4 files changed+31
cmd/root.go+2 internal/tui/components/chat/editor/editor.go+1 internal/tui/page/chat/chat.go+5 internal/tui/tui.go+23
cmd/root.go+2
@@ -118,6 +118,8 @@ to assist developers in writing, debugging, and understanding code directly from
118118 tea.WithAltScreen(),
119119 tea.WithKeyReleases(),
120120 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
121123 )
122124
123125 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) {
265265 }
266266 }
267267 }
268+
268269 m.textarea, cmd = m.textarea.Update(msg)
269270 cmds = append(cmds, cmd)
270271 return m, tea.Batch(cmds...)
internal/tui/page/chat/chat.go+5
@@ -68,6 +68,7 @@ const (
6868type ChatPage interface {
6969 util.Model
7070 layout.Help
71+ IsChatFocused() bool
7172}
7273
7374// cancelTimerCmd creates a command that expires the cancel timer
@@ -557,3 +558,7 @@ func (p *chatPage) Bindings() []key.Binding {
557558
558559 return bindings
559560}
561+
562+func (p *chatPage) IsChatFocused() bool {
563+ return p.focusedPane == PanelTypeChat
564+}
internal/tui/tui.go+23
@@ -30,6 +30,29 @@ import (
3030 "github.com/charmbracelet/lipgloss/v2"
3131)
3232
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+
3356// appModel represents the main application model that manages pages, dialogs, and UI state.
3457type appModel struct {
3558 wWidth, wHeight int // Window dimensions