Skip to content

perf: skip WSL discovery when filtering native-only paths - #20266

Merged
nwparker merged 4 commits into
mainfrom
OrcaWin/perf-native-path-wsl-filter
Sep 13, 2026
Merged

nwparker merged 4 commits into
mainfrom
OrcaWin/perf-native-path-wsl-filter

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 12, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​181 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​179
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​11 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​8

ELI5

Filtering local transcript/home paths on Windows no longer launches WSL just to return the same paths.

What Changed

Query running WSL distros only when at least one input is a WSL UNC path. Reuse the existing path predicate and filtering policy; mixed lists still query and filter by running distro, retaining original path order and spelling. Non-Windows behavior is unchanged.

Why

Measured the complete exported filter on Windows with actual wsl.exe --list --running --quiet calls. Median of 11 measured calls per variant after two warmups, alternating original/modified order:

Input Before After
Empty list 26.40 ms 0.0051 ms
One local home path 25.63 ms 0.0052 ms
Local home + non-WSL network share 25.41 ms 0.0060 ms

The modified native-only path performs zero WSL probes. This measures filtering latency, not full transcript loading. WSL-containing lists keep the existing probe, single-flight and failure-backoff behavior.

Linked Issue

User-requested Windows/WSL performance audit; no linked issue.

Visual Proof

N/A — no visual or interaction change.

Testing

  • 37 tests passed across the path filter, host-readable transcript paths, filesystem gate and cached session list.
  • Added empty/native/ordinary UNC, mixed distro and non-Windows coverage.
  • Real-process benchmark verified returned paths against the original input.
  • Node TypeScript check, targeted oxlint and formatting passed.

Review

No filesystem cache, process ownership, SSH routing, guest command or protocol changes. No query is skipped when WSL status can affect the filtering result; folder/worktree distinctions are irrelevant to this existing path-based policy.

Agent skill upstream boundary

  • Not applicable; no upstream skill material copied.

Checklist

  • Small and focused; self-reviewed.
  • Cross-platform and SSH behavior considered.
  • Relevant tests, typecheck, lint and formatting passed.

@coderabbitai

coderabbitai Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

filterPathsToRunningWslDistrosAsync now skips the running-distro lookup when inputs contain no WSL UNC paths. getAiVaultWslHomeDirs now returns no WSL homes when Windows has a confirmed empty cached distro list. Tests cover native paths, mixed paths, cache states, probe failures, and mock behavior.

Priority: ⬇️ Low

Merge Risk: 🟡 Moderate · up to 9e46a

On Windows, valid AI Vault WSL sessions and paths can be missed while an empty distro result is cached; resolve this before merging.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change, motivation, testing, scope, and cross-platform impact. However, it does not provide the required linked issue and omits the AI Disclosure section. Add a valid linked issue after “Fixes #” or explain the approved exception. Add the AI Disclosure section and state whether AI tools were used.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: skipping WSL discovery for native-only paths.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Skip the WSL probe for native-only lists — filterPathsToRunningWslDistrosAsync now calls listRunningWslDistrosAsync() only when paths.some(isWslUncPath), passing [] otherwise. Because isWslUncPath is exactly parseWslUncPath(path) !== null — the same predicate the inner filter uses to decide distro membership — the guard is provably equivalent: with no WSL UNC path in the list, no entry can be dropped regardless of which distros are running, so the result is unchanged.
  • New focused test — src/main/wsl-running-path-filter.test.ts covers empty/local/ordinary-UNC inputs asserting no probe, a mixed list asserting one probe plus order preservation with the stopped distro dropped, and a non-Windows case asserting WSL-shaped paths are not interpreted. The not.toHaveBeenCalled assertions fail against the pre-change code, so the coverage is real. Ran locally: 5 passed.

Pullfrog  | View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

- getAiVaultWslHomeDirs, the sibling in the same Promise.all as the
  native-path filter, still spawned wsl.exe unconditionally on win32;
  gate it on the cached installed-distro list so a host with no distro
  performs no probe when only native Codex homes are configured.
- Hosts with a distro installed keep probing from that sibling, so the
  running-distro last-known-good cache is still warmed by the listing
  and a later probe outage falls back to the observed list, not [].
- Add a test against the real wsl module asserting zero wsl.exe spawns
  across the whole listing Promise.all, plus the warmed-cache fallback.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Skipped the AI Vault running-distro probe on WSL-less hosts — getAiVaultWslHomeDirs now returns [] when (await listWslDistrosAsync()).length === 0, so a Windows host with no installed distro no longer pays for listRunningWslHomeDirsAsync()'s wsl.exe --list --running spawn. An installed distro is a precondition for a running one, so the guard is result-preserving.
  • End-to-end spawn-count test — cached-session-list-wsl-probe.test.ts drives the real wsl module against a mocked child_process (a per-function mock cannot observe the whole listing's Promise.all): zero wsl.exe spawns for a native-only listing when the installed cache is empty, exactly one --list --running plus one -d Ubuntu … echo $HOME when a distro is installed, then the filter's last-known-good fallback after a probe failure.
  • Mock plumbing — cached-session-list.test.ts, ai-vault.test.ts, and ai-vault-scan-coalescing.test.ts mock the newly imported listWslDistrosAsync.

Verified locally: 64 tests pass across the five touched/related files.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

… a probe

`listWslDistrosAsync()` resolves `[]` when the `wsl.exe` probe is rejected, so a
transient failure made `getAiVaultWslHomeDirs()` conclude "no WSL distros" and
skip discovery. That narrowed the allowed-roots set `ai-vault-delete` and
`ai-vault-subagent-list` validate against, wrongly rejecting WSL-hosted paths.

Gate on `hasCachedWslDistros()` / `getCachedWslDistros()` instead: a pure cache
read that only skips discovery once a successful probe has reported zero user
distros. It also never probes, so the AI Vault listing cannot be the first to
cache `[]` and flip a configured distro to "missing" in runtime resolution.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Replaced the probe-based WSL guard with a pure cache read — getAiVaultWslHomeDirs now short-circuits only when hasCachedWslDistros() && getCachedWslDistros()?.length === 0, instead of calling listWslDistrosAsync(). The prior guard treated a rejected wsl.exe --list --quiet probe (which resolves [] without caching) as "no distros installed", which narrowed the roots ai-vault-delete and ai-vault-subagent-list validate against and rejected legitimate WSL-hosted paths. A cache read cannot poison the cache and cannot confuse an unreachable WSL with an absent one — matching docs/reference/wsl-probe-failure-semantics.md.
  • Added a rejected-probe regression test — cached-session-list-wsl-probe.test.ts asserts that after listWslDistrosAsync() resolves [] from a rejected probe, getAiVaultWslHomeDirs() still issues the --list --running probe and returns the WSL home. The test fails against the previous guard, so it is real coverage.
  • Reworked the test mocks — cached-session-list.test.ts now mocks hasCachedWslDistros/getCachedWslDistros and covers both the cached-empty skip and the never-probed fallthrough; ai-vault.test.ts and ai-vault-scan-coalescing.test.ts add the hasCachedWslDistros mock. Ran the five touched/related files locally: 66 passed.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

check-changed-code-quality runs config/oxlint-code-quality-casting.json with
assertionStyle:'never' over changed lines, and `args as string[]` in the new
wsl-probe spy failed it. Narrow through Array.isArray instead, which is also
honest about execFile's argv being optional.

cached-session-list-wsl-probe + cached-session-list: 9/9 pass; tc:node clean;
changed-code quality gate passes.

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)
src/main/ai-vault/cached-session-list.ts (1)

140-146: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Do not short-circuit running-distro discovery when the installed-distro cache is empty.

listWslDistros() caches successful empty results during retry backoff because WSL can report no installed distros while provisioning. getAiVaultWslHomeDirs() treats that cached result as authoritative and skips listRunningWslHomeDirsAsync(), which independently lists running distros and resolves their home paths. This can omit valid AI Vault sessions and leave the subagent IPC path without the WSL roots needed to accept valid paths. Distinguish transient empty results from authoritative cache states or retain the running probe.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: cf2a37c4-8b5c-467c-b9f5-5f9ac61c31ca

📥 Commits

Reviewing files that changed from the base of the PR and between ea3ce03 and 9e46af1.

📒 Files selected for processing (1)
  • src/main/ai-vault/cached-session-list-wsl-probe.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@nwparker
nwparker merged commit 392583c into main Sep 13, 2026
34 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.

2 participants