Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(chat): retain history and smooth late-card return to latest
new-Beginner0a25866a275e
diff --cc apps/desktop/src/features/chat/transcript/hooks/useTranscriptLatestNavigation.tsindex c87fae4b6,c87fae4b6..5183edf2a--- a/apps/desktop/src/features/chat/transcript/hooks/useTranscriptLatestNavigation.ts+++ b/apps/desktop/src/features/chat/transcript/hooks/useTranscriptLatestNavigation.ts@@@ -10,6 -10,6 +10,18 @@@ export function useTranscriptLatestNaviposition.current = onPosition;const [navigation] = useState(() => createTranscriptLatestNavigation({geometry: () => scrollRef.current ?? undefined,++ captureAnchor: () => {++ const scroller = scrollRef.current;++ if (!scroller) return;++ const rect = scroller.getBoundingClientRect();++ const node = scroller.ownerDocument.elementFromPoint(++ rect.left + rect.width / 2, rect.top + Math.min(rect.height / 2, 120),++ )?.closest<HTMLElement>(".prose-chat p, .prose-chat li, .prose-chat pre, [data-message-id], [data-minimap-id]");++ if (!node || !scroller.contains(node)) return;++ const measure = () => node.isConnected && scroller.contains(node)++ ? node.getBoundingClientRect().top + scroller.scrollTop : undefined;++ return { top: measure() ?? 0, measure };++ },move: top => {const scroller = scrollRef.current;if (!scroller) return;diff --cc apps/desktop/src/lib/transcript-latest-navigation.tsindex 722420d3b,49206b108..f865b8787--- a/apps/desktop/src/lib/transcript-latest-navigation.ts+++ b/apps/desktop/src/lib/transcript-latest-navigation.ts@@@ -1,13 -1,13 +1,17 @@@type Geometry = { scrollTop: number; scrollHeight: number; clientHeight: number };++type LayoutAnchor = { top: number; measure: () => number | undefined };type ScrollPort = {geometry: () => Geometry | undefined;++ captureAnchor?: () => LayoutAnchor | undefined;move: (top: number) => void;request: (frame: (now: number) => void) => number;cancel: (frame: number) => void;now: () => number;reducedMotion: () => boolean;};- type Navigation = { from: number; startedAt: number; duration: number; lastTop: number; arrive: () => void };-type Navigation = { distance: number; startedAt: number; duration: number; arrive: () => void };++type Navigation = {++ remaining: number; anchor?: LayoutAnchor; startedAt: number; duration: number; arrive: () => void;++};/** One viewport owner for a short, interruptible trip through mounted content. */export function createTranscriptLatestNavigation(port: ScrollPort) {@@@ -27,7 -27,7 +31,7 @@@const target = Math.max(0, geometry.scrollHeight - geometry.clientHeight);const distance = Math.max(0, target - geometry.scrollTop);if (port.reducedMotion() || distance <= 1) { port.move(target); arrive(); return; }- const navigation: Navigation = { from: geometry.scrollTop, lastTop: geometry.scrollTop,- const navigation: Navigation = { distance,++ const navigation: Navigation = { remaining: 1, anchor: port.captureAnchor?.(),startedAt: port.now(), duration: Math.min(420, Math.max(180, distance / 30)), arrive };current = navigation;const advance = (now: number) => {@@@ -37,12 -37,12 +41,17 @@@if (!box || box.clientHeight <= 0) { cancel(true); return; }const bottom = Math.max(0, box.scrollHeight - box.clientHeight);const progress = Math.min(1, Math.max(0, (now - navigation.startedAt) / navigation.duration));-- const eased = 1 - (1 - progress) ** 3;- // Retarget late content growth without reversing the reader's movement.- const top = Math.min(bottom, Math.max(navigation.lastTop,- navigation.from + (bottom - navigation.from) * eased));- navigation.lastTop = top;- // Animate remaining viewport distance, not an absolute document offset.- // Lazy layout above the reader shifts both the target and the visible- // content; compensate that shift in full rather than easing it as motion.- const top = Math.max(0, bottom - navigation.distance * (1 - eased));-- port.move(top);++ const remaining = (1 - progress) ** 3;++ // Only actual displacement of visible content is layout compensation.++ // Growth below it (for example a changes card) extends the destination++ // and must be traversed, not applied as an instantaneous position jump.++ const measured = navigation.anchor?.measure();++ const shift = measured === undefined ? 0 : measured - (navigation.anchor?.top ?? measured);++ const origin = box.scrollTop + shift;++ const fraction = 1 - remaining / navigation.remaining;++ port.move(Math.max(0, Math.min(bottom, origin + (bottom - origin) * fraction)));++ navigation.remaining = remaining;++ navigation.anchor = port.captureAnchor?.();if (progress === 1) {current = undefined;navigation.arrive();diff --cc apps/desktop/src/stores/runtime/transcript-reading-runtime.tsindex 91f01bf02,91f01bf02..a1e93d138--- a/apps/desktop/src/stores/runtime/transcript-reading-runtime.ts+++ b/apps/desktop/src/stores/runtime/transcript-reading-runtime.ts@@@ -53,7 -53,7 +53,7 @@@ export function createTranscriptReadingset((state) => ({ transcriptViews: { ...state.transcriptViews, [sessionId]: view } }));}-- function returnToLatestTranscript(sessionId: string) {++ function clearTranscriptView(sessionId: string) {set((state) => {if (!state.transcriptViews[sessionId]) return {};const { [sessionId]: _released, ...transcriptViews } = state.transcriptViews;@@@ -61,17 -61,17 +61,26 @@@});}++ function returnToLatestTranscript(sessionId: string) {++ const state = get();++ const view = state.transcriptViews[sessionId];++ if (!view) return;++ const live = state.activeSessionId === sessionId++ ? state.messages : (state.retainedTranscripts[sessionId] ?? EMPTY_TRANSCRIPT);++ // Keep pages that extend the live tail, without joining across an unread++ // search/bookmark gap or copying historical data into the model cache.++ if (!view.hasMoreAfter && view.messages.findIndex(row => row.id === live[0]?.id) > 0) {++ publish(sessionId, { ...view, focus: null, restored: false, loading: null });++ } else clearTranscriptView(sessionId);++ }++function prepareReturnToLatestTranscript(sessionId: string): () => void {const current = get().transcriptViews[sessionId];if (!current) return () => {};const prepared: TranscriptView = { ...current, loading: null };publish(sessionId, prepared);return () => {-- set((state) => {-- if (state.transcriptViews[sessionId] !== prepared) return {};-- const { [sessionId]: _released, ...transcriptViews } = state.transcriptViews;-- return { transcriptViews };-- });++ if (get().transcriptViews[sessionId] === prepared) returnToLatestTranscript(sessionId);};}@@@ -230,7 -230,7 +239,8 @@@!(view.restored && previous.selectingSessionId === id) &&state.messages !== previous.messages &&transcriptWasRewritten(previous.messages, state.messages);-- if (evicted || started || rewritten) returnToLatestTranscript(id);++ if (evicted || rewritten) clearTranscriptView(id);++ else if (started) returnToLatestTranscript(id);}}diff --cc apps/desktop/test/transcript-latest-navigation.test.mjsindex 2c9b283f4,d46713285..67c498865--- a/apps/desktop/test/transcript-latest-navigation.test.mjs+++ b/apps/desktop/test/transcript-latest-navigation.test.mjs@@@ -11,23 -11,23 +11,26 @@@ function fixture(reduced = false)let now = 0;let id = 0;let arrivals = 0;++ let contentShift = 0;const navigation = createTranscriptLatestNavigation({geometry: () => box,++ captureAnchor: () => ({ top: contentShift, measure: () => contentShift }),move: top => { box.scrollTop = top; positions.push(top); },request: callback => { frames.set(++id, callback); return id; },cancel: id => frames.delete(id),now: () => now,reducedMotion: () => reduced,});-- const advance = () => {-- now += 16;++ const advance = (elapsed = 16) => {++ now += elapsed;const batch = [...frames.values()];frames.clear();for (const frame of batch) frame(now);};const finish = () => { for (let n = 0; navigation.isActive() && n < 60; n++) advance(); };return { box, navigation, positions, frames, advance, finish,-- start: () => navigation.start(() => arrivals++), arrivals: () => arrivals };++ start: () => navigation.start(() => arrivals++), arrivals: () => arrivals,++ shiftAbove: delta => { contentShift += delta; box.scrollHeight += delta; } };}test("latest moves continuously to bottom before committing the new view", () => {@@@ -55,6 -55,6 +58,22 @@@ test("late stream growth retargets theassert.equal(f.arrivals(), 1);});++test("a late changes card below the reader retargets without an instantaneous height jump", () => {++ const baseline = fixture();++ const changed = fixture();++ baseline.start(); changed.start();++ baseline.advance(); changed.advance();++ changed.box.scrollHeight += 37;++ baseline.advance(0); changed.advance(0);++ assert.equal(changed.box.scrollTop, baseline.box.scrollTop,++ "footer growth is a new destination, not displacement above visible text");++ baseline.advance(); changed.advance();++ assert(changed.box.scrollTop - baseline.box.scrollTop < 37);++ changed.finish();++ assert.equal(changed.box.scrollTop, 7437);++ assert.equal(changed.arrivals(), 1);++});++test("reader interruption retires every queued frame without committing latest", () => {const f = fixture();f.start(); f.advance();@@@ -86,3 -86,20 +105,20 @@@ test("reduced motion reaches bottom synassert.equal(f.arrivals(), 1);assert.equal(f.frames.size, 0);});++ for (const delta of [2400, -1200]) {+ test(`layout above the reader (${delta}px) does not alter latest's visible trajectory`, () => {+ const baseline = fixture();+ const changed = fixture();+ baseline.start(); changed.start();+ baseline.advance(); changed.advance();- changed.box.scrollHeight += delta;++ changed.shiftAbove(delta);+ baseline.advance(); changed.advance();+ const remaining = f => f.box.scrollHeight - f.box.clientHeight - f.box.scrollTop;+ assert(Math.abs(remaining(changed) - remaining(baseline)) <= 1,+ `layout must be compensated, not interpolated: ${remaining(changed)} vs ${remaining(baseline)}`);+ baseline.finish(); changed.finish();+ assert.equal(remaining(changed), 0);+ assert.equal(changed.arrivals(), 1);+ });+ }diff --cc apps/desktop/test/transcript-reading.test.mjsindex 4d9c7bd74,4d9c7bd74..f593277da--- a/apps/desktop/test/transcript-reading.test.mjs+++ b/apps/desktop/test/transcript-reading.test.mjs@@@ -208,6 -208,6 +208,41 @@@ test("ordinary history uses the same paassert.equal(r.visible().at(-1).content, "partial");});++for (const prepared of [false, true]) {++ test(`${prepared ? "animated" : "immediate"} latest preserves loaded pages, their cursor and live updates`, async () => {++ const rows = Array.from({ length: 30 }, (_, i) => message(`row-${i}`));++ const calls = [];++ const r = reader(async (_id, options) => {++ calls.push(options.messageBefore);++ const end = options.messageBefore;++ return page(rows.slice(Math.max(0, end - 10), end), {++ messageStart: Math.max(0, end - 10), messageEnd: end,++ hasMoreBefore: end > 10, hasMoreAfter: true,++ });++ }, {++ messages: rows.slice(20),++ sessionHistory: { s: { messageStart: 20, hasMoreBefore: true } },++ });++ const live = r.get().messages;++ await r.loadTranscriptPage("s", "before");++ const before = r.visible().map(row => row.id);++ if (prepared) r.prepareReturnToLatestTranscript("s")();++ else r.returnToLatestTranscript("s");++ assert.deepEqual(r.visible().map(row => row.id), before, "arrival must not discard a loaded page");++ assert.equal(r.view().focus, null);++ assert(!r.view().restored);++ assert.equal(r.get().messages, live, "old pages never become model input");++ r.set({ runningSessions: { s: true }, messages: [...live, message("stream", "new output")] });++ assert.equal(r.visible().at(-1).content, "new output");++ await r.loadTranscriptPage("s", "before");++ assert.deepEqual(calls, [20, 10], "continue beyond retained pages instead of rereading cursor 20");++ assert.equal(r.visible().length, 31);++ r.set({ runningSessions: {} });++ r.set({ messages: [message("rewritten")] });++ assert.equal(r.view(), undefined, "authoritative rewrites still invalidate the old pages");++ });++}++test("search supersedes an ordinary page and return-to-latest cancels historical paging", async () => {const older = deferred();const later = deferred();diff --cc docs/adr/0130-bounded-mounted-transcript-window.mdindex a4f5b8f12,af67c6eef..fd15ceebd--- a/docs/adr/0130-bounded-mounted-transcript-window.md+++ b/docs/adr/0130-bounded-mounted-transcript-window.md@@@ -131,18 -140,22 +140,22 @@@ and the `session.get` window contract a## Implementation notes- - **Gesture-driven ahead-loading vs. hard-edge lock:** A real upward scroll- gesture within `min(2400px, max(120px, 3 * clientHeight))` starts single-flight- escalation in the background, still mounting cached withheld rows before- requesting a Host page. Background escalation leaves `overflow-y` and main- scroll input unlocked, updates its actual-message reading anchor as the user- continues scrolling, and subtracts observed scroll displacement from its- viewport offset before correcting geometry changes. This preserves compositor- movement even when lazy rows lay out before their scroll event. Reaching `<= 120px`,- invoking the earlier-history continuation, or intersecting the `120px` top- boundary retains the brief input/`overflow-y: hidden` lock through IO and- three consecutive stable layout frames. Failed or empty reads release any lock- and wait for a new scroll gesture or explicit earlier-history action.+ - **Adaptive, gesture-driven ahead-loading:** The base lead is+ `min(2400px, max(120px, 3 * clientHeight))`. Upward speed in pixels/ms times+ measured page latency plus a `150ms` commit margin can increase that lead,+ capped at `max(base, min(12000px, 12 * clientHeight))`. Single-flight+ escalation still mounts cached withheld rows before requesting a Host page.+ No early-threshold observer drains pages at rest. All escalation paths,+ including the hard edge and explicit continuation, leave overflow and input+ untouched. The actual-message anchor subtracts observed scroll displacement+ before correcting layout, preserving compositor movement even when lazy rows+ lay out before their scroll event. A transaction settles after three stable+ layout frames. Failed or empty reads wait for new input or an explicit retry.-- **Layout-independent latest trajectory:** Animate remaining distance to the- current bottom, not an absolute initial scroll coordinate. Height changes- above the reader must not be multiplied into the remaining animation. Tests- separate legitimate final travel from history-to-live commit drift and use- nonempty layout-complete samples for delayed-layout stability (`<= 2px`).++- **Layout-independent latest trajectory:** Advance from the current position++ through the remaining easing interval. A measured visible-content anchor++ compensates layout displacement above the reader; growth below it, including++ a turn-changes card, extends the destination instead of instantly shifting++ the reader. Tests distinguish final animation travel from arrival drift.- **Interruptible return-to-latest:** Returning to latest uses one customviewport animation (`180–420ms` cubic ease-out, monotonic retargeting acrosslate stream growth; immediate under `prefers-reduced-motion: reduce`) instead@@@ -153,11 -166,21 +166,23 @@@zero-delta, or `Ctrl`+wheel input and nested scrollers, editable fields, orrow controls do not. Preparing return-to-latest from a historical`transcriptViews` slice replaces its identity with `loading: null` while-- keeping current messages mounted, clears that exact prepared view only on-- arrival, and commits on pane hide or unmount; disjoint search/history ranges++ keeping current messages mounted, exits that exact view's historical ownership++ on arrival, and commits on pane hide or unmount; tail-connected older pages and++ cursors remain available, while disjoint search/history rangesjoin the canonical live tail on arrival without fetching or animating unloadedintermediate ranges. Runtime `isRunning` state passed to scroll hooks staysreal rather than faked stopped by a historical view.- - **Cache invariants:** Existing message, page, mounted-window, recent snapshot,- and retained session-pane caches are unchanged; no idle TTL or memory- reclamation is introduced.+ - **Measured prose window:** `TranscriptProse` preserves the existing prose and+ message shells. At the current width, measured offscreen prose becomes an+ equal-height placeholder beyond five viewport heights; it remounts within+ three. Streaming, focused, selected, and search-target prose stays mounted.+ Missing measurements or a changed width require rendering again rather than+ guessing a height. Explicitly collapsed disclosure scopes release their+ Markdown without changing stored disclosure choices. One observer and frame+ scheduler per viewport handles scroll, resize, focus, and selection, and is+ disposed when its last shell leaves.-- **Cache invariants:** Message, page, mounted-row-window, recent snapshot, and- retained session-pane data caches are unchanged. There is no idle TTL or- session-data reclamation; viewport-driven Markdown unmounting is independent- of those caches and does not initiate history reads.++- **Cache invariants:** Returning to latest retains older pages connected to++ the canonical live tail, without hydrating model input or retaining historical++ focus. Disjoint snapshots still release to live; pane eviction and canonical++ rewrites invalidate old pages. Mounted-row bounds and prose recycling remain++ independent; no idle TTL or unrelated cache reclamation is introduced.diff --cc docs/spec/04-ux/09-interaction-patterns.mdindex d07429321,d4752e46d..ecfa1be20--- a/docs/spec/04-ux/09-interaction-patterns.md+++ b/docs/spec/04-ux/09-interaction-patterns.md@@@ -846,8 -846,8 +846,10 @@@ may be retained while exactly one worksowners until it settles or is cancelled. Record the pinned bookmarksynchronously and prepare any active historical `transcriptViews` slice byreplacing its identity with `loading: null` while keeping visible messages-- mounted; only that exact prepared view's arrival closure clears the historical-- view, while pane hide or unmount commits the accepted latest intent once++ mounted; only that exact prepared view's arrival closure exits historical++ ownership. Tail-connected older pages and their cursor remain available for++ later upward reading, without entering model input; live output remains++ authoritative. Pane hide or unmount commits the accepted latest intent oncewithout continuing an invisible animation. Explicit disjoint search or historyviews animate across currently mounted rows and join the canonical live tailon arrival without fetching or animating unloaded intermediate ranges.@@@ -855,6 -855,6 +857,9 @@@restoring the old reading offset; manual upward reading without return-to-latestretains its position, and reader interruption cancels the animation in placewithout committing arrival.++ During travel, compensate actual visible-content displacement above the++ reader. Added height below it, including a late turn-changes card, extends the++ destination and is traversed by the remaining animation, not an instant jump.- Stream completion (D676): if the user was following a turn that completes,its prompt scrolls to 16px below the titlebar band at the top of theviewport so the answer reads from its start, follow mode is released, anddiff --cc docs/spec/06-delivery/04-e2e-test-plan.mdindex 7a36ba428,72c98b5f4..9fd88396d--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@@ -13578,6 -13567,6 +13578,9 @@@ This test plan spec is accepted whenzero-delta, or `Ctrl`+wheel input and nested/editable/row controls. While apage is pending, return to latest, complete the old page, and also testhiding/unmounting mid-trip.++ 5. Return after loading older pages, then scroll upward again. Reveal a real++ turn-changes card during the trip and compare with layout growth above the++ visible text. Continue with live output and a canonical rewrite.- **Expected**: Ahead-loading mounts cached withheld history before Host IO,stays single-flight, does not set `overflow-y: hidden` or discard main scrollinput, tracks the newest actual message anchor across ongoing upward movement,@@@ -13593,9 -13582,9 +13596,13 @@@clears `loading` on a new view identity while keeping current messages visibleuntil exact-identity arrival, commits on hide/unmount, cancels in place onlyon genuine main-scroller input, and may skip unloaded intermediate ranges when-- a disjoint search/history view joins the live tail. Runtime `isRunning` stays-- real, and existing message/page/mounted-window/retained-pane caches remain-- unchanged without idle TTL or memory reclamation.++ a disjoint search/history view joins the live tail. Tail-connected older pages++ and their physical cursor survive arrival, so upward reading does not repeat++ covered reads; they remain outside model input and accept live updates. Pane++ eviction and canonical rewrites still invalidate them. Height added below++ visible text extends the destination without a full-height instantaneous jump;++ actual displacement above text is compensated. Runtime `isRunning` stays real;++ mounted-window bounds remain unchanged, without idle TTL or reclamation.- **Automation**: `node scripts/e2e-transcript-history-loading.mjs`, also run by`e2e-transcript-render.mjs`, plus `transcript-latest-navigation.test.mjs`,`transcript-reading.test.mjs`, and `transcript-scroll.test.mjs`. The directdiff --cc scripts/e2e/transcript-history-navigation.tsxindex 99b620efa,1ebfd3728..ca09dfeda--- a/scripts/e2e/transcript-history-navigation.tsx+++ b/scripts/e2e/transcript-history-navigation.tsx@@@ -70,6 -70,6 +70,12 @@@ globalThis.transcriptHistoryNavigationPconst scroller = () => host.querySelector<HTMLDivElement>(".thread-scroll")!;const busy = () => host.querySelector('.transcript-history-loading[aria-hidden="false"]') !== null;const bottom = () => Math.abs(scroller().scrollHeight - scroller().clientHeight - scroller().scrollTop) <= 2;++ // Arrival replaces the prepared identity; connected history data may survive.++ const latestArrival = () => {++ const prepared = useAppStore.getState().transcriptViews[id];++ return () => !prepared || useAppStore.getState().transcriptViews[id] !== prepared ||++ matchMedia("(prefers-reduced-motion: reduce)").matches;++ };const render = (visible = true) => flushSync(() => root.render(<I18nextProvider i18n={i18n}><div className="session-panes"><SessionPane key={id} sessionId={id} visible={visible} /></div></I18nextProvider>));@@@ -142,6 -195,6 +201,7 @@@const start = distance();const samples: number[] = [start];let sampling = true;++ let arrived = () => false;const observers = new Set<ResizeObserver>();const sample = () => {if (!sampling) return;@@@ -152,6 -205,29 +212,29 @@@observer.disconnect(); observers.delete(observer);if (!sampling) return;const viewport = el.getBoundingClientRect();+ const latest = el.querySelector<HTMLElement>(`[data-message-id="${CSS.escape(latestMessageId)}"]`);+ if (latest) {+ const rect = latest.getBoundingClientRect();+ if (rect.top < viewport.bottom && rect.bottom > viewport.top) {+ textOffsets.push(rect.top - viewport.top);+ // Near-bottom is not arrival: the last animation frames still+ // travel legitimately. Historical arrival commits the live view.- if (bottom() && (tailOnly || !useAppStore.getState().transcriptViews[id])) {++ if (bottom() && arrived()) {+ bottomOffsets.push(rect.top - viewport.top);+ }+ if (bottom()) {+ const walker = document.createTreeWalker(latest, NodeFilter.SHOW_TEXT);+ let text = walker.nextNode();+ while (text && !text.textContent?.trim()) text = walker.nextNode();+ const range = document.createRange();+ if (text) range.selectNodeContents(text);- arrivalSamples.push({ distance: distance(), history: Boolean(useAppStore.getState().transcriptViews[id]),++ arrivalSamples.push({ distance: distance(), history: !arrived(),+ rowTop: rect.top - viewport.top, textTop: text ? range.getBoundingClientRect().top - viewport.top : null,+ sameNode: latest === previousLatest });+ }+ previousLatest = latest;+ }+ }const painted = [...el.querySelectorAll<HTMLElement>("[data-message-id]")].some(node => {const rect = node.getBoundingClientRect();return rect.height > 0 && rect.bottom > viewport.top && rect.top < viewport.bottom &&@@@ -164,9 -240,9 +247,12 @@@};requestAnimationFrame(sample);host.querySelector<HTMLButtonElement>(".jump-latest-btn")!.click();++ arrived = latestArrival();try {-- await until(() => !useAppStore.getState().transcriptViews[id] && bottom(), "smooth latest did not finish");- for (let n = 0; n < 5; n++) await frame();++ await until(() => arrived() && bottom(), "smooth latest did not finish");++ if (!tailOnly) assert((useAppStore.getState().transcriptViews[id]?.messages.length ?? 0) >= 135,++ "latest arrival discarded the previously loaded page");+ for (let n = 0; n < 30; n++) await frame();} finally { sampling = false; for (const observer of observers) observer.disconnect(); }const intermediateFrames = samples.filter(value => value > 2 && value < start - 2).length;const reversal = Math.max(0, ...samples.slice(1).map((value, i) => value - samples[i]));@@@ -194,6 -276,6 +286,7 @@@const el = scroller();const oldTop = el.scrollTop;host.querySelector<HTMLButtonElement>(".jump-latest-btn")!.click();++ const arrived = latestArrival();await until(() => el.scrollTop > oldTop + 20 && !bottom(), "trip did not enter an intermediate position");if (action === "failed-search") {deferSearch = true;@@@ -244,14 -336,14 +347,14 @@@messages: useAppStore.getState().messages.map(message => ({ ...message, status: "complete" })) });} else if (action === "hide") {render(false);-- await until(() => !useAppStore.getState().transcriptViews[id], "hide did not commit accepted latest intent");++ await until(arrived, "hide did not commit accepted latest intent");render();} else if (action === "unmount") {flushSync(() => root.render(null));-- assert(!useAppStore.getState().transcriptViews[id], "unmount did not commit accepted latest intent");++ assert(arrived(), "unmount did not commit accepted latest intent");render();}-- await until(() => !useAppStore.getState().transcriptViews[id] && bottom(), `${action} lost latest`);++ await until(() => arrived() && bottom(), `${action} lost latest`);for (let n = 0; n < 15; n++) { await frame(); assert(bottom(), `${action} reversed accepted latest`); }}results.push({ lifecycle: action, ok: true });@@@ -385,12 -526,12 +537,13 @@@assert(button, "actual return-to-latest button missing");const readsBeforeJump = reads.length;button.click();++ const arrived = latestArrival();if (timing === "pending") { const item = pending.shift()!; item.resolve(item.response); }-- await until(() => !useAppStore.getState().transcriptViews[id] && bottom(), `latest button failed after ${timing} page`);++ await until(() => arrived() && bottom(), `latest button failed after ${timing} page`);for (let n = 0; n < 15; n++) { await frame(); assert(bottom(), "latest navigation was reversed after reaching bottom"); }assert(pending.length === 0 && reads.length === readsBeforeJump, "latest navigation started another history page");const result = { timing, role, top: scroller().scrollTop, height: scroller().scrollHeight,-- historical: Boolean(useAppStore.getState().transcriptViews[id]), reduced: matchMedia("(prefers-reduced-motion: reduce)").matches };++ historical: !arrived(), reduced: matchMedia("(prefers-reduced-motion: reduce)").matches };console.log("REAL_HISTORY_LATEST " + JSON.stringify(result));results.push(result);} catch (error) {