Repository navigation
fix(native-chat): resolve WSL Codex transcripts so Chat UI renders responses - #12473
Conversation
…sponses Codex reports a guest Linux transcript path. On a Windows host `existsSync` resolved it against the current drive (`C:\home\...`) and discarded it, and the id-based fallback only searched host roots. `resolveSessionFilePath` returned null forever while the watcher reported `watching: true`, leaving Chat UI permanently empty. Translate the guest path to its host-readable UNC twin, classifying **before** any `existsSync` probe on win32 so the `C:\home` false positive cannot fire. Adapted from #10639 with one required correction: it uses the **async cached** WSL seams (`listWslDistrosAsync` / `getWslHomeAsync`) rather than the `execFileSync` ones, which would stall the Electron main thread for up to 5s per tick of the resolve-poll loop on a cold distro. Fixes #10326 Co-authored-by: Orca <[email protected]>
📝 WalkthroughWalkthroughThe change adds Windows WSL transcript-path translation with cached distro-home discovery and Codex session-root enumeration. Session resolution converts hook-reported Linux paths and searches WSL roots after configured roots fail. Transcript watching translates explicit WSL paths before installation, retries unresolved paths on a slower cadence, and memoizes successful translations. Tests cover path classification, caching, distro selection, session fallback, polling, exact-path installation, and non-Windows behavior. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
Proof — run against real WSL2 from the Windows hostThe whole bug is that Codex reports a guest Linux path and the Windows main process cannot read it. So the proof is to put a real Codex-shaped transcript in the distro and probe it from Windows exactly the two ways the code does — before the fix, and after. Executed on Both halves of the fix are visible here:
Note This is a mechanism proof on the real platform, not a GUI recording. Driving Codex-in-WSL through the Chat UI end to end needs a full Orca build plus a Codex login on that host; I have not done that. The renderer half (the transcript watcher feeding the Chat panel) rests on the unit tests in this PR, which include the no-main-thread-stall assertion for the async WSL seams. Also worth stating plainly: the first time I ran this probe I got |
Three follow-ups from review of the WSL Codex transcript fix: - The UNC translation was retried on every fast resolve-poll tick (measured 10 sync UNC stats per 100ms) because only a successful result was memoized. Gate the retry to the slow fallback cadence. - A non-empty WSL home list was cached for the process lifetime, so a distro that was still booting during the first probe stayed excluded forever. Expire both branches; getWslHomeAsync caches successes, so a refresh only re-spawns wsl.exe for the distros that actually failed. - codexSessionsDirs enumerated every distro's home eagerly, waking distros the user left stopped even for native-Windows panes. Make the WSL roots a lazy tier consulted only after the host's own Codex roots miss. The resolve-poll suite became platform-dependent and only passed off Windows; pin the platform and add explicit win32 coverage.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/native-chat/host-readable-transcript-path.ts (1)
161-162: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse
path.win32.joinfor WSL UNC roots.
joinUnderWslHomeconstructs Windows separators directly. Use Node’s Windows path utility so this path construction does not depend on literal separators.Proposed change
-import { isAbsolute } from 'node:path' +import { isAbsolute, win32 } from 'node:path' ... function joinUnderWslHome(home: string, ...segments: string[]): string { - return `${home.replace(/[\\/]+$/, '')}\\${segments.join('\\')}` + return win32.join(home, ...segments) }Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 7b4d75b5-3b33-47b3-bb87-b698c9d0f3e2
📒 Files selected for processing (7)
src/main/native-chat/host-readable-transcript-path.test.tssrc/main/native-chat/host-readable-transcript-path.tssrc/main/native-chat/session-file-resolver-wsl.test.tssrc/main/native-chat/session-file-resolver.tssrc/main/native-chat/transcript-watch-resolve-poll.test.tssrc/main/native-chat/transcript-watch-wsl-exact-path.test.tssrc/main/native-chat/transcript-watch.ts
…sponses (stablyai#12473) * fix(native-chat): resolve WSL Codex transcripts so Chat UI renders responses Codex reports a guest Linux transcript path. On a Windows host `existsSync` resolved it against the current drive (`C:\home\...`) and discarded it, and the id-based fallback only searched host roots. `resolveSessionFilePath` returned null forever while the watcher reported `watching: true`, leaving Chat UI permanently empty. Translate the guest path to its host-readable UNC twin, classifying **before** any `existsSync` probe on win32 so the `C:\home` false positive cannot fire. Adapted from stablyai#10639 with one required correction: it uses the **async cached** WSL seams (`listWslDistrosAsync` / `getWslHomeAsync`) rather than the `execFileSync` ones, which would stall the Electron main thread for up to 5s per tick of the resolve-poll loop on a cold distro. Fixes stablyai#10326 Co-authored-by: Orca <[email protected]> * fix(native-chat): stop the WSL transcript probe firing every poll tick Three follow-ups from review of the WSL Codex transcript fix: - The UNC translation was retried on every fast resolve-poll tick (measured 10 sync UNC stats per 100ms) because only a successful result was memoized. Gate the retry to the slow fallback cadence. - A non-empty WSL home list was cached for the process lifetime, so a distro that was still booting during the first probe stayed excluded forever. Expire both branches; getWslHomeAsync caches successes, so a refresh only re-spawns wsl.exe for the distros that actually failed. - codexSessionsDirs enumerated every distro's home eagerly, waking distros the user left stopped even for native-Windows panes. Make the WSL roots a lazy tier consulted only after the host's own Codex roots miss. The resolve-poll suite became platform-dependent and only passed off Windows; pin the platform and add explicit win32 coverage. --------- Co-authored-by: Orca <[email protected]> Co-authored-by: OrcaWin <[email protected]>
Codex reports a guest Linux transcript path. On a Windows host
existsSyncresolved it against the current drive (C:\home\...) and discarded it, and the id-based fallback only searched host roots.resolveSessionFilePathreturned null forever while the watcher reportedwatching: true, leaving Chat UI permanently empty.Fix
Translate the guest path to its host-readable UNC twin, classifying before any
existsSyncprobe on win32 so theC:\homefalse positive cannot fire. Adapted from #10639 with one required correction: it uses the async cached WSL seams (listWslDistrosAsync/getWslHomeAsync) rather than theexecFileSyncones, which would stall the Electron main thread for up to 5s per tick of the resolve-poll loop on a cold distro.Verification
pnpm typecheckclean on this branchFixes #10326
Made with Orca 🐋