Skip to content

Mouse Support

Eshan Roy edited this page Jun 18, 2026 · 1 revision

Mouse Support

M31 Autonomous (M31A) provides full mouse interaction across all viewport-based screens.

Overview

Source: internal/tui/repl_mouse.go

Mouse support is enabled via tea.MouseAll in the program options. The REPL model dispatches mouse events to the appropriate handler based on coordinates and UI state.

Supported Events

Scroll Wheel

Scroll wheel events are forwarded to the active viewport. Supported on:

  • REPL viewport
  • Plan model viewport
  • Execute model viewport
  • Verify model viewport
  • Ship model viewport
  • Ledger model viewport
  • Chat history viewport

Left Click

Left-click events are routed based on the click coordinates:

Target Action
Viewport area Focus textarea + mark user-scrolled
Slash-suggestion overlay Select the suggestion item
Mention-suggestion overlay Complete the mention
Scrollbar thumb Begin drag-scrolling

Scrollbar Drag

Click and drag on the scrollbar thumb to scroll the viewport proportionally. The drag state is tracked via scrollbarDragging in the REPL model.

Implementation

The mouse event dispatcher is implemented in repl_mouse.go:

handleMouseMsg(msg)
    ├── MouseActionPress
    │   ├── WheelUp/Down/Left/Right → handleWheel()
    │   └── MouseButtonLeft → handleLeftClick()
    ├── MouseActionRelease
    │   └── MouseButtonLeft → stop drag
    └── MouseActionMotion
        └── handleScrollbarDrag()

Handler Functions

Function Purpose
handleMouseMsg() Main dispatcher for all mouse events
handleWheel() Scroll wheel events forwarded to viewport
handleLeftClick() Routes clicks to overlays, scrollbar, or viewport
handleScrollbarDrag() Drag-scrolling via scrollbar thumb
handleViewportClick() Tool card click detection in viewport

Key Bindings

Mouse events are handled in the Update loop alongside keyboard events. No additional keybindings are required -- mouse interaction is always active when the terminal supports it.

Terminal Compatibility

Mouse support requires a terminal that sends mouse escape sequences. Most modern terminals support this:

  • iTerm2 (macOS)
  • Terminal.app (macOS)
  • GNOME Terminal (Linux)
  • Alacritty
  • Kitty
  • Windows Terminal
  • WezTerm

Source Files

File Purpose
internal/tui/repl_mouse.go Mouse event dispatcher (301 lines)
internal/tui/repl_model.go Mouse state fields (scrollbarDragging, userScrolled)
internal/tui/repl.go Mouse event forwarding to handler
internal/tui/app_update.go Mouse event routing to sidebar and sub-models
internal/tui/sidebar_model.go Sidebar HandleMouse() method

Clone this wiki locally