Repository navigation
feat(cli): add orca ports to list a workspace's detected ports - #33016
Conversation
Scripts and agents had no way to read the ports Orca already detects for a workspace, so finding a dev server on a random port meant redoing the lsof scan by hand. `orca ports` reuses the host-scoped workspacePorts.scanHost RPC, keeps the rows owned by the current (or --worktree) workspace, and prints port, pid, process, connect host, protocol, how the owner was matched, and the advertised URL. --all shows every listener on that host. An older runtime without scanHost gets an "update Orca" error instead of a raw method_not_found. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Run inside a native folder, `orca ports` failed with selector_not_found (or picked an enclosing git worktree) because it only searched the worktree list. It now resolves the cwd like `agent launch`, native folders first, and shows that host's listeners. Rows are matched on the owner's path instead of its id, so every instance of a repo-backed folder workspace keeps its ports even though attribution names only the first instance as owner. `--all` adds the worktree id when two owners share a display name, and the skill guide notes that only workspace rows carry `owner` and `advertisedUrl`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ment the command Co-authored-by: Manuel Meurer <[email protected]>
…SSH scan limits Co-authored-by: Manuel Meurer <[email protected]>
… orca ports Co-authored-by: Manuel Meurer <[email protected]>
…ca ports Co-authored-by: Manuel Meurer <[email protected]>
Walkthrough
Priority: Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
87dfa37e-a9aa-4190-a3ff-7e61c100031f
Files selected for processing: 14-
docs/site/content/docs/cli/reference.mdxskill-guides/orca-cli.mdsrc/cli/args.tssrc/cli/bundled-skill-guides.tssrc/cli/command-scoped-flag-help.tssrc/cli/handler-group-manifest.tssrc/cli/handlers/ports.tssrc/cli/index-ports.test.tssrc/cli/ports-format.tssrc/cli/root-help-text-primary.tssrc/cli/root-help-text-secondary.tssrc/cli/specs/index.tssrc/cli/specs/ports.tssrc/main/startup/cli-command-names.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
-
| orca ports --all | ||
| ``` | ||
|
|
||
| `ports` lists the listening ports Orca tied to a workspace, from the host the workspace runs on. It defaults to the workspace that contains the current directory. Each row has `port`, `pid`, `processName`, `connectHost`, `protocol`, how Orca matched it (`owner.confidence`: `cwd` or `command`), and `advertisedUrl` when the dev server printed one in an Orca terminal. `--all` lists every listener on that host. Native folder workspaces need `--all`, because Orca does not tie ports to them. If `unavailableReason` is set, the scan could not run on that host; SSH workspaces opened directly from the desktop report this for now, while a workspace on a managed Orca server is scanned on that server. |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration |
Mark owner.confidence as workspace-only.
With --all, container and external rows have no owner. The current “Each row” wording can lead scripts to read a missing owner.confidence field. State that only kind: 'workspace' rows have owner.confidence and may have advertisedUrl, as the skill guide does.
ELI5
Orca already knows which ports each workspace's dev servers listen on, and shows them on the workspace card and in the Ports panel. Now the CLI can tell you too:
orca portslists them, so a script or agent can open "this workspace's dev site" without guessing the port.This builds on #32663 by @manuelmeurer, who designed and wrote the command. His two commits are kept with his authorship; this PR adds fixes on top.
What Changed
Before: the CLI had no way to read detected ports. Scripts had to repeat Orca's own scan with
lsof.After: a new read-only command,
orca ports [--worktree <selector>] [--all] [--json].--worktreeit uses the workspace containing the current directory, the same wayorca agent launchfinds it.match=cwd/match=command), and the URL the dev server printed in an Orca terminal, if Orca saw one.--jsongives the usual envelope withresultin theWorkspacePortHostScanResultshape.--alllists every listener on that workspace's host, with each row's owner.unavailableReasoninstead of an empty list. An older runtime with no host-scoped scan gets an "Update Orca" error.Mechanism: the handler calls the existing
workspacePorts.scanHostRPC (#27188), so the runtime decides which host to scan. The CLI then keeps only the rows whose owner path matches the workspace path fromworktree.show. No new RPC and no runtime changes.Changes on top of #32663:
jq '.result.ports[0]'could return another workspace's dev server. Noworca portsrefuses with a clear message that points to--all.--worktree path:<folder>. A path that names a native folder is recognised as that folder. If the path matches more than one workspace (two folders on different hosts, or a worktree and a folder), the command fails withselector_ambiguousand lists the candidates instead of guessing a host.docs/site/content/docs/cli/reference.mdx). The docs and skill guide note the folder and SSH limits.parseWorkspaceKeyis now reused.Why
Many dev servers (Vite when its default port is taken, Puma with port 0) pick a random port and write it nowhere. Orca already does the scan and attribution, including on managed servers, so exposing that result is simpler and more reliable than every script redoing it. Filtering in the CLI instead of adding a per-workspace RPC means it works with every runtime that already has
scanHost, with nothing new on the wire.There was no existing way to get this: no CLI command or
worktree psfield exposes ports, and the only RPCs areworkspacePorts.*, which the renderer calls.Linked Issue
Fixes #32632 (requested by @manuelmeurer)
Visual Proof
N/A: CLI-only change, with no UI.
Testing
src/cli/index-ports.test.ts(12 tests) runs the command throughmain(). It covers: the default workspace from cwd; an explicit selector; a folder-repo instance that shares its owner's path;--allowner rows; the JSON envelope; an unavailable scan; the "update Orca" error; a native folder refused without--alland scanned with it; apath:native folder; and an ambiguous path. The new folder tests fail on feat(cli): add orca ports to list a workspace's detected ports #32663's original handler.Live on macOS: I built the CLI and started an isolated headless runtime (
orca servewith a throwawayORCA_USER_DATA_PATH, the installed app binary, background launch). I added a temp git repo and started one HTTP listener inside the repo and one outside it.orca portsshowed only the repo's listener (47931 pid=… Python 127.0.0.1 unknown match=cwd,host=local).--allalso showed the outside listener asworkspace=(none).--jsonreturned the envelope.The full static job passed locally (lint, format, anti-slop, code-quality, type-aware, typecheck, ratchets, generated-catalog checks).
src/cliandsrc/main/startupunit tests ran single-worker.Not verified live: SSH (direct and managed server), WSL, and paired runtimes. By code reading: a workspace on a managed server is scanned on that server when the CLI runs there or with
--environment. Direct SSH workspaces get the runtime's existingunavailableReason, because the desktop runtime no longer scans SSH hosts (refactor(runtime): runtime git and file callers drop SSH arms #27501). WSL behaves the same as the Ports panel.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Codex review: round 1 was clean. Rounds 2 and 3 flagged path collisions in the new
path:to folder mapping (fixed above). Round 4 was clean. An independent review found no P0–P2 issues; its P3s were taken.Agent skill upstream boundary
Notes
Mobile: CLI-only, so there is no mobile surface to change.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)