diff --git a/src/servers/api/command-hq/router.ts b/src/servers/api/command-hq/router.ts index f4d1456a..3d77735d 100644 --- a/src/servers/api/command-hq/router.ts +++ b/src/servers/api/command-hq/router.ts @@ -15,6 +15,7 @@ import { loopPidPath, spawnedRecordPath, stopCommanderProcesses, + liveLoopPid, } from './spawned'; import type { ServerMessage } from '../chat/types'; import { @@ -255,7 +256,10 @@ commandHqRouter.get('/commanders', async (ctx) => { categoryId: row.categoryId, tagIds: tagsByRow.get(row.id) ?? [], running: runningById.get(row.sessionId) ?? false, - watcherArmed: row.watcherArmed, + // The pid file is the FACT; `watcher_armed` is a claim only one path sets. A commander that started + // its loop as a plain background job recorded its pid correctly and still reported unarmed, so the + // grid offered nothing to stop — which is the one thing this column exists to make possible. + watcherArmed: row.watcherArmed || liveLoopPid(who.email, row.sessionId) !== null, watcherArmedAt: row.watcherArmedAt, watcherStoppedAt: row.watcherStoppedAt, watcherLastFiredAt: lastFiredByRow.get(row.id) ?? null, @@ -401,7 +405,7 @@ commandHqRouter.get('/commanders/:sessionId', async (ctx) => { categoryId: row.categoryId, tagIds: tagsByRow.get(row.id) ?? [], running, - watcherArmed: row.watcherArmed, + watcherArmed: row.watcherArmed || liveLoopPid(who.email, row.sessionId) !== null, watcherArmedAt: row.watcherArmedAt, watcherStoppedAt: row.watcherStoppedAt, watcherLastFiredAt: lastFiredByRow.get(row.id) ?? null,