-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: Windows PATH and terminal DPI scaling improvements #1262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
2752fba
ddde098
931badd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -643,6 +643,53 @@ describe('claude-integration-handler - Helper Functions', () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| describe('escapeShellCommand', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| it('should add & call operator for PowerShell on Windows', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mockPlatform('win32'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { escapeShellCommand } = await import('../claude-integration-handler'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // PowerShell needs & to execute commands with -- flags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Without &, PowerShell interprets -- as the decrement operator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const result = escapeShellCommand('C:\\Users\\test\\claude.exe', 'powershell'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(result).toBe('& "C:\\Users\\test\\claude.exe"'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| it('should NOT add & call operator for cmd.exe on Windows', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mockPlatform('win32'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { escapeShellCommand } = await import('../claude-integration-handler'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const result = escapeShellCommand('C:\\Users\\test\\claude.exe', 'cmd'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(result).toBe('"C:\\Users\\test\\claude.exe"'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(result).not.toContain('&'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| it('should default to cmd.exe style when shellType is undefined on Windows', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mockPlatform('win32'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { escapeShellCommand } = await import('../claude-integration-handler'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const result = escapeShellCommand('C:\\Users\\test\\claude.exe'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(result).toBe('"C:\\Users\\test\\claude.exe"'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(result).not.toContain('&'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| it('should use single quotes on Unix', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mockPlatform('darwin'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { escapeShellCommand } = await import('../claude-integration-handler'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const result = escapeShellCommand('/usr/local/bin/claude'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(result).toBe("'/usr/local/bin/claude'"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| it('should escape special characters in PowerShell path', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mockPlatform('win32'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { escapeShellCommand } = await import('../claude-integration-handler'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Paths with special chars like % should be escaped | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const result = escapeShellCommand('C:\\Users\\test%user\\claude.exe', 'powershell'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(result).toBe('& "C:\\Users\\test%%user\\claude.exe"'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+646
to
+691
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add Linux coverage for These new tests exercise Windows and macOS, but not Linux. Please add a Linux case to satisfy the “all three platforms” test rule. ✅ Suggested test addition it('should use single quotes on Unix', async () => {
mockPlatform('darwin');
const { escapeShellCommand } = await import('../claude-integration-handler');
const result = escapeShellCommand('/usr/local/bin/claude');
expect(result).toBe("'/usr/local/bin/claude'");
});
+
+ it('should use single quotes on Linux', async () => {
+ mockPlatform('linux');
+ const { escapeShellCommand } = await import('../claude-integration-handler');
+
+ const result = escapeShellCommand('/usr/local/bin/claude');
+ expect(result).toBe("'/usr/local/bin/claude'");
+ });As per coding guidelines, please ensure platform-specific tests cover Windows, macOS, and Linux. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| describe('finalizeClaudeInvoke', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| it('should set terminal title to "Claude" for default profile when terminal has default name', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { finalizeClaudeInvoke } = await import('../claude-integration-handler'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ import * as OutputParser from './output-parser'; | |
| import * as SessionHandler from './session-handler'; | ||
| import * as PtyManager from './pty-manager'; | ||
| import { debugLog, debugError } from '../../shared/utils/debug-logger'; | ||
| import { escapeShellArg, escapeForWindowsDoubleQuote, buildCdCommand } from '../../shared/utils/shell-escape'; | ||
| import { escapeShellArg, escapeForWindowsDoubleQuote, buildCdCommand, type WindowsShellType } from '../../shared/utils/shell-escape'; | ||
| import { getClaudeCliInvocation, getClaudeCliInvocationAsync } from '../claude-cli-utils'; | ||
| import { isWindows } from '../platform'; | ||
| import type { | ||
|
|
@@ -94,16 +94,29 @@ function buildPathPrefix(pathEnv: string): string { | |
| * On Windows, wraps in double quotes for cmd.exe. Since the value is inside | ||
| * double quotes, we use escapeForWindowsDoubleQuote() (only escapes embedded | ||
| * double quotes as ""). Caret escaping is NOT used inside double quotes. | ||
| * | ||
| * For PowerShell, adds the call operator (&) before the command to prevent | ||
| * PowerShell from interpreting -- flags as the pre-decrement operator. | ||
| * | ||
| * On Unix/macOS, wraps in single quotes for bash. | ||
| * | ||
| * @param cmd - The command to escape | ||
| * @param shellType - On Windows, specify 'powershell' or 'cmd' for correct syntax. | ||
| * @returns The escaped command safe for use in shell commands | ||
| */ | ||
| function escapeShellCommand(cmd: string): string { | ||
| export function escapeShellCommand(cmd: string, shellType?: WindowsShellType): string { | ||
| if (isWindows()) { | ||
| // Windows: Wrap in double quotes and escape only embedded double quotes | ||
| // Inside double quotes, caret is literal, so use escapeForWindowsDoubleQuote() | ||
| const escapedCmd = escapeForWindowsDoubleQuote(cmd); | ||
|
|
||
| if (shellType === 'powershell') { | ||
| // PowerShell: Use call operator (&) to execute the command | ||
| // Without &, PowerShell interprets "--flag" as pre-decrement operator | ||
| return `& "${escapedCmd}"`; | ||
| } | ||
|
|
||
| // cmd.exe: Just wrap in double quotes | ||
| return `"${escapedCmd}"`; | ||
|
Comment on lines
+97
to
120
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: find . -type f -name "*integration-handler*" | head -20Repository: AndyMik90/Auto-Claude Length of output: 207 🏁 Script executed: fd "escapeForWindowsDoubleQuote" --type fRepository: AndyMik90/Auto-Claude Length of output: 47 🏁 Script executed: fd "claude-integration-handler" --type fRepository: AndyMik90/Auto-Claude Length of output: 203 🏁 Script executed: cat -n apps/frontend/src/main/terminal/claude-integration-handler.ts | sed -n '90,125p'Repository: AndyMik90/Auto-Claude Length of output: 1710 🏁 Script executed: rg "escapeForWindowsDoubleQuote" -A 10 -B 2Repository: AndyMik90/Auto-Claude Length of output: 16341 🏁 Script executed: cat -n apps/frontend/src/main/terminal/__tests__/claude-integration-handler.test.ts | grep -A 50 "escapeShellCommand"Repository: AndyMik90/Auto-Claude Length of output: 4461 🏁 Script executed: cat -n apps/frontend/src/shared/utils/shell-escape.ts | head -80Repository: AndyMik90/Auto-Claude Length of output: 3514 🏁 Script executed: cat -n apps/frontend/src/shared/utils/shell-escape.ts | sed -n '79,130p'Repository: AndyMik90/Auto-Claude Length of output: 2593 🏁 Script executed: # Check if there are any PowerShell-specific escaping functions in the codebase
rg "PowerShell|powershell" -A 3 -B 3 apps/frontend/src/shared/utils/shell-escape.tsRepository: AndyMik90/Auto-Claude Length of output: 1024 🏁 Script executed: cat -n apps/frontend/src/shared/utils/shell-escape.ts | sed -n '130,145p'Repository: AndyMik90/Auto-Claude Length of output: 948 🏁 Script executed: # Let me check the complete escapeForWindowsDoubleQuote function
cat -n apps/frontend/src/shared/utils/shell-escape.ts | sed -n '130,150p'Repository: AndyMik90/Auto-Claude Length of output: 1165 🏁 Script executed: # Check how escapeShellCommand is used in the codebase
rg "escapeShellCommand" -B 2 -A 2 --type ts --type tsxRepository: AndyMik90/Auto-Claude Length of output: 92 🏁 Script executed: # Let me verify the PowerShell-specific test more thoroughly
cat -n apps/frontend/src/main/terminal/__tests__/claude-integration-handler.test.ts | sed -n '683,691p'Repository: AndyMik90/Auto-Claude Length of output: 549 🏁 Script executed: # Let me search for more context about how PowerShell handles special characters
rg "PowerShell" -A 5 -B 5 apps/frontend/srcRepository: AndyMik90/Auto-Claude Length of output: 37372 🏁 Script executed: # Check if there are any other tests that validate PowerShell escaping with special characters
rg "powershell" apps/frontend/src/main/terminal/__tests__/claude-integration-handler.test.ts -A 3 -B 3Repository: AndyMik90/Auto-Claude Length of output: 675 Use PowerShell-safe escaping when In PowerShell, double-quoted strings trigger variable expansion ( Switch to single-quote escaping for PowerShell, which prevents all expansion. Handle only embedded single quotes by doubling them: 🔧 Suggested fixexport function escapeShellCommand(cmd: string, shellType?: WindowsShellType): string {
if (isWindows()) {
if (shellType === 'powershell') {
// PowerShell: Use single quotes to prevent variable expansion, backtick interpretation
const escapedCmd = cmd
.replace(/\r/g, '')
.replace(/\n/g, '')
.replace(/'/g, "''");
return `& '${escapedCmd}'`;
}
// cmd.exe: Wrap in double quotes and escape embedded double quotes/percents
const escapedCmd = escapeForWindowsDoubleQuote(cmd);
return `"${escapedCmd}"`;
}
// Unix/macOS: Wrap in single quotes for bash
return escapeShellArg(cmd);
}🤖 Prompt for AI Agents |
||
| } | ||
| // Unix/macOS: Wrap in single quotes for bash | ||
|
|
@@ -571,7 +584,7 @@ export function invokeClaude( | |
|
|
||
| const cwdCommand = buildCdCommand(cwd, terminal.shellType); | ||
| const { command: claudeCmd, env: claudeEnv } = getClaudeCliInvocation(); | ||
| const escapedClaudeCmd = escapeShellCommand(claudeCmd); | ||
| const escapedClaudeCmd = escapeShellCommand(claudeCmd, terminal.shellType); | ||
| const pathPrefix = buildPathPrefix(claudeEnv.PATH || ''); | ||
| const needsEnvOverride = profileId && profileId !== previousProfileId; | ||
|
|
||
|
|
@@ -676,7 +689,7 @@ export function resumeClaude( | |
| SessionHandler.releaseSessionId(terminal.id); | ||
|
|
||
| const { command: claudeCmd, env: claudeEnv } = getClaudeCliInvocation(); | ||
| const escapedClaudeCmd = escapeShellCommand(claudeCmd); | ||
| const escapedClaudeCmd = escapeShellCommand(claudeCmd, terminal.shellType); | ||
| const pathPrefix = buildPathPrefix(claudeEnv.PATH || ''); | ||
|
|
||
| // Always use --continue which resumes the most recent session in the current directory. | ||
|
|
@@ -793,7 +806,7 @@ export async function invokeClaudeAsync( | |
| if (timeoutId) clearTimeout(timeoutId); | ||
| }); | ||
|
|
||
| const escapedClaudeCmd = escapeShellCommand(claudeCmd); | ||
| const escapedClaudeCmd = escapeShellCommand(claudeCmd, terminal.shellType); | ||
| const pathPrefix = buildPathPrefix(claudeEnv.PATH || ''); | ||
| const needsEnvOverride = profileId && profileId !== previousProfileId; | ||
|
|
||
|
|
@@ -907,7 +920,7 @@ export async function resumeClaudeAsync( | |
| if (timeoutId) clearTimeout(timeoutId); | ||
| }); | ||
|
|
||
| const escapedClaudeCmd = escapeShellCommand(claudeCmd); | ||
| const escapedClaudeCmd = escapeShellCommand(claudeCmd, terminal.shellType); | ||
| const pathPrefix = buildPathPrefix(claudeEnv.PATH || ''); | ||
|
|
||
| // Always use --continue which resumes the most recent session in the current directory. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Use static import instead of dynamic
require.spawnSyncshould be imported at the top of the file alongsidespawnfromchild_processrather than using a dynamicrequirecall. This is cleaner and more consistent with the existing imports.♻️ Proposed fix
At the top of the file (line 10), update the import:
Then at line 779:
🤖 Prompt for AI Agents