Repository navigation
fix(branch-out): support Orca terminal handles and preserve cwd - #19
Conversation
|
thanks, this looks good. could you also update extensions/branch-out/README.md and packages/pi-branch-out/README.md to document ORCA_TERMINAL_HANDLE detection and the ORCA_PANE_KEY lookup path? the current docs still say ORCA_PANE_KEY is required |
Thanks for reviewing this and catching the missing documentation. Updated both READMEs in 75dfbc5. They now describe handle-based detection, the tabId:leafId lookup when no handle is supplied, and rejection of stale handles without falling back to another terminal. They also clarify that the child retains the Pi session working directory. The Orca regression test and git diff --check pass. No runtime code changed. |
|
thx! |
Why
/branchshould open a copy of the current session beside the terminal that invoked it, without changing the project that session is working on.In the Orca environment tested, the terminal provides
ORCA_WORKTREE_IDandORCA_TERMINAL_HANDLE, but noORCA_PANE_KEY. The existing detection therefore skips Orca and rejects the default split request, even though Orca supplies a usable terminal identity.Pi's working directory can also differ from the enclosing Orca workspace root. Without explicitly preserving that directory, the child can open the copied conversation in a different project.
Approach
ORCA_TERMINAL_HANDLEas an alternative to the pane key and match it against a fresh terminal list scoped to the current worktree. This targets the caller rather than guessing from the active tab or selecting another pane. A stale handle fails without falling back to an unrelated terminal.cd <quoted current directory> && pi --session <quoted fork file>in the child. The parent directory is unchanged, and a failedcdprevents launching Pi in the wrong directory.This is limited to compatibility within the existing Orca backend. No dependencies or configuration options are added. Other backends, session copying, focus restoration, and waiting for the current run to finish are unchanged.
Verification
node --test extensions/branch-out/orca.test.mjspassed. Checks cover handle-based detection, legacy pane-key lookup, stale-handle rejection, malformed JSON, exact split targeting, single-quote escaping in the directory, and split/focus command ordering.node --experimental-strip-types --check extensions/branch-out/index.tspassed.git diff --checkpassed.Other terminal backends were not manually retested. Package publication is left to the maintainer.
Fixes #18