Skip to content

Closing a secondary-panel tab jumps to the left neighbor instead of the source tab #3014

Closed

Description

@kongenpei

What happened

When a secondary-panel tab is closed, focus jumps to the left positional neighbor of the closed tab rather than returning to the tab that was active before the closed tab was opened.

This is most visible with the side-chat plugin: opening a side chat from a "source" tab, then closing the side-chat tab, lands you on whatever tab sits to the left in the strip instead of the source tab you came from.

Steps to reproduce

  1. Open a thread with the secondary panel showing several tabs (e.g. tab A, tab B where B is active).
  2. From B, open a side chat (or any new content tab C). C becomes active.
  3. Close C.

Expected

Focus returns to B (the tab active before C was opened), since B still exists.

Actual

Focus goes to the left positional neighbor (e.g. A), not B.

Root cause

getActiveTabIdAfterClose in packages/client-core/src/panel/secondaryPanelTabState.ts selects the next active tab purely by position:

const nextActiveTab =
  fileTabsAfterClose[closedFileTabIndex] ??
  fileTabsAfterClose[closedFileTabIndex - 1] ??
  null;

There is no record of the previously-active tab, so closing the active tab always falls to a positional neighbor.

Proposed fix

Track the most-recently-active prior tab as a transient previousActiveTabId on the secondary panel state, and on close prefer it when it still exists (fall back to the positional neighbor otherwise).

AGENT GENERATED

Activity

  1. added theissue type on Sep 3, 2026
  2. added
    ui
    confirmed-repro
    on Sep 3, 2026
  3. bb-slop-cop commented on Sep 3, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

  4. added a commit that references this issue on Sep 11, 2026
    b04091e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reproui

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions