Repository navigation
refactor(tabs): reuse the shared tab-order helper instead of three copies - #26704
Conversation
… logic Sleeping-session resume, AI vault resume and the plain quick-command terminal each carried a line-for-line copy of persistAgentLaunchTabOrder. Call the helper instead. No behavior change.
|
Ready summary
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughAI vault, quick-command, and sleeping-agent session launches now use Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to This refactor preserves tab ordering for quick commands and session resumes, with no concrete user-facing regression established. No actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |




ELI5
When Orca opens a new tab, it saves where that tab sits in the tab bar so the tab lands at the end instead of jumping to the front. One small function,
persistAgentLaunchTabOrder, already does this. Three other places had pasted their own copy of that function's body instead of calling it. This PR deletes the three copies and calls the function. Nothing you see changes.What Changed
The problem. The same tab-order code (read the worktree's terminal, editor and browser tabs, merge them with the saved tab-bar order, move the new tab to the end, save) was copied into three files on top of the shared function. Every copy is a place where a later fix has to be repeated by hand, and copies of this logic have already drifted: the plain "new terminal" path (
terminal-tab-create.ts) leaves out browser tabs, and every copy, including the shared function, leaves out simulator and chat tabs that the tab bar itself counts.User-facing change: none. Tabs open in exactly the same spot as before.
What was replaced (each was a line-for-line match of the shared function: same inputs, same merge call, same save):
sleeping-agent-session-launch.ts: the privateappendTabToWorktreeOrderfunction (resuming a sleeping agent session).launch-ai-vault-session.ts: the inline block that ran after an AI vault session resume.run-quick-command-in-new-tab.ts: the inline block that ran after a plain (non-agent) quick command opened its terminal. The block's laterfresh.setRecentQuickCommandForGroup(...)call now reads the store directly, the way the other branches in that file already do.Line delta: source −42 (7 added, 49 removed). One new test adds 25 lines.
This is phase 2, PR 1 of the agent-launch simplification. It changes nothing about how an agent receives its prompt. It only touches where a new tab is placed in the tab bar.
Why
Calling the existing function is the smallest change that removes the copies, and it adds no new abstraction. On purpose, this PR does not fix the drift listed above. Fixing it would change behavior, and this PR is meant to be a pure deletion. Those gaps are follow-ups:
terminal-tab-create.tsis a near-copy that leaves out browser tab ids. It stays as it is.Linked Issue
None (maintainer refactor).
Visual Proof
N/A — no UI change; pure refactor.
Testing
pnpm vitest run --config config/vitest.config.tson the tests next to each changed file:run-quick-command-in-new-tab.test.ts,launch-ai-vault-session.test.ts,sleeping-agent-session-launch-windows-quoting.test.tsand the sevenresume-sleeping-agent-session*.test.tsfiles. 10 files, 106 tests pass.New test in
run-quick-command-in-new-tab.test.ts: the quick-command terminal goes after existing editor and browser tabs in the saved order. It passes against main's original copy and against this branch, so it pins the behavior that already existed.pnpm tc:webpasses.orca-ci-checks(lint, code quality, localization) passes 22/22.Not run: manual app testing. The change is a call swap with matching logic.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Self-reviewed. Each removed block was compared against
launch-agent-tab-order.ts: same store reads, samereconcileTabOrderarguments, same filter-and-push, samesetTabBarOrdercall. Both versions read store state aftersetActiveTabType.Agent skill upstream boundary
Notes
Renderer-only, with no platform, SSH or mobile impact: the same store calls run in the same order.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Author: @BrennanKB5