Skip to content

Restore focus after closing tab context menus - #16138

Merged
acarl005 merged 4 commits into
masterfrom
factory/guard-stale-tab-config-index
Sep 24, 2026
Merged

acarl005 merged 4 commits into
masterfrom
factory/guard-stale-tab-config-index

Conversation

@warp-agent-staging

@warp-agent-staging warp-agent-staging Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

Closing a tab context menu hid the overlay but left its Menu view focused. In the Sentry event, the user selected “Close other tabs” for tab index 5, then switched away. Almost two minutes later the window regained focus and Select(Next) plus Enter were routed to the hidden menu, which dispatched the adjacent “Save as new config” action still carrying index 5 after the tab list had shrunk to one item.

Restore focus to the active tab whenever the tab context menu closes so hidden menus cannot continue handling keyboard input. Keep a checked tab lookup as defense in depth for positional actions that become stale before dispatch. Valid menu and save behavior is unchanged. This addresses Sentry fatal WARP-CLIENT-BETA-STABLE-8C2M / issue 7751633023.

Computer-use video recordings

Recording right-click on the 6th tab, opening its context menu, selecting Close other tabs, confirming one tab remains, moving focus away and back to the Warp window, then pressing Down once and Enter once, observing the final state.
Warp tab context menu - Close other tabs, then Down+Enter after focus change: Recording right-click on the 6th tab, opening its context menu, selecting Close other tabs, confirming one tab remains, moving focus away and back to the Warp window, then pressing Down once and Enter once, observing the final state.

Computer-use screenshots

Final stable Warp state after Close other tabs, focus-away-and-back, then Down+Enter: one tab ("New session") remains, no context menu/modal/editor is visible, and a faint overlapping/ghosted debug-style text ("Lines: 4 ...; Size ... KB (grid: 12.9 KB, flat: 5.1 KB)") appears near the bottom of the pane above the "Run commands" placeholder input.
Final stable Warp state after Close other tabs, focus-away-and-back, then Down+Enter: one tab ("New session") remains, no context menu/modal/editor is visible, and a faint overlapping/ghosted debug-style text ("Lines: 4 ...; Size ... KB (grid: 12.9 KB, flat: 5.1 KB)") appears near the bottom of the pane above the "Run commands" placeholder input.

Linked Issue

  • No GitHub issue; this PR is linked to the Sentry fatal above.
  • Computer-use video and screenshot evidence are included above.

Testing

Added regressions that verify closing the tab context menu restores focus to the active tab and that a stale save action cannot panic if its tab no longer exists.

On Ubuntu 24.04 x86_64 at exact commit 8ebe655ec15f49deb690c6d8bef28ea0b66326f6, cargo build --bin warp passed. Rendered verification created six tabs, used “Close other tabs” on tab 6, moved focus away and back, then pressed Down and Enter. Warp stayed open, the hidden menu did not handle the keys, the terminal remained the input target, no tab-config UI or file appeared, and no SaveCurrentTabAsNewConfig action was logged.

Authentication caveat: the fresh profile opened onboarding despite WARP_API_KEY and later logged Unauthorized: Expected a user account, so the requested authenticated-launch prerequisite was not satisfied. This is qualified verification of the rendered focus behavior, not a successful authenticated fresh-profile launch.

The focused tests and targeted Clippy were initially attempted locally with a single build job, but the 4 GB sandbox killed rustc/clippy-driver with SIGKILL. The first CI run exposed an immutable-versus-mutable AppContext mismatch in the new focus test; commit 8c6a89d18eb9de1ce830aefc17d75d5a36dce689 fixed that compile error. A focused run then exposed a same-update focus assertion; head commit 334c5c74b52bc0cc3af6bdc740e2845d75405521 moves that observation across the app update boundary. cargo nextest run -p warp -E 'test(test_closing_tab_context_menu_restores_active_tab_focus)' passes (1 passed, 6,861 skipped), as do cargo fmt --all --check and git diff --check. The fresh CI matrix is pending on the validated head.

  • Manually exercised the affected flow through computer use on Ubuntu 24.04 against the exact PR commit; authentication caveat documented above.

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

CHANGELOG-BUG-FIX: Fixed hidden tab context menus handling keyboard input after being closed.

Avoid indexing a tab position captured by a context menu after another action has changed the tab list. Add a regression for closing other tabs before the stale save action is dispatched.\n\nCo-Authored-By: Warp Agent <agent@warp.dev>
@warp-agent-staging

Copy link
Copy Markdown
Contributor Author

This PR was generated with Warp.

Comment @warp-staging-factory on this PR to send it follow-up work.

View run View conversation

@warp-agent-staging warp-agent-staging Bot changed the title Prevent stale tab config save actions from panicking Restore focus after closing tab context menus Sep 24, 2026
@acarl005
acarl005 marked this pull request as ready for review September 24, 2026 15:56
@acarl005
acarl005 requested review from acarl005 and removed request for advait-m September 24, 2026 15:57
@warp-agent-staging
warp-agent-staging Bot marked this pull request as draft September 24, 2026 17:20
@acarl005
acarl005 marked this pull request as ready for review September 24, 2026 17:21
@warp-agent-staging
warp-agent-staging Bot marked this pull request as draft September 24, 2026 17:43
@acarl005
acarl005 marked this pull request as ready for review September 24, 2026 17:43
@warp-agent-staging
warp-agent-staging Bot marked this pull request as draft September 24, 2026 17:44
@acarl005
acarl005 marked this pull request as ready for review September 24, 2026 17:44
@acarl005 acarl005 self-assigned this Sep 24, 2026
@acarl005
acarl005 enabled auto-merge (squash) September 24, 2026 17:55
@acarl005
acarl005 disabled auto-merge September 24, 2026 17:55
@acarl005
acarl005 enabled auto-merge (squash) September 24, 2026 17:55
@acarl005
acarl005 merged commit 43eae5e into master Sep 24, 2026
32 checks passed
@acarl005
acarl005 deleted the factory/guard-stale-tab-config-index branch September 24, 2026 18:06
zhangyu1818-bot added a commit to zhangyu1818/warply that referenced this pull request Sep 25, 2026
Port of upstream 43eae5e (warpdotdev#16138). Closing a tab context menu hid the
overlay but left its Menu view focused, so later keystrokes dispatched
stale positional actions. focus_active_tab is now called on
MenuEvent::Close, and save_current_tab_as_new_config uses a checked tab
lookup as defense in depth.

Tests remapped from upstream view_tests.rs to the fork's view_test.rs
after the close-tab test family; bodies applied verbatim.

Upstream df5cacf (docs: WARP_SKIP_COMMON_SKILLS_INSTALL) rejected: the
fork has no common-skills installer to document. See
docs/agents-wiki/upstream-master-audit-2026-09-25.md.
jwp2987 pushed a commit to jwp2987/phosphor that referenced this pull request Sep 27, 2026
Port of upstream 43eae5e (warpdotdev#16138), newer than pin 4111d08.

Refs #TBD — issue not yet filed (gh auth down); draft in the round's scratchpad.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TranscriptionFactory pushed a commit to TranscriptionFactory/warp that referenced this pull request Sep 28, 2026
Two fixes: closing a tab context menu left focus on the hidden menu view,
so the keyboard went nowhere until the user clicked; and
SaveCurrentTabAsNewConfig indexed self.tabs directly, panicking on a stale
tab index (e.g. after close_other_tabs shrank the list).

Fork adaptations:
- Kept our simpler handle_tab_right_click_menu_event. This fork has no tab
  group / multi-select context menus and no move-to-group sidecar, so the
  upstream arms for those have nothing to clear here; only the
  focus_active_tab call is the fix.
- Tests go in view_test.rs (this fork's name); upstream's view_tests.rs is
  not wired into the module tree here.

Verified: cargo check -p warp --lib --tests clean. The two new tests are
not runnable locally: all of workspace::view::tests (43 of 45, including
tests untouched by this change) fails on an unregistered
AgentProviderSecrets singleton, a pre-existing local harness breakage.

(cherry picked from commit 43eae5e08e57e70a6f0e1d75e1e69aba8d1fedb4)
zhangyu1818-bot added a commit to zhangyu1818/warply that referenced this pull request Oct 1, 2026
Port of upstream 43eae5e (warpdotdev#16138). Closing a tab context menu hid the
overlay but left its Menu view focused, so later keystrokes dispatched
stale positional actions. focus_active_tab is now called on
MenuEvent::Close, and save_current_tab_as_new_config uses a checked tab
lookup as defense in depth.

Tests remapped from upstream view_tests.rs to the fork's view_test.rs
after the close-tab test family; bodies applied verbatim.

Upstream df5cacf (docs: WARP_SKIP_COMMON_SKILLS_INSTALL) rejected: the
fork has no common-skills installer to document. See
docs/agents-wiki/upstream-master-audit-2026-09-25.md.
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