[Bug]: `orca environment rm` does not stop the connection — the running app keeps reconnecting to the removed environment until restart
Operating system
macOS
Orca version
1.4.204 (both machines)
Details
Short summary
Correction (see comment): the GUI trash button is not affected —
runtimeEnvironments:removedoes tear the transport down. This isorca environment rmonly, because the CLI is a separate process that rewrites the store file and never reaches the running app. Root cause and a suggested fix are in that comment.
orca environment rm — and the trash button in Settings → Remote Orca Servers — orca environment rm removes the environment from orca-environments.json, but the running client keeps the live WebSocket to that endpoint and re-establishes it when the connection drops. The removal only takes effect after the client app restarts. Meanwhile orca environment list reads the persisted file, so the removed server is invisible while it is still connected; the only way to see the discrepancy is lsof/netstat on port 6768.
What happened
Two machines, A and B, each running Orca as both client and server. A had two saved environments pointing at B's runtime over two different network paths (a Tailscale address and a WireGuard overlay address). I removed the overlay one on A.
T+0—orca environment rm --environment <name>returnedok: truewith the removed record.orca environment liston A then showed only the Tailscale environment.T+6min— A still had an established outbound connection tows://<overlay-ip>:6768, source portP1.T+10min— B's Orca was restarted for an unrelated reason, forcing both sides to re-establish.- After that, A's connection to the removed endpoint came back with a new source port
P2, numerically adjacent to the source port of the surviving Tailscale connection — i.e. both were opened in the same batch. A new source port means a new connection: the removed environment actively reconnected ~10 minutes after it was deleted from disk.
Control
B's Orca main process started after I had removed the mirror-image environment on B's side. B therefore booted with only one environment in memory, and it opened zero connections over the overlay path. Same build, same topology; the only difference is whether the environment was in memory when it was removed.
The endpoint is not on disk any more
I grepped the whole ~/Library/Application Support/orca tree for the overlay address. The only configuration-shaped hit is profiles/local-default/orca-data.json → .sshTargets[N].host, which belongs to the SSH-targets feature — not a WebSocket endpoint, not port 6768. orca-environments.json contains only the surviving endpoint. So ws://<overlay-ip>:6768 exists nowhere on disk, and the connection can only come from in-process state.
Note for anyone reproducing this: other files in that tree matched the address as well —
terminal-history/*/checkpoint.json,ai-vault/session-parse-cache.json,agent-hooks/last-status.json. Those are recorded terminal scrollback of my own commands, not configuration. Judge a hit by its path inside the JSON, not by the file name.
How can we reproduce it?
- Pair client A to server B's runtime twice, over two addresses that are both reachable. You now have two environments whose
runtimeIdis identical. - On B:
lsof -nP -iTCP:6768shows connections arriving over both paths. - On A:
orca environment rm --environment <the second one>. Confirmorca environment listno longer lists it. lsofagain on B: the connection over the removed path is still established.- Force a reconnect (restart B's Orca, or drop the link). The removed environment comes back with a new source port.
- Restart A's Orca: only now is it actually gone.
Anything else that might help
Why this is worth fixing beyond tidiness:
orca environment listis the supported way to see what is saved, and it disagrees with what is connected. There is no in-app way to notice the difference.- Someone who removes a server to stop it reaching their machine will reasonably believe it stopped.
- It compounds the duplicate-workspace behaviour: after removing the redundant environment nothing visibly changes until a restart, which invites people to keep removing things looking for an effect.
Suggested fix: when an environment is removed, close its transport and drop it from the in-memory reconnect set, so environment list and the live connection agree.
No endpoint credentials or pairing material are included in this report.
Source: stablyai/orca