Repository navigation
Replace three copied new-terminal tab-order blocks with the shared helper - #26771
Conversation
The + new-terminal path kept its own copy of the tab-order placement and left browser tabs out, so in a workspace with no saved order a browser tab could land after the new terminal. Use the shared persistAgentLaunchTabOrder helper instead.
handleNewTab's shell-override fallback and the menu new-terminal IPC fallback each kept an inline copy of the "put the new tab last" order logic. Both now call persistAgentLaunchTabOrder. The one behaviour difference: the shared reconcile drops ids repeated in a saved order, where the copies kept them.
|
Review and checks, head c7c7cc2
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (7)
💤 Files with no reviewable changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughTerminal creation through component actions and the new-terminal-tab IPC path now delegates saved tab-order updates to persistAgentLaunchTabOrder. The workspace store bindings no longer expose setTabBarOrder. Tests cover saved order when no order exists and when it contains repeated tab IDs. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The tab-order change is ready to merge after normal checks; no actionable risk remains identified. Pre-merge checks |
|
ELI5
When Orca opens a new terminal tab, it also saves the worktree's tab list with the new tab at the end. Three new-terminal paths each kept their own copy of that "put it at the end" code, and one copy had drifted: it forgot browser tabs. This PR deletes the three copies. All three now call the one shared function the agent-launch paths already use.
What Changed
The problem: three places held near-copies of the shared tab-placement function
persistAgentLaunchTabOrder:createNewTerminalTabinterminal-tab-create.ts, used by the file explorer's right-click Open in Terminal on a folder. Its copy listed terminal and editor tabs when it saved the worktree's tab order, and left browser tabs out.handleNewTab's fallback inuse-terminal-create-actions.ts. It runs when a terminal is opened with a specific shell, or the worktree has no tab group yet.tab-lifecycle-ipc-bridge.ts, used when the terminal is not created through a remote Orca host.Copies 2 and 3 matched each other line for line. Copy 1 was the one that drifted.
User-facing change: none expected in the normal tab strip. I checked this before writing the PR:
TabGroupPanel) draws from the tab group's own order. It does not read the worktree-level saved order (tabBarOrderByWorktree) that these three paths write.createTabalways puts the new terminal at the end of the group order, so on main the new terminal already shows last and other tabs stay put.Behaviour differences, both intended:
[browser, terminal, browser]plus a new terminal used to save[browser, terminal, browser, new]and now saves[browser, terminal, new]. A repeated id is already a broken state: the shared reconcile function drops repeats so the tab bar never shows the same tab twice. I compared copies 2 and 3 with the shared function line by line, and this is their only difference. Both read the store after the tab is created, append missing tabs in the same order (terminals, editors, browsers), move the new tab last, and call the same store action.Mechanism: each copy is replaced by
persistAgentLaunchTabOrder(worktreeId, newTab.id).use-terminal-create-actions.tsno longer needs thesetTabBarOrderstore binding, so this PR removes it fromuse-terminal-workspace-store-bindings.ts; nothing else read it.Line delta: across the four source files, +10 / −71 (net −61). The tests add 114 lines and remove 3.
This PR changes nothing about how agents are launched or how they receive prompts. The paired web-client path, where the host creates the terminal, returns before this code and is unchanged.
Why
The copies had already drifted, which is how path 1 lost browser tabs. Pointing every copy at one function keeps the next fix to tab placement in one place. Adding browser ids to copy 1 alone would have left three versions to drift again.
The shared function's name still says "agent launch", although it now covers general new-tab placement. I'm leaving the rename for later, because it would touch files in open launch PRs.
Copies this PR leaves alone. Searching for the same pattern turns up three more places that build the saved order inline. All three live inside store actions:
openNewTerminalTabInActiveWorkspaceinstore/terminals/terminal-active-workspace-creation.ts, the group path behind "+", Cmd+T and Cmd+J. It behaves the same as the old copies, including keeping repeated ids. I left it because it runs inside the store, and the shared function is a module outside the store that imports the store. Moving the shared function into the store is the follow-up.createBrowserTabinstore/slices/browser/browser-tab-actions.tsand the new-file path instore/slices/editor/actions/open-file-apply.tsbehave differently. They build the order inside the store update itself and append a tab id that is not in the store yet, so the shared function cannot serve them as written.Linked Issue
N/A (maintainer follow-up to #26704).
Visual Proof
N/A. Nothing visible changes in the normal tab strip (see above), and each changed path has a unit test.
Testing
Each changed path has its own unit test:
terminal-tab-actions.test.ts: Open in Terminal, with one terminal, one open browser tab and no saved order, saves[terminal, browser, new terminal]. On main's code it fails because the browser tab is missing.use-terminal-create-actions.test.tsx(new test): the shell-override fallback, given the saved order[browser, terminal, browser], saves[browser, terminal, new terminal].tab-lifecycle-ipc-bridge.test.ts(new file): the menu New Terminal fallback, with the same input and the same expected result.browser. That confirms the repeated-id drop is the only difference on those paths. With this change, all of them pass.Gates:
pnpm tc:webpasses.orca-ci-checks --no-typecheckpasses.I ran four test files by name: the three above plus
useIpcEvents-terminal-create-surfacing.test.ts. All 38 tests pass.A fresh reviewer checked the full diff for any behaviour change beyond the two differences above and found none. Its two notes (wording, and the copy left in
terminal-active-workspace-creation.ts) are addressed above.Not tested by hand in the running app; nothing on screen changes.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
Renderer-only tab-order change with no platform-specific code. SSH and folder workspaces go through the same local path as before, and the paired web/mobile host path is untouched.
Known gap, not changed here: the shared function also leaves simulator tabs and native chat tabs out of the saved order. Every caller had that gap before this PR, and it is a candidate follow-up.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Author: @BrennanKB5