Repository navigation
fix(cli): target the calling terminal's folder workspace, not its parent - #33703
Conversation
Every workspace in a folder project shares the project path, so the cwd match always picked the parent row. Fixes #33618
|
No actionable comments were generated in the recent review.
|
ELI5
When an agent in a folder project's second workspace opened a browser tab, the tab went to the project's first workspace instead. All of a folder project's workspaces live in the same folder, so the CLI couldn't tell them apart by folder. Now it asks the terminal which workspace it belongs to whenever the folder alone can't decide.
What Changed
orca tab create(ortab list,tab current, browser commands without--page,terminalcommands,computer,worktree current,--worktree current) from a terminal in a folder project's extra workspace, and the CLI resolves the parent<repoId>::<path>row. The tab lands in a workspace the user isn't looking at, and the workspace's own tab strip stays empty.<repoId>::<path>::workspace:<uuid>row, so the tab shows up in that workspace.selectEnclosingWorktreeSelectionOnHostpicks the innermost catalog row that contains the cwd. Rows with the same path used to resolve by catalog order, and the runtime always lists the parent first. Now the row whose id matches the pane'sORCA_WORKTREE_IDwins that tie. The cwd still decides whenever paths differ, so a terminal thatcds into another worktree still targets that worktree.Why
resolveCurrentWorktreeSelectionis the one cwd-based default that every implicit target goes through, and folder workspaces are the one case where the cwd can't pick a single row. Fixing the tie there covers every command at once, and nothing needs a special case.Alternatives considered:
getEmulatorWorktreeSelector's env-first order intogetBrowserWorktreeSelector. That would fix only browser commands, and it would ignore the cwd after acd.folder:<id>ids and conflicts with main in 8 files; six runtime files it edits no longer exist. It also adds a new selector module, runtime selector changes, help text and fail-closed behaviour, all beyond this issue. We rebuilt only the part this bug needs, on current main. fix(cli): target the spawning terminal's workspace, including Folder Workspaces #19700 also covers [Bug]: CLI commands from a Folder Workspace terminal target the UI-active workspace #19699's other asks forfolder:<id>workspaces, which this PR doesn't address, so [Bug]: CLI commands from a Folder Workspace terminal target the UI-active workspace #19699 stays open.Linked Issue
Fixes #33618
Linear: STA-12165
Visual Proof
N/A for screenshots: the change is in which workspace id the CLI sends. I reproduced it from real state on a throwaway
orca serve: a non-git folder project with a second workspace,ws2. Both rows have path/private/tmp/o33618-folder. I ran the commands from that folder.orca worktree current --json:ORCA_WORKTREE_ID= ws2 row…::/private/tmp/o33618-folder…::/private/tmp/o33618-folder::workspace:eed101ec-…I also ran
orca tab create --url about:blank --jsonwithORCA_WORKTREE_IDset to ws2.tab list --worktree allthen showed main's tab under the parent and this branch's tab under ws2.Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Manual (macOS): the headless serve repro above. I also ran from a git repo with
ORCA_WORKTREE_IDpointing at the folder workspace, and it still resolved to the git repo's own row.New test in
src/cli/browser.test.ts:tab createfrom a folder workspace pane targets that pane's row, not the parent that shares its path. It fails on main, which sendsid:repo::/tmp/folder.Focused suites pass:
browser,worktree-selector-caller-host,index-worktree-selector-resolution,index-terminal-commands,handlers/emulator. Bothcheck:code-quality:changedandcheck:react-doctor:changedare clean.AI Disclosure
Review
Agent skill upstream boundary
Notes
ORCA_WORKTREE_IDcomes from that runtime's catalog.ORCA_WORKTREE_IDis already forwarded through WSLENV.worktree.listfields older runtimes already return./tmp/...symlink never matches the cwd, because the shell reports the real path/private/tmp/.... Main has the same behaviour.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)