Skip to content

fix(ssh): defer managed serving until a connection needs it - #34593

Closed
hsusul wants to merge 2 commits into
stablyai:mainfrom
hsusul:fix/managed-serving-startup-isolation
Closed

hsusul wants to merge 2 commits into
stablyai:mainfrom
hsusul:fix/managed-serving-startup-isolation

Conversation

@hsusul

@hsusul hsusul commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

ELI5

A missing SSH serving file could stop Orca from opening, even when the user only needed local workspaces. Orca now loads that file when a managed connection needs it. A missing file still fails the managed operation.

What Changed

Separate existing status constants and listener registration from managed serving execution. The tunnel manager loads execution code from its serving callback. Status listeners still work when registered before that import or replaced while a wake is pending.

Why

Three eager runtime imports pulled the serving implementation into desktop startup. Moving only the tunnel import would leave the constant and listener consumers eager. This changes all three edges while retaining tunnel ownership, shutdown, serving checks, and cached verdicts. It does not repair quarantined files or change antivirus detection.

Linked Issue

Fixes #34378.

Visual Proof

No layout or interaction changes. A disposable production-build copy was launched with an isolated profile and all windows hidden. The intact control started. Removing only the serving chunk reproduced the failure before the fix. The fixed copy rendered its root with the same chunk removed.

Before:

Error: Cannot find module './orcad-managed-serving-CEw7iHwg.js'

After:

{"phase":"green","startup":"passed","ready":true,"windowsHidden":true}

Testing

  • I manually tested these changes locally. Actual built Electron startup on macOS, including the intact control and missing-chunk comparison above.
  • Automated tests added/updated. The import/shutdown regression failed before the fix. Five focused suites passed 45 tests. Tests also verify deferred import errors and listener registration/replacement.
  • pnpm build:electron-vite and pnpm tc:node passed.
  • pnpm check:changed --maxWorkers=2 passed all 19 checks.
  • Native Windows antivirus quarantine, Linux, WSL, and live SSH were not exercised. The missing artifact was simulated on macOS. Full native packaging and the complete unit suite remain for CI.

AI Disclosure

Developed with OpenAI Codex. GPT-6 Astra and GPT-6.1 Sol independently reviewed the final production diff.

Review

Review found no actionable issues. No platform-specific APIs, paths, shell commands, wire schemas, permission checks, or database formats change. Local, SSH, and WSL tunnel consumers retain their behavior. Existing serving cache and shutdown code remain in place. The implementation import is cached by the module loader. No renderer design, provider integration, or git-provider behavior changes.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

X/Twitter handle not provided.

Checklist

  • This PR is small and focused.
  • I explained what changed and why.
  • Before/after startup evidence is included above.
  • Self-reviewed for correctness, security, and performance.
  • Cross-platform, SSH/remote, and path/shortcut impact considered.
  • Full pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass. Local scoped checks are listed above; CI covers the complete checks.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent 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: c20654f1-dea7-4e32-a718-63e3f2de76c5
Commits

Reviewing files that changed from the base of the PR and between c63b949 and 187c925.

Files selected for processing: 10
  • src/main/ipc/runtime-environments/runtime-environment-managed-tunnel.test.ts
  • src/main/ipc/runtime-environments/runtime-environment-managed-tunnel.ts
  • src/main/managed-server/lifecycle/orcad-managed-serving-state.ts
  • src/main/managed-server/lifecycle/orcad-managed-serving.test.ts
  • src/main/managed-server/lifecycle/orcad-managed-serving.ts
  • src/main/managed-server/lifecycle/orcad-managed-tunnel-lazy-serving.test.ts
  • src/main/managed-server/lifecycle/orcad-managed-tunnel.ts
  • src/main/ssh/managed-server-fence-recheck.test.ts
  • src/main/ssh/managed-server-serving-gate.ts
  • src/main/ssh/ssh-host-server-on-connect-stopped-elsewhere.test.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.

Walkthrough

The change moves managed-serving result types, status details, and listener state into a separate module. The serving implementation retrieves the current listener for start and settlement notifications. The managed tunnel manager now dynamically imports the serving implementation when it runs a serving check. Tests cover listener registration and replacement, plus behavior when the serving implementation is unavailable.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 187c9

Local-only startup and shutdown do not require the managed-serving chunk. No actionable merge-blocking risk remains after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within survi… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: managed serving is deferred until a connection requires it.
Description check Passed The description follows the repository template and explains the user impact, implementation, rationale, linked issue, startup evidence, testing, limitations, AI disclosure, review notes, and checklis…
Linked Issues check Passed Issue #34378 requires deferred loading of the managed-serving chunk so a missing file does not block startup, while a managed operation still fails when it needs the file. The PR moves status types, c…
Out of Scope Changes check Passed The reviewed changes stay within issue #34378. They separate serving state from serving execution, defer the managed-serving import, update dependent imports, and add regression tests. These changes s…
Full details: Description check

Explanation

The description follows the repository template and explains the user impact, implementation, rationale, linked issue, startup evidence, testing, limitations, AI disclosure, review notes, and checklist status. It clearly states that full local validation was not run and that CI is expected to cover it.

Full details: Linked Issues check

Explanation

Issue #34378 requires deferred loading of the managed-serving chunk so a missing file does not block startup, while a managed operation still fails when it needs the file. The PR moves status types, constants, and listener state into orcad-managed-serving-state, removes the static serving import from orcad-managed-tunnel.ts, and dynamically imports orcad-managed-serving from ensureServing. The added tests cover shutdown without the serving implementation, deferred import errors, and listener registration or replacement. The reported focused tests and build checks also passed.

Full details: Out of Scope Changes check

Explanation

The reviewed changes stay within issue #34378. They separate serving state from serving execution, defer the managed-serving import, update dependent imports, and add regression tests. These changes support startup resilience and preserve managed-operation failure behavior. No antivirus detection, file repair, renderer, provider, or unrelated platform behavior changes are shown.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 10 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • 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

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

@nwparker

Copy link
Copy Markdown
Contributor

Thank you for this. Closing it because lazily importing the serving module doesn't fix #34378. The roughly 123 KB that antivirus flagged moves into orcad-managed-crash-loop-* and orcad-managed-tunnel-* chunks, which main still loads at startup, so a content-based verdict would flag those instead. Other startup paths also import the tunnel statically. A real fix needs either a larger refactor that takes the whole managed-server lifecycle off the startup path, or a clear missing-chunk error at bootstrap, so I've flagged #34378 for a maintainer decision.

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.

[Bug]: Orca fails to start when antivirus removes the orcad-managed-serving chunk, which main loads at startup

2 participants