fix(terminal): quote agent resume for the tab's real Windows shell (cmd.exe) (#12476)
* fix(terminal): quote agent resume commands for the tab's real Windows shell
Cold restore and sleeping-agent resume built their launch line without the
host shell family, so win32 fell back to PowerShell argv quoting. On cmd.exe
tabs those quotes arrived literally and agent CLIs rejected the resume argv
and permission flags after a reboot ("unexpected argument ''<uuid>'' found").
Both call sites now share resolveAgentResumeLaunchTarget, which resolves the
launch platform and the live shell family together via
resolveLocalWindowsAgentStartupShell, honoring a per-tab shell override for
cold restore and leaving SSH / remote-runtime / WSL workspaces on their own
default quoting.
Fixes #12320
Co-authored-by: Orca <help@stably.ai>
* test(shared): cover cmd.exe resume quoting at the plan layer
Adopted from #12321 by @CountClaw.
Co-authored-by: Orca <help@stably.ai>
---------
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
@@ -593,6 +593,40 @@ describe('tui agent startup plans', () => {
|
||||
expect(plan?.launchCommand).toBe("codex 'resume' 's1'")
|
||||
})
|
||||
|
||||
it('quotes Windows resume argv for cmd.exe when shell is cmd', () => {
|
||||
const plan = buildAgentResumeStartupPlan({
|
||||
agent: 'grok',
|
||||
providerSession: { key: 'session_id', id: '019fc272-80fa-7a91-80a2-9c461ef1a9da' },
|
||||
cmdOverrides: {},
|
||||
agentArgs: '--permission-mode bypassPermissions',
|
||||
platform: 'win32',
|
||||
shell: 'cmd'
|
||||
})
|
||||
|
||||
// Why: cmd.exe treats single quotes as literal characters. Resume must use
|
||||
// double quotes (or unquoted tokens) so the CLI receives clean argv.
|
||||
expect(plan?.launchCommand).toBe(
|
||||
'grok "--permission-mode" "bypassPermissions" "--resume" "019fc272-80fa-7a91-80a2-9c461ef1a9da"'
|
||||
)
|
||||
})
|
||||
|
||||
it('keeps cmd-quoted agentCommand aligned with cmd resume suffix', () => {
|
||||
const plan = buildAgentResumeStartupPlan({
|
||||
agent: 'grok',
|
||||
providerSession: { key: 'session_id', id: '019fc272-80fa-7a91-80a2-9c461ef1a9da' },
|
||||
cmdOverrides: {},
|
||||
agentCommand: 'grok "--permission-mode" "bypassPermissions"',
|
||||
platform: 'win32',
|
||||
shell: 'cmd'
|
||||
})
|
||||
|
||||
// Regression: agentCommand from a prior cmd launch + PowerShell-default resume
|
||||
// suffix produced mixed quoting and broke reboot restore on cmd.exe tabs.
|
||||
expect(plan?.launchCommand).toBe(
|
||||
'grok "--permission-mode" "bypassPermissions" "--resume" "019fc272-80fa-7a91-80a2-9c461ef1a9da"'
|
||||
)
|
||||
})
|
||||
|
||||
it('honors command overrides when building POSIX resume plans', () => {
|
||||
const plan = buildAgentResumeStartupPlan({
|
||||
agent: 'codex',
|
||||
|
||||
Reference in New Issue
Block a user