Skip to content

REF: share Sessions approval hit testing and filtered selection - #99

Merged
merefield merged 1 commit into
mainfrom
refactor/session-hit-testing-index
Nov 5, 2026
Merged

merefield merged 1 commit into
mainfrom
refactor/session-hit-testing-index

Conversation

@merefield

Copy link
Copy Markdown
Owner

Why

Finish the two small Sessions cleanup opportunities identified after #98: approval click geometry still repeated across detail modes, and navigation/dismissal independently built the same filtered session list. Share those rules to prevent future drift without changing the interface or widening the refactor into log scanning, scheduling or benchmark execution.

Changes

  • Add a single frame-local approval-button hit tester, alongside the shared button renderer. Reuse it for ordinary approvals in full detail/wide inline detail and quota-threshold approvals in split/wide/full detail.
  • Preserve the current frame offsets, control-row allocation, visible label widths, hit-test ordering, action strings and two-step confirmation rules. Confirmation-slot padding stays inactive; Unicode/ANSI label widths remain terminal-cell based. Remove the misleading profile-only helper name now that both approval families share the implementation.
  • Share the current filtered session IDs and selected index between keyboard session navigation and selected-session dismissal. Keep their distinct empty-list/focus behaviour, draft preservation, dismissal watermarks, scroll handling and accounting unchanged. No caching or additional session state.

No user-visible feature, layout, colour, shortcut, API, web-interface, dependency or version changes. The local release binary is not replaced. The main-owned duplication baseline is not edited.

Measurements

Compared with main at a955824, using its unchanged scanner and policy. All gated metrics are equal or lower, with no new production clone candidates:

Scan Clones before → after Duplicated lines before → after Duplicated tokens before → after
exact-50 31 → 29 285 → 267 2,231 → 2,089
renamed-50 149 → 147 1,537 → 1,519 11,175 → 11,033
exact-100 2 → 2 28 → 28 274 → 274
renamed-100 11 → 11 212 → 212 1,928 → 1,928

Production Go is 17 lines smaller; add 117 lines of regression tests without removing or weakening existing coverage. This is a modest consistency/maintenance improvement, not a binary-size or performance claim. Scanner spans are not unique removable LOC.

Validation

  • New hit-testing tests use explicit coordinates for short/tall layouts, ANSI/wide-character labels, exact left/right boundaries, wrapped-row gaps, empty controls and non-clickable confirmation padding.
  • New selection tests cover all status filters, dismissed/undisplayed/missing selections, an empty list, middle/last/sole matching rows, navigation vs dismissal focus differences, session-scoped draft retention, unchanged token accounting and dismissal activity watermarks.
  • Existing rendered click-surface, resize, confirmation, profile, filtering, navigation and draft regressions pass. The full/split/wide renderer callers remain covered by the existing interaction matrix.
  • Full race-enabled core suite with coverage passes: go test -race -cover -timeout 10m -skip '^TestLocalisedScreens$' ./....
  • go vet ./..., go build -trimpath ./... and git diff --check pass.
  • All seven existing terminal screenshot fixtures remain unchanged: make screenshots-check.
  • The complete 17-locale matrix remains enabled in CI, along with Linux/macOS/Windows tests. Test-source duplication stays report-only.

After merge and successful main CI, the existing main-only writer should automatically ratchet the baseline to these lower measurements.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the consolidation of approval hit testing and filtered session selection.

No open issues 🎉

What changed in this PR

This pull request consolidates Sessions approval hit testing and filtered session selection logic, reducing duplication while preserving existing UI behavior, focus handling, confirmation flows, dismissal state, drafts, and accounting.

Changes:

  • Adds shared frame-local approval-button hit testing across detail modes.
  • Shares filtered session selection between navigation and dismissal.
  • Adds regression coverage for hit-test boundaries, filters, focus, drafts, watermarks, and accounting.
File Description
internal/​ui/​monitor_selection_test.go Tests filtered selection, navigation, dismissal, drafts, watermarks, and accounting.
internal/​ui/​monitor_profile.go Removes the superseded profile-specific hit-testing helper.
internal/​ui/​monitor_context.go Reuses shared hit testing for full-detail and split-row controls.
internal/​ui/​monitor_context_modes.go Reuses shared hit testing for expanded inline approvals.
internal/​ui/​monitor_buttons_test.go Tests button geometry, visible-label boundaries, and confirmation-slot behavior.
internal/​ui/​monitor_approval.go Adds the shared approval-button hit-testing helper.
internal/​ui/​model.go Shares filtered session selection logic between navigation and dismissal.

Review effort: Lite

@merefield
merefield merged commit 64fb144 into main Nov 5, 2026
9 checks passed
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