Repository navigation
Conversation
📝 WalkthroughWalkthroughWeb-client detection now returns early for the explicit web-client flag and guards pathname access with a fallback to 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 43bbaa87-be7f-4468-95a9-bda6a75f12d4
📒 Files selected for processing (3)
src/renderer/src/components/right-sidebar/file-explorer-operation-owner.tssrc/renderer/src/lib/web-client-location.tssrc/renderer/src/lib/worktree-runtime-owner.ts
| if (worktreeRuntimeEnvironmentId !== null) { | ||
| return worktreeRuntimeEnvironmentId | ||
| } | ||
| // Why: worktrees on a headless serve report hostId "local", but a web | ||
| // client has no browser-local host — fall through to the runtime fallback. | ||
| if (!isWebClientLocation() || !state.settings?.activeRuntimeEnvironmentId?.trim()) { | ||
| return null | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Return the active runtime directly instead of falling through.
Falling through to the runtime fallback allows repo-level explicit overrides to inadvertently take precedence. If the repository has an SSH connection, the fall-through logic evaluates parsed?.kind === 'runtime' as false and returns null. On a web client, returning null maps to a local host, which lacks a PTY and will cause the exact agent and terminal launch failures this PR is intended to fix.
To ensure operations correctly route to the active runtime (and to maintain consistency with getFileExplorerOperationOwnerFromState), return the active runtime directly instead of falling out of the block.
🐛 Proposed fix to return the active runtime directly
if (worktreeRuntimeEnvironmentId !== null) {
return worktreeRuntimeEnvironmentId
}
- // Why: worktrees on a headless serve report hostId "local", but a web
- // client has no browser-local host — fall through to the runtime fallback.
- if (!isWebClientLocation() || !state.settings?.activeRuntimeEnvironmentId?.trim()) {
- return null
- }
+ // Why: worktrees on a headless serve report hostId "local", but a web
+ // client has no browser-local host — route through the active runtime.
+ if (isWebClientLocation() && state.settings?.activeRuntimeEnvironmentId?.trim()) {
+ return state.settings.activeRuntimeEnvironmentId.trim()
+ }
+ return null📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (worktreeRuntimeEnvironmentId !== null) { | |
| return worktreeRuntimeEnvironmentId | |
| } | |
| // Why: worktrees on a headless serve report hostId "local", but a web | |
| // client has no browser-local host — fall through to the runtime fallback. | |
| if (!isWebClientLocation() || !state.settings?.activeRuntimeEnvironmentId?.trim()) { | |
| return null | |
| } | |
| if (worktreeRuntimeEnvironmentId !== null) { | |
| return worktreeRuntimeEnvironmentId | |
| } | |
| // Why: worktrees on a headless serve report hostId "local", but a web | |
| // client has no browser-local host — route through the active runtime. | |
| if (isWebClientLocation() && state.settings?.activeRuntimeEnvironmentId?.trim()) { | |
| return state.settings.activeRuntimeEnvironmentId.trim() | |
| } | |
| return null |
|
Taking a look! |
Description
When a browser web client connects to a headless
orca serveinstance, workspaces owned by the server'slocalhost cannot be operated: launching agents/terminals fails with "Local PTYs unavailable" and the file explorer shows "Couldn't determine which host owns this workspace."Root cause: Worktrees on the serve machine report
hostId: "local", which causes bothgetRuntimeEnvironmentIdForWorktreeandgetFileExplorerOperationOwnerFromStateto resolve the owner as local — routing operations to the browser's local host (which has no PTY or filesystem) instead of the remote runtime environment.Fix: When running in a web client with an active runtime environment, treat
hostId: "local"worktrees as belonging to the runtime rather than the browser-local host. Changes span three files:worktree-runtime-owner.ts(getRuntimeEnvironmentIdForWorktree): Skip the early null return for explicit-local worktrees and fall through to theactiveRuntimeEnvironmentIdfallback when the client is a web browser.file-explorer-operation-owner.ts(getFileExplorerOperationOwnerFromState): When the exact worktree hostId is "local" and the web client has an active runtime environment, return{kind:'runtime', environmentId}instead of{kind:'local'}.web-client-location.ts(isWebClientLocation): Made defensive against test environments wherewindow.locationmay be undefined.No visual change
This is an architectural fix for operation routing — no UI changes.
Code review summary
isWebClientLocation()guard ensures desktop apps continue routing local worktrees to the local host.ssh:) are unaffected. Only the web-client + active-runtime combination triggers the new path.getRuntimeEnvironmentIdForWorktree.isWebClientLocation()call and optional chaining in the worktree owner resolution hot path. Negligible overhead.isWebClientLocation()which uses__ORCA_WEB_CLIENT__flag andwindow.locationchecks.Testing notes
orca serveinstance with a web browser client would confirm end-to-end.Fixes #9047