Skip to content

Fix Windows AI Vault resumes using the wrong shell - #13420

Merged
OrcaWin merged 2 commits into
mainfrom
jinwoo/sta-3687-bug-windows-queued-agent-commands-use-the-configured-shell
Aug 10, 2026
Merged

Fix Windows AI Vault resumes using the wrong shell#13420
OrcaWin merged 2 commits into
mainfrom
jinwoo/sta-3687-bug-windows-queued-agent-commands-use-the-configured-shell

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Closes #13095

Summary

  • Resolve AI Vault resume shell syntax from the target project's effective runtime, matching terminal tab creation.
  • Pass the recorded working directory as structured PTY startup metadata instead of embedding cd ... && in queued shell text.
  • Keep copied resume commands self-contained and preserve cwd/provider-session metadata across local, runtime, and drag/drop launches.
  • Make local missing-cwd recovery namespace-aware so WSL POSIX paths are provider-validated while missing Windows paths still fall back to the workspace root.

Deterministic repro: on Windows, set the global terminal shell to wsl.exe, pin the project runtime to windows-host, and resume an AI Vault session whose cwd is C:\Users\alice\repo. Before this change Orca queued POSIX cd ... && syntax into the PowerShell tab; PowerShell 5.1 rejects &&. The launch now queues only the agent invocation and sends cwd separately.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Additional validation:

  • 36 focused AI Vault resume tests pass.
  • 3 focused main-process cwd fallback regressions pass.
  • Native, type-aware, and React Doctor Oxlint scans pass for every changed file.
  • Max-lines ratchet and git diff --check pass.
  • PowerShell 5.1 runtime proof reproduces the old && parse failure and accepts the new startup path.
  • Electron dev runtime launched successfully with a live PowerShell terminal.

The complete pty.test.ts file has three unrelated Windows-only failures outside the changed cwdFallback branch (two POSIX-path expectations and one existing Codex provenance expectation); 439 tests passed and 19 skipped in that pre-rebase run.

AI Review Report

Three adversarial review passes covered Windows host/WSL/cmd/Git Bash behavior, SSH and runtime launches, folder workspaces, drag/drop compatibility, Codex-home/provider-session handling, daemon boundaries, mixed versions, and performance.

The first review found that actual-shell metadata was attempting to solve physical executable fallback incompletely, so that entire daemon/preload/transport tranche was removed and the PR was narrowed to #13095. It also found an over-broad WSL cwd fallback bypass; the guard was narrowed to WSL-owned POSIX namespaces and a discriminating Windows-path fallback test was added. Two fresh independent correctness reviewers then returned CLEAN on the same final round. The performance reviewer found no hot-path, IPC, process-probe, or retention regression.

Cross-platform review explicitly covered macOS, Linux, Windows, native Windows host shells, WSL path translation, Git Bash/cmd quoting, SSH, runtime-owned workspaces, folder workspaces, and Electron PTY startup behavior. No keyboard shortcut or UI-label behavior changed.

Security Audit

No new dependency, privilege, network, secret, or external process surface is introduced. Session cwd remains input to the existing PTY startup-cwd resolver and provider validation. The review checked command construction, quoting, path namespaces, Codex account-home routing, environment deletion, provider-session provenance, IPC boundaries, SSH isolation, and remote wire compatibility. No new wire field is introduced.

Notes

This intentionally does not attempt to reserialize startup commands after a configured executable physically falls back to a different shell family. A correct solution for that separate problem needs complete per-shell command and launch-config variants selected by the provider for each spawn attempt; command-only rewriting would be incomplete.

Linked PR #13238 was reviewed but not used because it covers cold restore rather than Resume in Worktree and its UUID-only test does not distinguish PowerShell from POSIX quoting.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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: 853bd351-5593-4112-86f8-2779e26f81f5

📥 Commits

Reviewing files that changed from the base of the PR and between ff99af3 and 38ceab0.

📒 Files selected for processing (2)
  • src/main/ipc/pty.test.ts
  • src/main/ipc/pty.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/ipc/pty.ts
  • src/main/ipc/pty.test.ts

📝 Walkthrough

Walkthrough

WSL PTY startup now distinguishes WSL-owned POSIX paths from Windows paths during directory validation. It probes WSL UNC directories asynchronously and applies worktree fallback only when the requested directory is missing and the workspace root exists. AI Vault resume construction now resolves startup shells and returns startup working directories separately from command text. Copy commands still embed working directories. New-tab launches forward session working directories to web sessions and regular tab startup state. Tests cover WSL, Windows, POSIX, SSH, UNC, remote, Codex, and OMP resume cases.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary fix for Windows AI Vault resume shell selection.
Description check ✅ Passed The description includes all required sections and provides detailed scope, testing, review, security, and platform notes.
Linked Issues check ✅ Passed The changes address issue #13095 by resolving runtime shell syntax, preserving resume metadata, and handling Windows and WSL working directories.
Out of Scope Changes check ✅ Passed The changed files and tests support the linked issue objectives without introducing unrelated functionality.
✨ 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.

@OrcaWin
OrcaWin force-pushed the jinwoo/sta-3687-bug-windows-queued-agent-commands-use-the-configured-shell branch from d514279 to ff99af3 Compare August 10, 2026 02:35

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b7617526-fe13-4790-8cdb-2e7fc635810e

📥 Commits

Reviewing files that changed from the base of the PR and between d514279 and ff99af3.

📒 Files selected for processing (6)
  • src/main/ipc/pty.test.ts
  • src/main/ipc/pty.ts
  • src/main/providers/local-pty-provider.test.ts
  • src/main/providers/local-pty-provider.ts
  • src/main/wsl.test.ts
  • src/main/wsl.ts

Comment thread src/main/ipc/pty.test.ts
cacheKey: 'repo-1:wsl'
}
}
})) as { startupCwdFallback?: { kind: string; cwd: string } }

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.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Remove the repeated type assertions.

The repeated })) as ... lines make this test file invalid TypeScript.

  • src/main/ipc/pty.test.ts#L12211-L12211: keep one closing type assertion for the spawn result.
  • src/main/ipc/pty.test.ts#L12275-L12275: keep one closing type assertion for the parameterized spawn result.
  • src/main/ipc/pty.test.ts#L12363-L12363: keep one closing type assertion for the Windows-path spawn result.
📍 Affects 1 file
  • src/main/ipc/pty.test.ts#L12211-L12211 (this comment)
  • src/main/ipc/pty.test.ts#L12275-L12275
  • src/main/ipc/pty.test.ts#L12363-L12363

@OrcaWin
OrcaWin force-pushed the jinwoo/sta-3687-bug-windows-queued-agent-commands-use-the-configured-shell branch from ff99af3 to 38ceab0 Compare August 10, 2026 02:44
@OrcaWin
OrcaWin merged commit bdd7631 into main Aug 10, 2026
44 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.

[Bug]: Windows queued agent commands use the configured shell dialect, not the pane's actual shell (wsl.exe setting emits POSIX && into PowerShell 5.1)

1 participant