@@ -30,6 +30,29 @@ import (
30 "github.com/charmbracelet/lipgloss/v2"
30 "github.com/charmbracelet/lipgloss/v2"
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
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
52+ // Allow all other events to pass through
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