@@ -32,6 +32,29 @@ import (
32 "github.com/charmbracelet/lipgloss/v2"
32 "github.com/charmbracelet/lipgloss/v2"
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
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
54+ // Allow all other events to pass through
35// appModel represents the main application model that manages pages, dialogs, and UI state.
58// appModel represents the main application model that manages pages, dialogs, and UI state.
36type appModel struct {
59type appModel struct {
37 wWidth, wHeight int // Window dimensions
60 wWidth, wHeight int // Window dimensions
@@ -67,6 +90,8 @@ func (a appModel) Init() tea.Cmd {
67 cmd = a.status.Init()
90 cmd = a.status.Init()
68 cmds = append(cmds, cmd)
91 cmds = append(cmds, cmd)
93+ cmds = append(cmds, tea.EnableMouseAllMotion)
70 return tea.Batch(cmds...)
95 return tea.Batch(cmds...)