diff --git a/src/features/tmux-installer/main/infrastructure/runtime/TmuxPlatformCommandExecutor.ts b/src/features/tmux-installer/main/infrastructure/runtime/TmuxPlatformCommandExecutor.ts index c0d10bbf..c0eae9c5 100644 --- a/src/features/tmux-installer/main/infrastructure/runtime/TmuxPlatformCommandExecutor.ts +++ b/src/features/tmux-installer/main/infrastructure/runtime/TmuxPlatformCommandExecutor.ts @@ -40,11 +40,15 @@ export interface RuntimeProcessTableRow { * very frequently (every team file change invalidates their per-team snapshot * caches), so without throttling here the main process spawns `ps` dozens of * times per second while a team runs. Those callers already tolerate ~2s - * staleness via their own snapshot caches, and the OS process table changes - * negligibly within a second, so a 1s window collapses the spawn storm without - * affecting liveness correctness. + * staleness via their own snapshot caches (AGENT_RUNTIME_SNAPSHOT_CACHE_TTL_MS), + * so caching the table for a SHORTER window than the consumers read it just + * re-spawns `ps` on every consumer rebuild for no freshness benefit. Match the + * 2s consumer window to collapse those redundant spawns: liveness verdicts are + * identity- (team+agent+command) not bare-PID matched, and OpenCode host cleanup + * re-validates each PID against live state before acting, so a ~2s-stale table + * cannot cause a wrong liveness call or an unsafe kill. */ -const RUNTIME_PROCESS_TABLE_CACHE_TTL_MS = 1_000; +const RUNTIME_PROCESS_TABLE_CACHE_TTL_MS = 2_000; interface RuntimeProcessTableCacheEntry { rows: RuntimeProcessTableRow[];