Desktop: cold resume paints the REST transcript before a slow session.resume settles (salvage #90130) - #101227
Merged
Conversation
…e session.resume settles The REST prefetch and the gateway `session.resume` already ran concurrently, but the prefetch result was held until the runtime resume settled. A cold profile build (skills / MCP / memory) can keep `session.resume` pending past the hydration budget while the complete transcript is already in hand, so a Bot Chat sat on the loader and burned its retries with readable history off screen. - Publish the grafted REST snapshot as soon as the prefetch resolves and `isCurrentResume()` holds; the runtime path grafts only its live projection onto that same snapshot, and the post-resume `chatMessageArraysEquivalent` skip keeps reference identity when nothing changed (no second DOM build). - Stamp the eagerly painted page with persisted-display provenance on the runtime state so the warm-path gate admits it on the next switch. - REST fallback after a resume rejection skips the redundant re-publish when the early paint already shows the transcript. Live repro (Electron e2e, session.resume stalled 25s via a temporary backend shim): main never painted within 20s; with this fix the transcript painted 150ms after the row click. Supersedes #90130. Co-authored-by: Alexandre Roumieu <269586168+alexandreroumieu-codeapprentice@users.noreply.github.com>
૮ >ﻌ< ა ci reviewran on bb6636c — fix(desktop): cold resume paints the prefetched REST transcr
|
This was referenced Sep 2, 2026
12 of 19 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Opening a persisted session whose runtime
session.resumeis slow (cold profile build: skills / MCP / memory) now paints the REST transcript as soon as it arrives instead of holding it off screen until the resume RPC settles.Root cause: the prefetch and
session.resumealready ran concurrently, but the prefetched page was only applied afterawait resumePromise. A cold build could hold that await past the Bot Chat hydration budget, so a session with fully readable history sat on the loader and burned its retries. Later mitigations (retryHydrationTimeoutOnce, 60s hydration timeout) retry longer but never paint early.Supersedes #90130 — reimplemented on current
mainwith the same design (early paint under theisCurrentResume()guard, runtime path grafts only its live projection, reference-identity skip after resume). Credit to @alexandreroumieu-codeapprentice, co-authored on the commit.Changes
use-session-actions/index.ts: publish the grafted REST snapshot when the prefetch resolves andisCurrentResume()holds (beforeawait resumePromise); the post-resumechatMessageArraysEquivalentskip keeps reference identity when the acknowledgement changes nothing.persisted-displaytranscript provenance on the runtime state, so the warm-path "hold unproven warm transcripts off the view" gate (b6eb17d) admits it on the next switch.use-session-actions.test.tsx: one new test — REST paints before a deferredsession.resumesettles and the painted array survives (same reference, latch clear) when that resume later rejects. The existing 500-message deferred-resume test now asserts pre-acknowledgement paint + identical reference afterwards.Validation
session.resumestalled 25s (temporary backend shim, not committed)[]while resume pending)e2e/large-session-resume.spec.ts(paint-count budget, one user row)use-session-actions.test.tsx(96) +transcript-provenance.test.tstsc --noEmit,eslinton touched filesLive repro: Electron e2e (built
dist/, real backend, seeded session viaRealSessionBuilder,session.resumehandler stalled 25s via an env-gated sleep) — before: viewport stayed empty for the full 20s window on main; after:E2E stall user message 4visible at 150ms while the resume RPC was still pending.Infographic