Skip to content

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

fix(transcript): cancel smooth navigation on reader input

Seraph-xd3ba191d5012
diff --git a/apps/desktop/src/features/chat/transcript/hooks/useTranscriptScroll.ts b/apps/desktop/src/features/chat/transcript/hooks/useTranscriptScroll.ts
index a901d3a62..063c8d203 100644
--- a/apps/desktop/src/features/chat/transcript/hooks/useTranscriptScroll.ts
+++ b/apps/desktop/src/features/chat/transcript/hooks/useTranscriptScroll.ts
@@ -192,6 +192,11 @@ export function useTranscriptScroll({
contentRef.current,
);
if (!isScrollGestureInput(event.type as ScrollInputType, input)) return;
+ // Minimap / jump navigation runs in the browser, independently of our
+ // follow rAF. Real input must retire that animation at its current offset
+ // before its queued frames can overwrite the reader's next movement.
+ const scroller = scrollRef.current;
+ if (scroller) scroller.scrollTo({ top: scroller.scrollTop, behavior: "instant" });
cancelReadingPosition();
lastScrollGestureAtRef.current = performance.now();
// Real input takes the viewport back from a held disclosure position.
diff --git a/docs/spec/04-ux/09-interaction-patterns.md b/docs/spec/04-ux/09-interaction-patterns.md
index 225326c7d..7216555bc 100644
--- a/docs/spec/04-ux/09-interaction-patterns.md
+++ b/docs/spec/04-ux/09-interaction-patterns.md
@@ -771,6 +771,10 @@ may be retained while exactly one workspace supplies the visible shell context.
- The first upward manual scroll movement pauses auto-scroll immediately and
cancels any pending follow frame; small trackpad deltas must not snap back to
the bottom
+- Scroll input owned by the transcript also cancels an in-flight browser smooth
+ navigation at its current offset. A previous minimap or jump navigation must
+ not resume after the reader takes over; nested-scroll input and ordinary row
+ controls do not cancel the transcript's navigation.
- 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
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 651ef0d22..683785816 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -27,6 +27,22 @@
## 1. Goals
+### E2E-TRANSCRIPT-scroll-interruption
+
+- **Preconditions:** Real Chromium with the production transcript scroll hook;
+ a scrollable transcript, manual disclosure reading, and normal motion.
+- **Steps:** Start a smooth navigation toward earlier history. Deliver
+ transcript-owned wheel input before yielding to its first animation frame.
+ Observe subsequent animation frames and run the long-history streaming probe.
+- **Expected:** Input stops the old browser animation at the current offset;
+ later frames cannot move the reader toward its stale destination. Streaming,
+ disclosure anchoring, pinned follow, and long-history work budgets still pass.
+- **Coverage:** `node scripts/e2e-transcript-disclosure-anchor.mjs` and
+ `node scripts/e2e-transcript-render.mjs`.
+- **Specs:** Interaction patterns §2.2. **Milestone:** Maintenance.
+- **Status:** Automated browser regression; the interruption assertion fails
+ without explicit cancellation of the browser-owned smooth navigation.
+
### E2E model discovery membership
- **Entry:** `node scripts/e2e-model-discovery-state.mjs` after building Host,
diff --git a/scripts/e2e/transcript-disclosure-anchor.tsx b/scripts/e2e/transcript-disclosure-anchor.tsx
index 813e13e23..34fcb8a74 100644
--- a/scripts/e2e/transcript-disclosure-anchor.tsx
+++ b/scripts/e2e/transcript-disclosure-anchor.tsx
@@ -672,9 +672,38 @@ globalThis.transcriptDisclosureProbe = async () => {
`pending collapse work moved the rapidly expanded title by ${rapidExpanded.titleTop - rapid.atExpansion.titleTop}px: ${JSON.stringify({ rapidBefore, atExpansion: rapid.atExpansion, rapidExpanded })}`,
);
+ // A minimap navigation can still be animating when the reader takes over.
+ // Exercise the browser-owned animation separately from queued follow rAFs.
+ const interruption = mount(<TranscriptFixture sessionId="scroll-interruption" messages={[
+ message("interrupt-user", "user", "Read history"), toolRowMessage("interrupt-tool"),
+ ]} />);
+ const interruptScroller = interruption.querySelector<HTMLElement>(".thread-scroll")!;
+ const interruptContent = interruption.querySelector<HTMLElement>(".thread-content")!;
+ const interruptTitle = interruption.querySelector<HTMLElement>(".tool-row-header")!;
+ await waitForLayout({ label: "interruption mount", scroller: interruptScroller,
+ content: interruptContent, title: interruptTitle,
+ expected: () => interruptTitle.isConnected, direction: "initial" });
+ await waitForLayout({ label: "interruption disclosure", scroller: interruptScroller,
+ content: interruptContent, title: interruptTitle,
+ expected: () => interruptTitle.getAttribute("aria-expanded") === "true", direction: "grow",
+ trigger: () => interruptTitle.click() });
+ assert(interruptScroller.scrollTop > 0, "interruption fixture has no scroll range");
+ interruptScroller.scrollTo({ top: 0, behavior: "smooth" });
+ const interruptedTop = interruptScroller.scrollTop;
+ interruptScroller.dispatchEvent(new WheelEvent("wheel", { bubbles: true, deltaY: -1 }));
+ // Interrupt before yielding: hidden Linux windows can finish a smooth
+ // navigation between two rAF callbacks, so waiting for a mid-point races it.
+ // Synthetic input has no native default scroll. Any later movement is the
+ // old animation, which the production input handler must relinquish.
+ for (let frame = 0; frame < 6; frame++) {
+ await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
+ assert(Math.abs(interruptScroller.scrollTop - interruptedTop) < 2,
+ `interrupted navigation moved the reader: ${interruptedTop} -> ${interruptScroller.scrollTop}`);
+ }
assert(renderErrors.length === 0, `React render errors: ${renderErrors.map(String).join("; ")}`);
return {
ok: true,
+ interruption: { interruptedTop, finalTop: interruptScroller.scrollTop },
process: { before: processBefore, collapsed: processCollapsed, expanded: processExpanded },
rapid: { before: rapidBefore, expanded: rapidExpanded },
transcript: { before, expanded, collapsed },