Skip to content

Activate next tab (below) after closing the active vertical tab#13142

Open
elviskahoro wants to merge 1 commit into
warpdotdev:masterfrom
elviskahoro:conductor/fix-tab-close-focus
Open

Activate next tab (below) after closing the active vertical tab#13142
elviskahoro wants to merge 1 commit into
warpdotdev:masterfrom
elviskahoro:conductor/fix-tab-close-focus

Conversation

@elviskahoro

@elviskahoro elviskahoro commented Jun 28, 2026

Copy link
Copy Markdown

Summary

Closing the active tab should move focus to the next tab — the tab to the
right (horizontal) or below (vertical) — falling back to the previous neighbor
only when you close the last tab. This is the standard convention set by
browsers and macOS apps.

Today the behavior is inconsistent between layouts:

  • Horizontal tabs already do the right thing. PR Activate right horizontal tab after close #11197 ("Activate right
    horizontal tab after close") changed the post-close selection from
    index.saturating_sub(1) (previous tab) to index.min(self.tabs.len() - 1)
    (next tab).
  • Vertical tabs still activate the previous (up) tab after a close.

This is the part that confused us: PR #11197 explicitly scoped its fix to
horizontal mode and called out that it would "preserve existing vertical tab
behavior." It did so by gating the new logic behind uses_vertical_tabs(ctx):

let active_index = if uses_vertical_tabs(ctx) {
    index.saturating_sub(1)         // vertical: previous/up tab
} else {
    index.min(self.tabs.len() - 1)  // horizontal: next/right tab
};

We couldn't find a reason vertical tabs should intentionally focus the
previous tab while horizontal focuses the next one — it breaks the same
convention #11197 set out to fix, just in the other layout. If there is a
deliberate reason for the asymmetry, please flag it on this PR.

Change

Drop the layout branch in Workspace::remove_tab and always use the
next-neighbor rule for both layouts:

// Activate the tab that was immediately after the closed one — to the right
// for horizontal tabs, below for vertical tabs. After removal that tab
// occupies the same index. If the closed tab was the last one, fall back to
// the new last tab (the previous neighbor).
let active_index = index.min(self.tabs.len() - 1);
self.activate_tab_internal(active_index, ctx);

remove_tab is the single point all close paths funnel through (keyboard, the
tab "X" button, the vertical-tabs panel, and tab-group closes), so this fixes
every entry point. Horizontal behavior is unchanged; only vertical tabs change
(previous → next).

Tests

  • Existing horizontal tests still pass (no regression):
    test_close_active_horizontal_tab_activates_tab_to_right,
    test_close_last_horizontal_tab_activates_tab_to_left.
  • Added vertical coverage mirroring them:
    test_close_active_vertical_tab_activates_tab_below (would have failed before
    this change), test_close_last_vertical_tab_activates_tab_above (fallback).
  • cargo check -p warp --tests clean; the four *_tab_activates_tab_* tests
    pass.

Closes #13143

Make tab-close focus consistent across layouts. PR warpdotdev#11197 made horizontal
tabs activate the tab to the right after closing the active tab, but it
explicitly preserved the old vertical-tab behavior, which still activates
the previous (up) tab. This unifies the two: closing the active tab now
focuses the next tab (right for horizontal, below for vertical), falling
back to the previous neighbor only when closing the last tab.

Adds unit tests for the vertical case (next-tab activation and last-tab
fallback), mirroring the existing horizontal tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cla-bot

cla-bot Bot commented Jun 28, 2026

Copy link
Copy Markdown

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @elviskahoro on file. In order for us to review and merge your code, each contributor must visit https://cla.warp.dev to read and agree to our CLA. Once you have done so, please comment @cla-bot check to trigger another check.

@oz-for-oss

oz-for-oss Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

@elviskahoro

Every PR must be linked to a same-repo issue before Oz can review it.

Next step: open or find a same-repo issue describing this change, then link it to this PR by adding Closes #123 to the PR description (or using the "Development" sidebar on GitHub). A maintainer will mark the issue ready-to-implement when it is ready. Once it is marked, comment /oz-review to re-trigger review.

See the contribution guidelines for the full readiness model.

Powered by Oz

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@elviskahoro

Every PR must be linked to a same-repo issue before Oz can review it.

Next step: open or find a same-repo issue describing this change, then link it to this PR by adding Closes #123 to the PR description (or using the "Development" sidebar on GitHub). A maintainer will mark the issue ready-to-implement when it is ready. Once it is marked, comment /oz-review to re-trigger review.

See the contribution guidelines for the full readiness model.

Powered by Oz

@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label Jun 28, 2026
@elviskahoro

Copy link
Copy Markdown
Author

@oz-agent This PR closes #13143 #13143

@elviskahoro

Copy link
Copy Markdown
Author

@bholmesdev I did the CLA check! lmk if this needs feature flag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Closing active vertical tab should activate next (below) tab, not previous

1 participant