Skip to content

fix(cli): preserve WSL cwd through the Windows bridge (#6965) - #7640

Merged
brennanb2025 merged 8 commits into
stablyai:mainfrom
rodboev:pr/orca-6965-wsl-cli-cwd-bridge
Jul 13, 2026
Merged

fix(cli): preserve WSL cwd through the Windows bridge (#6965)#7640
brennanb2025 merged 8 commits into
stablyai:mainfrom
rodboev:pr/orca-6965-wsl-cli-cwd-bridge

Conversation

@rodboev

@rodboev rodboev commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Preserve the invoking WSL cwd through the generated launcher and PowerShell bridge so the Windows batch entrypoint no longer inherits a UNC cwd. main() now defaults from ORCA_CLI_CWD when the bridge sets it, and explicit main(argv, cwd) calls still win.

Closes #6965.

Testing

  • pnpm exec vitest run --config config/vitest.config.ts src/main/cli/wsl-cli-installer.test.ts src/cli/index.test.ts
  • pnpm run typecheck:node
  • pnpm run typecheck:cli

AI Review Report

Windows, Linux, and macOS behavior stays bounded. The WSL-only bridge path sets ORCA_CLI_CWD, so non-WSL launches still resolve through process.cwd(), and empty env values fall back the same way. Remote selection rules, selector semantics, and GUI runtime projection remain unchanged. No provider-specific code changed, and no new persistent state or network surface was added.

Security Audit

The bridge only forwards a converted cwd value that it already owns from the generated launcher. It is quoted before the PowerShell hop, scoped to the bridge call, and restored in finally. Push-Location moves the Windows process to the launcher directory so cmd.exe does not inherit a WSL UNC cwd. No new shell interpolation or command construction was introduced beyond the existing generated script flow.

Notes

The fix stays inside the bridge boundary. resources/win32/bin/orca.cmd, src/main/wsl.ts, and src/cli/selectors.ts remain unchanged.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Updates worktree selector containment checks to use direct path-inside comparisons. WSL launcher generation now captures the current directory, converts it to a Windows path, and forwards it to the PowerShell bridge. The bridge manages ORCA_CLI_CWD, scopes execution to the launcher directory, computes exit codes, and performs cleanup. Tests verify script output and bridge-before-launcher installation ordering.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning src/cli/selectors.ts changes worktree containment logic even though the issue is about preserving WSL cwd through the bridge. Move the selector logic change into a separate PR or explain why it is required for the WSL cwd fix.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. 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 describes the main change: preserving WSL cwd through the Windows bridge.
Description check ✅ Passed The PR description covers the required summary, testing, AI review, security audit, and notes; only the optional Screenshots section is missing.
Linked Issues check ✅ Passed The bridge and launcher now preserve the WSL cwd before invoking Windows, matching #6965's requirement for selector-based commands.

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.

@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

Run ID: abf73873-2cad-4c34-b987-79e50c5b5334

📥 Commits

Reviewing files that changed from the base of the PR and between 98d850a and bd5ba80.

📒 Files selected for processing (4)
  • src/cli/index.test.ts
  • src/cli/index.ts
  • src/main/cli/wsl-cli-installer.test.ts
  • src/main/cli/wsl-cli-scripts.ts

Comment thread src/main/cli/wsl-cli-scripts.ts Outdated
@rodboev
rodboev force-pushed the pr/orca-6965-wsl-cli-cwd-bridge branch from 2f1fd70 to 9d8087f Compare July 11, 2026 02:30
@brennanb2025

Copy link
Copy Markdown
Contributor

Taking a look!

@brennanb2025
brennanb2025 merged commit f90cd6e into stablyai:main Jul 13, 2026
6 of 7 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]: WSL orca-ide CLI loses cwd when Windows cmd.exe falls back from UNC path

3 participants