Skip to content

Fix/windows provider cli resolution#1668

Open
Abdel-E wants to merge 2 commits intogeneralaction:mainfrom
Abdel-E:fix/windows-provider-cli-resolution
Open

Fix/windows provider cli resolution#1668
Abdel-E wants to merge 2 commits intogeneralaction:mainfrom
Abdel-E:fix/windows-provider-cli-resolution

Conversation

@Abdel-E
Copy link
Copy Markdown

@Abdel-E Abdel-E commented Apr 6, 2026

Summary

On Windows, provider discovery can return multiple lines from where-style resolution (e.g. an extensionless npm shim plus codex.cmd). This PR prefers a line that looks like a real executable on win32, and updates resolveCommandPath so PATHEXT-qualified candidates are tried before the bare name—so spawned CLIs resolve to an actual executable.

A second commit adjusts pnpm’s native build allowlist so node-pty’s install-time node-gyp step is skipped. Native node-pty is still built in postinstall via electron-rebuild for Electron, which is what the app loads; this avoids redundant/broken Node-targeted builds on some Windows toolchain setups.

Fixes

Fixes #1667

Snapshot

N/A — behavior fix (CLI path resolution / install reliability on Windows); no UI change.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • This change requires a documentation update

Mandatory Tasks

  • I have self-reviewed the code

Checklist

  • I have read the contributing guide
  • I have commented my code, particularly in hard-to-understand areas
  • I have checked if my PR needs changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Summary by CodeRabbit

  • Bug Fixes

    • Improved Windows executable resolution to prioritize files with recognized extensions (.com, .exe, .bat, .cmd, .ps1).
  • Tests

    • Added test coverage for Windows command path resolution behavior.

Abdel-E added 2 commits April 5, 2026 18:04
node-pty is rebuilt for Electron in postinstall via electron-rebuild. Skipping the package install-time node-gyp step avoids Windows toolchains where VS2022 lacks a detected SDK while electron-rebuild still succeeds.

Made-with: Cursor
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 6, 2026

@Abdel-E is attempting to deploy a commit to the General Action Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 6, 2026

📝 Walkthrough

Walkthrough

This pull request fixes a Windows-specific bug where extensionless npm shims were incorrectly selected over proper executable wrappers during provider command path resolution. Changes modify path resolution logic to prefer executable-like entries with valid extensions and reorder search candidates accordingly.

Changes

Cohort / File(s) Summary
Build Configuration
package.json
Moved node-pty from onlyBuiltDependencies to ignoredBuiltDependencies in pnpm configuration.
Windows Path Resolution
src/main/services/ConnectionsService.ts, src/main/services/ptyManager.ts
Modified Windows command path resolution to prefer executables with valid extensions (.com, .exe, .bat, .cmd, .ps1) over extensionless binaries; reordered candidate search to prioritize extension variants before plain base values.
Test Coverage
src/test/main/ConnectionsService.test.ts
Added Windows-specific test case verifying that .cmd executable wrappers are preferred over extensionless shims when resolving provider paths.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A shim without a proper coat,
Could make the Windows processes float,
But now we search with extension flair,
.cmd and .exe beyond compare!
The bunny fixed the path with care,
And providers launched from everywhere! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly references the main change: fixing Windows provider CLI resolution, which aligns with the core objective of preferring executable wrappers over extensionless shims.
Linked Issues check ✅ Passed The changes implement the primary requirements from issue #1667: preferring PATHEXT-qualified executables (.cmd, .bat, .exe) over extensionless shims in command path resolution on Windows, with tests validating the new behavior.
Out of Scope Changes check ✅ Passed The pnpm configuration change (node-pty handling) is a supporting fix related to Windows native builds; other changes are tightly scoped to Windows provider CLI resolution as required by issue #1667.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/services/ConnectionsService.ts (1)

393-398: Align Windows executable filtering with PATHEXT to avoid resolver drift.

This hardcoded extension list can diverge from the PATHEXT-driven logic already used in src/main/services/ptyManager.ts, causing inconsistent command selection paths over time.

♻️ Suggested refactor
       if (process.platform === 'win32') {
-        const executable = lines.find((line) => /\.(com|exe|bat|cmd|ps1)$/i.test(line));
+        const pathExts = new Set(
+          (process.env.PATHEXT || '.COM;.EXE;.BAT;.CMD')
+            .split(';')
+            .map((ext) => ext.trim().toLowerCase())
+            .filter(Boolean)
+        );
+        const executable = lines.find((line) => {
+          const lower = line.toLowerCase();
+          return Array.from(pathExts).some((ext) => lower.endsWith(ext));
+        });
         if (executable) {
           return executable;
         }
       }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/services/ConnectionsService.ts` around lines 393 - 398, The
Windows-only executable filter in ConnectionsService.ts (the process.platform
=== 'win32' branch that sets the executable variable) uses a hardcoded extension
list and should be aligned with the PATHEXT-driven logic used in ptyManager.ts
to avoid drift; update this branch to derive allowed extensions from
process.env.PATHEXT (split on ';', normalize and build a case-insensitive match)
or, better, reuse the same helper/utility used by ptyManager.ts (import the
function that parses PATHEXT if available) and then test lines against that
dynamic extension set instead of /\.(com|exe|bat|cmd|ps1)$/i.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/main/services/ConnectionsService.ts`:
- Around line 393-398: The Windows-only executable filter in
ConnectionsService.ts (the process.platform === 'win32' branch that sets the
executable variable) uses a hardcoded extension list and should be aligned with
the PATHEXT-driven logic used in ptyManager.ts to avoid drift; update this
branch to derive allowed extensions from process.env.PATHEXT (split on ';',
normalize and build a case-insensitive match) or, better, reuse the same
helper/utility used by ptyManager.ts (import the function that parses PATHEXT if
available) and then test lines against that dynamic extension set instead of
/\.(com|exe|bat|cmd|ps1)$/i.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c5570c75-fac3-4c7e-9f91-230e8b4d066f

📥 Commits

Reviewing files that changed from the base of the PR and between a31f064 and c47ec48.

📒 Files selected for processing (4)
  • package.json
  • src/main/services/ConnectionsService.ts
  • src/main/services/ptyManager.ts
  • src/test/main/ConnectionsService.test.ts

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]: fix(windows) - provider direct PTY spawn can choose extensionless shim and fail with ERROR_BAD_EXE_FORMAT (193)

1 participant