fix(browse): keep agentStatus's zombie check before the generation return (terminal-agent-watchdog source pin)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
garrytanandcapy-ai[bot] committed 2026-10-28 14:17:56 +00:00
1 parent caa404d166
commit 20d7707314
1 file changed
+4 -4
+4 -4
View File
@@ -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 {