Repository navigation
Fix packaged MCP launcher paths with spaces - #92
Conversation
|
CodeAnt AI is reviewing your PR. |
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds packaged-mode shim creation for Agent Relay MCP launchers with whitespace or special characters, enhances verification to validate shim paths, and expands broker tests to assert whitespace-free shim resolution and percent-sign escaping on Windows. ChangesMCP Launcher Shim Materialization
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to handle packaged MCP launcher paths containing spaces by generating a space-free shim launcher (using /tmp on POSIX and tmpdir() on Windows). Feedback focuses on two edge cases on Windows: first, tmpdir() can still contain spaces if the user's username has spaces, so a fallback to space-free directories like C:\Users\Public is recommended; second, percent signs % in the launcher path must be escaped as %% in the generated batch file to prevent unexpected expansion by CMD.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| function packagedMcpShimRoot(): string { | ||
| // Use /tmp on POSIX so the MCP command handed to Codex has no spaces even | ||
| // when the app is installed as "Pear by Agent Relay.app". | ||
| return process.platform === 'win32' ? tmpdir() : '/tmp' | ||
| } |
There was a problem hiding this comment.
On Windows, if the user's username contains spaces (e.g., C:\Users\John Doe), tmpdir() will return a path with spaces. Consequently, packagedMcpShimRoot() will return a path with spaces, and the generated shim path will still contain spaces, defeating the purpose of this PR and causing the verification tests to fail.
We should fall back to a space-free writable directory on Windows (such as C:\Users\Public or C:\ProgramData) if the default temp directory contains spaces.
function packagedMcpShimRoot(): string {
// Use /tmp on POSIX so the MCP command handed to Codex has no spaces even
// when the app is installed as "Pear by Agent Relay.app".
if (process.platform !== 'win32') {
return '/tmp'
}
const defaultTmp = tmpdir()
if (!/\s/.test(defaultTmp)) {
return defaultTmp
}
// Fallback to space-free writable directories on Windows if the user's temp directory contains spaces
const publicDir = process.env.PUBLIC || 'C:\\Users\\Public'
if (existsSync(publicDir) && !/\s/.test(publicDir)) {
return publicDir
}
const programData = process.env.ProgramData || 'C:\\ProgramData'
if (existsSync(programData) && !/\s/.test(programData)) {
return programData
}
return defaultTmp
}There was a problem hiding this comment.
Addressed in b693858: packaged Windows shims now try whitespace-free roots only (temp when clean, then PUBLIC, then ProgramData) and fail rather than returning a command path with spaces.
| function windowsCmdQuote(value: string): string { | ||
| return `"${value.replace(/"/g, '""')}"` | ||
| } |
There was a problem hiding this comment.
In Windows batch (.cmd/.bat) files, percent signs % are special characters used for variable and parameter expansion (e.g., %1, %VAR%). If the launcherPath contains a % character (for example, in a URL-encoded path or a username containing %), CMD will attempt to expand it, which can corrupt the path and cause execution to fail.
To prevent this, any literal % in the path must be escaped by doubling it to %% inside the batch file.
| function windowsCmdQuote(value: string): string { | |
| return `"${value.replace(/"/g, '""')}"` | |
| } | |
| function windowsCmdQuote(value: string): string { | |
| return `"${value.replace(/"/g, '""').replace(/%/g, '%%')}"` | |
| } |
There was a problem hiding this comment.
Addressed in b693858: literal percent signs are now doubled in generated .cmd shims, with a regression test covering a %USER% launcher path.
|
CodeAnt AI finished reviewing your PR. |
User description
Summary
Verification
CodeAnt-AI Description
Fix packaged MCP launches when the app is installed in a folder with spaces
What Changed
app.asar.Impact
✅ Fewer packaged launch failures✅ Works from app folders with spaces✅ Clearer packaged MCP startup checks🔄 Retrigger CodeAnt AI Review
💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.