Skip to content

fix(preflight): do not pin empty WSL/local agent detection (#8366) - #8391

Closed
bbingz wants to merge 4 commits into
stablyai:mainfrom
bbingz:fix/wsl-agent-detect-nonsticky-empty
Closed

bbingz wants to merge 4 commits into
stablyai:mainfrom
bbingz:fix/wsl-agent-detect-nonsticky-empty

Conversation

@bbingz

@bbingz bbingz commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

An empty local/WSL agent-detection result no longer permanently suppresses later probes. Retry one timed-out WSL cold-start probe, retain the single attempt for non-timeout failures, and allow an empty local cache to be refreshed when a launch surface opens again. Each mounted surface retries each distinct local context once, so A -> B probes B while A -> B -> A does not loop. Closes #8366; #8336 remains independent and #8110 is outside this fix.

The rebase preserves current per-context caches, in-flight deduplication, stale-result fencing, SSH/runtime detection branches, and the current WSL process wrapper. Codex found the first candidate's constant local retry key would suppress the first retry in context B; Cursor added the A/B/A regression and corrected the key. The new empty-cache store test moved to the existing local-state test module to respect max-lines. Main's existing assertions are unchanged.

Validation: Cursor and Codex each passed the final 68 tests across 4 files, covering WSL timeout behavior, local caches and the rendered React hook harness. Node/Web non-composite typechecks and changed-file lint/format passed. No live Windows/WSL/SSH or rendered Orca Electron session was exercised.

Full repository suite/build and default composite typechecks were not run for this candidate. Known baseline TS2883 is not treated as passing; only the explicit non-composite checks above are claimed.

Cursor reviewed the final candidate; Codex independently reviewed the diff and raw checks. Reviewed commit: 4d49dcff6ceeb7763492d1a35b9c4477a506186b; rebased onto bba68b1bddf1276c8bd27ad4ca41efcbd4260321.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

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

No actionable comments were generated in the recent review.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c33941d3-72ba-4217-b54d-933435d95240

📥 Commits

Reviewing files that changed from the base of the PR and between 889dd4c and 02dd71a4f0db7f6f564b888d45152d48563126e3.

📒 Files selected for processing (6)
  • src/main/ipc/preflight-wsl-agent-detection.test.ts
  • src/main/ipc/preflight-wsl-agent-detection.ts
  • src/renderer/src/hooks/useDetectedAgents.test.tsx
  • src/renderer/src/hooks/useDetectedAgents.ts
  • src/renderer/src/store/slices/detected-agents.test.ts
  • src/renderer/src/store/slices/local-detected-agent-state.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/renderer/src/hooks/useDetectedAgents.ts
  • src/main/ipc/preflight-wsl-agent-detection.test.ts
  • src/renderer/src/store/slices/detected-agents.test.ts
Walkthrough

WSL agent detection now retries once after timeout or killed-child failures and does not retry other failures. Local detected-agent state no longer reuses empty cached lists for detection or refresh flows. The local detection hook tracks one empty-result retry per mount. Tests cover probe retry counts, non-retry failures, empty-result re-detection, rerender behavior, and remount behavior.

Mergeability Score: 🔵 Low · up to 02dd7

The new WSL retry could briefly overlap with a still-terminating probe after a timeout, potentially causing flaky detection or extra process activity. The change is otherwise mergeable with explicit owner confirmation that child termination is complete before retrying.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address issue #8366 by retrying flaky WSL probes and preventing empty local detection results from hiding installed agents.
Out of Scope Changes check ✅ Passed The implementation and tests remain focused on WSL and local agent detection caching, retry behavior, and remount handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and concisely describes the main change: preventing empty WSL and local agent detection results from being permanently cached.
Description check ✅ Passed The description explains the change, motivation, linked issue, testing, review scope, and known validation limits. It does not use the required template headings or explicitly provide the required Vis…
  • 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.

@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/ipc/preflight-wsl-agent-detection.test.ts (1)

99-135: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider adding a retry exhaustion test.

The three new tests cover single-retry success and non-retriable failure, but don't verify behavior when both attempts timeout (retry exhaustion). A test confirming detectWslCommandsOnPath returns an empty Set and execFileAsyncMock is called exactly twice after two consecutive ETIMEDOUT rejections would close the gap.

🧪 Suggested test for retry exhaustion
  it('returns an empty set when both attempts timeout', async () => {
    const timeoutError = Object.assign(new Error('Timed out running wsl.exe'), {
      code: 'ETIMEDOUT'
    })
    execFileAsyncMock.mockRejectedValue(timeoutError)

    const found = await detectWslCommandsOnPath({ distro: 'Ubuntu' }, ['grok'])

    expect(found).toEqual(new Set())
    expect(execFileAsyncMock).toHaveBeenCalledTimes(2)
  })

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d1b358ea-54b0-4880-a68a-aef5c16402c7

📥 Commits

Reviewing files that changed from the base of the PR and between 26934b1 and 8663d45.

📒 Files selected for processing (4)
  • src/main/ipc/preflight-wsl-agent-detection.test.ts
  • src/main/ipc/preflight-wsl-agent-detection.ts
  • src/renderer/src/store/slices/detected-agents.test.ts
  • src/renderer/src/store/slices/detected-agents.ts

bbingz added a commit to bbingz/orca that referenced this pull request Jul 12, 2026
Store non-sticky empty was not enough: useDetectedAgents only called
ensureLocal when detectedIds was null, so TabBar/QuickLaunch never
re-probed after a WSL cold-start []. Mirror SSH/runtime one-shot empty
remount retry for local surfaces (stablyai#8366 / stablyai#8391).
@bbingz

bbingz commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 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.

@bbingz
bbingz force-pushed the fix/wsl-agent-detect-nonsticky-empty branch from b01b463 to 3557906 Compare July 14, 2026 00:37
@bbingz
bbingz force-pushed the fix/wsl-agent-detect-nonsticky-empty branch 2 times, most recently from d869edb to a499c6b Compare July 18, 2026 14:56
@bbingz

bbingz commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (was ~241 commits behind). Focused tests still pass:

  • preflight-wsl-agent-detection
  • useDetectedAgents
  • detected-agents

Ready for re-review / CI.

@OrcaWin

OrcaWin commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Taking a look!

@OrcaWin

OrcaWin commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Did a deep review of this cold-start empty-agent-list fix (#8366) — correctness, cross-platform, SSH/runtime, and perf/regression angles — plus ran the full test suite for the touched files.

Verdict: solid. The three-part approach is correct and minimal, and it reuses the already-shipped non-sticky-empty pattern (ensureRemoteDetectedAgents / ensureRuntimeDetectedAgents, #6029) rather than inventing a new caching scheme:

  • Store: existing?.length guard + nulling detectPromise on empty resolves (and in refreshDetectedAgents) so an empty [] can't be re-cached as a hit — while non-empty still short-circuits.
  • Hook: one fresh probe per launch-surface remount on [], bounded by the per-mount retriedEmptyTargetRef guard, mirroring the ssh/runtime branches.
  • WSL probe: one bounded ETIMEDOUT/killed retry to absorb a single cold-start miss.

Things I specifically checked and confirmed are not problems: no re-probe/render loop (per-mount ref guard + module-scoped detectPromise dedup means at most one in-flight wsl.exe probe even under rapid reopen); warm path is byte-for-byte unchanged (no perf regression for installed agents); the two effect callers (StatusBar, useComposerState) depend on the stable action ref, not detectedAgentIds, so non-sticky-empty doesn't make them loop; retry bound is exactly one; SSH/runtime branches untouched.

One change I pushed (commit 35fe8b0): corrected the comment on isWslAgentDetectionTimeoutError. It claimed "Node's execFile timeout sets code=ETIMEDOUT" — I verified empirically that Node's execFile timeout actually kills the child with code=null, killed=true (SIGTERM); the ETIMEDOUT code comes only from the in-file Promise.race wrapper. The predicate itself was already correct (it checks both) — but the comment misexplained the exact mechanism, which could lead a future maintainer to drop the killed check and silently break the execFile-timeout retry path. Comment-only, no behavior change.

Validation: 30/30 tests pass across the three touched test files, tsc --noEmit (node project) clean on the changed files, oxlint clean. LGTM to merge.

@bbingz

bbingz commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

@OrcaWin Thanks for the deep review and “solid” verdict on the cold-start empty agent-list fix (#8366).

Still MERGEABLE on current main. Happy to take any final nits; otherwise this is ready to land.

bbingz added a commit to bbingz/orca that referenced this pull request Jul 23, 2026
Store non-sticky empty was not enough: useDetectedAgents only called
ensureLocal when detectedIds was null, so TabBar/QuickLaunch never
re-probed after a WSL cold-start []. Mirror SSH/runtime one-shot empty
remount retry for local surfaces (stablyai#8366 / stablyai#8391).
@bbingz
bbingz force-pushed the fix/wsl-agent-detect-nonsticky-empty branch from 35fe8b0 to 8910a7f Compare July 23, 2026 07:06
@bbingz

bbingz commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Restack note

Rebased onto latest main (was DIRTY). Conflicts in useDetectedAgents:

Ready for upstream review; community author cannot merge.

@nwparker nwparker added the bug Something isn't working label Jul 27, 2026
@OrcaWin
OrcaWin force-pushed the fix/wsl-agent-detect-nonsticky-empty branch from 289e263 to 5e1432e Compare July 28, 2026 04:12
@OrcaWin

OrcaWin commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Rebased this onto the latest main and pushed the review fixes here to help get it landed — CI should be green now. Thanks so much for the contribution!

@bbingz

bbingz commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Status: still CLEAN and MERGEABLE against current main, with the full 22/22 check rollup green on 5e1432e3b — deliberately not pushing anything so that signal stays intact. None of the three touched files (detected-agents.ts, useDetectedAgents.ts, preflight-wsl-agent-detection.ts) has changed upstream since.

The bug is still live on main: src/renderer/src/store/slices/detected-agents.ts:68 — if (existing && detectedContextKey === contextKey) returns a cached empty detection as a hit, which is what pins the empty WSL/local agent list. #8366 is still open. @OrcaWin this one is merge-ready as-is.

bbingz added a commit to bbingz/orca that referenced this pull request Aug 11, 2026
Store non-sticky empty was not enough: useDetectedAgents only called
ensureLocal when detectedIds was null, so TabBar/QuickLaunch never
re-probed after a WSL cold-start []. Mirror SSH/runtime one-shot empty
remount retry for local surfaces (stablyai#8366 / stablyai#8391).
@bbingz
bbingz force-pushed the fix/wsl-agent-detect-nonsticky-empty branch from 5e1432e to c084b8a Compare August 11, 2026 19:25
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@bbingz
bbingz force-pushed the fix/wsl-agent-detect-nonsticky-empty branch from c084b8a to 02dd71a Compare August 13, 2026 05:04
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@bbingz
bbingz force-pushed the fix/wsl-agent-detect-nonsticky-empty branch from 02dd71a to 4d49dcf Compare September 8, 2026 17:55
@bbingz
bbingz force-pushed the fix/wsl-agent-detect-nonsticky-empty branch from 4d49dcf to 0371455 Compare September 19, 2026 12:30
bbingz and others added 4 commits October 25, 2026 15:12
…8366)

Empty [] is truthy, so a cold-start soft-fail permanently hid agents from
the launcher until a context switch. Match remote/runtime non-sticky empty
caching, clear empty detectPromise snapshots, and retry one WSL ETIMEDOUT.
Store non-sticky empty was not enough: useDetectedAgents only called
ensureLocal when detectedIds was null, so TabBar/QuickLaunch never
re-probed after a WSL cold-start []. Mirror SSH/runtime one-shot empty
remount retry for local surfaces (stablyai#8366 / stablyai#8391).
A mounted launcher that already consumed the empty-retry slot on context A
must still probe a distinct cached-empty context B, without A→B→A thrash.

Co-authored-by: Cursor <cursoragent@cursor.com>
@bbingz
bbingz force-pushed the fix/wsl-agent-detect-nonsticky-empty branch from 0371455 to cfb1600 Compare October 25, 2026 07:23
@nwparker

Copy link
Copy Markdown
Contributor

Thanks for working on this fix! This fixes empty or timed-out WSL agent detection, which runs from Windows by probing the distro through wsl.exe. The new WSL hosts bridge runs Orca's server inside the distro, so agents are detected natively from inside the distro and this probe isn't used anymore.

To switch: Settings → Experimental → WSL hosts, then Add a project → Add remote host → Add WSL distro. Existing \\wsl.localhost or W:\ projects can be moved over from the project.

Closing this since the new bridge replaces that code path; if the problem still shows up with WSL hosts on, please open an issue with details.

@nwparker nwparker closed this Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[windows] Sometimes Grok CLI is not detected in Orca but works in system terminal

4 participants