Skip to content

The agent that grows with you

fix(desktop): gate transcript budget cap so Show earlier works

Brooklyn Nicholsona24c12d14f5f
diff --git a/apps/desktop/src/components/assistant-ui/thread/list.test.ts b/apps/desktop/src/components/assistant-ui/thread/list.test.ts
index 8747bcc31ab..ebddf9ab6a3 100644
--- a/apps/desktop/src/components/assistant-ui/thread/list.test.ts
+++ b/apps/desktop/src/components/assistant-ui/thread/list.test.ts
@@ -9,6 +9,7 @@ import {
liveTailStart,
type MessageGroup,
resolveThreadScrollTarget,
+ shouldClampTranscriptBudget,
subscribeToThreadForeground,
transcriptPaneBudget
} from './list'
@@ -98,6 +99,18 @@ describe('transcriptPaneBudget', () => {
})
})
+describe('shouldClampTranscriptBudget', () => {
+ it('never snaps a visible pane back after Show earlier', () => {
+ expect(shouldClampTranscriptBudget(false, 10, 5)).toBe(false)
+ expect(shouldClampTranscriptBudget(false, 5, 5)).toBe(false)
+ })
+
+ it('snaps only a hot-hidden pane that outgrew the retention budget', () => {
+ expect(shouldClampTranscriptBudget(true, 10, 5)).toBe(true)
+ expect(shouldClampTranscriptBudget(true, 5, 5)).toBe(false)
+ })
+})
+
describe('buildGroups', () => {
it('returns no groups for an empty signature', () => {
expect(buildGroups('')).toEqual([])
diff --git a/apps/desktop/src/components/assistant-ui/thread/list.tsx b/apps/desktop/src/components/assistant-ui/thread/list.tsx
index 94afcf04744..5d7e43d3b9a 100644
--- a/apps/desktop/src/components/assistant-ui/thread/list.tsx
+++ b/apps/desktop/src/components/assistant-ui/thread/list.tsx
@@ -105,6 +105,13 @@ export const transcriptPaneBudget = (mountedPanes: number, hidden: boolean): num
hidden
? HIDDEN_TRANSCRIPT_RENDER_BUDGET
: Math.max(Math.ceil(RENDER_BUDGET / Math.max(1, mountedPanes)), RENDER_BUDGET / 4)
+
+// "Show earlier" raises renderBudget ABOVE paneBudget (one pane page per click).
+// The render-phase cap must only snap a hot-hidden pane down to its retention
+// budget — a visible pane's growth has to survive the next render or the click
+// is a no-op. Parked panes are unmounted, so they never hit this path.
+export const shouldClampTranscriptBudget = (hidden: boolean, renderBudget: number, paneBudget: number): boolean =>
+ hidden && renderBudget > paneBudget
// Units the backfill adds per committed step (see the backfill effect). ~8-15
// ordinary turns or 1-2 tool-heavy ones per frame — big enough to fill a page
// in ~10 frames, small enough that no single commit approaches a frame budget.
@@ -433,7 +440,7 @@ const ThreadMessageListInner: FC<ThreadMessageListProps> = ({
setBudgetSessionKey(sessionKey)
setHadGroups(hasGroups)
setRenderBudget(FIRST_PAINT_BUDGET)
- } else if (renderBudget > paneBudget) {
+ } else if (shouldClampTranscriptBudget(paneLifecycle === 'hot-hidden', renderBudget, paneBudget)) {
// Apply the hidden budget during render so React never first commits the
// stale full transcript after this pane moves to the background.
setRenderBudget(paneBudget)
@@ -692,14 +699,13 @@ const ThreadMessageListInner: FC<ThreadMessageListProps> = ({
}
anchorBeforePrepend()
+ // Both paths grow the DOM budget by one pane page. Windowed rows are older
+ // than the current page, so expand-without-grow paints nothing.
+ setRenderBudget(budget => budget + paneBudget)
- if (action === 'dom') {
- setRenderBudget(budget => budget + paneBudget)
-
- return
+ if (action === 'window') {
+ expandWindow()
}
-
- expandWindow()
}, [anchorBeforePrepend, expandWindow, hiddenCount, olderAvailable, paneBudget])
useLayoutEffect(() => {