Repository navigation
Description
Chat view gets displaced when a stale "load older rows" scroll anchor is consumed on a later commit
Summary
The chat's bottom-anchored scroll shell saves a scroll anchor when it starts loading older rows, and a layout effect with no dependency array consumes that anchor on a later, unrelated re-render, writing capture.scrollTop + (scrollHeight − capture.scrollHeight) to the scroll view. The write's value always matches the formula exactly, it reproduces with natural gestures (four runs, no interception), and it can fire without any click as well. Depending on whether scrolling has since refreshed the anchor, the consume lands at the wrong place: thousands of pixels away from the reader's position, sometimes pinning them to the bottom, sometimes displacing them from it.
Versions and environment
- bb 0.44.0 (desktop app,
/Applications/bb.app); served bundlepage-shell-B24TvAJg.jsmatches the source atadbce963ae138ba077afbe011edb414ade4dcf26(desktop-v0.44.0verified byte-identical). - macOS 26.7 (Build 25G229), Apple Silicon.
- No agent or provider involved; the shell runs behind
ThreadChatandBottomAnchoredScrollBodyon the main thread view and on plugin-embedded panes alike (Focus Board pane,ThreadChatcompact/contained).
Steps to reproduce
Natural-gesture repro (no interception, no synthetic events; runs nat1–nat4, 4/4):
- Open a pane whose transcript first page is several viewports tall with older rows available (
GET /api/v1/threads/:id/timeline→timelinePage.hasOlderRows: true). - Wheel the transcript to the top; the natural older-rows fetch loads (HTTP 200). The anchor, saved at fetch start, stays pending after a successful load.
- Wheel back down to a reading position (the runs stopped 61–441 px above the bottom).
- Click a message row.
- The view yanks by the full prepended amount; a near-bottom click displaces up to roughly half a pane before re-pinning.
Ambient variant (no click): with the anchor pending and the reader mid-transcript, let a realtime update or query refetch re-render the shell — the same write fires with no reader input (runs d1, d4, d8), and if it changes no content size the wrong position sticks (measured rests of 1.9 s, 2.5 s, 3+ s; the shell corrects only on a content-size change via its ResizeObserver).
The upward-from-pinned-bottom shape of the original incident needs one staged freeze (abort the /timeline?beforeAnchor* fetch, move the view to the top without wheel input so the anchor freezes at 0, return it to the bottom without scroll input, then click): write lands mid-transcript from the pinned bottom (4853 → 16, 5/5 valid runs, ≤ ~90 ms after pointerdown). Staged runs reproduce the arithmetic and stack; note that natural scrolling cannot freeze the anchor this way (scroll intent refreshes it), so this shape is a mechanism probe of the same defect.
Scripted repro (self-contained; clean boot, fresh Chrome profile; needs npm i puppeteer-core, a Chrome binary, the app URL); the review copy of this draft carries the same script as bb-click-jump-repro.mjs:
import puppeteer from "puppeteer-core";
const APP = process.env.BB_APP ?? "http://127.0.0.1:38886/";
const TITLE = process.env.THREAD_TITLE ?? "Hattrick Development";
const browser = await puppeteer.launch({
executablePath: process.env.CHROME_PATH ?? "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
headless: "new",
args: ["--window-size=1600,1200", "--disable-gpu", "--disable-dev-shm-usage"],
defaultViewport: { width: 1600, height: 1200 },
});
const page = await browser.newPage();
page.on("pageerror", (e) => console.log("[pageerror]", String(e).slice(0, 200)));
await page.evaluateOnNewDocument(() => {
window.__t0 = performance.now();
window.__writes = [];
window.__samples = [];
const tryPatch = () => {
const el = document.querySelector(".thread-scrollbar");
if (!el || window.__el) return;
window.__el = el;
const desc = Object.getOwnPropertyDescriptor(Element.prototype, "scrollTop");
Object.defineProperty(el, "scrollTop", {
configurable: true,
get() { return desc.get.call(this); },
set(v) {
window.__writes.push({
t: Math.round(performance.now() - window.__t0),
top: Math.round(v),
topWas: Math.round(desc.get.call(this)),
sh: Math.round(this.scrollHeight),
ch: this.clientHeight,
stack: (new Error().stack || "").split("\n").slice(2, 8)
.map((s) => s.trim().replace(/https?:\/\/[^)\s]*?\/(assets|dist)\//, "").replace(/:\d+:\d+/g, ""))
.join(" | ").slice(0, 400),
});
desc.set.call(this, v);
},
});
};
const mo = new MutationObserver(tryPatch);
try { mo.observe(document.documentElement, { subtree: true, childList: true, attributes: true }); } catch {}
setInterval(tryPatch, 25);
setInterval(() => {
if (!window.__el) return;
(window.__samples ??= []).push({ t: Math.round(performance.now() - window.__t0), top: Math.round(window.__el.scrollTop), sh: Math.round(window.__el.scrollHeight) });
}, 40);
});
await page.setRequestInterception(true);
page.on("request", (req) => {
const u = req.url();
if (u.includes("/timeline?") && u.includes("beforeAnchor")) {
console.log(">> aborting older-rows preload");
req.abort("failed");
return;
}
req.continue();
});
await page.goto(APP, { waitUntil: "networkidle2", timeout: 30000 });
await new Promise((r) => setTimeout(r, 2500));
await page.evaluate(() => {
[...document.querySelectorAll("button")].find((el) => (el.textContent ?? "").trim() === "Focus Board")?.click();
});
await new Promise((r) => setTimeout(r, 2500));
await page.evaluate((title) => {
const t = [...document.querySelectorAll("[data-thread-card]")].find((e) => (e.textContent ?? "").includes(title));
if (t) t.scrollIntoView({ block: "center", inline: "center" });
}, TITLE);
await new Promise((r) => setTimeout(r, 700));
const cardRect = await page.evaluate((title) => {
const t = [...document.querySelectorAll("[data-thread-card]")].find((e) => (e.textContent ?? "").includes(title));
if (!t) return null;
const r = t.getBoundingClientRect();
return { x: r.x + r.width / 2, y: r.y + Math.min(r.height / 2, 30) };
}, TITLE);
if (!cardRect) { console.error("card not found:", TITLE); await browser.close(); process.exit(1); }
await page.mouse.click(cardRect.x, cardRect.y);
await new Promise((r) => setTimeout(r, 2500));
const paneInfo = await page.evaluate(() => {
const aside = document.querySelector('aside[aria-label^="Thread:"]');
const el = aside && aside.querySelector(".thread-scrollbar");
return el ? { thread: aside.getAttribute("aria-label"), top: Math.round(el.scrollTop), sh: Math.round(el.scrollHeight), max: Math.round(el.scrollHeight - el.clientHeight) } : null;
});
if (!paneInfo) { console.error("pane did not open"); await browser.close(); process.exit(1); }
console.log("pane open:", JSON.stringify(paneInfo));
await page.evaluate(() => { const el = document.querySelector(".thread-scrollbar"); el.scrollTop = 0; });
await new Promise((r) => setTimeout(r, 5000));
await page.evaluate(() => { const el = document.querySelector(".thread-scrollbar"); el.scrollTop = el.scrollHeight - el.clientHeight; });
await new Promise((r) => setTimeout(r, 80));
const clicked = await page.evaluate(() => {
const el = document.querySelector(".thread-scrollbar");
const e = el.getBoundingClientRect();
const comp = document.querySelector("[data-app-composer]") ?? document.querySelector("[data-promptbox-shell]");
const compTop = comp ? comp.getBoundingClientRect().top : e.bottom - 110;
const rows = [...el.querySelectorAll("[data-timeline-row-id]")].filter((r) => r.getBoundingClientRect().bottom <= compTop - 20);
const pick = rows[rows.length - 1];
if (!pick) return null;
const r = pick.getBoundingClientRect();
const y = Math.min(r.bottom - 8, compTop - 12, e.bottom - 12);
return { x: r.x + Math.min(150, r.width / 2), y: Math.max(y, e.y + 12) };
});
if (!clicked) { console.log("no clickable row found above composer; abort"); await browser.close(); process.exit(1); }
console.log(">> click:", JSON.stringify(clicked));
await page.mouse.click(clicked.x, clicked.y);
await new Promise((r) => setTimeout(r, 3000));
const writes = await page.evaluate(() => window.__writes ?? []);
console.log("== scrollTop writes:", JSON.stringify(writes, null, 1));
const yank = writes.find((w) => (w.stack || "").includes("We (page-shell"));
console.log(yank ? "BOGUS WRITE: scrollTop " + yank.topWas + " -> " + yank.top + " (stack below)\n" + yank.stack : "no bogus write this run; retry (an ambient commit may have consumed the anchor)");
await page.screenshot({ path: "/tmp/bb-click-jump-repro.png" });
await browser.close();Tried, did not reproduce: the same click on a transcript whose timeline has no older cursor (hasOlderRows: false) writes nothing (no anchor is ever taken; 5+ instrumented runs); clicks that do not re-render the scroll shell write nothing even with an anchor pending, which is why the symptom reads as "sometimes clicking".
Expected vs actual
Actual (natural runs; the read is pre-clamp via the instrumented setter):
nat1 wheel to top, natural fetch loads (sh 5871 -> 11940), composer click:
write 0 -> 6069 stack We 0 + (11940 - 5871)
nat2 natural load -> wheel to 61 px above bottom -> click row:
write 11200 -> 17411 (clamps to bottom) 11200 + (12295 - 6084)
nat3 natural load -> wheel to 441 px above bottom -> click row:
write 10820 -> 17031 10820 + 6211
nat4 natural load -> wheel to 187 px above bottom -> click row:
write 13140 -> 20131 13140 + 6991
Staged upward shape (pinned at bottom, anchor frozen at {scrollTop: 0, scrollHeight: 5871}):
pointerdown t=13933
scrollTop write t=13936: topWas 4853 -> 16 (live sh 5887) <- We | commitLayoutEffects
pointerup t=13940
click t=13942
scrollTop write t=13973: -> 4834 sh 5868 <- resize-driven re-clamp (je | St, ResizeObserver)
settling to pinned bottom; final top 4787 of sh 5821
at We (page-shell-B24TvAJg.js) // the anchor consume, a layout effect with no dep array
at zc (boot-vendor-DTModT0X.js) // react-dom commitLayoutEffects
at il (boot-vendor-DTModT0X.js)
Expected: a reader's scroll position is not rewritten by an unrelated later commit; loading older rows and returning to a reading position is stable; clicking a message row does not move the view.
Evidence
Measurement: every programmatic scrollTop write recorded with its pre-clamp value, live scrollHeight/clientHeight, and new Error().stack; 40 ms position samples plus pointer/click/wheel markers. Minified names (We, je, Ne, He, gt) were each mapped against the served bundle and the source (an adversarial round re-verified the mappings independently). Line references are to apps/app/src/components/ui/bottom-anchored-scroll-body.tsx at https://github.com/get-bb/bb/blob/adbce963ae138ba077afbe011edb414ade4dcf26/apps/app/src/components/ui/bottom-anchored-scroll-body.tsx (same lines in desktop-v0.44.0).
What we think the cause is (observed chain; interpretation labeled ours):
- Capture: the older-rows preload calls
captureScrollAnchor()before its fetch, storing{scrollHeight, scrollTop}in a ref (#L422-L431; bundleHe). - Consume: a no-dep
useLayoutEffectruns on the shell's every re-render and applies + clears only whendelta > 0(#L432-L441; bundleWe, the only no-dep layout effect in the chunk) — an anchor underdelta <= 0survives indefinitely. - Survival is normal: a failed load keeps the anchor (the
autoLoadFailedlatch,useAutoLoadOlderRows.ts#L58-L72), and successful loads keep it too (d6, nat1–nat4: anchors outlive HTTP 200 loads that add rows; the consume waits for the shell's later re-render). - Direction: with recent scroll input the shell overwrites only the anchor's
scrollTopwith the live position, keeping the stalescrollHeight(#L639-L661, write at#L651; bundlegt; this "advance while loading" behavior is what Fix timeline scroll anchor while older rows load #2427 shipped, closed 2026-08-25, its test covering prepend plus continued scrolling only). Refreshed anchor → overshoot clamped to the bottom (the 2026-09-29 recordings:9971 -> 19387 written, clamped to 10473 on a live max of 10457; also nat2–nat4). Frozen anchor → lands short of the maximum and displaces the view upward, by the content that was below the fold at capture (capture.scrollHeight − capture.scrollTop − clientHeight, verified exactly; e.g.4837 = 5871 − 0 − 1034). - Ambient consumes exist (d1, d4, d8; a natural-input persistent variant is expected but not yet run), and a consume with no content-size change leaves no automatic correction.
Adjacent path examined, not implicated: the row-anchor restore (applyScrollRestore at #L549-L568 via advancePendingScrollRestore #L700, thread-keyed effect #L778-L792) clamps writes to the maximum and never appeared in any captured stack.
Investigation doc (with the raw 2026-09-29 recordings and the update entries): https://github.com/cristoslc/bb-plugin-focus-board/blob/06e2ed795a6343cd630b5d737c84343faa99c51a/docs/chat-click-jump-2026-09-29.md
What you ruled out
- Not a plugin click handler: all yanking stacks resolve to the host bundle's page-shell module + React
commitLayoutEffects; a stack audit found plugin frames only in the guard's superseded revert writes (one invalid run). - Not the row-anchor restore path: it clamps to the maximum and never appeared in any stack.
- Not a fetch-failure regression: reproduced with the natural older-page fetch succeeding (nat1–nat4, d6) and with an aborted fetch — same write, same formula.
- Not other shell adjusters (selection snap / caret-in-view / unread divider): no-capture control clicks write nothing.
- Not Fix timeline scroll anchor while older rows load #2427 working as designed: its test covers only the in-flight case; a capture outliving its load is unhandled.
- Still present at
adbce963ae138ba077afbe011edb414ade4dcf26(served build verified identical via stack frames); Fix follow-up scroll jumps in long threads #1750 and Transcript flickers between full history and "Loading older messages…" while background subagents stream #4388 cover different symptoms.
Suggested priority and effort
Priority Medium, effort Low. Every long-transcript reader in a bottom-anchored pane can hit this once an anchor survives its load, the normal state after any older-rows load; the next render, often the reader's own click, then displaces the view badly, and the wrong position can stick. No data loss. #2427's own test shows where the change belongs.
AGENT GENERATED
Activity
bb-slop-cop commentedon Oct 3, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotui,confirmed-repro.git diff --check. Browser verification is blocked by missing Chrome.Docs: click-jump guard fix live-verified in both modes; investigation…
Certification closed: verdict 2026-10-05 rev 2 — ready-to-finalize; i…
Fix iOS scroll jumps while loading windowed history (get-bb#5022)
Revert "Fix iOS scroll jumps while loading windowed history (#5022)" (#…
The pane retires the chat-click jump guard and re-verifies the other …