diff --git a/server/index.js b/server/index.js index 0887b2a..169d042 100755 --- a/server/index.js +++ b/server/index.js @@ -1730,8 +1730,14 @@ function handleShellConnection(ws) { shellCommand = 'cursor-agent'; } } else if (provider === 'codex') { + // Use codex command; attempt to resume and fall back to a new session when the resume fails. if (hasSession && sessionId) { - shellCommand = `codex resume "${sessionId}"`; + if (os.platform() === 'win32') { + // PowerShell syntax for fallback + shellCommand = `codex resume "${sessionId}"; if ($LASTEXITCODE -ne 0) { codex }`; + } else { + shellCommand = `codex resume "${sessionId}" || codex`; + } } else { shellCommand = 'codex'; } @@ -1765,7 +1771,11 @@ function handleShellConnection(ws) { // Claude (default provider) const command = initialCommand || 'claude'; if (hasSession && sessionId) { - shellCommand = `claude --resume "${sessionId}"`; + if (os.platform() === 'win32') { + shellCommand = `claude --resume "${sessionId}"; if ($LASTEXITCODE -ne 0) { claude }`; + } else { + shellCommand = `claude --resume "${sessionId}" || claude`; + } } else { shellCommand = command; }