Skip to content

fix: resolve local worktrees to the connected server on web clients (#9047) - #9147

Closed
PannenetsF wants to merge 1 commit into
stablyai:mainfrom
PannenetsF:fix/web-client-local-worktree-host-resolution
Closed

PannenetsF wants to merge 1 commit into
stablyai:mainfrom
PannenetsF:fix/web-client-local-worktree-host-resolution

Conversation

@PannenetsF

@PannenetsF PannenetsF commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On a browser web client connected to a headless orca serve, worktrees stored as host:local are unusable:

  • getFileExplorerOperationOwnerFromState resolved them to { kind: 'local' }.
  • getFileExplorerOperationRoute({kind:'local'}) then routed to { activeRuntimeEnvironmentId: null } — the browser's local host, which in a web client has no filesystem or PTY.

Symptoms for every pre-existing or UI-added local-host project: the file explorer shows "Couldn't determine which host owns this workspace", and terminals/agents show "Local PTYs are unavailable in the web client" / "Couldn't launch — the terminal did not start."

A web client has no local host — host:local means "the server I'm connected to". This change resolves a local-owned worktree to the connected server's runtime environment (the client's activeRuntimeEnvironmentId, seeded from the connected environment id at web startup) when running as a web client. It is per-connection, so different browsers/devices each resolve to their own connected server (no shared/global pin). Desktop behavior is unchanged, and it falls back to local when no connected runtime env is known.

Also hardens isWebClientLocation() so it doesn't throw when window exists without a location (guards window.location?.pathname).

Fixes #9047.

Screenshots

No visual change to component markup. Behavior-only: in a web client, opening a local-host worktree now loads files and starts terminals/agents against the connected server instead of erroring.

Testing

  • pnpm typecheck — pass for the web project (tsc --noEmit -p config/tsconfig.tc.web.json); no errors in changed files.
  • pnpm lint — ran oxlint on the changed files (pass); did not run the full lint script (localization/ratchet gates unrelated to this change).
  • pnpm test — ran the affected suites (see below, all pass); could not run the full suite locally because the native node-pty postinstall build fails in my environment (unrelated to this change).
  • pnpm build — not run locally (blocked by the same native-module build issue).
  • Added regression tests.

Ran and passed:

  • New file-explorer-operation-owner.test.ts (3 cases): desktop keeps local; web client routes local → connected runtime env; web client with no connected env falls back to local.
  • Existing safety-critical suites unaffected: file-explorer-delete-owner-provenance.test.ts, remote-host-file-delete-repro.test.ts, worktree-activation.test.ts — 42 passed total.
  • Reverse-verified: the web-client test fails on the pre-change source and passes with the fix.

AI Review Report

Reviewed with an AI coding agent, focused on the destructive-action path:

  • Delete safety preserved: the fix changes the owner (to {kind:'runtime'}), not just the route. useFileDeletion keys its OS-Trash-vs-permanent-remote logic on operationOwner.kind; because a web-client local worktree now consistently presents as runtime, deletes correctly take the remote path (confirm dialog + no bogus local-trash on a remote path) instead of the inconsistent "local kind, runtime route" state a route-only patch would create.
  • Blast radius: all consumers go through getFileExplorerOperationOwner/...FromState + getFileExplorerOperationRoute (file explorer tree, directory listing, quick-open, deletion). The store-backed entry points inject isWebClientLocation(); the pure ...FromState takes an explicit isWebClient flag defaulting to false, so non-web callers and existing tests are unchanged.
  • No global/shared state: resolution uses the client's own activeRuntimeEnvironmentId, so concurrent browsers/devices each resolve to their own connected server; nothing is pinned server-side.
  • Cross-platform: pure TS host-id resolution; no shell/path/OS APIs. isWebClientLocation() hardening only adds optional chaining.

Security Audit

  • Destructive actions: deletion authorization is unchanged in intent — a web-client local worktree now routes to the connected server (remote, with confirm) rather than attempting a local-host op the browser can't perform; it fails closed to unresolved when neither SSH nor a connected runtime env is known.
  • Input handling / secrets / deps / IPC: no new external input, no secrets, no dependency changes, no IPC contract change. Uses the existing activeRuntimeEnvironmentId and isWebClientLocation() signals.
  • Follow-up: none identified.

Notes

  • Behavior-only; desktop unchanged.
  • Root-cause and repro were confirmed on a containerized IPv6-only orca serve reached from a browser; this is the same class as the file-explorer/terminal host-unresolved reports.

ELI5

When you use Orca in a browser connected to a remote server, local worktrees were treated as if they lived on the browser’s machine—which has no files. They now correctly open on the connected server so the file explorer and terminals work.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3a190e02-613a-4957-b43c-fca0b36b3688

📥 Commits

Reviewing files that changed from the base of the PR and between 1272406 and 1122dcb20c6eda744a09af84ff0e4616ebd02d58.

📒 Files selected for processing (4)
  • src/renderer/src/components/quick-open-file-list.ts
  • src/renderer/src/components/right-sidebar/file-explorer-operation-owner.test.ts
  • src/renderer/src/components/right-sidebar/file-explorer-operation-owner.ts
  • src/renderer/src/lib/web-client-location.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/renderer/src/components/right-sidebar/file-explorer-operation-owner.test.ts
  • src/renderer/src/lib/web-client-location.ts
  • src/renderer/src/components/quick-open-file-list.ts
  • src/renderer/src/components/right-sidebar/file-explorer-operation-owner.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

File explorer operation-owner resolution now accepts web-client context. Web clients map local worktrees to a connected runtime environment when available, while desktop clients and disconnected web clients retain local ownership. Quick-open file-list loading passes the detected client location. Web-client detection handles missing location data. Tests cover desktop, connected-runtime, and fallback routing.

Merge Risk: ⚪ Minimal · up to 1122d

This change routes local worktrees in web clients to the connected server while preserving desktop behavior, with regression tests covering the new resolution paths; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes resolving local worktrees to the connected server for web clients.
Description check ✅ Passed The description explains the problem, solution, rationale, linked issue, behavior impact, testing, and safety considerations; omitted template sections are non-critical.
Linked Issues check ✅ Passed The changes satisfy issue #9047 by routing web-client local worktrees to the connected runtime while preserving desktop behavior and fallback handling.
Out of Scope Changes check ✅ Passed The implementation, hardening change, and regression tests are directly related to the linked issue and stated objectives.

Comment @coderabbitai help to get the list of available commands.

@brennanb2025

Copy link
Copy Markdown
Contributor

Taking a look!

@PannenetsF

Copy link
Copy Markdown
Contributor Author

Hi @brennanb2025, thanks for taking a look at this one earlier! Whenever you have a moment, is there anything you'd like me to adjust, or any context that would help move it along? Happy to rebase onto latest main if it's drifted. No rush — just flagging it's ready for another pass.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@PannenetsF
PannenetsF force-pushed the fix/web-client-local-worktree-host-resolution branch from 5c4f4f7 to 8408760 Compare August 18, 2026 14:28
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@PannenetsF
PannenetsF force-pushed the fix/web-client-local-worktree-host-resolution branch 2 times, most recently from 455b436 to 1122dcb Compare August 19, 2026 04:30
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@PannenetsF

Copy link
Copy Markdown
Contributor Author

@brennanb2025 Rebased onto the latest main and resolved all conflicts. Verified locally (typecheck + targeted tests pass); CI is pending maintainer approval to run. Ready for review whenever you have a moment — thanks!

On a browser web client connected to a headless `orca serve`, worktrees stored
as host:local are unusable: getFileExplorerOperationOwnerFromState resolved them
to { kind: 'local' }, and getFileExplorerOperationRoute then routed to
{ activeRuntimeEnvironmentId: null } — i.e. the browser's local host, which has
no filesystem or PTY. The result is "Couldn't determine which host owns this
workspace" in the file explorer and "Local PTYs are unavailable" / "Couldn't
launch <agent> — the terminal did not start" for terminals/agents, for every
pre-existing or UI-added local-host project.

A web client has no local host; host:local means "the server I'm connected to".
Resolve a local-owned worktree to the connected server's runtime environment
(the client's activeRuntimeEnvironmentId, which is seeded from the connected
environment id at web startup) when running as a web client. This is
per-connection, so different browsers/devices each resolve to their own
connected server — no shared/global pin. Desktop behavior is unchanged, and it
falls back to local when no connected runtime env is known.

Also harden isWebClientLocation() to not throw when window exists without a
location (guards window.location?.pathname).

Fixes stablyai#9047

Co-Authored-By: Claude Fable 5 <[email protected]>
@PannenetsF
PannenetsF force-pushed the fix/web-client-local-worktree-host-resolution branch from 1122dcb to ca987d2 Compare September 12, 2026 12:14
@nwparker

nwparker commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Closing as superseded — the linked issue (#9047) has been resolved on main by #9776 (15362fde16), #9785 (34c160442f), #27266 (5b676777ba). Thanks for the contribution!

@nwparker nwparker closed this Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working orca-remote-server Remote Orca Server / orca serve / paired remote runtime

Projects

None yet

4 participants