fix(desktop): recover failed shell environment capture #10537
main fromrefs/pull/10537/head·opened View on GitHubProblem#
A timed-out desktop login-shell probe could leave every provider using launchd's default PATH while both install spans reported success, so every provider showed "not found on PATH".
Change#
Retry each POSIX shell once when it returns no usable PATH, retain the launchctl fallback, and fail the install effect if neither captures PATH.
After Electron is ready, show a native warning with Retry and Continue before starting the bundled server. Retry captures the environment again in the same process, so providers inherit the recovered PATH. Continue preserves startup and explains the absolute CLI path workaround. Windows is unchanged.
This handles failed startup capture only. Refreshing an already-running server after Continue remains the separate #9429 concern.
Scope and approval#
Fixes #10534. Maintainer triage confirmed the bug and suggested this fix (stop recording a swallowed capture failure as success, retry once, surface the failure, offer re-capture without quitting): https://github.com/pingdotgg/t3code/issues/10534#issuecomment-5573001305
Verification#
- The retry and false-success regressions in
DesktopShellEnvironment.test.tsfail against the original code. Tests cover the 5-second timeout, bounded retries, launchctl fallback, failed parent spans, and recovery choices. Each unsuccessful shell candidate can now take one additional 5-second attempt. - An isolated Linux Electron harness ran real shell subprocesses: a cold probe timed out on the original code and left a fixture CLI unresolved; the patched code retried and spawned it by bare name. Native Retry recaptured PATH without restarting Electron; Escape continued with the inherited PATH.
- After rebasing on current
mainand switching the capture error toSchema.TaggedError(review feedback):vp test run src/shell/DesktopShellEnvironment.test.ts src/app/DesktopAppErrors.test.tsinapps/desktop, 22 of 22 passed.tsc --noEmitforapps/desktop: no errors.vp lintandvp fmt --checkon all five changed files: clean. - Not checked: macOS itself and the full desktop client were not exercised.
Evidence below uses the production capture/recovery code with a controlled shell and fixture CLI. The surrounding diagnostics are the test harness, not the T3 client UI.
| Before: silent success with missing CLI | After: capture failure with recovery choices |
|---|---|
![]() | ![]() |
Retry recording · Recovered PATH and successful child process
Original change by GPT-6 via Codex in T3 Code. Rebase, review fix, and description update by Claude Opus 5.5 via Claude Code.
Note
Recover from failed shell environment capture during desktop startup#
- Desktop startup previously failed when shell-environment installation threw
DesktopShellEnvironmentCaptureError; it now captures the result and continues to the Electron-ready stage - After Electron is ready, the workflow invokes shell-environment recovery, converting recovery failures into fatal startup failures
- User can retry (reinstalls the environment) or continue (proceeds without a successful capture)
- Risk: startup now proceeds past a failed capture in DesktopApp.ts; consumers relying on a populated shell environment may see missing variables when the user chooses "continue"
Summary by CodeRabbit#
Bug Fixes
- Improved desktop startup reliability when the shell environment or PATH cannot be detected.
- Shell environment detection now retries transient or empty results and uses a fallback where available.
New Features
- Added recovery prompts when shell environment detection fails, allowing you to retry or continue starting the app.
- Startup errors are now handled more gracefully instead of interrupting the launch process.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Approved at
592f467Macroscope's review found this PR approvable — This is a narrowly scoped desktop startup fix that bounds shell-capture retries, surfaces failures, and offers recovery only when the existing capture path fails. Successful startup and Windows behavior remain unchanged, and the new recovery behavior is covered by focused tests.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Team
Run ID:
6420af12-36c6-4a46-97ce-0dbfe68071e5📥 Commits
Reviewing files that changed from the base of the PR and between 357b8d5217cd62826767b6ce6d7c47915f2777d2 and 28b6b6f4c43dd91e81f3ce661e20d6fb77656ec3.
📒 Files selected for processing (5)
apps/desktop/src/app/DesktopApp.tsapps/desktop/src/app/DesktopAppErrors.test.tsapps/desktop/src/shell/DesktopShellEnvironment.test.tsapps/desktop/src/shell/DesktopShellEnvironment.tsapps/desktop/src/shell/DesktopShellEnvironmentRecovery.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
📝 Walkthrough
Walkthrough#
The desktop now retries login-shell PATH capture, returns typed capture failures, logs installation errors, and offers Retry or Continue recovery after startup. Tests cover timeout retries, fallback behavior, failure spans, logging, and dialog responses.
Changes#
Shell environment recovery
Layer / File(s) Summary Capture retries and failure reporting
apps/desktop/src/shell/DesktopShellEnvironment.ts,apps/desktop/src/shell/DesktopShellEnvironment.test.tsShell environment capture retries empty PATH results, trims PATH checks, returns DesktopShellEnvironmentCaptureErrorwhen capture fails, and logs installation errors. Tests cover retries, timeouts, fallback behavior, span failures, and command logging.Interactive recovery flow
apps/desktop/src/shell/DesktopShellEnvironmentRecovery.ts,apps/desktop/src/app/DesktopAppErrors.test.tsrecoverShellEnvironmentdisplays Retry and Continue options. Retry repeats installation after failure. Tests cover response sequences and capture attempts.Startup recovery integration
apps/desktop/src/app/DesktopApp.tsStartup records the shell installation result and invokes recovery after the app is ready when installation fails. Fatal recovery causes are routed through fatalStartupCause.Estimated code review effort: 3 (Moderate) | ~20 minutes
Sequence Diagram(s)#
sequenceDiagram participant DesktopApp participant DesktopShellEnvironment participant RecoveryDialog participant ElectronDialog DesktopApp->>DesktopShellEnvironment: Install shell environment DesktopShellEnvironment-->>DesktopApp: Capture failure DesktopApp->>RecoveryDialog: Start recovery RecoveryDialog->>ElectronDialog: Show Retry or Continue ElectronDialog-->>RecoveryDialog: Retry RecoveryDialog->>DesktopShellEnvironment: Install shell environment DesktopShellEnvironment-->>RecoveryDialog: Success or failureSuggested reviewers:
juliusmarmingeMerge Risk: ⚪ Minimal · up to
28b6bDesktop shell environment capture now reports failures accurately, offers recovery before server startup, and preserves a Continue path when capture cannot succeed. The change is ready to merge.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ 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. Analyzed 1 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold. ✅ Passed checks (4 passed)
Check name Status Explanation Linked Issues check ✅ Passed The changes address issue #10534by retrying POSIX shell capture, retaining the launchctl fallback, failing when no PATH is captured, surfacing the failure in the UI, and allowing same-process recover…Out of Scope Changes check ✅ Passed The changed files and tests remain focused on desktop shell environment capture, failure reporting, recovery, and related regression coverage. No unrelated code changes are identified. Title check ✅ Passed The title clearly and concisely describes the main change: recovering from failed desktop shell environment capture. Description check ✅ Passed The description includes the required Problem, Change, Scope and approval, and Verification sections. It explains the bug, fix, linked issue and maintainer approval, focused test results, manual check… - Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
Comment `@coderabbitai help` to get the list of available commands.Note: GPT-6 on behalf of shivam (@shivamhwp).
DesktopShellEnvironmentCaptureErrorextendsSchema.TaggedErrorClass, which is absent from the current Effect version. Importing the recovery path throwsTypeError: TaggedErrorClass is not a function, before desktop startup can offer Retry or Continue, and desktop typecheck fails.Use
Schema.TaggedError<DesktopShellEnvironmentCaptureError>(), matching the two existing shell-environment error classes in this file. Keep the distinction from #9429: startup recovery does not refresh the environment of an already-running server.juliusmarminge added labelsmacroscope-review
[claude-opus-5-5] Responding on behalf of Guille
@shivamhwp thanks. Rebased on current main and switched
DesktopShellEnvironmentCaptureErrortoSchema.TaggedError<DesktopShellEnvironmentCaptureError>(), matching the two existing shell-environment errors (592f467151). Desktoptsc --noEmitnow passes and the 22 shell-environment and startup recovery tests pass. Scope is unchanged: startup recovery only re-captures before the bundled server starts; refreshing an already-running server stays with #9429.macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Note
Written by
claude-opus-5-5on behalf of MariaHi! We are cleaning up open PRs, and this one appears to have been created with an older model (
gpt-6). If this change is really important, we recommend rebuilding the PR with a newer model if possible.maria-rcks closed this
Sign in to join this conversation.


macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed