diff --git a/src/renderer/src/components/terminal-pane/pty-transport.ts b/src/renderer/src/components/terminal-pane/pty-transport.ts index e06a4c6eac7..f385ddd2b36 100644 --- a/src/renderer/src/components/terminal-pane/pty-transport.ts +++ b/src/renderer/src/components/terminal-pane/pty-transport.ts @@ -76,6 +76,7 @@ export const MAX_PENDING_PTY_SIDE_EFFECTS = 512 // Why: agent status is last-wins store state, but payloads can carry KB-scale prompt/tool strings; // carry only the newest few through eviction so a status flood cannot re-grow what it evicted. export const MAX_EVICTED_AGENT_STATUS_PAYLOAD_CARRY = 16 +const MAX_EVICTED_AGENT_TITLE_TRANSITION_CARRY = 3 type PtyOutputCallbacks = Parameters[0]['callbacks'] @@ -218,7 +219,7 @@ export function createPtyOutputProcessor({ continue } evictedAgentTitleTransitions.push({ phase, title }) - if (evictedAgentTitleTransitions.length > 3) { + if (evictedAgentTitleTransitions.length > MAX_EVICTED_AGENT_TITLE_TRANSITION_CARRY) { evictedAgentTitleTransitions.shift() } } diff --git a/src/renderer/src/components/terminal-pane/terminal-eviction-exempt-tabs.test.ts b/src/renderer/src/components/terminal-pane/terminal-eviction-exempt-tabs.test.ts index bcb3f55310b..d6318c89869 100644 --- a/src/renderer/src/components/terminal-pane/terminal-eviction-exempt-tabs.test.ts +++ b/src/renderer/src/components/terminal-pane/terminal-eviction-exempt-tabs.test.ts @@ -56,6 +56,21 @@ describe('selectEvictionExemptTerminalTabLayoutKey', () => { ) }) + it('is stable across leaf-map insertion order', () => { + const first = layoutState({ + [LEAF_ID]: PTY_ID, + [SECOND_LEAF_ID]: 'pty-local-detached' + }) + const reversed = layoutState({ + [SECOND_LEAF_ID]: 'pty-local-detached', + [LEAF_ID]: PTY_ID + }) + + expect(selectEvictionExemptTerminalTabLayoutKey(first, TABS)).toBe( + selectEvictionExemptTerminalTabLayoutKey(reversed, TABS) + ) + }) + it('tolerates tabs with no persisted layout', () => { expect(selectEvictionExemptTerminalTabLayoutKey({ terminalLayoutsByTabId: {} }, TABS)).toBe( JSON.stringify([[TAB_ID, []]])