Skip to content

feat: cache bottom-panel geometry; resolve_bottom_panel_zone (#418) - #424

Merged
JDonaghy merged 4 commits into
developfrom
issue-418-terminal-hit-regions
May 16, 2026
Merged

feat: cache bottom-panel geometry; resolve_bottom_panel_zone (#418)#424
JDonaghy merged 4 commits into
developfrom
issue-418-terminal-hit-regions

Conversation

@JDonaghy

Copy link
Copy Markdown
Owner

Summary

  • GTK: terminal panel click handlers should use cached hit regions from draw #418 main feature — Both GTK click handlers (mouse-down, mouse-drag) and the TUI mouse handler each recomputed the bottom panel's top-y and zone-row boundaries from scratch (~20 lines of chrome/status/wildmenu math per site, including a pixel-exact maximize snap that had to match draw.rs by hand — three copies, three drift opportunities). Now: paint-time writes a single BottomPanelGeometry { top_y, height, row_h }; click handlers call Engine::resolve_bottom_panel_zone(y) -> Option<BottomPanelZone> and dispatch on TabBar / Toolbar / Content { row_offset }. Net -125 lines across the two backends. Sidesteps the PanelChromeDesc row-vs-pixel discrepancy (quadraui: PanelChromeDesc is row-based but GTK chrome is sub-row (pixel mismatch) #168) for the click path — paint/click agreement is guaranteed by construction.
  • Drive-by fix:quadraui::ContextMenuItem gained checked/key_equivalent/submenu fields; develop wasn't compiling. Added ..Default::default() to the 4 literals in src/render.rs. Smallest possible unblock; the struct derives Default and the docstring explicitly recommends struct-update syntax.
  • CLAUDE.md docs: — New step 1 in the dev workflow: claim an issue before starting work via gh issue edit <N> --add-assignee @me plus an empty branch push. Multiple agents may run concurrently; an explicit claim signal prevents races. Step 3 adjusted so subsequent pushes to the claim branch are fine (PR-creation gate is preserved).

Closes #418.

Test plan

  • cargo fmt && cargo clippy -- -D warnings && cargo test --no-default-features --lib && cargo build — all green locally before pushing
  • GTK terminal click parity (non-maximized): open the terminal panel, click the tab bar (TERMINAL / DEBUG CONSOLE), click toolbar buttons (split / maximize / close / + new tab), click in the content area and drag-select text
  • GTK terminal click parity (maximized): maximize the terminal panel, repeat all of the above — verify the panel top still resolves correctly under the pixel-exact maximize snap
  • GTK split divider: with terminal split active, click the divider (should start drag) and the panes on either side (should switch focus)
  • TUI terminal click parity: same checklist as GTK — tab bar, toolbar buttons, content selection, scrollbar column drag in the scrollback
  • TUI terminal-debug switch: with both terminal and debug output present, click between TERMINAL and DEBUG CONSOLE in the tab bar
  • Click below the panel: verify clicks on the status bar / wildmenu / debug toolbar rows don't wrongly resolve to terminal content (the new height bound in BottomPanelGeometry)

🤖 Generated with Claude Code

JDonaghy and others added 3 commits May 16, 2026 14:56
…g work

Multiple agents may be active concurrently; without an explicit claim
signal two agents can race on the same issue. Adds a new step 1 to the
development workflow: `gh issue edit <N> --add-assignee @me` plus an
empty feature branch pushed from develop. Adjusts step 3 so subsequent
pushes to the claim branch are fine (the no-PR-yet gate is preserved).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
quadraui::ContextMenuItem gained three new optional fields (checked,
key_equivalent, submenu); develop wouldn't compile without them. The
struct derives Default and the doc explicitly recommends struct-update
syntax for forward compat. Patches the 4 literals in src/render.rs
(build_menu_defs separator + item; context_menu_to_quadraui item +
separator_after). Drive-by to unblock CI for issue-418.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Both GTK click handlers (mouse-down, mouse-drag) and the TUI mouse
handler each recomputed the bottom panel's top-y and zone-row
boundaries from scratch — ~20 lines of chrome/status/wildmenu math
per site, including a pixel-exact maximize snap that had to match
draw.rs by hand. Three copies, three opportunities to drift.

This caches the geometry once at paint time and exposes a single
engine helper:

- New `BottomPanelGeometry { top_y, height, row_h }` written at paint
  time by gtk/draw.rs (pixels) and tui_main/render_impl.rs (rows).
  Cleared in the else-branch when the panel isn't painted.
- New `BottomPanelZone { TabBar, Toolbar, Content { row_offset } }`
  returned by `Engine::resolve_bottom_panel_zone(y)` — unit-agnostic
  so both backends share the same dispatch.
- GTK click handlers reduced from ~50 lines of pixel math each to a
  single `resolve_bottom_panel_zone(y)` call. Net -95 lines in
  gtk/mod.rs.
- TUI mouse handler same migration for the tab-bar and terminal-panel
  dispatch sites. Net -30 lines in tui_main/mouse.rs.

Sidesteps the PanelChromeDesc row-vs-pixel discrepancy (#168) for
the click path: the click handlers now read the same value the paint
function wrote, so paint/click agreement is guaranteed by construction.

Closes #418.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace uniform `row_h` with `toolbar_y`, `content_y`, and
`content_row_h` so backends with non-uniform row heights (e.g. GTK's
taller tab bar) get correct zone detection. Also fixes:
- TerminalCopySelection RefCell double-borrow (same pattern as #419)
- ContextMenuItem ..Default::default() compile error after rebase

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@JDonaghy
JDonaghy force-pushed the issue-418-terminal-hit-regions branch from de8f14b to 8a53307 Compare May 16, 2026 21:11
@JDonaghy

Copy link
Copy Markdown
Owner Author

Rebased onto develop, fixed three issues:

  1. BottomPanelGeometry — replaced uniform row_h with explicit toolbar_y / content_y / content_row_h offsets so backends with non-uniform row heights get correct zone detection.
  2. TerminalCopySelection RefCell crash — same double-borrow pattern fixed in refactor: route GTK clipboard read/write through engine callbacks (#417) #419, reintroduced by the PR's old code surviving rebase.
  3. ContextMenuItem compile error — removed ..Default::default() (struct doesn't derive Default).

Pre-existing TUI terminal split issues filed as #428. Terminal click dedup follow-up filed as #429.

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.

1 participant