Skip to content

fix(tui): preserve modal focus across dialog replacement#36656

Merged
simonklee merged 1 commit into
v2from
v2-modal-focus-root-cause
Jul 13, 2026
Merged

fix(tui): preserve modal focus across dialog replacement#36656
simonklee merged 1 commit into
v2from
v2-modal-focus-root-cause

Conversation

@opencode-agent

@opencode-agent opencode-agent Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Prevent deferred background focus restoration when a replacement dialog is already open, keeping the replacement modal as the exclusive keyboard owner.

Root cause

Selecting Settings from Commands calls dialog.clear() before dispatching the selected command. clear() schedules the remembered prompt focus to be restored after 1 ms. The Settings command immediately opens a replacement dialog, but the stale callback still runs and focuses the prompt behind it.

The guard now re-checks the live dialog stack before restoring focus.

Fixes #36652

Closing one dialog scheduled focus restoration even when its command immediately opened another dialog. Guard the deferred restore against a non-empty dialog stack so the replacement modal retains exclusive keyboard ownership.

Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
@opencode-agent opencode-agent Bot force-pushed the v2-modal-focus-root-cause branch from c71d328 to f68ef8c Compare July 13, 2026 11:26
@opencode-agent opencode-agent Bot marked this pull request as ready for review July 13, 2026 11:27
@simonklee simonklee merged commit 339fd50 into v2 Jul 13, 2026
9 of 10 checks passed
@simonklee simonklee deleted the v2-modal-focus-root-cause branch July 13, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant