Skip to content

fix(secondary-panel): return to source tab when closing a tab - #3015

Open
kongenpei wants to merge 1 commit into
get-bb:mainfrom
kongenpei:bb/side-chat-thr_uf7gt7g9h4
Open

fix(secondary-panel): return to source tab when closing a tab#3015
kongenpei wants to merge 1 commit into
get-bb:mainfrom
kongenpei:bb/side-chat-thr_uf7gt7g9h4

Conversation

@kongenpei

Copy link
Copy Markdown
Contributor

What was wrong

Closing a secondary-panel tab moved focus to the left positional neighbor of the closed tab instead of returning to the tab that was active before the closed tab was opened. With the side-chat plugin this is jarring: open a side chat from a source tab, close it, and you land on an unrelated left-neighbor tab rather than the source tab.

Root cause: getActiveTabIdAfterClose in packages/client-core/src/panel/secondaryPanelTabState.ts picked the next tab purely by position, with no memory of the previously-active tab.

Fixes #3014

What changed

  • Track the most-recently-active prior tab as a transient previousActiveTabId on the secondary panel group state. It is recorded whenever activation changes the active tab (only if the prior tab still exists), and preserved across no-op activations/updates.
  • getActiveTabIdAfterClose now prefers previousActiveTabId when it still exists and is a file tab; otherwise it falls back to the original positional logic.
  • The field is transient: it is stripped by normalizeFixedSecondaryPanelTabGroupState before serialization, never persisted to localStorage, never synced to the server, and never crosses the host-daemon boundary. No HOST_DAEMON_PROTOCOL_VERSION bump required.

How verified

  • Updated secondaryPanelTabState.test.ts: added a return-to-source test and a positional-fallback test (source tab gone), and corrected the existing close assertion to reflect MRU behavior.
  • Relying on remote CI for the full build/test run.

AGENT GENERATED

When a secondary-panel tab (e.g. a side-chat plugin panel) was closed,
focus jumped to the left positional neighbor instead of the tab that was
active before the closed tab was opened. Track the most-recently-active
prior tab as a transient previousActiveTabId and prefer it on close when
it still exists, falling back to the positional neighbor otherwise.

Co-authored-by: TRAE CLI <traecli@bytedance.com>
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.

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

1 participant