From 5c8f583f31f2e4450c334db929d7b996692a46cb Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Sat, 25 Jul 2026 14:34:48 -0700 Subject: [PATCH] fix(terminal): keep the hidden clock running through transient background-measure windows (C1 review #5) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Whole-worktree background mounts (browser-automation bootstrap lease, mobile mounts, agent wakes) open a ~3s self-clearing measure window that previously deleted hiddenSince — every remount restarted the 30s hysteresis and the 45min retention TTL, so a periodically re-mounted force-parked worktree never re-parked. The measure window still pauses parking/eviction verdicts (all selectors skip measuring candidates); only the clock survives, so the prior verdict resumes as soon as the window closes. Visible and portal-holding worktrees still reset the clock. Co-authored-by: Orca --- src/renderer/src/components/Terminal.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/components/Terminal.tsx b/src/renderer/src/components/Terminal.tsx index 239d471ce2f..931bdd47b0a 100644 --- a/src/renderer/src/components/Terminal.tsx +++ b/src/renderer/src/components/Terminal.tsx @@ -887,10 +887,17 @@ function Terminal(): React.JSX.Element | null { const shouldMeasureHiddenWorktree = !isVisible && measurableBackgroundWorktreeIdsRef.current.has(worktreeId) const hasActivityTerminalPortal = portalWorktreeIds.has(worktreeId) - if (isVisible || shouldMeasureHiddenWorktree || hasActivityTerminalPortal) { + if (isVisible || hasActivityTerminalPortal) { terminalWorktreeHiddenSinceRef.current.delete(worktreeId) - } else if (!terminalWorktreeHiddenSinceRef.current.has(worktreeId)) { - terminalWorktreeHiddenSinceRef.current.set(worktreeId, nowMs) + } else if (!shouldMeasureHiddenWorktree) { + // Why measuring is excluded here but still pauses the verdicts below: + // the ~3s background-measure window (automation lease, mobile mount, + // agent wake) is transient — resetting hiddenSince would restart the + // 30s hysteresis AND the 45min retention TTL on every remount, so a + // periodically re-mounted force-parked worktree would never re-park. + if (!terminalWorktreeHiddenSinceRef.current.has(worktreeId)) { + terminalWorktreeHiddenSinceRef.current.set(worktreeId, nowMs) + } } retentionCandidates.push({