Skip to content

fix(tui): let a new approval actually take focus - #414

Merged
github-actions[bot] merged 1 commit into
mainfrom
fix/approval-focus-claim
Aug 21, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
fix/approval-focus-claim

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

An approval prompt that painted before the tick got its focus grab silently skipped, and every key on the card except Esc did nothing. The card looked interactive and wasn't.

The bug

draw() calls sync_approval_menu() (app/render.rs:318), which stamps menu.call_id. sync_approval_focus() (app/shell.rs:210) used that same field to decide whether the prompt was new — so once a frame had painted, the prompt read as already-seen and focus was never claimed.

handle_approval_menu_key gates on FocusBlock::Approval, so arrows, Enter and the shortcut letters (y/a/n) were all dropped. Esc worked only because it is handled globally.

The gate itself is correct and stays: Tab away to the file explorer mid-approval and arrows should move the tree, not the menu. The defect was upstream of it.

The fix

sync_approval_focus tracks its own focus_claimed_for, so what a frame does can no longer decide what the tick has handled.

This is the same class as the existing "no side effects in draw()" rule. draw() still mutates menu state — that is load-bearing for rendering and now harmless — so this change does not touch it.

Verification

approval_claims_focus_even_if_a_frame_paints_first simulates the real order (draw, then tick). Reverting only approvals.rs makes it fail at the focus assertion; it passes with the fix.

cargo fmt --all -- --check clean, cargo clippy --all-targets clean, cargo test --workspace green across 45 test binaries.

https://claude.ai/code/session_01XBsriDsqoNQsMD1dgacF5p

An approval that painted before the tick got its focus grab silently
skipped, and every key on the card except Esc did nothing.

`draw` calls `sync_approval_menu`, which stamps `menu.call_id`.
`sync_approval_focus` used that same field to decide whether the prompt
was new — so once a frame had painted, the prompt read as already seen
and focus was never claimed. `handle_approval_menu_key` gates on
`FocusBlock::Approval`, so arrows, Enter and the shortcut letters were
all dropped, leaving a prompt on screen that looked interactive and
wasn't.

Give the focus grab its own `focus_claimed_for`, so what a frame does
can't decide what the tick has handled.

Claude-Session: https://claude.ai/code/session_01XBsriDsqoNQsMD1dgacF5p
@github-actions
github-actions Bot enabled auto-merge (squash) August 21, 2026 14:55
@github-actions
github-actions Bot merged commit 8c19bba into main Aug 21, 2026
8 checks passed
mohitranka added a commit that referenced this pull request Aug 21, 2026
An approval that painted before the tick got its focus grab silently
skipped, and every key on the card except Esc did nothing.

`draw` calls `sync_approval_menu`, which stamps `menu.call_id`.
`sync_approval_focus` used that same field to decide whether the prompt
was new — so once a frame had painted, the prompt read as already seen
and focus was never claimed. `handle_approval_menu_key` gates on
`FocusBlock::Approval`, so arrows, Enter and the shortcut letters were
all dropped, leaving a prompt on screen that looked interactive and
wasn't.

Give the focus grab its own `focus_claimed_for`, so what a frame does
can't decide what the tick has handled.

Claude-Session: https://claude.ai/code/session_01XBsriDsqoNQsMD1dgacF5p
mohitranka added a commit that referenced this pull request Sep 11, 2026
An approval that painted before the tick got its focus grab silently
skipped, and every key on the card except Esc did nothing.

`draw` calls `sync_approval_menu`, which stamps `menu.call_id`.
`sync_approval_focus` used that same field to decide whether the prompt
was new — so once a frame had painted, the prompt read as already seen
and focus was never claimed. `handle_approval_menu_key` gates on
`FocusBlock::Approval`, so arrows, Enter and the shortcut letters were
all dropped, leaving a prompt on screen that looked interactive and
wasn't.

Give the focus grab its own `focus_claimed_for`, so what a frame does
can't decide what the tick has handled.

Claude-Session: https://claude.ai/code/session_01XBsriDsqoNQsMD1dgacF5p
mohitranka added a commit that referenced this pull request Sep 11, 2026
An approval that painted before the tick got its focus grab silently
skipped, and every key on the card except Esc did nothing.

`draw` calls `sync_approval_menu`, which stamps `menu.call_id`.
`sync_approval_focus` used that same field to decide whether the prompt
was new — so once a frame had painted, the prompt read as already seen
and focus was never claimed. `handle_approval_menu_key` gates on
`FocusBlock::Approval`, so arrows, Enter and the shortcut letters were
all dropped, leaving a prompt on screen that looked interactive and
wasn't.

Give the focus grab its own `focus_claimed_for`, so what a frame does
can't decide what the tick has handled.

Claude-Session: https://claude.ai/code/session_01XBsriDsqoNQsMD1dgacF5p
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