From f96c672a9e57a7bc79b39474a710edaa4ffb44a2 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Fri, 16 Oct 2026 14:17:59 -0700 Subject: [PATCH] fix(hibernation): never hibernate floating-workspace terminals (#29790) * fix(hibernation): never hibernate floating-workspace terminals * docs(hibernation): clarify floating terminal idle policy --------- Co-authored-by: m4air --- .../src/lib/agent-hibernation-planner.test.ts | 16 ++++++++++++++++ .../src/lib/agent-hibernation-planner.ts | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/src/renderer/src/lib/agent-hibernation-planner.test.ts b/src/renderer/src/lib/agent-hibernation-planner.test.ts index c0c83e16c6b..4e327184de0 100644 --- a/src/renderer/src/lib/agent-hibernation-planner.test.ts +++ b/src/renderer/src/lib/agent-hibernation-planner.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from 'vitest' import type { AgentStatusEntry } from '../../../shared/agent-status-types' +import { FLOATING_TERMINAL_WORKTREE_ID } from '../../../shared/constants' import type { TerminalLayoutSnapshot, TerminalTab } from '../../../shared/terminal-tab-types' import { DEFAULT_AGENT_HIBERNATION_IDLE_MS, @@ -101,6 +102,21 @@ describe('agent sleep planner', () => { expect(plannedWorktrees(snapshot({ foregroundTerminalTabIds: ['tab-1'] }))).toEqual([]) }) + it('never plans automatic hibernation for a floating-workspace pane', () => { + expect(plannedWorktrees(snapshot())).toEqual(['wt-bg']) + const floating = entry({ worktreeId: FLOATING_TERMINAL_WORKTREE_ID }) + expect( + plannedWorktrees( + snapshot({ + tabsByWorktree: { + [FLOATING_TERMINAL_WORKTREE_ID]: [tab('tab-1', FLOATING_TERMINAL_WORKTREE_ID)] + }, + agentStatusByPaneKey: { [floating.paneKey]: floating } + }) + ) + ).toEqual([]) + }) + it('requires done resumable provider-session entries', () => { for (const state of ['working', 'waiting', 'blocked'] as const) { const e = entry({ state }) diff --git a/src/renderer/src/lib/agent-hibernation-planner.ts b/src/renderer/src/lib/agent-hibernation-planner.ts index 410fb393043..f5094bd0ed0 100644 --- a/src/renderer/src/lib/agent-hibernation-planner.ts +++ b/src/renderer/src/lib/agent-hibernation-planner.ts @@ -1,4 +1,5 @@ import type { AgentStatusEntry } from '../../../shared/agent-status-types' +import { FLOATING_TERMINAL_WORKTREE_ID } from '../../../shared/constants' import type { TerminalTab } from '../../../shared/terminal-tab-types' import { getEligiblePane, @@ -119,6 +120,10 @@ export function planAgentHibernationCandidates( if (!worktreeId || tabs.length === 0) { continue } + // Floating terminals stay running when idle; the user must not need a hibernation resume. + if (worktreeId === FLOATING_TERMINAL_WORKTREE_ID) { + continue + } if ( runtimeLivenessRequiredWorktreeIds.has(worktreeId) && !Object.hasOwn(snapshot.runtimeLivePtyIdsByWorktreeId ?? {}, worktreeId)