Skip to content

chore(wsl): log what a Sleep's folder read saw for each terminal - #35150

Merged
nwparker merged 2 commits into
mainfrom
nwparker/wsl-sleep-cwd-diagnostic
Oct 28, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/wsl-sleep-cwd-diagnostic

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​184 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​183
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​103 $\color{#cf222e}{\Huge{\mathbf{−}}}$​47 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​56

ELI5

On the WSL test machine, a terminal paused by a project move sometimes comes back in the project's top folder instead of the folder the shell was in. The code that records that folder hasn't changed, so we can't tell from the code why it fails. This adds one log line per terminal Sleep that says what Orca tried and what it found, so the next device run shows the cause.

What Changed

Before: a Sleep that failed to learn a WSL bridge terminal's folder left no trace. The terminal just woke in the folder it was started in.

After: every Sleep logs one info line. For example:

[history] Sleep folder for <session>: wsl probe (budget 750ms, rows 12, shells 1), distro Ubuntu, pane <tab>:<leaf>, live true, folder found in 84ms

The line names:

  • which read ran:
    • wsl probe: the read inside the distro for bridge panes.
    • live probe: the read for native shells.
  • the read's time budget.
  • how many process rows the distro returned: none when it wasn't read, was refused, or timed out (timed out is added in that case).
  • how many shells carry the pane's identity: a folder is used only when exactly one does.
  • the distro and pane id Orca knew: unknown means it didn't know the pane was a WSL pane.
  • whether the pane was live.
  • whether a folder was found, and how long it took.

Mechanism:

  • readDaemonWslSleepCwd now delegates to readDaemonWslSleepCwdWithFacts, which returns those counts with the folder. Its result is unchanged.
  • The native read moves unchanged to its own module, daemon-live-sleep-cwd.ts, so the session-control file stays under its line limit.
  • No behavior changes: the same folder reaches the same checkpoint.

Why

The only lead on the device regression is a checkpoint that ended up at the project root. Each of the three possible causes leaves a different value on this line:

  • an older terminal service whose pane Orca doesn't recognise as WSL: unknown distro or pane
  • two shells carrying the pane's identity: shells 2
  • a distro read that timed out: rows none timed out

The alternative, asking the user to collect process tables by hand, isn't reliable mid-move.

Flag-off: no behavior change with ORCA_INTERNAL_WSL_HOSTS unset. Every Sleep, on any platform, adds one info line to the main log.

User-risk: none to behavior. One log line per terminal Sleep. It contains internal session and pane ids and a distro name; no folder paths or terminal contents.

Linked Issue

On-device WSL verification, 5e: a bridge pane paused by a move woke at the project root.

Visual Proof

N/A. Logging only.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • daemon-pty-adapter-wsl-sleep-cwd.test.ts: a real adapter Sleep of a WSL bridge pane logs exactly one line naming the wsl probe, rows 2, shells 1, distro, pane and folder found.

  • daemon-wsl-sleep-cwd.test.ts:

    • two shells on one pane report shells 2 with no folder
    • an unanswered read reports timed out
  • New daemon-pty-adapter-wsl-sleep-cwd-relaunch.test.ts: regression tests that a bridge pane still keeps its folder at Sleep after a renderer reload or app relaunch. Covers:

    • re-spawn with and without its environment, before and after the relaunched app adopts the session
    • sleep → wake → sleep at a new folder
    • a woken pane slept by a relaunched app that only adopted it

Checks run: pnpm tc, pnpm run typecheck:ci, 11 daemon test files (138 tests passing, including the Sleep-folder, quit-folder (#35141), history, distro-loss relaunch, cold-restore and fenced-termination suites), pnpm run check:code-quality:changed, anti-slop oxlint, oxlint (max-lines), ast-grep scan and gates.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • SSH: remote panes go through the live read; the line says live probe.
  • Folder workspaces: unaffected.
  • Wire compatibility: no change; nothing new is sent between client and daemon.

Status

Ready for review. Rebased onto main after #35141. Intended to ship in the next device build. Device runs show a fresh pane keeps its folder through both a move pause and Sleep → Wake; only one earlier pane lost it once, so this line is meant to catch the intermittent case.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@nwparker

Copy link
Copy Markdown
Contributor Author

STATUS: ready. Head 0f7c5da, from origin/main a6fdeda. Each Sleep now logs one info line: which read ran, budget, distro rows, pane-shell count, distro and pane known, live, and whether a folder was found. No behavior change. Checks: pnpm tc, typecheck:ci, 9 daemon test files (125 tests passing), code-quality, anti-slop, oxlint, ast-grep scan and gates. Note: #35141 edits the same Sleep block (it renames the Sleep folder map, sleepShellCwds → probedShellCwds), so whichever merges second needs a small rebase.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c7089e12-8b61-49b5-b545-dfef6119a207
Commits

Reviewing files that changed from the base of the PR and between 24b738a and 14eb406.

Files selected for processing: 6
  • src/main/daemon/daemon-live-sleep-cwd.ts
  • src/main/daemon/daemon-pty-adapter-wsl-sleep-cwd-relaunch.test.ts
  • src/main/daemon/daemon-pty-adapter-wsl-sleep-cwd.test.ts
  • src/main/daemon/daemon-pty-session-control.ts
  • src/main/daemon/daemon-wsl-sleep-cwd.test.ts
  • src/main/daemon/daemon-wsl-sleep-cwd.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

Walkthrough

Sleep handling now reads native or WSL CWD through dedicated readers and logs read details. The WSL reader reports read facts, including its budget, row and shell counts, and timeout status. New tests check WSL read results, diagnostic output, and checkpoint CWDs across pane reloads, relaunches, and wake-and-sleep scenarios.

Priority: Low

Merge Risk: Minimal · up to 14eb4

No merge-blocking issue was identified in the Sleep folder-read changes; they are ready for normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: adding WSL Sleep folder-read logging for terminals.
Description check Passed The description is detailed and covers the required change, rationale, testing, visual proof, compatibility notes, and checklist. The linked issue is described as “On-device WSL verification, 5e” rath…
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.
Full details: Description check

Explanation

The description is detailed and covers the required change, rationale, testing, visual proof, compatibility notes, and checklist. The linked issue is described as “On-device WSL verification, 5e” rather than provided as an actual issue link, and several validation checklist items remain unchecked, but the description is otherwise complete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 6 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • 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.

@nwparker
nwparker force-pushed the nwparker/wsl-sleep-cwd-diagnostic branch from 0f7c5da to 14eb406 Compare October 28, 2026 14:52
@nwparker

Copy link
Copy Markdown
Contributor Author

STATUS: rebased onto main bafe4d5 (includes #35141, so the per-pane folder map is now probedShellCwds). Head 14eb406. Conflicts resolved in daemon-wsl-sleep-cwd.ts: the facts read now also takes #35141's optional time cap, and the at-quit read is kept. Added daemon-pty-adapter-wsl-sleep-cwd-relaunch.test.ts (the reload/relaunch regression tests). Checks: pnpm tc, typecheck:ci, 11 daemon test files (138 tests passing), code-quality, anti-slop, oxlint, ast-grep scan and gates. Not merged.

@nwparker
nwparker merged commit e9515b5 into main Oct 28, 2026
52 checks passed
nwparker added a commit that referenced this pull request Oct 28, 2026
…trace (#35378)

* chore(wsl): keep the Sleep folder and bridge-exit lines in the local trace

A packaged build keeps no console, so #35150's Sleep folder line and the WSL bridge exit verdict
were invisible on a device. Each now also goes to main.trace.ndjson as a span with the line and
its facts as filterable fields.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(wsl): keep session paths and distro names out of the persisted WSL trace

---------

Co-authored-by: Claude <noreply@anthropic.com>
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.

1 participant