@@ -32,6 +32,29 @@ import (
3232 "github.com/charmbracelet/lipgloss/v2"
3333)
3434
35+// MouseEventFilter filters mouse events based on the current focus state
36+// This is used with tea.WithFilter to prevent mouse scroll events from
37+// interfering with typing performance in the editor
38+func MouseEventFilter(m tea.Model, msg tea.Msg) tea.Msg {
39+ // Only filter mouse events
40+ switch msg.(type) {
41+ case tea.MouseWheelMsg, tea.MouseMotionMsg:
42+ // Check if we have an appModel and if editor is focused
43+ if appModel, ok := m.(*appModel); ok {
44+ if appModel.currentPage == chat.ChatPageID {
45+ if chatPage, ok := appModel.pages[appModel.currentPage].(chat.ChatPage); ok {
46+ // If editor is focused (not chatFocused), filter out mouse wheel/motion events
47+ if !chatPage.IsChatFocused() {
48+ return nil // Filter out the event
49+ }
50+ }
51+ }
52+ }
53+ }
54+ // Allow all other events to pass through
55+ return msg
56+}
57+
3558// appModel represents the main application model that manages pages, dialogs, and UI state.
3659type appModel struct {
3760 wWidth, wHeight int // Window dimensions
@@ -67,6 +90,8 @@ func (a appModel) Init() tea.Cmd {
6790 cmd = a.status.Init()
6891 cmds = append(cmds, cmd)
6992
93+ cmds = append(cmds, tea.EnableMouseAllMotion)
94+
7095 return tea.Batch(cmds...)
7196}
7297