diff --git a/browse/src/terminal-agent-control.ts b/browse/src/terminal-agent-control.ts index d53dcf624..2c364e1de 100644 --- a/browse/src/terminal-agent-control.ts +++ b/browse/src/terminal-agent-control.ts @@ -368,9 +368,8 @@ function agentStatus(record: AgentRecord, ownerPid?: number): 'owned' | 'gone' | if (ownerPid !== undefined && (record.ownerPid !== ownerPid || record.ownerStartTime !== readAgentStartTime(ownerPid))) return 'unknown'; const actual = agentProcessInfo(record.pid); if (!actual.startTime) return isAgentRecordLive(record) ? 'unknown' : 'gone'; - const ownsGeneration = actual.commandLine.split(/\s+/).some(arg => arg.replace(/^['"]|['"]$/g, '') === `--agent-gen=${record.gen}`); - if (actual.startTime !== record.startTime && process.platform === 'win32' && !actual.commandLine) return 'unknown'; - if (actual.startTime !== record.startTime && !(process.platform === 'win32' && ownsGeneration)) return 'gone'; + if (actual.startTime !== record.startTime && process.platform !== 'win32') return 'gone'; + if (actual.startTime !== record.startTime && !actual.commandLine) return 'unknown'; try { let state: string | undefined; if (process.platform === 'linux') { @@ -382,7 +381,8 @@ function agentStatus(record: AgentRecord, ownerPid?: number): 'owned' | 'gone' | if (state === 'Z') return 'gone'; } catch {} if (!isAgentRecordLive(record)) return 'gone'; - return ownsGeneration ? 'owned' : 'unknown'; + return actual.commandLine.split(/\s+/).some(arg => arg.replace(/^['"]|['"]$/g, '') === `--agent-gen=${record.gen}`) + ? 'owned' : actual.startTime === record.startTime ? 'unknown' : 'gone'; } export function isOurAgent(record: AgentRecord, ownerPid?: number): boolean {