perf: large threads open from a viewport snapshot, and typing and streaming render less #18220
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
juliusmarminge added labelsmacroscope-review
- apps/web/src/components/chat/ChatComposer.tsx line 4595OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -4456,4 +4589,7 @@44564589 position: promptHistoryPositionRef.current,44574590 currentPrompt: promptRef.current,44584591 });4459- if (!step) return false;4592+ if (!step) {4593+ // Past the oldest loaded prompt, a long thread still has older ones:4594+ // load the next page and step once it arrives.4595+ if (direction !== "backward" || promptHistoryPositionRef.current === null) return false;apps/web/src/components/files/useFileSaveCoordinator.ts lines 46 to 55Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -42,5 +43,7 @@4243 environmentId,4344 input: { cwd, relativePath, contents: nextContents },4445 }),45- onConfirmed: (confirmedContents) =>46- confirmProjectFileQueryData(environmentId, cwd, relativePath, confirmedContents),46+ onConfirmed: (confirmedContents) => {47+ confirmProjectFileQueryData(environmentId, cwd, relativePath, confirmedContents);48+ invalidateReviewWorkspace(environmentId, cwd);49+ },apps/web/src/components/ChatView.tsx lines 2240 to 2240OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2230,3 +2237,4 @@22302237 );22312238 const isServerThread = serverThread !== null;22322239 const activeThread = isServerThread ? serverThread : localDraftThread;2240+ const hasActiveThread = activeThread !== null;
- apps/web/src/components/chat/ChatComposer.tsx line 4280Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -4468,9 +4621,13 @@44684621 composerPreviewAnnotations.length,44694622 composerReviewComments.length,44704623 isComposerApprovalState,4624+ onLoadOlderPromptHistory,44714625 pendingUserInputs.length,44724626 promptRef,44734627 replacePromptFromHistory,44744628 ],44754629 );447646304631+ useEffect(() => {4632+ const pending = olderPromptRecallPendingRef.current;4633+ if (pending === null) return;
- @@ -3343,5 +3401,20 @@33433401 WHERE thread_id = ${threadId}33443402 AND (status IN ('pending','capturing')33453403 OR checkpoint_id IN (SELECT value FROM json_each(${cohortCheckpointIds}))33463404 OR run_id IN (SELECT value FROM json_each(${cohortRunIds}))3347- OR node_id IN (SELECT value FROM json_each(${cohortNodeIds})))3405+ OR node_id IN (SELECT value FROM json_each(${checkpointNodeIds}))3406+ -- A viewport keeps the runs of the latest user turns listed for3407+ -- the Diff panel and Review, bounded like a turn-aligned window:3408+ -- from the run of the twelfth latest user turn (a page plus3409+ -- two), or every run when there are fewer. Wake-up runs ride3410+ -- along without using up the turn budget. With no user turn3411+ -- among the latest turns, only the window's own runs are listed.3412+ -- Their file lists arrive with the rows' history page.3413+ OR (${window.deferHistoricalSupport ? 1 : 0} = 1 AND app_run_ordinal >= (3414+ WITH turn_starts AS (3415+ SELECT run.ordinal AS run_ordinal,3416+ json_extract(item.payload_json, '$.createdBy') = 'user' AS by_user3417+ FROM orchestration_v2_projection_turn_items AS item3418+ JOIN orchestration_v2_projection_runs AS run ON run.run_id = item.run_id3419+ WHERE item.thread_id = ${threadId}3420+ AND item.type = 'user_message'
juliusmarminge assignedjuliusmarminge
juliusmarminge closed this
Sign in to join this conversation.

Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline: unavailable · PR result:
7f2c3cf· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.