Skip to content

Recover desktop startup and local fallback - #1121

Merged
ross0x01 merged 1 commit into
mainfrom
agent/recover-desktop-startup
Aug 17, 2026
Merged

Recover desktop startup and local fallback#1121
ross0x01 merged 1 commit into
mainfrom
agent/recover-desktop-startup

Conversation

@ross0x01

@ross0x01 ross0x01 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • retry desktop bridge startup failures with bounded backoff and privacy-safe recovery telemetry
  • preserve and allow a healthy remote Local runner when the internal Desktop bridge is unavailable
  • show Local reconnecting or Local unavailable instead of falsely falling back to Cloud
  • redact authentication URLs and query values from native desktop logs

Root cause

The existing recovery logic retried terminal bridge failures only after a bridge had started. A readiness failure during startup moved the bridge directly to a failed state. Free Desktop sessions also forced the internal desktop preference and the send gate ignored a healthy npx @hackerai/local connection. When the selected local option was missing, the selector rendered the first available option, which was Cloud. Native single-instance and deep-link logs also included complete authentication URLs.

Validation

  • focused regression suites: 5 suites, 40 tests passed
  • full Jest suite: 386 suites, 3,922 tests passed
  • pnpm typecheck
  • pnpm lint
  • Prettier check
  • git diff --check
  • branch-specific desktop build: Linux x64/ARM64 and macOS x64/ARM64 compiled and packaged successfully; Windows was rejected before checkout because feature branches are not allowed into the protected trusted-signing environment

Manual verification

  1. In the free Kali desktop app, start a separate npx @hackerai/local runner and interrupt the internal Desktop bridge. Confirm the selector keeps/selects the remote hostname and Agent commands still run there.
  2. Repeat without a remote runner. Confirm the selector shows Local reconnecting, then Local unavailable, and never changes to Cloud.
  3. Restore the internal transport and confirm the bridge reconnects automatically within the bounded retry sequence.
  4. Complete Linux deep-link authentication and inspect ~/hackerai-desktop.log. Confirm it contains no token, desktop_state, origin value, or raw deep-link query.

This change does not introduce Cloud execution as a fallback; it preserves explicit local host affinity.

@vercel

vercel Bot commented Aug 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hackerai Ready Ready Preview Aug 17, 2026 10:21pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 273db11d-28dd-4a52-bb24-ddebca7c286c

📥 Commits

Reviewing files that changed from the base of the PR and between 20c5448 and 72fcb53.

📒 Files selected for processing (9)
  • app/components/ChatInput/ChatInput.tsx
  • app/components/SandboxSelector.tsx
  • app/components/__tests__/SandboxSelector.test.tsx
  • app/contexts/GlobalState.tsx
  • app/hooks/__tests__/useSandboxPreference.test.tsx
  • app/hooks/useSandboxPreference.ts
  • lib/activation/__tests__/free-desktop-sandbox.test.ts
  • lib/activation/free-desktop-sandbox.ts
  • packages/desktop/src-tauri/src/lib.rs

Included review availability: 2 reviews are currently available. Based on recent review activity, included reviews refill at 4 per hour.


📝 Walkthrough

Walkthrough

The PR adds free desktop sandbox preference resolution, availability detection, bridge recovery telemetry, and status-aware selector behavior. It also sanitizes desktop deep-link logs by removing authentication tokens, query parameters, and full URLs.

Changes

Free desktop sandbox management

Layer / File(s) Summary
Desktop bridge recovery
app/hooks/useSandboxPreference.ts, app/hooks/__tests__/useSandboxPreference.test.tsx
Typed recovery reasons now use centralized retry scheduling with generation checks, retry limits, telemetry, delayed retries, and startup-failure recovery.
Free desktop sandbox resolution
lib/activation/free-desktop-sandbox.ts, lib/activation/__tests__/free-desktop-sandbox.test.ts
New helpers preserve valid desktop or remote selections, select available fallbacks, and evaluate desktop and local runner availability.
Global preference integration
app/contexts/GlobalState.tsx
Free desktop mode now applies the resolved sandbox preference instead of always selecting Desktop.
Sandbox availability UI
app/components/ChatInput/ChatInput.tsx, app/components/SandboxSelector.tsx, app/components/__tests__/SandboxSelector.test.tsx
Chat input messages and send-disabled reasons identify the selected unavailable sandbox. The selector displays reconnecting or unavailable states and preserves stale selections.

Secure desktop deep-link logging

Layer / File(s) Summary
Deep-link log sanitization
packages/desktop/src-tauri/src/lib.rs
Callback, single-instance, and deep-link logs now use sanitized labels and omit tokens, query parameters, full URLs, and sensitive argument contents. Tests verify query values are excluded.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 72fcb

The change improves desktop/local recovery, preserves local execution when the internal bridge is unavailable, and redacts sensitive native logs. No actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant SandboxSelector
  participant GlobalState
  participant LocalConnections
  participant ChatInput
  User->>SandboxSelector: select sandbox
  SandboxSelector->>GlobalState: update sandbox preference
  GlobalState->>LocalConnections: inspect available runners
  GlobalState-->>SandboxSelector: resolved preference and status
  SandboxSelector-->>User: display selected or unavailable sandbox
  ChatInput->>GlobalState: read selected preference and availability
  GlobalState-->>ChatInput: availability result
  ChatInput-->>User: allow send or show reconnection reason
Loading

Possibly related PRs

Suggested labels: codex

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% 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
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 Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: desktop startup recovery and local fallback behavior.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/recover-desktop-startup

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

@ross0x01
ross0x01 merged commit 1bf9f8c into main Aug 17, 2026
12 of 13 checks passed
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.

1 participant