Skip to content

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

fix(chat): retire competing owners during latest navigation

new-Beginnere64d06f00cb1
diff --git a/apps/desktop/src/features/chat/transcript/ChatTranscript.tsx b/apps/desktop/src/features/chat/transcript/ChatTranscript.tsx
index 2a3bc8853..90dbaad69 100644
--- a/apps/desktop/src/features/chat/transcript/ChatTranscript.tsx
+++ b/apps/desktop/src/features/chat/transcript/ChatTranscript.tsx
@@ -184,6 +184,7 @@ function TranscriptBody({
revealEarlierHistory,
releaseFollow,
jumpToLatest,
+ isLatestNavigationActive,
disclosureAnchorNotifier,
} = useTranscriptScroll({
sessionId,
@@ -200,6 +201,7 @@ function TranscriptBody({
paneVisible,
searchTarget,
readingWindow,
+ navigationLoading,
onRestoreReading,
});
const returnToLatest = useCallback(() => {
@@ -212,7 +214,7 @@ function TranscriptBody({
);
const automaticContinuation = readingWindow && !searchTarget;
useTranscriptContinuation({
- scrollRef, contentRef, messages, onLoadNewer,
+ scrollRef, contentRef, messages, onLoadNewer, isNavigationActive: isLatestNavigationActive,
enabled: automaticContinuation && hasMoreAfter && paneVisible && !veilCovering,
cursor: continuationCursor,
loading: navigationLoading,
diff --git a/apps/desktop/src/features/chat/transcript/hooks/useTranscriptHistoryPaging.ts b/apps/desktop/src/features/chat/transcript/hooks/useTranscriptHistoryPaging.ts
index bd3380c4a..a1b8ff62c 100644
--- a/apps/desktop/src/features/chat/transcript/hooks/useTranscriptHistoryPaging.ts
+++ b/apps/desktop/src/features/chat/transcript/hooks/useTranscriptHistoryPaging.ts
@@ -36,7 +36,7 @@ export function useTranscriptHistoryPaging({ scrollRef, contentRef, visible, sou
contentRef: RefObject<HTMLDivElement | null>;
visible: boolean;
sourceHead: string | undefined;
- onStart: () => void;
+ onStart: (background: boolean) => void;
onPosition: (top: number) => void;
onSettled: () => void;
}) {
@@ -114,7 +114,7 @@ export function useTranscriptHistoryPaging({ scrollRef, contentRef, visible, sou
holdRef.current = hold; // Synchronous: two scroll events cannot start two pages.
if (!background) scroller.style.overflowY = "hidden";
inFlightRef.current = true;
- callbacks.current.onStart();
+ callbacks.current.onStart(background);
setPhase(page ? "page" : "mount");
const finish = () => {
inFlightRef.current = false;
diff --git a/apps/desktop/src/features/chat/transcript/hooks/useTranscriptScroll.ts b/apps/desktop/src/features/chat/transcript/hooks/useTranscriptScroll.ts
index af64c19a1..438a92883 100644
--- a/apps/desktop/src/features/chat/transcript/hooks/useTranscriptScroll.ts
+++ b/apps/desktop/src/features/chat/transcript/hooks/useTranscriptScroll.ts
@@ -64,6 +64,7 @@ type UseTranscriptScrollOptions = {
paneVisible: boolean;
searchTarget: TranscriptSearchTarget | null;
readingWindow: boolean;
+ navigationLoading?: boolean;
onRestoreReading?: RestoreTranscriptReading;
};
@@ -81,6 +82,7 @@ export function useTranscriptScroll({
paneVisible,
searchTarget,
readingWindow,
+ navigationLoading = false,
onRestoreReading,
}: UseTranscriptScrollOptions) {
const scrollRef = useRef<HTMLDivElement>(null);
@@ -191,10 +193,10 @@ export function useTranscriptScroll({
enterDisclosureReading,
recordScrollPosition,
);
- const startHistoryReading = useCallback(() => {
+ const startHistoryReading = useCallback((background: boolean) => {
releaseDisclosureAnchor();
- releaseFollow();
- }, [releaseDisclosureAnchor, releaseFollow]);
+ if (background) leaveFollow(); else releaseFollow();
+ }, [leaveFollow, releaseDisclosureAnchor, releaseFollow]);
const {
loadingOlder, pending: historyPending, run: preserveHistory, retry: retryHistoryPaging,
restore: restoreHistoryAnchor, isHeld: isHistoryPaging, isLocked: isHistoryLocked,
@@ -212,6 +214,13 @@ export function useTranscriptScroll({
disclosureAnchorNotifier(title);
}, [cancelHistoryPaging, disclosureAnchorNotifier]);
+ useLayoutEffect(() => {
+ if (!navigationLoading || !latestNavigation.isActive()) return;
+ latestNavigation.cancel();
+ leaveFollow();
+ rememberReadingPosition();
+ }, [latestNavigation, leaveFollow, navigationLoading, rememberReadingPosition]);
+
// A user scroll-up gesture always emits input before its scroll events;
// programmatic follow scrolling and layout clamps (composer collapse on
// send, indicator mount/unmount) never do. Track the last real input so
@@ -230,7 +239,9 @@ export function useTranscriptScroll({
contentRef.current,
);
if (!isScrollGestureInput(event.type as ScrollInputType, input)) return;
- if (latestNavigation.isActive()) { latestNavigation.cancel(); leaveFollow(); }
+ if (latestNavigation.isActive()) {
+ latestNavigation.cancel(); leaveFollow(); rememberReadingPosition();
+ }
if (!(event instanceof WheelEvent) || (!event.ctrlKey && event.deltaY !== 0)) retryHistoryPaging();
// Minimap / jump navigation runs in the browser, independently of our
// follow rAF. Real input must retire that animation at its current offset
@@ -241,7 +252,7 @@ export function useTranscriptScroll({
// Real input takes the viewport back from a held disclosure position.
releaseDisclosureAnchor();
},
- [cancelReadingPosition, isHistoryLocked, latestNavigation, leaveFollow, releaseDisclosureAnchor, retryHistoryPaging],
+ [cancelReadingPosition, isHistoryLocked, latestNavigation, leaveFollow, releaseDisclosureAnchor, rememberReadingPosition, retryHistoryPaging],
);
useEffect(() => {
@@ -856,6 +867,7 @@ export function useTranscriptScroll({
revealEarlierHistory,
scrollToBottom,
jumpToLatest,
+ isLatestNavigationActive: latestNavigation.isActive,
releaseFollow: releaseNavigationFollow,
disclosureAnchorNotifier: notifyDisclosure,
};
diff --git a/apps/desktop/src/hooks/use-transcript-continuation.ts b/apps/desktop/src/hooks/use-transcript-continuation.ts
index cfba105a7..125861a8b 100644
--- a/apps/desktop/src/hooks/use-transcript-continuation.ts
+++ b/apps/desktop/src/hooks/use-transcript-continuation.ts
@@ -3,7 +3,7 @@ import type { UiMessage } from "@pi-desktop/shared";
/** Continue a restored reading range without turning it into a manual search page. */
export function useTranscriptContinuation({
- scrollRef, contentRef, enabled, loading, messages, cursor, onLoadNewer,
+ scrollRef, contentRef, enabled, loading, messages, cursor, onLoadNewer, isNavigationActive,
}: {
scrollRef: RefObject<HTMLDivElement | null>;
contentRef: RefObject<HTMLDivElement | null>;
@@ -13,6 +13,7 @@ export function useTranscriptContinuation({
cursor?: number;
/** The reading service owns request coalescing, stale results and error reporting. */
onLoadNewer?: () => Promise<void>;
+ isNavigationActive?: () => boolean;
}) {
const attemptedRef = useRef<{ cursor?: number } | null>(null);
useEffect(() => {
@@ -21,7 +22,7 @@ export function useTranscriptContinuation({
if (!enabled || loading || !onLoadNewer || !scroller || !content) return;
let requested = false;
const check = () => {
- if (requested || scroller.clientHeight <= 0) return;
+ if (requested || scroller.clientHeight <= 0 || isNavigationActive?.()) return;
if (scroller.scrollHeight - scroller.clientHeight - scroller.scrollTop > 240) return;
// A failed/empty page must not spin on loading, resize or queued scroll
// events. New reading input can retry; new rows can fill a short viewport.
@@ -47,5 +48,5 @@ export function useTranscriptContinuation({
for (const event of inputEvents) scroller.removeEventListener(event, onInput);
observer?.disconnect();
};
- }, [contentRef, cursor, enabled, loading, messages, onLoadNewer, scrollRef]);
+ }, [contentRef, cursor, enabled, isNavigationActive, loading, messages, onLoadNewer, scrollRef]);
}
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 8184fc154..50723e30f 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -13563,8 +13563,14 @@ This test plan spec is accepted when:
empty visible-message frames) and ahead-read cases (standalone user rows and
mixed grouped answers moving the same visible message `100px` during pending
IO and keeping drift `<= 2px` after prepend) alongside the retained quiet
- stability and pending/settled latest-button cases. Only external Host IPC is
- controlled; run with normal motion enabled. Manual procedures:
+ stability and pending/settled latest-button cases. Additional regressions cover
+ 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;
+ the ordinary-motion cases still require intermediate frames. Manual procedures:
`tests/history-loading-scroll-test-cases.md`.
- **Specs linked**: `04-ux/09-interaction-patterns.md` §2.2 / §9.1 / §10.4, ADR 0130.
- **Acceptance**: C (conversation), Quality.
diff --git a/scripts/e2e-transcript-history-loading.mjs b/scripts/e2e-transcript-history-loading.mjs
index cd2eda2a0..92387ea57 100644
--- a/scripts/e2e-transcript-history-loading.mjs
+++ b/scripts/e2e-transcript-history-loading.mjs
@@ -74,6 +74,14 @@ app.whenReady().then(async () => {
const free = await call('inspect()');
assert(Math.abs(free.top - after.top) > 2 || free.calls > after.calls, name + ': scrolling/retry remained locked after completion');
}
+ let crossingError;
+ try {
+ await call('reset()');
+ const crossing = await call('crossAhead()');
+ assert.equal(crossing.locked, false, 'crossing the ahead band locked input');
+ await call('release(false,false,true)');
+ console.log('HISTORY_AHEAD_CROSSING ' + JSON.stringify({ ok: true }));
+ } catch (error) { crossingError = error; console.log('HISTORY_AHEAD_CROSSING_ERROR ' + String(error)); }
await call('reset()');
await call('beginAhead()');
await call('frames()');
@@ -111,6 +119,7 @@ app.whenReady().then(async () => {
const reduced = await js('globalThis.transcriptHistoryNavigationProbe(true)');
console.log('LATEST_REDUCED_MOTION ' + JSON.stringify(reduced));
} finally { win.webContents.debugger.detach(); }
+ assert.equal(crossingError, undefined, 'ahead-loading interrupted browser smooth scroll');
console.log('HISTORY_LOADING_PROBE ' + JSON.stringify({ ok: true, cases: results.length, cachedWindow: true, inputOwnership: true, latestNavigation: true }));
app.exit(0);
} catch(e) { console.error(e.stack || String(e)); app.exit(1); }
diff --git a/scripts/e2e/transcript-history-loading.tsx b/scripts/e2e/transcript-history-loading.tsx
index 87b62d33b..d2d35c787 100644
--- a/scripts/e2e/transcript-history-loading.tsx
+++ b/scripts/e2e/transcript-history-loading.tsx
@@ -161,6 +161,19 @@ function track() {
sampling = requestAnimationFrame(sample);
return inspect();
}
+async function crossAhead() {
+ const el = scroller();
+ for (const row of el.querySelectorAll<HTMLElement>("[data-message-id], [data-minimap-id]")) row.style.contentVisibility = "visible";
+ el.dispatchEvent(new WheelEvent("wheel", { bubbles: true, deltaY: -100 }));
+ el.scrollTo({ top: el.clientHeight * 3 + 400, behavior: "instant" });
+ el.dispatchEvent(new Event("scroll", { bubbles: true }));
+ await frame(); await frame();
+ el.dispatchEvent(new KeyboardEvent("keydown", { bubbles: true, key: "PageUp" }));
+ el.scrollTo({ top: el.clientHeight, behavior: "smooth" });
+ await until(() => calls === 1, "smooth upward travel did not prefetch");
+ await until(() => Math.abs(el.scrollTop - el.clientHeight) <= 2, "prefetch interrupted browser smooth upward travel");
+ return track();
+}
async function growMountedWindow() {
const el = scroller();
const count = el.querySelectorAll("[data-minimap-id]").length;
@@ -176,12 +189,12 @@ async function growMountedWindow() {
declare global { var historyLoadingFixture: { reset: typeof reset; begin: typeof begin; release: typeof release;
inspect: typeof inspect; growTail: typeof growTail; hideAndReveal: typeof hideAndReveal;
inputOwnership: typeof inputOwnership; jumpWhileLoading: typeof jumpWhileLoading; beginAhead: typeof beginAhead; track: typeof track;
- growMountedWindow: typeof growMountedWindow; armNativeInput: typeof armNativeInput;
+ growMountedWindow: typeof growMountedWindow; crossAhead: typeof crossAhead; armNativeInput: typeof armNativeInput;
finishNativeInput: typeof finishNativeInput; frames: () => Promise<void> }; }
await i18n.init({ lng: "en", resources: { en: { translation: en } } });
useAppStore.setState({ activeSessionId: "history-fixture", messages: [], sessions: [], runningSessions: {},
pendingPlans: {}, pendingAsks: {}, pendingPermissions: {}, planningStates: {}, latestTurnResults: {},
settings: { ...useAppStore.getState().settings, smoothStreaming: false } });
-globalThis.historyLoadingFixture = { reset, begin, beginAhead, track, release, inspect, growTail, hideAndReveal, inputOwnership, jumpWhileLoading, growMountedWindow, armNativeInput, finishNativeInput,
+globalThis.historyLoadingFixture = { reset, begin, beginAhead, track, release, inspect, growTail, hideAndReveal, inputOwnership, jumpWhileLoading, growMountedWindow, crossAhead, armNativeInput, finishNativeInput,
frames: async () => { for (let n = 0; n < 4; n++) await frame(); } };
await reset();
diff --git a/scripts/e2e/transcript-history-navigation.tsx b/scripts/e2e/transcript-history-navigation.tsx
index ead6dfc38..12062b7fe 100644
--- a/scripts/e2e/transcript-history-navigation.tsx
+++ b/scripts/e2e/transcript-history-navigation.tsx
@@ -7,6 +7,7 @@ import { IPC } from "@pi-desktop/shared/protocol";
import type { Result, SessionSummary, UiMessage } from "@pi-desktop/shared";
import { SessionPane } from "../../apps/desktop/src/components/SessionPane";
import { useAppStore } from "../../apps/desktop/src/stores/app-store";
+import { getTranscriptReadingPosition } from "../../apps/desktop/src/lib/transcript-reading-position";
const frame = () => new Promise<void>(resolve => requestAnimationFrame(() => resolve()));
async function until(predicate: () => boolean, label: string) {
@@ -37,6 +38,8 @@ globalThis.transcriptHistoryNavigationProbe = async (reducedOnly = false) => {
let pending: { resolve: (value: unknown) => void; response: unknown }[] = [];
const reads: number[] = [];
const unexpected: string[] = [];
+ let deferSearch = false;
+ let searchRead: { resolve: (value: unknown) => void } | undefined;
window.piDesktop = { channels: IPC, platform: "win32", on: () => () => {},
invoke: async <T,>(channel: string, ...args: unknown[]): Promise<Result<T>> => {
let value: unknown;
@@ -49,7 +52,9 @@ globalThis.transcriptHistoryNavigationProbe = async (reducedOnly = false) => {
const start = Math.max(0, end - limit);
const response = { session: { ...summary, messages: data.slice(start, end), messageStart: start,
messageEnd: end, hasMoreBefore: start > 0, hasMoreAfter: end < data.length } };
- if (before !== undefined && before < data.length) {
+ if ("messageAround" in input && deferSearch) {
+ value = await new Promise(resolve => { searchRead = { resolve }; });
+ } else if (before !== undefined && before < data.length) {
reads.push(before);
value = await new Promise(resolve => pending.push({ resolve, response }));
} else value = response;
@@ -71,6 +76,7 @@ globalThis.transcriptHistoryNavigationProbe = async (reducedOnly = false) => {
const reset = async (name: string, role: "user" | "mixed" = "user", running = false, tailOnly = false) => {
flushSync(() => root.render(null));
for (const item of pending.splice(0)) item.resolve(item.response);
+ searchRead?.resolve({ session: null }); searchRead = undefined; deferSearch = false;
id = `navigation-${name}`;
const count = tailOnly ? 35 : 280;
data = Array.from({ length: count }, (_, index) => ({ id: `${id}-${index}`,
@@ -179,7 +185,7 @@ globalThis.transcriptHistoryNavigationProbe = async (reducedOnly = false) => {
assert(failures.length === 0 && unexpected.length === 0, failures.join("\n"));
return { ok: true, reducedMotion: true, cases: results };
}
- for (const action of ["interrupt", "growth", "complete", "hide", "unmount", "new-search"] as const) {
+ for (const action of ["interrupt", "press", "growth", "complete", "hide", "unmount", "new-search", "failed-search"] as const) {
await reset(`lifecycle-${action}`, "mixed", action === "growth" || action === "complete");
const anchor = begin();
try {
@@ -189,7 +195,31 @@ globalThis.transcriptHistoryNavigationProbe = async (reducedOnly = false) => {
const oldTop = el.scrollTop;
host.querySelector<HTMLButtonElement>(".jump-latest-btn")!.click();
await until(() => el.scrollTop > oldTop + 20 && !bottom(), "trip did not enter an intermediate position");
- if (action === "new-search") {
+ if (action === "failed-search") {
+ deferSearch = true;
+ const request = useAppStore.getState().navigateTranscript({ sessionId: id, messageId: data[270].id, query: "Message 270" });
+ await until(() => Boolean(searchRead), "delayed search did not start");
+ await frame();
+ const stopped = el.scrollTop;
+ for (let n = 0; n < 70; n++) await frame();
+ assert(Math.abs(el.scrollTop - stopped) <= 2 && !bottom(), "pending search did not cancel latest motion");
+ searchRead!.resolve({ session: null }); searchRead = undefined;
+ await request;
+ assert(Boolean(host.querySelector(".jump-latest-btn")), "failed search stranded history with no navigation control");
+ deferSearch = false;
+ } else if (action === "press") {
+ el.dispatchEvent(new PointerEvent("pointerdown", { bubbles: true, button: 0 }));
+ const bookmark = getTranscriptReadingPosition(id);
+ assert(bookmark?.pinned === false && bookmark.messageId, "press-only interruption left a pinned bookmark");
+ const stopped = el.scrollTop;
+ flushSync(() => root.render(null)); render();
+ await until(() => Boolean(scroller().querySelector(`[data-message-id="${CSS.escape(bookmark.messageId!)}"]`)), "interrupted reading row did not remount");
+ await frame();
+ const restoredOffset = () => scroller().querySelector<HTMLElement>(`[data-message-id="${CSS.escape(bookmark.messageId!)}"]`)!.getBoundingClientRect().top - scroller().getBoundingClientRect().top;
+ await until(() => Math.abs(restoredOffset() - bookmark.offset) <= 2,
+ `press-only interruption lost reading row on remount: expected=${bookmark.offset}, now=${restoredOffset()}, oldTop=${stopped}`);
+ assert(!bottom(), "press-only interruption repinned on remount");
+ } else if (action === "new-search") {
await useAppStore.getState().navigateTranscript({ sessionId: id, messageId: data[270].id, query: "Message 270" });
await until(() => useAppStore.getState().transcriptViews[id]?.focus?.messageId === data[270].id,
"new search did not replace latest intent");
@@ -229,12 +259,17 @@ globalThis.transcriptHistoryNavigationProbe = async (reducedOnly = false) => {
} catch (error) { failures.push(String(error)); console.log("LATEST_LIFECYCLE_ERROR " + action + " " + String(error)); }
finally { anchor.stop(); }
}
- await reset("focused-disjoint", "mixed");
- useAppStore.setState({ transcriptViews: { [id]: { messages: data.slice(0, 35), messageStart: 0,
- messageEnd: 35, hasMoreBefore: false, hasMoreAfter: true, loading: null,
- focus: { sessionId: id, messageId: data[0].id, query: "Message 0", requestId: 991 } } } });
- await until(() => Boolean(host.querySelector(".transcript-search-target")), "search target did not mount");
- {
+ for (const kind of ["focused", "restored"] as const) {
+ await reset(`${kind}-disjoint`, "mixed");
+ useAppStore.setState({ transcriptViews: { [id]: { messages: data.slice(0, 35), messageStart: 0,
+ messageEnd: 35, hasMoreBefore: false, hasMoreAfter: true, loading: null,
+ focus: { sessionId: id, messageId: data[0].id, query: "Message 0", requestId: 991 } } } });
+ await until(() => Boolean(host.querySelector(".transcript-search-target")), "search target did not mount");
+ if (kind === "restored") {
+ const view = useAppStore.getState().transcriptViews[id]!;
+ useAppStore.setState({ transcriptViews: { [id]: { ...view, focus: null, restored: true } } });
+ await until(() => !host.querySelector(".transcript-search-target"), "restored view did not leave search");
+ }
const el = scroller();
const positions: number[] = [];
let sampling = true;
@@ -246,15 +281,37 @@ globalThis.transcriptHistoryNavigationProbe = async (reducedOnly = false) => {
const beforeReads = reads.length;
host.querySelector<HTMLButtonElement>(".jump-latest-btn")!.click();
try {
- await until(() => !useAppStore.getState().transcriptViews[id] && bottom(), "disjoint search failed to join live tail");
+ await until(() => !useAppStore.getState().transcriptViews[id] && bottom(), `${kind} disjoint range failed to join live tail`);
const reversal = Math.max(0, ...positions.slice(1).map((top, n) => positions[n] - top));
assert(reversal <= 2, `old search alignment reversed latest: ${reversal}`);
assert(reads.length === beforeReads, "explicit latest read unloaded intermediate history");
- results.push({ focusedDisjoint: true, reversal });
- console.log("LATEST_FOCUSED_DISJOINT " + JSON.stringify({ reversal }));
- } catch (error) { failures.push(String(error)); console.log("LATEST_FOCUSED_DISJOINT_ERROR " + String(error)); }
+ results.push({ disjoint: kind, reversal });
+ console.log("LATEST_DISJOINT " + JSON.stringify({ kind, reversal }));
+ } catch (error) { failures.push(String(error)); console.log("LATEST_DISJOINT_ERROR " + kind + " " + String(error)); }
finally { sampling = false; }
}
+ await reset("prefetch-repin", "mixed", true);
+ {
+ const anchor = begin(scroller().clientHeight * 2);
+ try {
+ await until(() => pending.length === 1, "repin setup did not prefetch");
+ const el = scroller();
+ el.dispatchEvent(new WheelEvent("wheel", { bubbles: true, deltaY: 100 }));
+ el.scrollTo({ top: el.scrollHeight - el.clientHeight, behavior: "instant" });
+ el.dispatchEvent(new Event("scroll", { bubbles: true }));
+ await frame();
+ 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(400), status: "streaming" }] });
+ for (let n = 0; n < 8; n++) await frame();
+ assert(bottom() && !host.querySelector(".jump-latest-btn"), "repinned prefetch did not follow new output");
+ await finish();
+ assert(bottom(), "late prefetched page stole resumed follow");
+ results.push({ prefetchRepin: true });
+ console.log("PREFETCH_REPIN " + JSON.stringify({ ok: true }));
+ } catch (error) { failures.push(String(error)); console.log("PREFETCH_REPIN_ERROR " + String(error)); }
+ finally { anchor.stop(); }
+ }
for (const role of ["user", "mixed"] as const) {
await reset(`prefetch-${role}`, role);
const anchor = begin(scroller().clientHeight * 2);
diff --git a/scripts/e2e/transcript-reading-position.tsx b/scripts/e2e/transcript-reading-position.tsx
index f7d704f2f..aa7fa970b 100644
--- a/scripts/e2e/transcript-reading-position.tsx
+++ b/scripts/e2e/transcript-reading-position.tsx
@@ -94,13 +94,18 @@ globalThis.transcriptReadingPositionProbe = async () => {
a.dispatchEvent(new WheelEvent("wheel", { bubbles: true, deltaY: -500 }));
a.scrollTop = 650;
a.dispatchEvent(new Event("scroll", { bubbles: true }));
- await frame();
const row = a.querySelector<HTMLElement>('[data-message-id="m47"]');
assert(row, "reading row exists");
+ const messageOffset = () => row.getBoundingClientRect().top - a.getBoundingClientRect().top;
+ const beforeGrowthOffset = messageOffset();
+ await frame();
+ const warmOffset = messageOffset();
+ const warmTop = a.scrollTop;
+ assert(Math.abs(warmOffset - beforeGrowthOffset) < 2, "ahead-mount changed the visible reading row");
select("B");
await frame();
select("A");
- assert(Math.abs(a.scrollTop - 650) < 2, `warm return lost offset: ${a.scrollTop}`);
+ assert(Math.abs(messageOffset() - warmOffset) < 2, `warm return lost reading offset: ${messageOffset()} vs ${warmOffset}`);
flushSync(() => row.querySelector<HTMLButtonElement>("button")!.click());
await frame();
a.dispatchEvent(new WheelEvent("wheel", { bubbles: true, deltaY: 400 }));
@@ -149,7 +154,7 @@ globalThis.transcriptReadingPositionProbe = async () => {
finishDeferredRestore = undefined;
await until(() => Math.abs(deferredScroller.scrollTop - 650) < 2,
"the saved offset applies after a successful restore lookup");
- return { ok: true, warmOffset: 650, restoredOffset, panes: host.querySelectorAll("[data-pane]").length };
+ return { ok: true, warmTop, warmOffset, restoredOffset, panes: host.querySelectorAll("[data-pane]").length };
} catch (error) {
return { ok: false, error: error instanceof Error ? error.stack : String(error) };
} finally {
diff --git a/tests/history-loading-scroll-test-cases.md b/tests/history-loading-scroll-test-cases.md
index dcf9badb1..eefebbe64 100644
--- a/tests/history-loading-scroll-test-cases.md
+++ b/tests/history-loading-scroll-test-cases.md
@@ -159,7 +159,12 @@ intermediate frames, reversal `<= 2px`, and zero empty visible-message frames),
two ahead-read prefetch cases (standalone user rows and mixed grouped answers
moving the same visible message `100px` during IO and staying within `2px` after
prepend), two quiet message-stability cases, and four pending/settled
-latest-button cases.
+latest-button cases. Boundary regressions also cross the prefetch threshold with
+browser-native smooth travel, resume follow during pending IO, interrupt by a
+press without a scroll and remount the saved message, start a delayed failed
+search, and return from focused/restored disjoint ranges without forward paging.
+Stream growth/completion, hide/unmount, and reduced-motion media emulation are
+covered separately. Empty-view checks run after layout, before paint.
| Requirement | Cases | Evidence level |
| --- | --- | --- |