Skip to content

feat(gui): 60 FPS draggable sidebar divider with visual hover indicator - #48

Open
felipecm-br wants to merge 1 commit into
Blankeos:mainfrom
felipecm-br:feat/draggable-grab-column-hover
Open

felipecm-br wants to merge 1 commit into
Blankeos:mainfrom
felipecm-br:feat/draggable-grab-column-hover

Conversation

@felipecm-br

@felipecm-br felipecm-br commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR enhances the draggable sidebar divider with a visual grab column indicator and smooth 60 FPS mouse drag responsiveness.

Changes & Improvements:

  1. Visual Grab Column & Hover Feedback:

    • Computes a dedicated 1-column separator (grab_column) in normal horizontal layout between the sidebar panels and the main/diff panel.
    • Renders a clean separator (│) at rest matching border styles.
    • Highlights the entire separator column using theme.selected_bg and theme.accent when hovered or actively dragged.
    • Enables terminal mouse motion reporting via DEC 1003h (\x1b[?1003h) so hover states update cleanly when moving the cursor across the divider.
    • Restores terminal mouse mode (\x1b[?1003l) cleanly in both restore_terminal and the panic hook.
  2. 60 FPS Responsive Dragging:

    • In input_wait_timeout(), previously only asynchronous operations dropped the poll timeout to 16ms. During mouse drag resizing, it was constrained to 5 FPS (200ms) or 20 FPS (50ms).
    • Added self.sidebar_resizing to the 16ms condition so dragging gestures are smooth at ~60 FPS without triggering unnecessary Git state reloads.
  3. Tests & Formatting:

    • Added unit test grab_column_layout_and_resizing_timeout verifying the 1-char layout strip and the 16ms timeout during active drag.
    • All 372 unit tests passing; code formatted with cargo fmt.
screenrecording-2026-10-09_20-41-07.mp4

- Reserve a 1-column visual grab strip between sidebar and main panel in normal layout
- Highlight grab strip with theme selected_bg and accent color on mouse hover and drag
- Cap frame rate to 16ms (~60 FPS) in input_wait_timeout during active sidebar resizing
- Enable terminal mouse motion tracking (DEC 1003h) with safe teardown in restore_terminal and panic hook
- Add unit tests for grab_column calculation and 16ms resizing timeout
@Blankeos

Blankeos commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

feat/draggable-grab-column-hover → main
Model: claude-sonnet-5-5, effort unknown

Confidence: 3/5

Works and tests/fmt pass, but the "60 FPS" claim doesn't hold up when measured, it re-enables the passive mouse motion (?1003h) that main deliberately avoids, and the hover affordance disappears on narrow (portrait) terminals.

Checks run

  • cargo test: 372 passed, 0 failed. cargo fmt --check: clean.
  • Ran main (6dba4a0) and this PR as release builds in a pty (120x30) and replayed an SGR mouse drag of 100 events at 30, 60 and 120 Hz, plus 5s idle and 5s of 60 Hz hover.
    • Event → first-output latency: median ~1.3ms on both, p95 ~3-5ms on both. No difference.
    • CPU during the drag: main 0.15s/0.13s/0.23s vs PR 0.19s/0.17s/0.34s (60/120/30 Hz). Frames drawn: main 188/179/199 vs PR 234/218/323. The PR draws more, not faster.
    • Idle and hover cost: identical.
  • Why: wait_batch uses recv_timeout, which returns the instant an event arrives. The poll timeout only matters when no input is arriving, so lowering it to 16ms while dragging can't make drag more responsive. It only adds idle redraws between events.
  • Screenshots in the VM, main vs PR:
    • 120x30: the strip is 1 column, a grey full-height bar on hover/drag; the drag moves the sidebar.
    • 80x40 (portrait, width <= 84 and height > 25): grab_column is None, so layout is unchanged and hovering the horizontal divider shows nothing.
    • 80x24 (narrow landscape): the strip still renders and costs 1 of 80 columns.

Summary

Thanks Felipe, the grab strip is a nice idea and lazygit does have a draggable divider. Three things:

  1. Perf claim: measured above, there's no drag-latency gain. I'd drop the 16ms change (or the claim). If drag ever feels laggy it's the redraw cost per event, not the poll timeout.
  2. ?1003h: EnableMouseCaptureWithoutHover exists because passive motion made some terminals focus/redraw on pointer movement. This undoes that for every user, for a hover color. Hover could be limited to the drag, or 1003 enabled only while the pointer is near the divider.
  3. Narrow terminals: in portrait there's no strip and no hover, so the feature is inconsistent. Either give the horizontal divider the same highlight or document it as landscape-only.

Map

flowchart LR
  main[main.rs panic hook] -->|1003l| term[gui/mod.rs setup/restore_terminal]
  term -->|1003h| mouse[handle_mouse hover + drag]
  mouse --> hit[sidebar_divider_hit]
  hit --> layout[layout.rs grab_column]
  mouse -->|grab_column_hovered| views[views.rs render]
  layout --> views
  mouse --> timeout[input_wait_timeout 16ms]
Loading

Start at layout.rs (new grab_column), then handle_mouse in gui/mod.rs.

Regressions

  • Passive motion reporting is back on for all sessions.
  • Main panel is permanently 1 column narrower in landscape Normal layout (checked 120 and 80 wide; nothing broke visually).
  • A left-drag starting in the main panel and crossing the 3-column hit zone no longer updates text selection while over it.
  • The 3-column hit zone overlaps the neighbouring panels' border cells.
  • Portrait mode has no hover feedback.
  • More redraws during drag (see CPU/frames above).

Migrations

None.

Before merging

  • Drop or justify the 16ms timeout (no measured gain)
  • Decide on ?1003h (opt-in, or only while near the divider)
  • Decide on portrait feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants