Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(chat): use native smooth scrolling for return to latest

new-Beginner2d20113e3cb8
diff --cc apps/desktop/src/features/chat/transcript/hooks/useTranscriptLatestNavigation.ts
index c87fae4b6,5183edf2a..c7236f951
--- a/apps/desktop/src/features/chat/transcript/hooks/useTranscriptLatestNavigation.ts
+++ b/apps/desktop/src/features/chat/transcript/hooks/useTranscriptLatestNavigation.ts
@@@ -1,24 -1,36 +1,21 @@@
--import { useEffect, useLayoutEffect, useRef, useState, type RefObject } from "react";
++import { useEffect, useLayoutEffect, useState, type RefObject } from "react";
++import { stopSmoothScroll } from "../../../../lib/scroll-input";
import { createTranscriptLatestNavigation } from "../../../../lib/transcript-latest-navigation";
--export function useTranscriptLatestNavigation({ scrollRef, visible, onPosition }: {
++export function useTranscriptLatestNavigation({ scrollRef, visible }: {
scrollRef: RefObject<HTMLDivElement | null>;
visible: boolean;
-- onPosition: (top: number) => void;
}) {
-- const position = useRef(onPosition);
-- position.current = onPosition;
const [navigation] = useState(() => createTranscriptLatestNavigation({
geometry: () => scrollRef.current ?? undefined,
- move: top => {
- captureAnchor: () => {
++ move: (top, behavior) => scrollRef.current?.scrollTo({ top, behavior }),
++ onScrollEnd: listener => {
const scroller = scrollRef.current;
-- if (!scroller) return;
- scroller.scrollTo({ top, behavior: "instant" });
- position.current(scroller.scrollTop);
- 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 };
++ const handle = (event: Event) => { if (event.target === scroller) listener(); };
++ scroller?.addEventListener("scrollend", handle);
++ return () => scroller?.removeEventListener("scrollend", handle);
},
- move: top => {
- const scroller = scrollRef.current;
- if (!scroller) return;
- scroller.scrollTo({ top, behavior: "instant" });
- position.current(scroller.scrollTop);
- },
-- request: frame => requestAnimationFrame(frame),
-- cancel: frame => cancelAnimationFrame(frame),
-- now: () => performance.now(),
++ stop: () => stopSmoothScroll(scrollRef.current),
reducedMotion: () => window.matchMedia("(prefers-reduced-motion: reduce)").matches,
}));
// The explicit latest intent survives an immediate pane hide or eviction.
diff --cc apps/desktop/src/features/chat/transcript/hooks/useTranscriptScroll.ts
index 438a92883,908dc5f75..836c9842c
--- a/apps/desktop/src/features/chat/transcript/hooks/useTranscriptScroll.ts
+++ b/apps/desktop/src/features/chat/transcript/hooks/useTranscriptScroll.ts
@@@ -107,12 -108,12 +108,7 @@@ export function useTranscriptScroll(
// Read by `reachTop`, which must stay referentially stable for the scroll
// listener; the projection it describes is only known later in this render.
const historyLengthRef = useRef(0);
-- const latestNavigation = useTranscriptLatestNavigation({
-- scrollRef, visible: paneVisible, onPosition: top => {
-- lastScrollTopRef.current = top;
-- lastLaidOutScrollTopRef.current = top;
-- },
-- });
++ const latestNavigation = useTranscriptLatestNavigation({ scrollRef, visible: paneVisible });
const scrollToBottom = useCallback((behavior: ScrollBehavior = "auto") => {
if (latestNavigation.isActive()) return;
diff --cc apps/desktop/src/lib/transcript-latest-navigation.ts
index 722420d3b,f865b8787..88957de2b
--- a/apps/desktop/src/lib/transcript-latest-navigation.ts
+++ b/apps/desktop/src/lib/transcript-latest-navigation.ts
@@@ -1,54 -1,63 +1,50 @@@
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;
++ move: (top: number, behavior: ScrollBehavior) => void;
++ onScrollEnd: (listener: () => void) => () => void;
++ stop: () => void;
reducedMotion: () => boolean;
};
- type Navigation = { from: number; startedAt: number; duration: number; lastTop: number; arrive: () => void };
-type Navigation = {
- remaining: number; anchor?: LayoutAnchor; startedAt: number; duration: number; arrive: () => void;
-};
++type Navigation = { arrive: () => void; detach: () => void };
--/** One viewport owner for a short, interruptible trip through mounted content. */
++/** Own the latest intent; let the browser animate it just like a turn-marker jump. */
export function createTranscriptLatestNavigation(port: ScrollPort) {
let current: Navigation | undefined;
-- let frame = 0;
const cancel = (commit = false) => {
const previous = current;
++ if (!previous) return;
current = undefined;
-- port.cancel(frame);
-- frame = 0;
-- if (commit) previous?.arrive();
++ previous.detach();
++ port.stop();
++ if (commit) previous.arrive();
};
const start = (arrive: () => void = () => {}) => {
cancel();
const geometry = port.geometry();
if (!geometry || geometry.clientHeight <= 0) { arrive(); return; }
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 = { remaining: 1, anchor: port.captureAnchor?.(),
-- startedAt: port.now(), duration: Math.min(420, Math.max(180, distance / 30)), arrive };
++ if (port.reducedMotion() || Math.abs(target - geometry.scrollTop) <= 1) {
++ port.move(target, "auto"); arrive(); return;
++ }
++ const navigation: Navigation = { arrive, detach: () => {} };
current = navigation;
-- const advance = (now: number) => {
-- frame = 0;
++ navigation.detach = port.onScrollEnd(() => {
if (current !== navigation) return;
const box = port.geometry();
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;
- 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();
-- } else frame = port.request(advance);
-- };
-- frame = port.request(advance);
++ if (Math.abs(bottom - box.scrollTop) > 1) {
++ // Lazy layout or a late card can extend the destination. Finish that
++ // distance natively too, without interrupting an animation every frame.
++ port.move(bottom, port.reducedMotion() ? "auto" : "smooth");
++ return;
++ }
++ current = undefined;
++ navigation.detach();
++ navigation.arrive();
++ });
++ port.move(target, "smooth");
};
return { start, cancel, isActive: () => current !== undefined };
}
diff --cc apps/desktop/test/transcript-latest-navigation.test.mjs
index 2c9b283f4,67c498865..5903fc7a5
--- a/apps/desktop/test/transcript-latest-navigation.test.mjs
+++ b/apps/desktop/test/transcript-latest-navigation.test.mjs
@@@ -6,83 -6,119 +6,109 @@@ const { createTranscriptLatestNavigatio
function fixture(reduced = false) {
const box = { scrollTop: 80, scrollHeight: 8000, clientHeight: 600 };
-- const frames = new Map();
-- const positions = [];
-- let now = 0;
-- let id = 0;
++ const listeners = new Set();
++ const moves = [];
let arrivals = 0;
- let contentShift = 0;
++ let stops = 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,
++ move: (top, behavior) => {
++ moves.push({ top, behavior });
++ if (behavior === "auto") box.scrollTop = top;
++ },
++ onScrollEnd: listener => { listeners.add(listener); return () => listeners.delete(listener); },
++ stop: () => { stops++; },
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);
++ return { box, navigation, moves, listeners,
++ start: () => navigation.start(() => arrivals++), arrivals: () => arrivals, stops: () => stops,
++ settle: (top = moves.at(-1).top) => {
++ box.scrollTop = Math.min(top, box.scrollHeight - box.clientHeight);
++ for (const listener of [...listeners]) listener();
++ },
};
-- 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", () => {
++test("latest delegates movement to browser smooth scroll, just like a turn marker", () => {
const f = fixture();
f.start();
-- assert.equal(f.box.scrollTop, 80);
-- f.advance();
-- assert(f.box.scrollTop > 80 && f.box.scrollTop < 7400);
++ assert.deepEqual(f.moves, [{ top: 7400, behavior: "smooth" }]);
++ assert.equal(f.box.scrollTop, 80, "the controller must not simulate animation frames");
assert.equal(f.arrivals(), 0);
-- f.finish();
-- assert(f.positions.length >= 8);
-- assert(f.positions.every((top, i) => i === 0 || top >= f.positions[i - 1]));
-- assert.equal(f.box.scrollTop, 7400);
++ assert(f.navigation.isActive());
++ f.box.scrollTop = 900;
++ assert.equal(f.moves.length, 1, "intermediate browser positions need no scroll writes");
++ f.settle();
assert.equal(f.arrivals(), 1);
-- assert.equal(f.frames.size, 0);
++ assert.equal(f.navigation.isActive(), false);
++ assert.equal(f.listeners.size, 0);
});
--test("late stream growth retargets the trip without reversing or losing bottom", () => {
++test("a late changes card extends native travel without an instant height jump", () => {
const f = fixture();
-- f.start(); f.advance();
-- f.box.scrollHeight += 800;
-- f.finish();
-- assert(f.positions.every((top, i) => i === 0 || top >= f.positions[i - 1]));
-- assert.equal(f.box.scrollTop, 8200);
++ f.start();
++ f.box.scrollTop = 900;
++ f.box.scrollHeight += 56;
++ assert.equal(f.moves.length, 1, "layout growth must not interrupt the current browser animation");
++ f.settle(7400);
++ assert.deepEqual(f.moves.at(-1), { top: 7456, behavior: "smooth" });
++ assert.equal(f.box.scrollTop, 7400, "remaining distance is animated, never snapped");
++ assert.equal(f.arrivals(), 0);
++ f.settle();
assert.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", () => {
++test("reader interruption stops native travel and detaches obsolete arrival", () => {
const f = fixture();
-- f.start(); f.advance();
-- const top = f.box.scrollTop;
-- f.navigation.cancel(); f.advance();
-- assert.equal(f.box.scrollTop, top);
++ f.start();
++ const obsolete = [...f.listeners][0];
++ f.box.scrollTop = 900;
++ f.navigation.cancel();
++ obsolete();
++ assert.equal(f.stops(), 1);
++ assert.equal(f.box.scrollTop, 900);
assert.equal(f.arrivals(), 0);
assert.equal(f.navigation.isActive(), false);
-- assert.equal(f.frames.size, 0);
++ assert.equal(f.listeners.size, 0);
});
--test("pane hide commits accepted latest intent once without finishing an invisible animation", () => {
++test("pane hide commits latest intent exactly once and stops invisible native motion", () => {
const f = fixture();
-- f.start(); f.advance(); f.navigation.cancel(true); f.navigation.cancel(true); f.advance();
++ f.start();
++ f.navigation.cancel(true); f.navigation.cancel(true);
assert.equal(f.arrivals(), 1);
-- assert.equal(f.frames.size, 0);
++ assert.equal(f.stops(), 1);
++ assert.equal(f.listeners.size, 0);
});
--test("repeated navigation cannot commit an obsolete trip", () => {
++test("a repeated click cannot commit the previous native trip", () => {
const f = fixture();
-- f.start(); f.advance(); f.start(); f.finish();
++ f.start();
++ const obsolete = [...f.listeners][0];
++ f.start(); obsolete();
++ assert.equal(f.arrivals(), 0);
++ assert.equal(f.listeners.size, 1);
++ f.settle();
assert.equal(f.arrivals(), 1);
});
--test("reduced motion reaches bottom synchronously", () => {
++test("reduced motion uses the turn marker's immediate auto behavior", () => {
const f = fixture(true);
f.start();
++ assert.deepEqual(f.moves, [{ top: 7400, behavior: "auto" }]);
assert.equal(f.box.scrollTop, 7400);
assert.equal(f.arrivals(), 1);
-- assert.equal(f.frames.size, 0);
++ assert.equal(f.listeners.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.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);
- });
-}
++test("an already-bottomed or hidden scroller does not wait for a nonexistent scrollend", () => {
++ for (const hidden of [false, true]) {
++ const f = fixture();
++ f.box.scrollTop = 7400;
++ if (hidden) f.box.clientHeight = 0;
++ f.start();
++ assert.equal(f.arrivals(), 1);
++ assert.equal(f.listeners.size, 0);
++ assert.equal(f.navigation.isActive(), false);
++ }
+});
diff --cc docs/adr/0130-bounded-mounted-transcript-window.md
index a4f5b8f12,fd15ceebd..ba100f24f
--- a/docs/adr/0130-bounded-mounted-transcript-window.md
+++ b/docs/adr/0130-bounded-mounted-transcript-window.md
@@@ -131,23 -140,27 +140,26 @@@ 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.
- - **Interruptible return-to-latest:** Returning to latest uses one custom
- viewport animation (`180–420ms` cubic ease-out, monotonic retargeting across
- late stream growth; immediate under `prefers-reduced-motion: reduce`) instead
- of browser smooth scroll, suppressing competing follow, layout, previous
- search-alignment, and turn-completion scroll owners while active. A new search
+ - **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:** 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 custom
- viewport animation (`180–420ms` cubic ease-out, monotonic retargeting across
- late stream growth; immediate under `prefers-reduced-motion: reduce`) instead
- of browser smooth scroll, suppressing competing follow, layout, previous
- search-alignment, and turn-completion scroll owners while active. A new search
++- **Native latest trajectory:** Return-to-latest uses browser `smooth` scrolling,
++ exactly like conversation turn markers (`auto` under reduced motion). The app
++ does not impose an easing curve, duration, or per-frame position writes.
++ A `scrollend` listener commits arrival only at the current bottom; if lazy
++ layout or a late turn-changes card extends it, native scrolling finishes the
++ remaining distance instead of snapping. Completion and cancellation remove
++ the listener.
++- **Interruptible return-to-latest:** Competing follow, layout, previous search
++ alignment, and turn-completion scroll owners yield while travel is active. A new search
request still cancels the trip. Genuine main-scroller input
cancels the animation in place without committing arrival; horizontal,
zero-delta, or `Ctrl`+wheel input and nested scrollers, editable fields, or
diff --cc docs/spec/04-ux/09-interaction-patterns.md
index 08e66b9c1,ecfa1be20..fc63e6459
--- a/docs/spec/04-ux/09-interaction-patterns.md
+++ b/docs/spec/04-ux/09-interaction-patterns.md
@@@ -824,7 -824,7 +824,7 @@@ may be retained while exactly one works
cancels any pending follow frame; small trackpad deltas must not snap back to
the bottom
- Scroll input owned by the transcript cancels an in-flight browser smooth
-- navigation or custom return-to-latest animation at its current offset. A
++ navigation or native return-to-latest animation at its current offset. A
previous minimap or return-to-latest move must not resume after the reader
takes over; horizontal, zero-delta, or `Ctrl`+wheel input, nested-scroll
input, editable fields, and ordinary row controls do not cancel it.
@@@ -838,16 -838,18 +838,17 @@@
- Sending a new prompt, retrying, or regenerating always re-pins follow mode and jumps to the bottom before the turn continues, even if the user had scrolled up
- "Scroll to bottom" floating button appears as soon as manual upward scrolling
releases follow mode
--- Return-to-latest ("Scroll to bottom" button, context menu, radial menu) runs
-- one custom interruptible viewport animation (`180–420ms` cubic ease-out,
-- monotonic retargeting across late stream growth without reversing; immediate
-- when `prefers-reduced-motion: reduce` is active) instead of browser smooth
-- scroll, suppressing competing follow, layout, previous search alignment, and turn-completion scroll
-- owners until it settles or is cancelled. Record the pinned bookmark
++- Return-to-latest ("Scroll to bottom" button, context menu, radial menu) uses
++ browser `scrollTo({ behavior: "smooth" })`, matching conversation turn markers;
++ reduced motion uses `auto`. Duration and easing belong to the browser, not
++ a custom frame loop. Competing follow, layout, previous search alignment, and
++ turn-completion owners yield until `scrollend` or cancellation. Record the pinned bookmark
synchronously and prepare any active historical `transcriptViews` slice by
replacing 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 once
without continuing an invisible animation. Explicit disjoint search or history
views animate across currently mounted rows and join the canonical live tail
on arrival without fetching or animating unloaded intermediate ranges.
@@@ -855,6 -857,9 +856,9 @@@
restoring the old reading offset; manual upward reading without return-to-latest
retains its position, and reader interruption cancels the animation in place
without 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.
++ Native travel is not interrupted by per-frame position corrections. At
++ `scrollend`, recheck the current bottom; a late card or layout change extends
++ native travel before arrival rather than causing an instantaneous final 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 the
viewport so the answer reads from its start, follow mode is released, and
@@@ -1696,9 -1711,9 +1712,9 @@@ Project drag/drop follows these pattern
- Button appears as soon as upward scrolling releases follow mode
- Click button: retires the prior scroll gesture and history hold, prepares any
historical view without removing visible messages until arrival (or commits on
-- hide/unmount), and drives the custom `180–420ms` cubic ease-out animation to
-- bottom (immediate under reduced motion) while suppressing competing scroll
-- owners. Queued scroll events or a pending page cannot reopen historical
++ hide/unmount), and starts browser-native smooth scrolling like a turn marker
++ (`auto` under reduced motion) while suppressing competing scroll owners until
++ native completion. Queued scroll events or a pending page cannot reopen historical
reading or start another page read during that trip.
- Button disappears when at bottom
- A delegation tab uses the same single-body scroll owner as the work panel.
@@@ -1888,10 -1903,10 +1904,9 @@@ This does not prevent state changes �
- Session activation uses an immediate layout-phase bottom position so the
first visible frame is already stable at the latest record.
--- Return-to-latest runs its `180–420ms` cubic ease-out viewport animation and
-- minimap navigation uses browser smooth scrolling only when the OS has not
-- requested reduced motion; under `prefers-reduced-motion: reduce` both position
-- immediately.
++- Return-to-latest and minimap navigation both use browser-native smooth
++ scrolling with browser-owned timing. Under `prefers-reduced-motion: reduce`,
++ both use immediate `auto` positioning.
- Turn-start following uses an immediate layout-phase update and then a
frame-coalesced instant follow; it does not start overlapping smooth-scroll
animations for token groups.
diff --cc docs/spec/06-delivery/04-e2e-test-plan.md
index f7041b3ad,9fd88396d..8d380b319
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@@ -13606,20 -13585,24 +13609,24 @@@ This test plan spec is accepted when
stays single-flight, does not set `overflow-y: hidden` or discard main scroll
input, tracks the newest actual message anchor across ongoing upward movement,
and keeps that message within `2px` when the page prepends; there is no
- early-threshold observer or eager draining at rest. Only the `<= 120px` hard
- edge, explicit earlier-history action, and underfilled `120px` observer briefly
- lock `overflow-y` and discard main-scroller vertical wheel/touch/scroll-key
- input through IO and three stable layout frames while preserving horizontal,
- zero-delta, and `Ctrl`+wheel input, nested scrolling, editable fields, and
- title activation. Return-to-latest runs one `180–420ms` cubic ease-out
- viewport animation (immediate under reduced motion) while suppressing
- competing follow/layout/turn-completion owners; preparing a historical view
+ early-threshold observer or eager draining at rest. The `<= 120px` hard edge,
+ explicit earlier-history action, and underfilled observer use the same moving
+ anchor without locking overflow or discarding input. Native wheel movement
+ must occur during IO, with insertion preserving the resulting reading point.
+ Nested scrolling, editable fields and title activation remain independent.
- Return-to-latest runs one `180–420ms` cubic ease-out
- viewport animation (immediate under reduced motion) while suppressing
- competing follow/layout/turn-completion owners; preparing a historical view
++ Return-to-latest uses the same browser-native smooth scrolling as conversation
++ turn markers (`auto` under reduced motion), without custom easing, timing, or
++ per-frame position writes. Competing follow/layout/turn-completion owners yield; preparing a historical view
clears `loading` on a new view identity while keeping current messages visible
until exact-identity arrival, commits on hide/unmount, cancels in place only
on 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.
++ eviction and canonical rewrites still invalidate them. Native `scrollend`
++ rechecks the current bottom and smoothly finishes any remaining distance after
++ a late card or layout change, without a full-height instantaneous jump.
++ Runtime `isRunning` and 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 direct
@@@ -13640,11 -13623,36 +13647,37 @@@
native browser smooth travel across the prefetch threshold, resuming follow
during pending IO, press-only interruption plus remount, delayed failed search,
focused and restored disjoint ranges (no automatic forward reads), stream
- growth/completion, hide/unmount, and reduced-motion media emulation. Empty
- layout viewports are checked after layout and before paint, not before lazy
- rows have had their layout opportunity. Only external Host IPC is controlled;
+ growth/completion, hide/unmount, and reduced-motion media emulation. An extra
- latest case changes height above the reader by `2400px`; unit cases also shrink
- it by `1200px`. Separate final animation travel from history-release drift.
++ latest case changes height above the reader by `2400px`. The minimap jump
++ journey then clicks latest and verifies one native smooth command with no
++ instantaneous intermediate travel. Separate final travel from arrival drift.
+ Delayed-layout checks require nonempty post-layout/prepaint samples within
+ `2px`, retaining pre-layout rAF diagnostics rather than treating them as paint.
+ Only external Host IPC is controlled;
the ordinary-motion cases still require intermediate frames. Manual procedures:
`tests/history-loading-scroll-test-cases.md`.
+ The production `SessionPane` resource journey opens collapsed process groups,
+ traverses both ends and the middle, and checks measured prose recycling plus
+ restoration of visible content without additional history requests. A separate
+ variant includes a 1,600-paragraph final answer. `--manual-smoke` drives the
+ manual toolbar through two 100-message pages and reset, sending 24 native
+ wheel events in each direction per pending page; directional movement,
+ single-flight requests, and frame-gap p95 <= 100ms are checked. This is a
+ measured fixture budget, not a universal zero-latency guarantee.
+ `node scripts/manual-transcript-desktop.mjs --interaction-smoke` complements
+ this with the complete product shell and real Host database: native upward
+ wheel input crosses the initial 100-message page without mounting all 1,000
+ messages, then the actual latest button reaches the bottom with nonblank
+ sampled frames and <=2px tail drift during 600ms after arrival. The isolated
+ instance confirms the application's normal quit dialog and exits.
+ Late-reading regressions wait until the page has settled, then change content
+ above the reading point by 120px, balance it with a -120px change below, and
+ change an earlier paragraph inside a long answer. Nonempty pre-paint samples
+ must stay within 1px. Six consecutive 20px steps additionally compare the
+ actual painted text crop byte-for-byte, not merely the eventual scrollTop.
+ Full-Desktop interaction smoke repeats the painted reading check after a real
+ Host page. Original native smooth input, resumed follow, search, disclosure,
+ hide/reveal and turn-completion paths remain required.
- **Specs linked**: `04-ux/09-interaction-patterns.md` §2.2 / §9.1 / §10.4, ADR 0130.
- **Acceptance**: C (conversation), Quality.
- **Status**: Automated Electron fixture and unit regressions implemented; run
diff --cc scripts/e2e-transcript-minimap-jump.mjs
index 824256327,824256327..0d1173acc
--- a/scripts/e2e-transcript-minimap-jump.mjs
+++ b/scripts/e2e-transcript-minimap-jump.mjs
@@@ -83,7 -83,7 +83,7 @@@ const { app, BrowserWindow } = require(
const path = require("node:path");
app.setPath("userData", path.join(__dirname, "profile"));
app.whenReady().then(async () => {
-- const window = new BrowserWindow({ show: false, width: 1200, height: 720, webPreferences: { sandbox: true, contextIsolation: true, nodeIntegration: false, backgroundThrottling: false } });
++ const window = new BrowserWindow({ show: true, width: 1200, height: 720, webPreferences: { sandbox: true, contextIsolation: true, nodeIntegration: false, backgroundThrottling: false } });
window.webContents.on("console-message", (event) => console.error(event.message));
try {
await window.loadFile(path.join(__dirname, "index.html"));
diff --cc scripts/e2e/transcript-history-navigation.tsx
index 99b620efa,ca09dfeda..9efdadcb6
--- a/scripts/e2e/transcript-history-navigation.tsx
+++ b/scripts/e2e/transcript-history-navigation.tsx
@@@ -235,7 -328,17 +328,17 @@@ globalThis.transcriptHistoryNavigationP
assert(Math.abs(el.scrollTop - stopped) <= 2 && !bottom(), "reader input did not retire the trip");
assert(Boolean(useAppStore.getState().transcriptViews[id]), "interruption committed latest");
} else {
- if (action === "growth") {
+ if (action === "layout-above") {
+ const content = el.querySelector<HTMLElement>(".thread-content")!;
- const remaining = el.scrollHeight - el.clientHeight - el.scrollTop;
++ const beforeLayout = el.scrollTop;
+ const previousPadding = content.style.paddingTop;
+ content.style.paddingTop = "2400px";
+ await frame();
- const afterLayout = el.scrollHeight - el.clientHeight - el.scrollTop;
++ const afterLayout = el.scrollTop;
+ content.style.paddingTop = previousPadding;
- assert(afterLayout <= remaining + 2,
- `layout above reversed latest travel: before=${remaining}, after=${afterLayout}`);
++ assert(afterLayout >= beforeLayout - 2,
++ `native latest reversed during layout: before=${beforeLayout}, after=${afterLayout}`);
+ } else if (action === "growth") {
const live = useAppStore.getState().messages.map(message => ({ ...message, status: "complete" as const }));
useAppStore.setState({ messages: [...live, { ...data.at(-1)!, id: `${id}-new`,
content: "New live output. ".repeat(300), status: "streaming" }] });
diff --cc scripts/e2e/transcript-minimap-jump.tsx
index 2a0bff3e1,2a0bff3e1..c3c410191
--- a/scripts/e2e/transcript-minimap-jump.tsx
+++ b/scripts/e2e/transcript-minimap-jump.tsx
@@@ -177,6 -177,6 +177,12 @@@ export async function transcriptMinimap
"outline mounts",
);
const scroller = element(".thread-scroll");
++ // Compare native movement against fixed, measured turn offsets rather than
++ // content-visibility estimates; dynamic-height arrival has its own journey.
++ for (const node of scroller.querySelectorAll<HTMLElement>(".message-row")) {
++ node.style.contentVisibility = "visible";
++ node.getBoundingClientRect();
++ }
const distanceFromBottom = () =>
scroller.scrollHeight - scroller.clientHeight - scroller.scrollTop;
// The transcript mounts pinned to the bottom: that is the state the reported
@@@ -227,8 -227,8 +233,44 @@@
turnTop() > -8 && turnTop() < 96,
`the clicked turn is not on screen: ${JSON.stringify(readout())}`,
);
++ const nativeMove = scroller.scrollTo.bind(scroller);
++ const calls: { top: number; behavior: ScrollBehavior; displacement: number }[] = [];
++ let ended = false;
++ const onEnd = (event: Event) => { if (event.target === scroller) ended = true; };
++ scroller.addEventListener("scrollend", onEnd);
++ scroller.scrollTo = (options?: ScrollToOptions | number, y?: number) => {
++ const before = scroller.scrollTop;
++ if (typeof options === "number") nativeMove(options, y ?? 0);
++ else nativeMove(options);
++ calls.push({ top: typeof options === "number" ? y ?? 0 : options?.top ?? before,
++ behavior: typeof options === "number" ? "auto" : options?.behavior ?? "auto",
++ displacement: scroller.scrollTop - before });
++ };
++ let intermediateFrames = 0;
++ const start = scroller.scrollTop;
++ try {
++ element<HTMLButtonElement>(".jump-latest-btn").click();
++ for (let index = 0; index < 400; index++) {
++ await frame();
++ if (scroller.scrollTop > start + 2 && distanceFromBottom() > 2) intermediateFrames++;
++ if (ended && Math.abs(distanceFromBottom()) <= 2) break;
++ }
++ assert(ended && Math.abs(distanceFromBottom()) <= 2, "native return did not finish at bottom");
++ assert(calls.filter(call => call.behavior === "smooth").length === 1,
++ `fixed-layout latest must use one browser animation: ${JSON.stringify(calls)}`);
++ assert(calls.every(call => call.behavior === "smooth" || Math.abs(call.displacement) <= 2),
++ `latest still writes instantaneous animation positions: ${JSON.stringify(calls)}`);
++ assert(intermediateFrames >= 3, `native latest snapped instead of travelling: ${JSON.stringify({ start, intermediateFrames, calls, ...readout() })}`);
++ for (let index = 0; index < 12; index++) {
++ await frame();
++ assert(Math.abs(distanceFromBottom()) <= 2, "native latest bounced after arrival");
++ }
++ } finally {
++ scroller.scrollTo = nativeMove;
++ scroller.removeEventListener("scrollend", onEnd);
++ }
assert(errors.length === 0, `render errors: ${errors.map(String)}`);
-- return { ok: true, dashes: dashes.length, ...readout() };
++ return { ok: true, dashes: dashes.length, nativeLatest: { calls, intermediateFrames }, ...readout() };
} catch (error) {
return {
ok: false,
diff --cc tests/history-loading-scroll-test-cases.md
index 9822e1736,9397fefde..722f0d9c1
--- a/tests/history-loading-scroll-test-cases.md
+++ b/tests/history-loading-scroll-test-cases.md
@@@ -3,15 -3,15 +3,15 @@@
## Scope and prerequisites
- Requirements: request earlier history ahead of the top edge on upward scroll
- (`min(2400px, max(120px, 3 * clientHeight))`) without hiding overflow or
- blocking scroll input while tracking the newest actual message anchor; retain
- the brief scroll-input and `overflow-y: hidden` lock only for the `<= 120px`
- hard edge, explicit earlier-history actions, and underfilled top-boundary
- observer through IO and three stable layout frames; and drive return-to-latest
- through one custom interruptible `180–420ms` cubic ease-out viewport animation
- (immediate under reduced motion) that keeps visible messages mounted until
- arrival. Existing message, page, mounted-window, and retained-pane caches stay
- unchanged, with no idle TTL or memory reclamation.
+ (base `min(2400px, max(120px, 3 * clientHeight))`, increased by speed times
+ measured read latency plus `150ms`, capped at twelve screens or `12000px`)
+ without hiding overflow or blocking input. All paths, including the hard edge
+ and explicit continuation, track the moving actual-message anchor through IO
+ and three stable layout frames. Drive return-to-latest
- through one custom interruptible `180–420ms` cubic ease-out viewport animation
- (immediate under reduced motion) that keeps visible messages mounted until
- arrival. Existing message, page, mounted-window, and retained-pane caches stay
- unchanged, with no idle TTL or memory reclamation.
++ through browser-native smooth scrolling like the conversation turn markers
++ (`auto` under reduced motion), keeping visible messages mounted until native
++ arrival. Tail-connected loaded pages and cursors remain available, independently
++ of mounted-window bounds; no idle TTL or memory reclamation is introduced.
- Follow-up integration base: official `vastsa/PI-Desktop` main,
`14b928f3171e9e00b6d2851d67c832812ff61fc7`, including merged PR #2080.
The continuous-answer jump and pending-page latest-button race both fail on
@@@ -91,12 -155,12 +155,12 @@@ are used. It is not a mock implementati
and `prefers-reduced-motion: reduce`, and test interrupting mid-flight with
main-scroller vertical wheel vs horizontal/zero/`Ctrl` wheel or nested/editable
controls, plus hiding/switching panes mid-trip.
--- Expected: with normal motion, the viewport animates smoothly (`180–420ms`
-- cubic ease-out, monotonic without reversing, no empty message viewport frame)
-- while suppressing competing follow, layout, and turn-completion owners;
-- reduced motion reaches the bottom immediately. Preparing a historical view
-- invalidates any pending page's `TranscriptView` identity (`loading: null`)
-- without removing visible messages and clears that exact view only on arrival,
++- Expected: normal motion uses browser-native smooth scrolling with the same
++ browser-owned timing as turn markers, no instantaneous intermediate position
++ writes, and no empty message viewport frame. Competing follow, layout, and
++ turn-completion owners yield until native completion; reduced motion uses
++ immediate `auto`. Preparing history invalidates pending page ownership without
++ removing visible messages; arrival exits historical ownership but retains connected pages,
while pane hide or unmount commits the accepted latest intent once. Genuine
main-scroller input cancels the trip at its current offset without committing
arrival; horizontal, zero-delta, and `Ctrl`+wheel input and nested/editable/row