Skip to content

🤖 feat: parent-tab tracking for file preview close navigation#2660

Open
ibetitsmike wants to merge 3 commits intomainfrom
mike/parent-tab-tracking
Open

🤖 feat: parent-tab tracking for file preview close navigation#2660
ibetitsmike wants to merge 3 commits intomainfrom
mike/parent-tab-tracking

Conversation

@ibetitsmike
Copy link
Contributor

Summary

When a file preview tab is opened from another tab (e.g., Review or Explorer), closing the file now returns focus to the tab that opened it instead of falling back to whichever tab happens to be positionally adjacent.

Background

File preview tabs are opened from the Review or Explorer panels. When the user closes a file preview, the previous behavior picked the next (or previous) tab in the array — which is disorienting because the user expects to return to where they came from. This change adds a "parent tab" concept so closing a file navigates back naturally.

Implementation

Adds an optional parentTab map (Record<string, string>) to RightSidebarLayoutState as a side-channel alongside the existing tree structure. This avoids changing the recursive RightSidebarLayoutNode tree.

rightSidebarLayout.ts:

  • Extended RightSidebarLayoutState interface with optional parentTab field
  • removeTabFromNode() now accepts an optional preferredActiveTab — when the active tab is removed and a parent exists in the same tabset, it's activated instead of positional fallback
  • removeTabEverywhere() looks up the parent before removal, passes it through, and cleans up stale entries (both for the removed tab and any orphaned children pointing to it)
  • isRightSidebarLayoutState() validator accepts the optional parentTab field for backward compat

RightSidebar.tsx:

  • handleOpenFile now records the currently active tab as the parent of the new file tab

Tests (7 new):

  • Parent tab activation, positional fallback when parent is in different tabset, entry cleanup, orphan cleanup, backward compat validation (with/without/invalid parentTab)

Generated with mux • Model: anthropic:claude-opus-4-6 • Thinking: xhigh • Cost: $3.65

When a file preview tab is opened from another tab (e.g., review or
explorer), closing the file tab now returns focus to the originating
tab instead of falling back to positional adjacency.

- Add parentTab map to RightSidebarLayoutState
- Update removeTabFromNode/removeTabEverywhere to prefer parent tab
- Record parent tab in handleOpenFile
- Clean up stale entries on tab removal
- Add 7 tests for parent-tab behavior and backward compat
@ibetitsmike
Copy link
Contributor Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3b2917413e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

When a file that's already open is selected again from a different tab
(e.g., originally from Review, later from Explorer), update the parentTab
entry to reflect the most recent origin so close navigates correctly.
@ibetitsmike
Copy link
Contributor Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cd8af75fe0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Avoid writing cross-tabset parents that can never be activated on close.
When re-selecting an already-open file from a different tabset, the
parentTab entry is left unchanged to preserve the existing (usable)
parent rather than overwriting it with an unreachable cross-tabset tab.
@ibetitsmike
Copy link
Contributor Author

@codex review

Addressed the cross-tabset parentTab overwrite issue — now only refreshes parentTab when the origin tab is in the same tabset as the file tab. Cross-tabset origins are left unchanged to preserve the existing usable parent.

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. More of your lovely PRs please.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@ibetitsmike ibetitsmike added this pull request to the merge queue Feb 27, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 27, 2026
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.

1 participant