Respect terminalWindowsShell setting for local Windows agent launches (#7526)

Ensure agent CLI startup and draft launch commands use the correct quoting
format based on the user's configured local Windows shell (e.g., cmd.exe).
This avoids using host settings for remote/SSH targets where local shell
preferences do not apply.
This commit is contained in:
Jinjing
2026-07-06 01:05:56 -07:00
committed by GitHub
parent be4d963905
commit 2b5f6af0e9
5 changed files with 295 additions and 32 deletions
+136
View File
@@ -3538,6 +3538,7 @@ describe('OrcaRuntimeService', () => {
...store,
getSettings: () => ({
...store.getSettings(),
terminalWindowsShell: 'cmd.exe',
agentCmdOverrides: {}
}),
getRepos: () => [remoteRepo],
@@ -7264,6 +7265,94 @@ describe('OrcaRuntimeService', () => {
)
})
it('quotes local Windows bare agent command defaults for cmd.exe terminal creates', async () => {
setPlatform('win32')
const spawn = vi.fn().mockResolvedValue({ id: 'pty-bg' })
const runtimeStore = {
...store,
getSettings: () => ({
...store.getSettings(),
disabledTuiAgents: [],
terminalWindowsShell: 'cmd.exe',
agentCmdOverrides: {},
agentDefaultArgs: { claude: '--dangerously-skip-permissions' },
agentDefaultEnv: {}
})
}
const runtime = new OrcaRuntimeService(runtimeStore)
runtime.setPtyController({
spawn,
write: () => true,
kill: () => true,
getForegroundProcess: async () => null
})
await runtime.createTerminal(`path:${TEST_WORKTREE_PATH}`, {
command: 'claude',
title: 'worker'
})
const spawnCall = spawn.mock.calls[0]?.[0] as { command?: string } | undefined
expect(spawnCall?.command).toBe('claude "--dangerously-skip-permissions"')
})
it('does not use the local Windows shell setting for remote Windows bare agent creates', async () => {
const remoteRepo = {
id: TEST_REPO_ID,
path: 'C:/remote/repo',
displayName: 'repo',
badgeColor: 'blue',
addedAt: 1,
connectionId: 'ssh-1'
}
const remoteStore = {
...store,
getRepos: () => [remoteRepo],
getRepo: (id: string) => (id === TEST_REPO_ID ? remoteRepo : undefined),
getSettings: () => ({
...store.getSettings(),
disabledTuiAgents: [],
terminalWindowsShell: 'cmd.exe',
agentCmdOverrides: {},
agentDefaultArgs: { claude: '--dangerously-skip-permissions' },
agentDefaultEnv: {}
})
}
const provider = {
exec: vi.fn().mockResolvedValue({ stdout: '', stderr: '' }),
listWorktrees: vi.fn().mockResolvedValue([
{
path: 'C:/remote/repo',
head: 'abc',
branch: 'main',
isBare: false,
isMainWorktree: true
}
])
}
const spawn = vi.fn().mockResolvedValue({ id: 'pty-remote-windows-bare' })
registerSshGitProvider('ssh-1', provider as never)
const runtime = new OrcaRuntimeService(remoteStore as never)
runtime.setPtyController({
spawn,
write: () => true,
kill: () => true,
getForegroundProcess: async () => null
})
try {
await runtime.createTerminal('path:C:/remote/repo', {
command: 'claude',
title: 'worker'
})
const spawnCall = spawn.mock.calls[0]?.[0] as { command?: string } | undefined
expect(spawnCall?.command).toBe("claude '--dangerously-skip-permissions'")
} finally {
unregisterSshGitProvider('ssh-1')
}
})
it('matches canonical bare agent commands when a command override is configured', async () => {
const spawn = vi.fn().mockResolvedValue({ id: 'pty-bg' })
const runtimeStore = {
@@ -17184,6 +17273,53 @@ describe('OrcaRuntimeService', () => {
})
})
it('uses cmd.exe quoting for mobile agent launch commands in local Windows host runtimes', async () => {
await withPlatform('win32', async () => {
const spawn = vi.fn().mockResolvedValue({ id: 'pty-agent-cmd' })
const runtime = new OrcaRuntimeService({
...store,
getProjects: () => [
{
id: 'project-1',
displayName: 'repo',
badgeColor: 'blue',
sourceRepoIds: [TEST_REPO_ID],
localWindowsRuntimePreference: { kind: 'windows-host' },
createdAt: 0,
updatedAt: 0
}
],
getSettings: () => ({
...store.getSettings(),
disabledTuiAgents: [],
agentCmdOverrides: { 'command-code': 'command-code --profile mobile' },
agentDefaultArgs: { 'command-code': '--note "can\'t"' },
localWindowsRuntimeDefault: { kind: 'wsl', distro: 'Ubuntu' },
terminalWindowsShell: 'cmd.exe'
})
} as never)
runtime.setPtyController({
spawn,
write: () => true,
kill: () => true,
getForegroundProcess: async () => null
})
runtime.syncWindowGraph(0, { tabs: [], leaves: [] })
await runtime.createMobileSessionTerminal(`id:${TEST_WORKTREE_ID}`, {
agent: 'command-code'
})
expect(spawn).toHaveBeenCalledWith(
expect.objectContaining({
command: 'command-code --profile mobile "--note" "can\'t"',
cwd: TEST_WORKTREE_PATH,
worktreeId: TEST_WORKTREE_ID
})
)
})
})
it('publishes headless mobile session agent identity with synthesized PTY status', async () => {
const spawn = vi.fn().mockResolvedValue({ id: 'pty-agent' })
const runtime = new OrcaRuntimeService({