Repository navigation
Detect installed GitHub CLI behind hung launchers - #25183
Conversation
|
Important Review skippedWe couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (6)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughPreflight detection now hydrates shell PATH on non-Windows platforms, with an option to force refresh. Local command probes divide the remaining timeout across candidates and continue after individual timeouts. If no candidate succeeds, the result reports a timed-out binary. Windows process-tree termination resolves Priority: ➖ Normal Merge Risk: 🔵 Low · up to Recovery behind a hung launcher is improved, but with several candidates and another timeout, detection can report the wrong launcher. This is a bounded issue to address or accept before merging. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The changes remain within existing local tool-execution permissions and improve cleanup. However, recovery can proceed when cleanup could not confirm that the previous launcher's children stopped, potentially overlapping executable activity. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 8 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
72e5be21-af84-43ab-a69f-4fbc282dff97
📒 Files selected for processing (6)
src/main/ipc/agent-detection-shell-path.tssrc/main/ipc/preflight-command-exec.test.tssrc/main/ipc/preflight-command-exec.tssrc/main/ipc/preflight-host-cli-status.test.tssrc/main/ipc/preflight-runnable-local-cli.test.tssrc/main/preflight/agent-detection.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.
| } | ||
| ) | ||
|
|
||
| it('refreshes the POSIX shell PATH on Re-check after a CLI install', async () => { |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
ast-grep outline src/main/ipc/preflight-host-cli-status.test.ts --items all --match 'beforeEach|afterEach'
rg -n -C 5 'beforeEach|afterEach|restoreAllMocks|stubGlobal|Object\.defineProperty\(process|spyOn\(process, .platform.' src/main/ipc/preflight-host-cli-status.test.tsRepository: stablyai/orca
Length of output: 4595
🏁 Script executed:
printf '%s\n' '--- test source ---'
sed -n '690,755p' src/main/ipc/preflight-host-cli-status.test.ts | cat -n
printf '%s\n' '--- relevant base-to-head diff ---'
git diff --unified=5 2b3b692d29102b87389042a5614d80b93956d5e0 07cf3c24848eff6073db5d53e0a05058ac7ecc13 -- src/main/ipc/preflight-host-cli-status.test.ts | sed -n '/waits for the %s shell PATH/,/awaits the persisted Windows Path refresh/p'Repository: stablyai/orca
Length of output: 6238
🏁 Script executed:
printf '%s\n' '--- test harness and imports ---'
sed -n '1,160p' src/main/ipc/preflight-host-cli-status.test.ts | cat -n
printf '%s\n' '--- runPreflightCheck definitions and platform branches ---'
rg -n -C 5 'runPreflightCheck|process\.platform|hydrateShellPath|mergePersistedWindowsPath' src/main/ipcRepository: stablyai/orca
Length of output: 45659
🏁 Script executed:
printf '%s\n' '--- agent-detection outline ---'
ast-grep outline src/main/preflight/agent-detection.ts
printf '%s\n' '--- platform-dependent preflight implementation ---'
rg -n -C 8 'export (async )?function runPreflightCheck|runPreflightCheck|process\.platform|hydrateShellPath|mergePathSegments|buildLocalPreflightEnv|refreshShellPathAndDetectAgents' src/main/preflight/agent-detection.ts src/main/ipc/preflight-local-env.tsRepository: stablyai/orca
Length of output: 14475
Set a POSIX platform in both tests.
On Windows, the refresh test skips shell hydration. Its merge mock therefore does not change execFileAsyncMock from rejection to success, and the forced check can still report gh as not installed. The hydration-failure test can pass without exercising the hydration-failure path.
🐛 Suggested fix
it('refreshes the POSIX shell PATH on Re-check after a CLI install', async () => {
+ Object.defineProperty(process, 'platform', { configurable: true, value: 'linux' })
execFileAsyncMock.mockRejectedValue(
@@
it('uses the inherited PATH when POSIX shell hydration fails', async () => {
+ Object.defineProperty(process, 'platform', { configurable: true, value: 'linux' })
hydrateShellPathMock.mockResolvedValue({ ok: false, segments: [], failureReason: 'timeout' })There was a problem hiding this comment.
Important
The budget that is supposed to "leave time for a working copy behind a launcher that never returns" is measured against the wall clock, but a timed-out candidate's terminationBarrier charges a mandatory ~2s POSIX teardown before runProcess resolves — so the working copy's slice can shrink to a few hundred milliseconds, which can reproduce the "not installed" result this PR fixes. Details inline.
Reviewed changes
- Recover after a timed-out candidate —
probeRunnableLocalCommandnow continues past a timed-out copy instead of returning at the first one, and shares the 5sPREFLIGHT_COMMAND_TIMEOUT_MSbudget across candidates (preflight-command-exec.ts). - Stop the hung launcher's tree — multi-candidate probes pass
terminationBarrier: truethroughexecLocalPreflightCommandOrThrowintorunProcess, so a timed-out launcher's descendants are terminated before probing continues. - Hydrate shell PATH before POSIX preflight —
executePreflightCheckawaitshydrateShellPathForAgentDetection(context, force)on non-win32, andforcere-probes the login shell (agent-detection-shell-path.ts,agent-detection.ts), closing the startup race between the async PATH probe and the cached missing-CLI result. - Tests — unit coverage for recovery/timeout accounting/explicit paths plus a real-process integration case whose hung launcher traps
TERMand proves its descendant was killed.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
| return { status: 'timeout', binary } | ||
| } | ||
| // Leave time for a working copy behind a launcher that never returns. | ||
| const timeoutMs = Math.max(1, Math.floor(remainingMs / (probes.length - index))) |
There was a problem hiding this comment.
The shared budget is wall-clock (deadline = Date.now() + PREFLIGHT_COMMAND_TIMEOUT_MS), but a timed-out candidate's terminationBarrier adds a mandatory ~2s POSIX grace before runProcess resolves. That teardown is charged against remainingMs, so the working copy behind a hung launcher gets far less than its nominal share — with 4 candidates it lands at ~583ms, which many version-manager shims exceed on a cold cache, reintroducing the installed: false result this PR targets.
Technical details
# Termination-barrier teardown consumes the probe budget
## Affected sites
- `src/main/ipc/preflight-command-exec.ts:183` — `remainingMs` is wall-clock, so the ~2s barrier grace spent on each timed-out candidate shrinks every later candidate's slice.
- `src/main/ipc/preflight-command-exec.ts:179` — once the deadline is exhausted mid-loop, the early return reports `binary` (the current, never-probed candidate) rather than `timedOutBinary`; in practice only reachable because of the overrun above.
- `src/shared/child-process/run-process.ts:205-269` — on POSIX the barrier only settles inside the `PROCESS_EXIT_GRACE_MS` (2000ms) timer, so every timed-out barrier probe costs `timeoutMs + ~2s` even when SIGTERM killed the tree immediately.
## Required outcome
- A working copy behind a hung launcher should keep a meaningful slice of the 5s budget, not the residual after teardown overhead.
- When the deadline is exhausted, the reported `binary` should be the candidate that actually timed out.
## Suggested approach (optional)
- Track elapsed *child* time rather than pure wall clock (e.g. add `PROCESS_EXIT_GRACE_MS` back to the deadline per timed-out candidate), or reserve the barrier grace when sizing the initial share.
- Return `{ status: 'timeout', binary: timedOutBinary ?? binary }` (or classify as `exec_failed` when no candidate timed out) at the `remainingMs <= 0` branch.
## Open questions for the human (optional)
- In the Omarchy reproduction, how many candidates were ahead of the working mise shim, and what did the winning copy's share work out to?There was a problem hiding this comment.
Important
The recovery budget's per-candidate division still does not account for the termination barrier's fixed ~2s POSIX teardown. A working copy behind two timed-out launchers gets a sub-second slice, and behind three it is never probed — which can reproduce the installed: false result this PR fixes. Details inline.
Reviewed changes
- Recover past a timed-out launcher —
probeRunnableLocalCommandnow continues to the next executable copy instead of returning at the first; the first candidate keeps the full 5s and a second 5s recovery budget is shared across the rest (preflight-command-exec.ts). - Stop the hung launcher's tree before continuing — multi-candidate probes pass
terminationBarrier: trueintorunProcess, andexecLocalPreflightCommandOrThrowawaits the runner directly when set and treatsoutputTruncatedas failure. - Hydrate the shell PATH before POSIX preflight —
executePreflightCheckawaitshydrateShellPathForAgentDetection(context, force)on non-win32 andforcere-probes the login shell (agent-detection.ts,agent-detection-shell-path.ts), closing the startup race behind a cached missing-CLI result. - Absolute Windows
taskkill—forceTerminateProcessTreeresolvestaskkill.exethroughwindowsSystem32Binary, so a pruned or shadowed PATH can no longer block tree cleanup (process-tree-termination.ts). - Tests and native-platform CI — new unit and real-process coverage for recovery, timeout accounting, explicit paths, and tree termination, plus a new
preflight-cli-platformsworkflow running the CLI/PATH suites on Ubuntu, macOS, and Windows.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
| const timeoutMs = recoveryDeadline | ||
| ? Math.max(1, Math.floor(remainingMs / (probes.length - index))) | ||
| : remainingMs |
There was a problem hiding this comment.
The recovery budget is divided evenly by remaining candidate count, but each timed-out candidate also pays the termination barrier's fixed ~2s POSIX grace (run-process.ts only settles a POSIX barrier inside the PROCESS_EXIT_GRACE_MS timer). That overhead is charged against remainingMs, so the division fronts more time per candidate than the budget can pay: with the fourth of four candidates healthy and the first three hung, the loop exhausts recoveryDeadline and returns before probing it, and with two hung ahead the working copy gets ~0.7s. Commit db62b17 fixed the healthy-first-copy case (it now keeps the full 5s), but this recovery-phase interaction is unchanged.
Technical details
# Termination-barrier grace is not reserved in the recovery budget
## Affected sites
- `src/main/ipc/preflight-command-exec.ts:184-186` — `Math.floor(remainingMs / (probes.length - index))` sizes each share as if a failed probe consumed only `timeoutMs`, ignoring the ~2s grace every timed-out barrier probe also spends.
- `src/main/ipc/preflight-command-exec.ts:180-182` — when the overrun exhausts `recoveryDeadline`, the early return reports the current, never-probed `binary` (not `timedOutBinary`) and can classify ordinary-failure exhaustion as `timeout`.
- `src/shared/child-process/run-process.ts:205-269` — on POSIX the barrier resolves only inside the `PROCESS_EXIT_GRACE_MS` (2000ms) timer, so a timed-out barrier probe costs `timeoutMs + ~2s` even when SIGTERM killed the tree immediately.
## Required outcome
- A working copy behind one or more timed-out launchers should still be probed with a meaningful slice (the reported Omarchy case has a single hung launcher, which the current code handles).
- Exhaustion should report the candidate that actually timed out.
## Suggested approach (optional)
- Reserve the barrier grace when dividing (e.g. `remainingMs - PROCESS_EXIT_GRACE_MS * remaining`), or measure recovery against child time rather than wall clock.
- Return `{ status: 'timeout', binary: timedOutBinary ?? binary }` at the `remainingMs <= 0` branch.
## Open questions for the human (optional)
- Is a multi-hung-launcher PATH (two or more wrappers before the working shim) in scope, or is the single-hung case the acceptance bar?42fb4cb to
d2c827f
Compare
…cs (#30897) The daily full E2E run on main fails these specs every time because the product moved on and PR CI only runs specs a PR touches: - editor header menu renamed to File actions (#30129) - terminal attention: an on-screen bell leaves no unread marker (#28637) - terminal file drops carry their source host (#26830) - single-choice questions auto-submit (#26288) - phone terminal rows carry customTitle (#30037) - gh/git preflight re-reads the login shell PATH (#25183) - board drag starts after the target column is in view - chat history anchor read after scroll settles

ELI5
Orca should recognize an installed GitHub CLI even when the first
ghlauncher it finds gets stuck. A fresh Omarchy install currently reports “CLI not installed” in that situation.What Changed
Local CLI detection keeps its original five-second allowance for healthy copies. After a timeout, one additional five-second recovery budget is shared across the remaining executable copies, with the existing four-copy limit. The shared process runner stops a timed-out launcher's children before detection continues. Authentication and subsequent GitHub/GitLab commands keep using the copy that passed the version check. On Windows, process cleanup now resolves
taskkill.exethrough the existing absolute System32 resolver; a sparse or shadowed PATH can no longer prevent child cleanup.On Linux and macOS, preflight now waits for the existing shell PATH resolver before checking tools. Re-check refreshes that PATH, so an early check or a newly installed CLI cannot leave a stale missing-CLI result. WSL continues to check tools inside its own distro.
Why
Reproduced with AUR
stably-orca-bin1.4.220 on Omarchy.~/.local/bin/ghrunsmise x gh -- gh; in Orca's environment, the innerghresolves back to that launcher and loops. The actual mise shim and installed binary both run successfully, but detection previously stopped at the first timeout. There is also a startup race between the asynchronous shell PATH probe and the cached preflight result.Extending the existing executable search covers mise and other launchers without hardcoding install directories or overriding the user's PATH order. A single recovery budget avoids paying another five seconds for every failed copy. Healthy and explicitly selected binaries retain their original five-second allowance. A regression test protects slow but healthy first copies. The absolute System32 lookup also keeps Windows child cleanup working when PATH is limited to tool directories. Only actual hangs can add the recovery budget and bounded process cleanup time.
Linked Issue
None — maintainer fix for a reproduced installation problem.
Visual Proof
Before/after backend evidence with the same hanging
ghfixture placed ahead of the real Omarchy mise shim:The installed app separately returned
gh: { installed: false, authenticated: false }before a local launcher repair andgh: { installed: true, authenticated: true }afterward. That local workaround is outside this diff.Rendered screenshots were not collected because the
$electronskill required by AGENTS.md is unavailable in this session. There are no renderer code changes.Testing
Linux: focused preflight and process-termination tests passed, including real hung launchers, candidate limits, healthy-first-copy timeout preservation, explicit paths, shell PATH ordering, forced refresh, and runtime preflight. The latest production detection selected and pinned the actual Omarchy mise shim behind a hanging fixture: baseline timed out after 5.0 seconds; this revision recovered after 7.1 seconds including process cleanup. The installed app separately confirms
installed: trueandauthenticated: trueafter the local wrapper repair.A broader preflight and shared-child-process run passed 316 tests and skipped 53. It also found one pre-existing failure in
bounded-output-sink.test.ts: the backing allocation is 65,599 bytes against a 65,536-byte assertion. The isolated test fails too, and replaying the base revision's identical test dependencies reproduces it. Those files are unchanged in this PR.pnpm tc:nodeandpnpm run check:code-quality:changedpassed. Native platform CI is green on final commit42fb4cbabc:The workflow keeps these native CLI and shell-PATH checks running for future changes. WSL routing remains covered by existing mocks; no live WSL or SSH host was tested. Rendered UI was not exercised. Full builds and remaining suites are left to CI; the main static-analysis job is still queued.
Review
The Omarchy wrapper generator still needs its own upstream correction to remove recursion for every application. This PR fixes Orca's PATH race and its failure to recover a usable installed CLI; the local launcher repair removes the recursion on the reported machine.
The RPC shape and status meanings are unchanged. SSH runtimes apply the fix on their execution host; client-side remote agent detection is unchanged. No repository/worktree assumption is added, and GitLab uses the same launcher recovery.
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
No credentials or machine-specific install paths are added to Orca. Only version probes are retried; authentication and other operations are not replayed against alternate copies.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)