Skip to content

feat(remote): authenticate desktop and CLI tunnel connections - #31885

Open
chunchet-ng wants to merge 48 commits into
stablyai:mainfrom
chunchet-ng:feat/desktop-tunnel-auth
Open

chunchet-ng wants to merge 48 commits into
stablyai:mainfrom
chunchet-ng:feat/desktop-tunnel-auth

Conversation

@chunchet-ng

@chunchet-ng chunchet-ng commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Desktop Orca and its CLI can connect to a manually configured secure tunnel that requires authentication headers. Desktop saves them in protected OS storage; the CLI reads an explicitly selected private file.

What Changed

Adds native server-menu controls for masked credential replacement and explicit clearing, plus optional headers during verified pairing. The host is verified and saved first; if credential storage fails, retry saves credentials without replaying the pairing link. Drafts reset when the secure origin or pinned host key changes.

All Node WebSocket constructors validate the secure origin, pinned host key and headers before dialing and refuse redirects. Desktop connection, status, subscription, browser-host and delegated phone-relay paths receive the same bound credentials. Credential mutations retire cached transports. Unreadable storage produces a failed status request without interrupting startup or transport retirement. Managed SSH/WSL paths remain separate.

CLI users set ORCA_REMOTE_AUTH_FILE to a bounded private JSON file, checked against the selected server. POSIX ownership/mode and native Windows DACL verification fail closed. Header values stay out of saved environment metadata, IPC status, pairing links and Orca authentication frames.

Tunnel authentication also follows the connections that replace a pairing code with a private device token. Credential deletion no longer blocks the app; a save made while deletion is pending is refused to protect newer values.

Why

Extends existing transports, secure-file writes, SecretStore and connection invalidation. No Cloudflare SDK, dependency additions or remote protocol changes. Explicit CLI file input avoids placing credential values in command arguments. Browser builds use browser authentication and do not expose native credential controls.

Linked Issue

Addresses #24709 for desktop and CLI authentication. This is partial scope; tunnel provisioning stays manual.

Stacked on #31880 while its mobile transport work is reviewed. First-time mobile pairing is #31886. The current shared base is 87f30cf; its changes will drop out after #31880 merges. Address validation is independently in #31499.

Visual Proof

Pending before/after capture of the native Add server and server-menu credential controls with synthetic, masked values. No physical device is available. The contributor permits review after automated checks pass, with native interaction behavior explicitly unverified.

Testing

November 11 review fixes, source commit f000955e2dec

  • Credential-only retry survives a failed server-list refresh without replaying a consumed pairing code. The CLI compares BigInt file IDs and nanosecond change times from the opened file and final path. The collision regression and all 25 focused credential-file and bounded-reader tests passed on macOS.
  • The final mobile safeguards are included. All 15 selected checks for that integration passed. All 22 static/type checks for the CLI follow-up passed. The broad related-unit selection exceeded its one-minute limit, so the complete changed gate remains incomplete.
  • Local validation uses upstream 4a31139c50b because the newer upstream commit introduced an unrelated renderer import error. The refresh preserves upstream source moves.

The final combined local checkout of #31499, #31880, #31885 and #31886 passed 3,860 mobile tests across 606 suites, 154 desktop/browser/file-reader tests across 23 suites, and all root and mobile production typechecks. The four sources merge together cleanly.

Fresh native builds, physical-device save/restart/background reconnect, native UI checks and live Cloudflare or Traefik acceptance are pending for these commits. Windows identity handling has a regression using synthetic colliding IDs. It has not been exercised on a Windows machine during this update.

The required upstream workflow for this source commit is awaiting maintainer approval. PR Checks run

Risk

Level: Medium. The riskiest boundary is binding protected desktop/CLI credentials to the correct paired server and retiring transports after credential changes. A regression could block remote access, keep a connection using old credentials or send credentials to the wrong endpoint. Mixed-version peers, SSH/WSL routing and browser header exclusion are preserved. Linux native-keyring and rendered UI acceptance remain unverified. Revert this PR to restore the previous transport; a revert does not delete saved credential files or revoke Cloudflare tokens. Clear credentials before rollback and revoke tokens separately.

AI Disclosure

Implemented with Codex (GPT-6) assistance. Independent read-only reviews were used during development. The review and test results above include their limits and do not constitute human maintainer approval.

Review

No new wire fields are sent to remote Orca peers. Credentials are bound and checked before each dial; encrypted envelopes cannot silently downgrade to plaintext or headerless access. Corrupt or mismatched stored credentials require explicit clearing before replacement.

Agent skill upstream boundary

  • Not applicable: no upstream skill-installer source or resources copied.

Notes

Tunnel creation remains manual under the approved scope. Browser Access-session acceptance and real-phone storage/reconnect remain distinct from these transport and protected-store checks. Validation-only workflows are on separate fork branches and are absent from this PR.

Checklist

  • Focused desktop/CLI authentication; before/after, mechanism and alternatives explained
  • Source reviewed for correctness, security and performance
  • Cross-platform, SSH/remote, folder-workspace and mixed-version behavior considered
  • Native UI visual proof attached
  • Fresh platform checks pass on the current source (earlier evidence linked above)
  • Exact-head upstream PR workflow passes before merge
  • Real-device and rendered UI acceptance (disclosed follow-up; contributor permits review without a device)

@chunchet-ng
chunchet-ng marked this pull request as ready for review October 22, 2026 07:41
Copilot AI balanced review requested due to automatic review settings October 22, 2026 07:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

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
Walkthrough

Adds endpoint-bound authentication headers for secure WebSocket connections across desktop, mobile, and CLI flows. The changes include header validation, protected credential storage, pairing and connection routing, settings interfaces, and mobile diagnostics. Authenticated connections disable redirects. The Android WebSocket patch exposes redirect-control support and HTTP upgrade status. Documentation and tests cover credential handling and platform-specific behavior.

Merge Risk: Low · up to f3de1

Mobile users may be unable to edit or remove a host when the keychain is locked. Leaving the edit screen mid-save can require re-entering credentials after an address change. The CLI's Windows file-identity check has a narrow precision gap. None of these is severe, and each has a workaround, so the PR is mergeable once the owner is aware of them.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: tunnel authentication for desktop and CLI connections.
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description is mostly complete and follows the required structure. It explains the user impact, changes, rationale, linked issue, testing, risk, AI disclosure, security considerations, and rollbac…
Full details: Description check

Explanation

The description is mostly complete and follows the required structure. It explains the user impact, changes, rationale, linked issue, testing, risk, AI disclosure, security considerations, and rollback guidance. It clearly discloses that native UI proof, fresh platform checks, real-device testing, and some broad validation remain incomplete.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments: 1
src/main/runtime/runtime-environment-edge-auth.ts: 1

22-28: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Cache edge-auth resolution on the terminal input path.

callRuntimeEnvironment resolves edge authentication before it uses the cached request transport. For direct wss:// environments, each terminal.send and terminal.updateViewport call can therefore perform synchronous credential-file I/O. Configured credentials also perform protected-storage decryption and parsing on the main process input path. This is more than a trivial nitpick.

Cache successful credentials and a missing-credentials result. Do not cache read or decrypt failures. Invalidate the cache after successful credential writes and clears, and during environment transport invalidation. Include the full pairing identity, including the device token. The cache key in the sketch must not omit that token.

♻️ Suggested cache
 type EdgeAuth = NonNullable<PairedRuntimeConnection['edgeAuth']>
+const edgeAuthCache = new Map<
+  string,
+  { key: string; edgeAuth: EdgeAuth | null }
+>()
+
+export function forgetRuntimeEnvironmentEdgeAuth(environmentId: string): void {
+  edgeAuthCache.delete(environmentId)
+}
 ...
-  const edgeAuth = readRuntimeEdgeAuth(userDataPath, environment)
+  const key = [
+    userDataPath,
+    environment.pairingRevision ?? environment.createdAt,
+    connection.endpoint,
+    connection.credential.deviceToken,
+    connection.hostPublicKeyB64
+  ].join('\0')
+  const cached = edgeAuthCache.get(environment.id)
+  const edgeAuth =
+    cached?.key === key ? cached.edgeAuth : readRuntimeEdgeAuth(userDataPath, environment)
+  if (cached?.key !== key) {
+    edgeAuthCache.set(environment.id, { key, edgeAuth })
+  }
   if (!edgeAuth) {
     return connection
   }

Call forgetRuntimeEnvironmentEdgeAuth after successful writeRuntimeEdgeAuth and clearRuntimeEdgeAuth operations, or from invalidateRuntimeEnvironmentTransport. Preserve the existing remoteRuntimeConnectOptions call for cached credentials.


ℹ️ 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: 3ee71b87-2680-4512-a845-464905d1e4ea
📥 Commits

Reviewing files that changed from the base of the PR and between 57f1fce and f338a464232ab9d834c29210847c7f0fdf4a6cc9.

⛔ Files ignored due to path filters: 1
  • mobile/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing: 95
  • .github/workflows/mobile-android-release.yml
  • docs/site/content/docs/cli/reference.mdx
  • docs/site/content/docs/mobile.mdx
  • docs/site/content/docs/remote-servers.mdx
  • mobile/README.md
  • mobile/app.json
  • mobile/app/h/[hostId]/edit.tsx
  • mobile/patches/[email protected]
  • mobile/pnpm-workspace.yaml
  • mobile/scripts/endpoint-auth-ios-codegen.test.ts
  • mobile/scripts/endpoint-auth-native-bridge.test.ts
  • mobile/src/components/edge-auth-headers-section.test.tsx
  • mobile/src/components/edge-auth-headers-section.tsx
  • mobile/src/components/host-edit-styles.ts
  • mobile/src/diagnostics/use-mobile-web-bundle-probe.test.tsx
  • mobile/src/host-edit-route-accessibility.test.ts
  • mobile/src/host-edit-save-flow.test.ts
  • mobile/src/transport/client-context.test.ts
  • mobile/src/transport/direct-rpc-client.ts
  • mobile/src/transport/endpoint-auth-headers-store.test.ts
  • mobile/src/transport/endpoint-auth-headers-store.ts
  • mobile/src/transport/endpoint-auth-headers-store.web.ts
  • mobile/src/transport/endpoint-auth-headers.test.ts
  • mobile/src/transport/endpoint-auth-headers.ts
  • mobile/src/transport/host-entry-opener.ts
  • mobile/src/transport/host-logical-client.ts
  • mobile/src/transport/host-open-recovery.test.tsx
  • mobile/src/transport/host-removal-lifecycle.test.ts
  • mobile/src/transport/host-removal-lifecycle.ts
  • mobile/src/transport/mobile-endpoint-lifecycle.ts
  • mobile/src/transport/rpc-client-socket-factory.ts
  • mobile/src/transport/rpc-client-socket-headers.test.ts
  • mobile/src/transport/rpc-client-socket-session.ts
  • mobile/src/transport/rpc-client.ts
  • mobile/src/transport/rpc-socket-close-evidence.ts
  • mobile/src/transport/settings-host-client-lifecycle.test.ts
  • mobile/src/transport/unpaired-host-credential-deletion.test.ts
  • mobile/src/transport/unpaired-host-credential-deletion.ts
  • src/cli/runtime/remote-edge-auth-file-windows.test.ts
  • src/cli/runtime/remote-edge-auth-file.test.ts
  • src/cli/runtime/remote-edge-auth-file.ts
  • src/cli/runtime/runtime-remote-pairing.ts
  • src/cli/runtime/websocket-transport.test.ts
  • src/main/browser/paired-runtime-browser-client-host-runtime.ts
  • src/main/credentials/runtime-edge-auth-store.test.ts
  • src/main/credentials/runtime-edge-auth-store.ts
  • src/main/ipc/runtime-environments/runtime-environment-connectivity-handlers.ts
  • src/main/ipc/runtime-environments/runtime-environment-edge-auth-handlers.test.ts
  • src/main/ipc/runtime-environments/runtime-environment-edge-auth-handlers.ts
  • src/main/ipc/runtime-environments/runtime-environment-edge-auth-status.test.ts
  • src/main/ipc/runtime-environments/runtime-environment-handler-channels.ts
  • src/main/ipc/runtime-environments/runtime-environment-manual-disconnect.ts
  • src/main/ipc/runtime-environments/runtime-environment-mobile-relay-hosts.test.ts
  • src/main/ipc/runtime-environments/runtime-environment-mobile-relay-hosts.ts
  • src/main/ipc/runtime-environments/runtime-environment-pairing-edge-auth.test.ts
  • src/main/ipc/runtime-environments/runtime-environment-pairing-verification.ts
  • src/main/ipc/runtime-environments/runtime-environment-request-connections.ts
  • src/main/ipc/runtime-environments/runtime-environment-status-owner.ts
  • src/main/ipc/runtime-environments/runtime-environment-support-routing.ts
  • src/main/ipc/runtime-environments/runtime-environment-transport-routing.ts
  • src/main/ipc/runtime-environments/runtime-environments.ts
  • src/main/runtime/mobile-desktop-relay/mobile-desktop-relay-hosts.ts
  • src/main/runtime/mobile-desktop-relay/mobile-desktop-relay.test.ts
  • src/main/runtime/mobile-desktop-relay/mobile-desktop-relay.ts
  • src/main/runtime/runtime-environment-edge-auth.test.ts
  • src/main/runtime/runtime-environment-edge-auth.ts
  • src/preload/api/runtime-api.ts
  • src/preload/api/runtime-environments-bridge.ts
  • src/renderer/src/components/settings/RuntimeEnvironmentsPane.tsx
  • src/renderer/src/components/settings/RuntimeHostAccessForm.tsx
  • src/renderer/src/components/settings/runtime-add-server-dialog.test.tsx
  • src/renderer/src/components/settings/runtime-add-server-dialog.tsx
  • src/renderer/src/components/settings/runtime-edge-auth-fields.test.tsx
  • src/renderer/src/components/settings/runtime-edge-auth-fields.tsx
  • src/renderer/src/components/settings/runtime-server-edge-auth-action.test.tsx
  • src/renderer/src/components/settings/runtime-server-edge-auth-action.tsx
  • src/renderer/src/components/settings/runtime-server-row-menu.tsx
  • src/renderer/src/components/settings/runtime-server-row.tsx
  • src/renderer/src/components/settings/use-runtime-environment-mutation-actions.test.tsx
  • src/renderer/src/components/settings/use-runtime-environment-mutation-actions.ts
  • src/renderer/src/web/preload-api/web-runtime-environments-api.ts
  • src/renderer/src/web/preload-api/web-runtime-pairing-verification.ts
  • src/renderer/src/web/web-preload-api-runtime-environment.test.ts
  • src/shared/network/endpoint-auth-headers.test.ts
  • src/shared/network/endpoint-auth-headers.ts
  • src/shared/paired-runtime-connection.ts
  • src/shared/remote-pairing-verification.ts
  • src/shared/remote-runtime-connect-bound.ts
  • src/shared/remote-runtime-edge-auth.test.ts
  • src/shared/remote-runtime-request-socket.ts
  • src/shared/remote-runtime-request-websocket.ts
  • src/shared/remote-runtime-subscription-transport.ts
  • src/shared/runtime-edge-auth-types.ts
  • src/shared/secure-file-windows.test.ts
  • src/shared/secure-file.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread mobile/app/h/[hostId]/edit.tsx Resolved
@chunchet-ng

Copy link
Copy Markdown
Contributor Author

Addressed the performance note in the review summary in 72579369f5. Repeated connection resolution now caches validated credentials and missing-credential results by profile and full pairing identity, including the device token. Read/decrypt failures are not cached. Writes, clears and transport invalidation evict cached values; eviction occurs before file publication so a later durability failure cannot leave stale values. Binding checks still run before dialing.

The regression first observed 100 decryptions for 100 resolutions, then passed with one. A publication-then-error regression also failed before its fix. The affected 10 suites passed 76 tests; all four root typecheck projects, changed-code quality, lint and formatting passed. An independent review rechecked the cache edge case. The broad desktop test attempt did not produce a final result; the normal test wrapper also requires Bun, which is unavailable in this shell. Fresh three-platform validation is being dispatched.

The docstring-coverage warning is advisory; I kept comments to non-obvious behavior as required by this repository rather than adding redundant function descriptions. Upstream PR CI still requires maintainer approval.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Persist credentials after a committed endpoint update. · edit.tsx:167-172

mobile/app/h/[hostId]/edit.tsx:167-172
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Persist credentials after a committed endpoint update.

If the metadata write commits after the route revision changes, do not return before persistAuthChanges. Persist the captured headers, then re-prime and refresh the client. Guard setHost and all other UI updates with the revision check.

Suggested fix
-    if (revision !== routeRevision.current) {
-      await reprimeHosts()
-      if (nextEndpoint !== undefined) {
-        refreshHostClient(host.id)
-      }
-      return
-    }
-
     // Retrying after a keychain failure must compare against the committed address.
-    setHost({ ...host, personalName: nextName || undefined, endpoint: endpointEdit.endpoint })
+    if (revision === routeRevision.current) {
+      setHost({ ...host, personalName: nextName || undefined, endpoint: endpointEdit.endpoint })
+    }

Update the pending-save test to expect writeEndpointAuthHeaders after leaving during the metadata write.

🔇 Additional comments: 7
src/main/credentials/runtime-edge-auth-store.ts: 1

1-178: LGTM!

src/main/credentials/runtime-edge-auth-store.test.ts: 1

1-257: LGTM!

src/main/ipc/runtime-environments/runtime-environment-edge-auth-status.test.ts: 1

1-41: LGTM!

src/main/ipc/runtime-environments/runtime-environments.ts: 1

1-2: LGTM!

Also applies to: 85-85

src/main/runtime/runtime-environment-edge-auth.ts: 2

1-13: LGTM!

Also applies to: 20-29


14-19: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Share the edge-auth eligibility check between the resolver and the save handler.

The resolver decides which connections receive stored credentials. registerRuntimeEnvironmentEdgeAuthHandlers (saveEdgeAuth) decides which connections may store them. The two code paths use separate inline conditions. The resolver tests connectionDependency === 'ssh-tunnel'. The handler tests whether connectionDependency is truthy. The two conditions match today because the type has one value. They will diverge if a new dependency kind is added.

Export one predicate, for example isDirectSecureEdgeAuthEnvironment(environment), from this module. Use it in both places. Then a change to the eligibility rule applies to saving and sending together.

src/main/runtime/runtime-environment-edge-auth.test.ts: 1

1-85: LGTM!


ℹ️ 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: 198d9b8b-b9d9-4b0c-a513-3055d54ab108
📥 Commits

Reviewing files that changed from the base of the PR and between f338a464232ab9d834c29210847c7f0fdf4a6cc9 and 72579369f569a6eff7c38ebfd64c0e86d615d92b.

⛔ Files ignored due to path filters: 1
  • mobile/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing: 8
  • mobile/app/h/[hostId]/edit.tsx
  • mobile/src/host-edit-save-flow.test.ts
  • src/main/credentials/runtime-edge-auth-store.test.ts
  • src/main/credentials/runtime-edge-auth-store.ts
  • src/main/ipc/runtime-environments/runtime-environment-edge-auth-status.test.ts
  • src/main/ipc/runtime-environments/runtime-environments.ts
  • src/main/runtime/runtime-environment-edge-auth.test.ts
  • src/main/runtime/runtime-environment-edge-auth.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@chunchet-ng

Copy link
Copy Markdown
Contributor Author

Follow-up to the latest review summary:

The suggested write after route cancellation would reverse the existing cancellation contract. Leaving or changing the route invalidates its revision. If the already-started metadata write later commits, the app re-primes the committed address and refreshes the client, but it does not start a new secret write from the canceled form. Existing credentials remain stored and bound to their original secure origin; they are not deleted or silently rebound. A changed endpoint can consequently need credential entry again. That is a recovery limitation, not a lost stored credential, and I am keeping this boundary rather than persisting canceled input.

The current regression does not start saving credentials after leaving during the metadata write explicitly covers that choice. I reran the host-edit and credential-store suites: 37 tests passed. The ordinary non-canceled path still saves headers after metadata and reports a storage-only retryable failure.

The proposed eligibility abstraction is an unverified future-proofing suggestion: connectionDependency is currently z.literal('ssh-tunnel').optional(), so the resolver and save handler have equivalent dependency checks. No current unsupported dependency bypass was identified. I have retained the focused implementation and existing eligibility tests.

All inline conversations remain resolved. Current upstream PR workflows still await maintainer approval; the successful clean job is separate from the required PR workflow.

@chunchet-ng
chunchet-ng force-pushed the feat/desktop-tunnel-auth branch from 7257936 to f269fd9 Compare October 25, 2026 06:32

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


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: 68dc1724-3cfa-4619-a560-53e36421693e
Commits

Reviewing files that changed from the base of the PR and between 72579369f569a6eff7c38ebfd64c0e86d615d92b and f269fd9cb4080b64d79e4cca183c0f3eb71995ac.

Files ignored due to path filters: 1
  • mobile/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing: 25
  • docs/site/content/docs/cli/reference.mdx
  • mobile/pnpm-workspace.yaml
  • mobile/src/host-edit-route-accessibility.test.ts
  • mobile/src/transport/client-context.test.ts
  • src/cli/runtime/remote-edge-auth-file.ts
  • src/cli/runtime/websocket-transport.test.ts
  • src/main/browser/paired-runtime-browser-client-host-runtime.ts
  • src/main/credentials/runtime-edge-auth-store.ts
  • src/main/ipc/runtime-environments/runtime-environment-connectivity-handlers.ts
  • src/main/ipc/runtime-environments/runtime-environment-mobile-relay-hosts.ts
  • src/main/ipc/runtime-environments/runtime-environment-pairing-verification.ts
  • src/main/ipc/runtime-environments/runtime-environment-request-connections.ts
  • src/main/ipc/runtime-environments/runtime-environment-status-owner.ts
  • src/main/ipc/runtime-environments/runtime-environment-support-routing.ts
  • src/main/ipc/runtime-environments/runtime-environment-transport-routing.ts
  • src/main/ipc/runtime-environments/runtime-environments.ts
  • src/main/runtime/mobile-desktop-relay/mobile-desktop-relay.test.ts
  • src/main/runtime/runtime-environment-edge-auth.ts
  • src/preload/api/runtime-api.ts
  • src/renderer/src/components/settings/use-runtime-environment-mutation-actions.test.tsx
  • src/shared/remote-runtime-edge-auth.test.ts
  • src/shared/remote-runtime/remote-runtime-connect-bound.ts
  • src/shared/remote-runtime/requests/remote-runtime-request-socket.ts
  • src/shared/remote-runtime/requests/remote-runtime-request-websocket.ts
  • src/shared/remote-runtime/requests/remote-runtime-subscription-transport.ts
Files skipped from review as they are similar to previous changes: 1
  • src/main/ipc/runtime-environments/runtime-environment-request-connections.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.

@chunchet-ng
chunchet-ng force-pushed the feat/desktop-tunnel-auth branch from f269fd9 to bcf7fd8 Compare October 25, 2026 08:04

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Invalidate transports on every replacement attempt, not… · runtime-edge-auth-store.ts:121-164

src/main/credentials/runtime-edge-auth-store.ts:121-164
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Invalidate transports on every replacement attempt, not only on success.

writeRuntimeEdgeAuth can publish new credentials to disk and then throw. The save handler skips transport invalidation on that path.

In src/main/ipc/runtime-environments/runtime-environment-edge-auth-handlers.ts, saveEdgeAuth calls writeRuntimeEdgeAuth(...) and then await invalidateTransport(environment.id) on the next line. If the write throws, the handler exits before invalidation. Open connections and subscriptions for that environment keep the headers they were built with. The disk now holds the replacement credentials. The user sees a save error and may assume nothing changed.

The consequence is narrow. Resolution reads the credential cache, which the store evicts before publication, so new requests read the new envelope. The stale state lasts only until existing connections reconnect. A retry that succeeds also invalidates transports.

The fix is to invalidate in a finally block. Invalidation on a failed attempt that wrote nothing only forces a reconnect.

Suggested fix
-    writeRuntimeEdgeAuth(getUserDataPath(), environment, normalized.headers)
-    await invalidateTransport(environment.id)
+    try {
+      writeRuntimeEdgeAuth(getUserDataPath(), environment, normalized.headers)
+    } finally {
+      await invalidateTransport(environment.id)
+    }

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: f627e89c-4139-4f46-9490-8c480570964b
Commits

Reviewing files that changed from the base of the PR and between bcf7fd880814991c7cb601e558acc531f1b44b32 and d8e103097e1aac50d37ddc8ad4d984a7a3171524.

Files selected for processing: 3
  • docs/site/content/docs/cli/reference.mdx
  • src/cli/runtime/remote-edge-auth-file.test.ts
  • src/cli/runtime/remote-edge-auth-file.ts
Files skipped from review as they are similar to previous changes: 2
  • src/cli/runtime/remote-edge-auth-file.test.ts
  • src/cli/runtime/remote-edge-auth-file.ts

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

@chunchet-ng

Copy link
Copy Markdown
Contributor Author

Addressed the failed-write transport finding in 48ac96e54c0.

After a validated credential write throws, the handler now attempts to retire the environment's existing transports. It preserves the original storage error if retirement also throws or rejects. Successful writes still surface retirement errors. Invalid headers or stale pairing revisions continue to stop before storage or transport changes. The pairing path already retires transports when a credential-save failure returns a saved environment ID.

Three regression cases failed before the fix and pass now. The affected IPC/store/pairing suites pass 30 tests; the broader IPC/store/secure-file check passes 289 tests across 49 suites (two skipped). All four root type-check projects and the changed-code gate pass. Fresh macOS/Linux/Windows validation, including protected-store restart checks on macOS/Windows and the standard Node/Bun test selector, passed on matching product source: https://github.com/chunchet-ng/orca/actions/runs/40281387740 .

The upstream conflicts are resolved while preserving the new desktop chat-history APIs and moved disconnect handling. Independent review found no confirmed issue. Upstream required PR CI still needs maintainer approval.

chunchet-ng and others added 3 commits November 3, 2026 09:35
Adapt Mark Hingston's native edge-auth work to current host lifecycles.
Bind credentials to the WSS origin so partial endpoint saves cannot
forward old credentials to a new host. Preserve the current E2EE flow.

Refs stablyai#24709
Source: stablyai#25077
Co-authored-by: Mark Hingston <[email protected]>
Android WebSockets forward custom headers across redirects. Disable both redirect modes for credential-bearing sockets and refuse credentials on Android clients without this native protection.

Build React Native from source so its patched module ships in Android apps. Preserve ordinary sockets and the existing E2EE flow.
Prefab 2.1.0 parses equals signs in patched dependency paths as options. Hash mobile package directory names so React Native source builds reach the compiler without changing dependency versions.

Guard the installed ReactAndroid source path with a regression test.
Comment thread mobile/app/h/[hostId]/edit.tsx Resolved
@chunchet-ng

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chunchet-ng

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chunchet-ng

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor
Action not completed

Head commit changed.

@chunchet-ng

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

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: 6ca627af-d395-40f0-9d69-38bd8fd7cb3d
Commits

Reviewing files that changed from the base of the PR and between 13af8e9 and f3de11d.

Files ignored due to path filters: 1

  • mobile/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing: 83

  • .github/workflows/mobile-android-release.yml
  • config/scripts/test-runtime/sqlite-admission/vitest-node-runtime-files.mjs
  • docs/site/content/docs/cli/reference.mdx
  • docs/site/content/docs/remote-servers.mdx
  • mobile/app.json
  • mobile/app/h/[hostId]/edit.tsx
  • mobile/patches/[email protected]
  • mobile/scripts/endpoint-auth-native-bridge.test.ts
  • mobile/src/components/edge-auth-headers-section.tsx
  • mobile/src/components/host-edit-styles.ts
  • mobile/src/diagnostics/connection/socket-event-debug.ts
  • mobile/src/diagnostics/host-reachability.test.ts
  • mobile/src/diagnostics/host-reachability.ts
  • mobile/src/diagnostics/use-troubleshoot-diagnostics-edge-auth.test.tsx
  • mobile/src/diagnostics/use-troubleshoot-diagnostics.ts
  • mobile/src/host-catalog/host-removal-lifecycle.ts
  • mobile/src/i18n/en-runtime-required.json
  • mobile/src/i18n/locales/en.json
  • mobile/src/pairing/unpaired-host-credential-deletion.ts
  • mobile/src/transport/connection/client-context.test.ts
  • mobile/src/transport/connection/host-entry-opener.ts
  • mobile/src/transport/connection/host-logical-client.ts
  • mobile/src/transport/connection/mobile-endpoint-lifecycle.ts
  • mobile/src/transport/endpoint-auth-headers-store.test.ts
  • mobile/src/transport/endpoint-auth-headers-store.ts
  • mobile/src/transport/endpoint-auth-headers.ts
  • mobile/src/transport/hosts/host-open-recovery.test.tsx
  • mobile/src/transport/rpc-client-socket-headers.test.ts
  • mobile/src/transport/rpc/direct-rpc-client.ts
  • mobile/src/transport/rpc/direct-rpc-connect.ts
  • mobile/src/transport/rpc/rpc-client-socket-factory.ts
  • mobile/src/transport/rpc/rpc-client-socket-session.ts
  • mobile/src/transport/rpc/rpc-socket-close-evidence.ts
  • mobile/src/transport/unpaired-host-credential-deletion.test.ts
  • src/cli/runtime/remote-edge-auth-file.test.ts
  • src/cli/runtime/remote-edge-auth-file.ts
  • src/cli/runtime/runtime-remote-pairing.ts
  • src/cli/runtime/websocket-transport.test.ts
  • src/main/browser/client-hosts/lifecycle/paired-runtime-browser-client-host-runtime.ts
  • src/main/credentials/runtime-edge-auth-store.test.ts
  • src/main/credentials/runtime-edge-auth-store.ts
  • src/main/ipc/runtime-environments/runtime-environment-connectivity-handlers.ts
  • src/main/ipc/runtime-environments/runtime-environment-edge-auth-handlers.test.ts
  • src/main/ipc/runtime-environments/runtime-environment-edge-auth-handlers.ts
  • src/main/ipc/runtime-environments/runtime-environment-edge-auth-status.test.ts
  • src/main/ipc/runtime-environments/runtime-environment-manual-disconnect.ts
  • src/main/ipc/runtime-environments/runtime-environment-mobile-relay-hosts.ts
  • src/main/ipc/runtime-environments/runtime-environment-pairing-edge-auth.test.ts
  • src/main/ipc/runtime-environments/runtime-environment-pairing-verification.ts
  • src/main/ipc/runtime-environments/runtime-environment-removal-cleanup.ts
  • src/main/ipc/runtime-environments/runtime-environment-removal-storage.test.ts
  • src/main/ipc/runtime-environments/runtime-environment-request-connections.ts
  • src/main/ipc/runtime-environments/runtime-environment-status-owner.ts
  • src/main/ipc/runtime-environments/runtime-environment-support-routing.ts
  • src/main/ipc/runtime-environments/runtime-environment-transport-routing.ts
  • src/main/ipc/runtime-environments/runtime-environments.ts
  • src/main/runtime/mobile-desktop-relay/mobile-desktop-relay-hosts.ts
  • src/main/runtime/mobile-desktop-relay/mobile-desktop-relay.test.ts
  • src/main/runtime/mobile-desktop-relay/mobile-desktop-relay.ts
  • src/main/runtime/runtime-environment-edge-auth.test.ts
  • src/main/runtime/runtime-environment-edge-auth.ts
  • src/preload/api/runtime-api.ts
  • src/renderer/src/components/runtime-access/RuntimeHostAccessForm.tsx
  • src/renderer/src/components/settings/runtime-add-server-dialog.test.tsx
  • src/renderer/src/components/settings/runtime-edge-auth-fields.tsx
  • src/renderer/src/components/settings/runtime-environments/catalog/RuntimeEnvironmentsPane.tsx
  • src/renderer/src/components/settings/runtime-environments/catalog/use-runtime-environment-mutation-actions.test.tsx
  • src/renderer/src/components/settings/runtime-environments/catalog/use-runtime-environment-mutation-actions.ts
  • src/renderer/src/components/settings/runtime-environments/pairing/runtime-add-server-dialog.tsx
  • src/renderer/src/components/settings/runtime-environments/server-rows/runtime-server-row-menu.tsx
  • src/renderer/src/components/settings/runtime-environments/server-rows/runtime-server-row.tsx
  • src/renderer/src/components/settings/runtime-server-edge-auth-action.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/web/preload-api/web-runtime-environments-api.ts
  • src/renderer/src/web/preload-api/web-runtime-pairing-verification.ts
  • src/shared/remote-runtime-edge-auth.test.ts
  • src/shared/remote-runtime/pairing/paired-runtime-connection.ts
  • src/shared/remote-runtime/pairing/remote-pairing-ticket-exchange.ts
  • src/shared/remote-runtime/pairing/remote-pairing-verification.ts
  • src/shared/remote-runtime/remote-runtime-connect-bound.ts
  • src/shared/remote-runtime/requests/remote-runtime-request-socket.ts
  • src/shared/remote-runtime/requests/remote-runtime-request-websocket.ts
  • src/shared/secure-storage/secure-file.ts
Files skipped from review as they are similar to previous changes: 4

  • mobile/src/i18n/en-runtime-required.json
  • mobile/src/i18n/locales/en.json
  • mobile/src/components/host-edit-styles.ts
  • src/renderer/src/i18n/locales/en.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Comment thread mobile/app/h/[hostId]/edit.tsx Resolved

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants