Repository navigation
Proposal: find the selected worktree with orca worktree ps --json #2
Copy link
Copy link
Open
Description
Summary
The sync process finds the selected worktree in the private profile state of Orca: orca-data.json, and profile-state.db after #1. Orca 1.4.214 changed this store from JSON to SQLite, and the change stopped the plugin. The Orca CLI has a documented command that gives the same information: orca worktree ps --json. I propose to use it, so that the next change to the internal store does not stop the plugin again.
What the command gives
- The CLI reference documents it (reference.mdx#L94).
- Each row has
path,branch,hostIdandisActive(runtime-worktree-contracts.ts#L93). isActivecomes fromworkspaceSession.activeWorktreeId(runtime-worktree-ps-activity.ts#L222-L226). This is the same field thatworkspace.pyreads today.- On Orca 1.4.224 (macOS), with 5 worktrees, the command returned exactly one row with
isActive: trueandhostId: "local".
Advantages
- The plugin uses a documented contract, not an internal schema. The state store has a schema version and a
domain_versionfor each document. - The installer does not have to find a profile, and
--profile/--orca-stateare not necessary. install.pyalready finds the CLI withfind_orca().
Costs and open points
- CPU. On my machine, one call took 0.11 s, with about 0.09 s of CPU and 89 MB of peak memory. With the current 0.75 s poll, that is about 12% of one core. A poll of 2–3 s, or a CLI read only when the state store cannot be read, can decrease this cost.
- Output size. The output was about 18 KB for 5 worktrees. It includes agent previews and the last agent messages. The sync process must keep only
path,hostIdandisActive, and never log the rest. - Runtime. The command needs the Orca runtime. This is true while the watcher runs in an Orca terminal, but the watcher must show a clear message when the CLI cannot connect.
- Remote hosts. With SSH hosts, there can possibly be one active row for each host (I did not test this). The watcher should use only
hostId == "local"and keep the "Remote workspaces are not supported" message. - Selectors.
orca worktree show --worktree activeandorca worktree currentdo not help. Both resolve the worktree from the working directory of the caller (selectors.ts#L113), not from the selection in the left sidebar. From another directory, the command fails.
Why the plugin API does not replace the sync process
workspace.readContextgives the branch and the display name, but not the path. Orca removes the path on purpose (plugin-host-service-bindings.ts#L45-L46).- The panel CSP is
default-src 'none'; connect-src 'none'(plugin-panel-shell.ts#L21). Thus the generated HTML file stays the only way to give the graph to the panel.
Related: #1 (support for profile-state.db).
🤖 Generated with Claude Code
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity