Skip to content

fix(terminal): a WSL pane a relaunched window reattached keeps its folder when slept - #33496

Merged
nwparker merged 1 commit into
mainfrom
nwparker/wsl-sleep-reattached-pane
Oct 25, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/wsl-sleep-reattached-pane

Conversation

@nwparker

@nwparker nwparker commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​22 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​22
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​17 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​9

ELI5

On Windows, restart Orca, click back into a WSL terminal you had cd'd somewhere, then put its workspace to sleep. On waking, it opened at the workspace root instead of where you were. Now it keeps the folder.

What Changed

Before:

After: Sleep keeps the folder for reattached terminals too.

Mechanism:

Why

The daemon already keeps the spawn pane key for each session, so asking it once at Sleep is exact. The alternative was passing the key through every reattach path in the window and runtime, which is a much wider change for the same answer.

Linked Issue

Follow-up to #33398 and #33425, from a Windows/WSL verification run (5e: kill at quiesced rolled a cd'd pane back to the root).

Visual Proof

N/A: main-process daemon client, no UI change. The test below reproduces the relaunch, reattach and Sleep path.

Testing

  • New case in daemon-pty-adapter-wsl-sleep-cwd.test.ts:

    • Spawn a WSL pane, disconnect, then a fresh client attach()es it (no spawn environment) and sleeps it.
    • The folder read runs and the checkpoint keeps …\deep\er.
    • Fails on main before this change.
  • The seed-failure regression test (fix(terminal): a pane a relaunched app has not reopened keeps its history and folder when slept #33425) and the other folder cases still pass.

  • pnpm tc:node, check:code-quality:changed and run-ratchets.mjs pass.

  • In src/main/daemon, the only failures are the real-shell shell-ready tests, which also fail on clean main here. daemon-pty-adapter-history-recovery failed once under load and passes twice alone.

  • I manually tested these changes locally

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

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

  • Scope: Windows only, and only sessions with a WSL distro.
  • Cost: at most one extra local listSessions per Sleep of such a session.
  • SSH and macOS/Linux: unchanged.

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)

🤖 Generated with Claude Code

…lder when slept

After an app relaunch, the window reattaches a live pane without its spawn environment, so the
daemon client never learned the pane's ORCA_PANE_KEY. Sleep then skipped the folder read for it,
and the pane woke at its spawn folder. A move's kill-at-quiesced rollback also put a pane `cd`'d
before the relaunch back at the project root (awin verify-11, 5e). Sleep now takes the pane key
from the daemon's session list when it knows the session's distro but not its key. That is the
same one `listSessions` the adoption of an unattached session already uses.

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

coderabbitai Bot commented Oct 25, 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: 60a4c5cd-f87c-4761-965c-40dea1c34508
Commits

Reviewing files that changed from the base of the PR and between 3e950ca and e02e726.

Files selected for processing: 2
  • src/main/daemon/daemon-pty-adapter-wsl-sleep-cwd.test.ts
  • src/main/daemon/daemon-pty-process-inspection.ts

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

Walkthrough

The process inspection method now handles session adoption and WSL pane-key recovery as separate conditions. When adoption is not needed and a listed session has a WSL distro and pane key, the method caches that key. A new test covers a reattached adapter that shuts down after the shell changes directory. The test expects the adapter to read running guest process rows and checkpoint the updated WSL folder.

Priority: Normal

Merge Risk: Minimal · up to e02e7

The reattached WSL pane can recover its folder for Sleep checkpoints. A failed lookup still allows the checkpoint to complete with the previous folder fallback. This change is mergeable after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title identifies the WSL terminal folder preservation fix after a window relaunch and reattach. The wording is awkward, but the title is specific and related to the main change.
Description check Passed The description explains the user impact, mechanism, rationale, scope, testing, and compatibility considerations. It includes the required visual-proof statement and checklist updates. The linked issu…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
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 explains the user impact, mechanism, rationale, scope, testing, and compatibility considerations. It includes the required visual-proof statement and checklist updates. The linked issue section references issues but does not provide a Fixes #... link, and several validation checklist items remain unchecked.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

Finishing Touches
📝 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 merged commit 08019f4 into main Oct 25, 2026
45 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.

1 participant