@@ -31,6 +31,29 @@ import (
31 "github.com/charmbracelet/lipgloss/v2"
31 "github.com/charmbracelet/lipgloss/v2"
34+// MouseEventFilter filters mouse events based on the current focus state
35+// This is used with tea.WithFilter to prevent mouse scroll events from
36+// interfering with typing performance in the editor
37+func MouseEventFilter(m tea.Model, msg tea.Msg) tea.Msg {
38+ // Only filter mouse events
40+ case tea.MouseWheelMsg, tea.MouseMotionMsg:
41+ // Check if we have an appModel and if editor is focused
42+ if appModel, ok := m.(*appModel); ok {
43+ if appModel.currentPage == chat.ChatPageID {
44+ if chatPage, ok := appModel.pages[appModel.currentPage].(chat.ChatPage); ok {
45+ // If editor is focused (not chatFocused), filter out mouse wheel/motion events
46+ if !chatPage.IsChatFocused() {
47+ return nil // Filter out the event
53+ // Allow all other events to pass through
34// appModel represents the main application model that manages pages, dialogs, and UI state.
57// appModel represents the main application model that manages pages, dialogs, and UI state.
35type appModel struct {
58type appModel struct {
36 wWidth, wHeight int // Window dimensions
59 wWidth, wHeight int // Window dimensions
@@ -82,9 +105,6 @@ func (a appModel) Init() tea.Cmd {
82 return nil
105 return nil
85− // Enable mouse support.
86− cmds = append(cmds, tea.EnableMouseAllMotion)
88 return tea.Batch(cmds...)
108 return tea.Batch(cmds...)