Skip to content

Proposal: find the selected worktree with orca worktree ps --json #2

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

Advantages

  • The plugin uses a documented contract, not an internal schema. The state store has a schema version and a domain_version for each document.
  • The installer does not have to find a profile, and --profile / --orca-state are not necessary.
  • install.py already finds the CLI with find_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, hostId and isActive, 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 active and orca worktree current do 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.readContext gives 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions