Skip to content

fix(source-control): preserve Windows command override paths - #11380

Closed
bbingz wants to merge 2 commits into
stablyai:mainfrom
bbingz:fix/windows-command-template-paths
Closed

bbingz wants to merge 2 commits into
stablyai:mainfrom
bbingz:fix/windows-command-template-paths

Conversation

@bbingz

@bbingz bbingz commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Tokenize custom commands using the execution target path flavor.
  • Preserve native Windows backslashes while retaining POSIX escaping for macOS, Linux, WSL, and POSIX SSH targets.
  • Propagate SSH host path flavor through commit, PR, branch-name, and model-discovery planning.

Fixes #11375

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions

Focused checks:

  • 304 tests passed, 1 skipped across command parsing, planning, generation, IPC, runtime, branch rename, and renderer plan coverage.
  • pnpm run check:code-quality:changed
  • pnpm run check:max-lines-ratchet
  • git diff --check

AI Review Report

Reviewed command tokenization, all local and SSH generation callers, WSL isolation, and model discovery. Greptile rated the change 5/5 with no files needing attention. CodeRabbit flagged one verbose comment; commit 8a55e3ba8 condensed it. Cross-platform review verified that macOS, Linux, WSL, and POSIX SSH keep existing backslash escapes while native and SSH Windows preserve path separators.

Security Audit

The tokenizer remains argv-only and does not add shell execution, variable expansion, command substitution, globbing, or home expansion. The review covered arbitrary command overrides, quoted paths, WSL host separation, SSH host path flavor, and fallback behavior when remote platform detection is unavailable. No secrets or dependency changes are included.

Notes

The path flavor defaults to POSIX for backward compatibility. Native Windows is selected only for a local win32 target without WSL or an SSH host explicitly detected as Windows.

@greptile-apps

greptile-apps Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR fixes Windows command override paths being corrupted by the POSIX tokenizer when users specify agent command paths like C:\\Program Files\\agent.exe for SSH targets running Windows. It introduces a CommandTemplatePathFlavor type ('posix' | 'windows') and threads it through the entire command planning stack so backslashes are preserved literally on Windows rather than interpreted as escape sequences.

  • Adds pathFlavor parameter to tokenizeCustomCommandTemplate and planCustomCommand; the backslash-escape branch is now gated on pathFlavor === 'posix', leaving Windows paths intact.
  • Adds optional commandPathFlavor to the remote generation target type and a getCommandPathFlavor helper that resolves the correct flavor for both local (via process.platform) and remote (via provider.getHostPlatform()) targets.
  • Updates all remote target construction sites in filesystem.ts, orca-runtime-git.ts, and first-work-generation-target.ts to read provider.getHostPlatform?.()?.pathFlavor ?? 'posix'; propagates the same flavor into discoverCommitMessageModelsRemote for model discovery.

Confidence Score: 5/5

The change is a well-scoped, additive fix: backslash handling in the tokenizer is gated by a new parameter with a safe POSIX default, and all call sites consistently derive the flavor from the SSH provider's reported host platform. No existing behavior changes for macOS, Linux, or WSL targets.

All call sites use optional chaining with a 'posix' fallback, so the feature degrades gracefully when getHostPlatform is absent. The options parameter to discoverCommitMessageModelsLocal defaults to {}, making options.wslDistro safely undefined. The non-null assertion (provider!) in orca-runtime-git.ts is backed by an explicit early return on target.connectionId && !provider. New tests cover the Windows native, remote-Windows, and WSL POSIX paths.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
src/shared/commit-message-prompt.ts Adds CommandTemplatePathFlavor type and pathFlavor parameter to tokenizeCustomCommandTemplate and planCustomCommand; backslash escape logic is gated on pathFlavor === 'posix' so Windows backslashes are passed through literally.
src/shared/commit-message-plan.ts Adds CommitMessagePlanOptions with optional commandPathFlavor; propagates pathFlavor through planAgentBinary, planAdditionalAgentArgs, and planCommitMessageGeneration.
src/main/text-generation/commit-message-text-generation.ts Adds optional commandPathFlavor to remote CommitMessageGenerationTarget; adds getCommandPathFlavor helper; plumbs flavor into all three generation functions and both local/remote model discovery paths.
src/main/ipc/filesystem.ts Three remote target construction sites updated to set commandPathFlavor from provider.getHostPlatform?.()?.pathFlavor ?? 'posix'; remote model discovery call updated with same flavor.
src/main/runtime/orca-runtime-git.ts Four remote target / discovery call sites updated with commandPathFlavor; one uses provider!.getHostPlatform?.() which is safe given the preceding null guard at line 720.
src/main/agent-hooks/first-work-generation-target.ts Adds commandPathFlavor to the remote generation target built from an SSH provider, propagating path flavor into branch-name generation.
src/shared/commit-message-plan.test.ts Adds a test verifying that Windows agentCommandOverride paths with backslashes are preserved when commandPathFlavor: 'windows' is passed.
src/shared/commit-message-prompt.test.ts Adds unit tests for the two new tokenizer behaviors: Windows paths keep backslashes, POSIX paths still honor backslash-escape sequences.
src/main/text-generation/commit-message-text-generation.test.ts Adds tests for native Windows local spawn, remote Windows target with Windows paths, and WSL POSIX override paths; updates existing WSL test to include a POSIX override command.
src/main/ipc/filesystem.test.ts Updates SSH provider mock to return getHostPlatform with pathFlavor: 'windows'; extends expectations to assert commandPathFlavor: 'windows' propagates correctly.

Reviews (2): Last reviewed commit: "style: condense command tokenizer commen..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jul 29, 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: 7cc3e34f-162d-4a69-af31-c4bb968fcbc0

📥 Commits

Reviewing files that changed from the base of the PR and between 9507cbc and 1fa8bdc.

📒 Files selected for processing (10)
  • src/main/agent-hooks/first-work-generation-target.ts
  • src/main/ipc/filesystem.test.ts
  • src/main/ipc/filesystem.ts
  • src/main/runtime/orca-runtime-git.ts
  • src/main/text-generation/commit-message-text-generation.test.ts
  • src/main/text-generation/commit-message-text-generation.ts
  • src/shared/commit-message-plan.test.ts
  • src/shared/commit-message-plan.ts
  • src/shared/commit-message-prompt.test.ts
  • src/shared/commit-message-prompt.ts
🚧 Files skipped from review as they are similar to previous changes (10)
  • src/main/agent-hooks/first-work-generation-target.ts
  • src/main/ipc/filesystem.ts
  • src/main/ipc/filesystem.test.ts
  • src/shared/commit-message-prompt.test.ts
  • src/main/text-generation/commit-message-text-generation.test.ts
  • src/main/text-generation/commit-message-text-generation.ts
  • src/main/runtime/orca-runtime-git.ts
  • src/shared/commit-message-plan.ts
  • src/shared/commit-message-prompt.ts
  • src/shared/commit-message-plan.test.ts

📝 Walkthrough

Walkthrough

Command planning now accepts POSIX or Windows path flavors and preserves backslashes according to the selected platform. Local, WSL, and remote model discovery and generation paths derive and propagate this flavor. SSH providers expose host platform information to remote commit message, pull request field, and model discovery flows. Tests cover Windows command overrides, PowerShell paths, WSL path mapping, remote planning, and SSH propagation.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.08% 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 main change: preserving Windows command override paths.
Description check ✅ Passed The description covers the required sections, testing, cross-platform review, security audit, and platform-specific notes.
Linked Issues check ✅ Passed The changes address #11375 by preserving Windows paths, retaining POSIX escaping, propagating remote path flavor, and adding regression tests.
Out of Scope Changes check ✅ Passed The changes and tests remain focused on target-aware command path tokenization and its propagation through generation and discovery flows.

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.

🧹 Nitpick comments (1)
src/shared/commit-message-prompt.ts (1)

140-142: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Condense this implementation comment.

The new three-line comment exceeds the repository’s concise, preferably one-line comment convention.

Proposed change
-// Why: this parser only groups argv; Windows keeps path separators literal,
-// while POSIX targets retain the existing backslash escapes. We do not expand
-// variables, substitutions, globs, or `~`.
+// Why: POSIX honors backslash escapes; Windows preserves them literally.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bb5f4673-4c57-40f5-b515-77912a295381

📥 Commits

Reviewing files that changed from the base of the PR and between 4543bb6 and 9fe3b10c1ba1fb9b74ac7583be6d66e31995608a.

📒 Files selected for processing (10)
  • src/main/agent-hooks/first-work-generation-target.ts
  • src/main/ipc/filesystem.test.ts
  • src/main/ipc/filesystem.ts
  • src/main/runtime/orca-runtime-git.ts
  • src/main/text-generation/commit-message-text-generation.test.ts
  • src/main/text-generation/commit-message-text-generation.ts
  • src/shared/commit-message-plan.test.ts
  • src/shared/commit-message-plan.ts
  • src/shared/commit-message-prompt.test.ts
  • src/shared/commit-message-prompt.ts

@bbingz
bbingz force-pushed the fix/windows-command-template-paths branch from 8a55e3b to 1fa8bdc Compare August 5, 2026 04:11
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@bbingz

bbingz commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Closing as part of fork PR backlog cleanup.

This branch is long-conflicted (DIRTY) against current main and is not on the active campaign rebase list. Feel free to reopen or cut a fresh PR from an updated branch if the change is still needed.

@bbingz bbingz closed this Aug 10, 2026
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.

Windows: command overrides with native absolute paths are corrupted by POSIX backslash tokenization

2 participants