Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(agentic-ide): stop a Claude Code pane losing its scrollbar to a misread screen

Ruben Lütke37ff9d60bcb9
diff --git a/jarvis/ui/web/frontend/src/components/agentic/PaneScrollbar.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/PaneScrollbar.test.tsx
index 35adb0ef8d..65b610a47c 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/PaneScrollbar.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/PaneScrollbar.test.tsx
@@ -366,6 +366,67 @@ describe("PaneScrollbar", () => {
}
});
+ /*
+ * The same rule for the question that was never answered at all — a notch
+ * relayed into a terminal that was still being built, or while the agent was
+ * repainting its whole screen. Nothing is measured either way, so the pane
+ * looks exactly like one with no history: no bar. Treating only an explicit
+ * "nothing here" as re-askable left such a pane one unlucky probe away from
+ * having no scrollbar for the rest of its life, which is the original bug
+ * with a rarer trigger.
+ */
+ it("asks again when the first probe went unanswered", () => {
+ vi.useFakeTimers();
+ try {
+ const pane = fakeTerminal({
+ type: "alternate",
+ length: 24,
+ mouseTrackingMode: "any",
+ });
+ const relayed: number[] = [];
+ render(<Harness term={pane.term} />);
+ const host = document.querySelector(".agentic-terminal-host")!;
+ const paneScreen = host.querySelector(".xterm-screen")!;
+ paneScreen.addEventListener("wheel", (event) => {
+ const delta = (event as WheelEvent).deltaY;
+ relayed.push(delta);
+ pane.show(
+ delta < 0
+ ? [...transcript(0, 1), ...transcript(1, 23)]
+ : transcript(1, 24),
+ );
+ });
+ // The terminal is not up yet: there is nothing to hand a notch to.
+ paneScreen.remove();
+
+ reachForTheBar();
+ act(() =>
+ vi.advanceTimersByTime(PROBE_WAIT_MS + PROBE_RETURN_MS + SETTLE_MS * 2),
+ );
+ expect(relayed).toEqual([]);
+ expect(screen.queryByTestId("pane-scrollbar-Dana")).toBeNull();
+
+ // Pointer away, the terminal arrives, and the question is asked again.
+ fireEvent.mouseMove(screen.getByTestId("region"), {
+ clientX: 40,
+ clientY: 150,
+ });
+ host.appendChild(paneScreen);
+ act(() => vi.advanceTimersByTime(PROBE_STALE_MS));
+ reachForTheBar();
+ act(() =>
+ vi.advanceTimersByTime(PROBE_WAIT_MS + PROBE_RETURN_MS + SETTLE_MS * 2),
+ );
+
+ expect(relayed).toEqual([-1, 1]);
+ expect(screen.getByTestId("pane-scrollbar-Dana").dataset.mode).toBe(
+ "app",
+ );
+ } finally {
+ vi.useRealTimers();
+ }
+ });
+
/*
* And it is only for panes whose application holds the history. A terminal that
* owns its scrollback already reports the truth, and a relayed notch there would
diff --git a/jarvis/ui/web/frontend/src/components/agentic/PaneScrollbar.tsx b/jarvis/ui/web/frontend/src/components/agentic/PaneScrollbar.tsx
index 522d151ec7..08cd3f1103 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/PaneScrollbar.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/PaneScrollbar.tsx
@@ -212,9 +212,15 @@ export function PaneScrollbar({
// settle period later and a pointer crossing the hot zone twice in that time
// must not ask twice.
//
- // One answer does expire: "this pane has no history at all" is true of the
- // moment it was measured, and a pane that was empty when it opened fills up.
- // See `measuredNoHistory` in ./paneAppScroll.
+ // Only one answer stands for good: "there IS history here". Everything else
+ // expires. "This pane has no history at all" is true of the moment it was
+ // measured, and a pane that was empty when it opened fills up; a probe that
+ // produced no answer AT ALL — sent while the application was repainting, or
+ // into a terminal that was still being built — leaves the pane in the very
+ // same state, without a bar and with nothing measured. Treating only the
+ // first of those as re-askable is what left a pane one unlucky probe away
+ // from having no scrollbar for the rest of its life. See `measuredNoHistory`
+ // and `PROBE_STALE_MS` in ./paneAppScroll.
const probedAt = useRef<{ epoch: number; at: number } | null>(null);
useEffect(() => {
if (!nearEdge) return;
@@ -225,10 +231,7 @@ export function PaneScrollbar({
const stale = () => {
const last = probedAt.current;
if (!last || last.epoch !== epoch) return true;
- return (
- measuredNoHistory(positionRef.current) &&
- Date.now() - last.at >= PROBE_STALE_MS
- );
+ return Date.now() - last.at >= PROBE_STALE_MS;
};
// Nothing to ask while a history is known to exist — except when the only
// thing known is that there was none, and that reading has gone stale.
diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneAppScroll.test.ts b/jarvis/ui/web/frontend/src/components/agentic/paneAppScroll.test.ts
index 41dde3f54d..1517115f5d 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/paneAppScroll.test.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/paneAppScroll.test.ts
@@ -104,6 +104,40 @@ describe("detectShift", () => {
expect(detectShift(before, after)).toBe(1);
});
+ /*
+ * The failure the whole bar hung on, in miniature — measured 2026-07-27 by
+ * replaying a recorded Claude Code 2.1.220 session into a real terminal.
+ *
+ * A column of short, look-alike rows (numbers, a file tree, a wrapped list)
+ * carries nothing recognisable enough to survive a scroll, so the only rows
+ * that still match are the ones the application pins to the bottom — and
+ * those match at a shift of zero by construction. Read as "the screen did not
+ * move", that is an end of the history at distance zero: a pane with nothing
+ * to scroll, and therefore no scrollbar at all, while its transcript was
+ * scrolling three lines at a time under the pointer.
+ *
+ * "We cannot say how far it went" is the honest answer, and it costs nothing:
+ * the caller falls back to what it asked for and claims no end of anything.
+ */
+ it("refuses to call a screen still that plainly changed", () => {
+ const furniture = [
+ "─────────────────",
+ "> type here",
+ "─────────────────",
+ "main · Opus 5 (1M context)",
+ "bypass permissions on",
+ ];
+ const numbers = (from: number) =>
+ Array.from({ length: 10 }, (_, i) => ` ${from + i}`);
+
+ expect(
+ detectShift(
+ [...numbers(40), ...furniture],
+ [...numbers(37), ...furniture],
+ ),
+ ).toBeNull();
+ });
+
it("refuses to guess from a screen with nothing on it", () => {
expect(detectShift(["", "", "a", ""], ["", "", "", "a"])).toBeNull();
expect(detectShift(transcript(1, 2), transcript(1, 2))).toBeNull();
diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneAppScroll.ts b/jarvis/ui/web/frontend/src/components/agentic/paneAppScroll.ts
index f173434057..ccaf26f58e 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/paneAppScroll.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/paneAppScroll.ts
@@ -153,6 +153,31 @@ function identifiable(text: string): boolean {
return text.trim().length > 2;
}
+/**
+ * How many rows hold different text than they did a moment ago.
+ *
+ * The evidence that SOMETHING happened, counted without any claim about what.
+ * A row that was blank and still is does not count, and neither does trailing
+ * whitespace — an application that repaints a row with the same text on it has
+ * not moved anything.
+ *
+ * Used by {@link detectShift} to tell its two silences apart. See the reasoning
+ * there: a screen full of short, look-alike rows can be scrolled without a
+ * single row being recognisable afterwards, and the difference between "it did
+ * not move" and "we cannot say how far" is the difference between a pane that
+ * keeps its scrollbar and one that loses it.
+ */
+function restlessRows(before: string[], after: string[]): number {
+ const rows = Math.max(before.length, after.length);
+ let restless = 0;
+ for (let i = 0; i < rows; i += 1) {
+ const was = (before[i] ?? "").trim();
+ const now = (after[i] ?? "").trim();
+ if (was !== now && (was !== "" || now !== "")) restless += 1;
+ }
+ return restless;
+}
+
/**
* The lines currently on screen, top row first.
*
@@ -189,6 +214,26 @@ export function visibleRows(term: Terminal | null): string[] {
* the prompt box and status line of a coding agent — match at zero and nowhere
* else, so they raise every candidate's floor equally and never decide the
* outcome as long as the scrolling region is the larger part of the screen.
+ *
+ * ## Zero is a verdict, and it is only reached on a still screen
+ *
+ * "Did not move" is the single most consequential answer this function gives:
+ * {@link applyShift} reads it as an end of the history, and an end of the
+ * history at distance zero is a pane with nothing to scroll — which takes its
+ * scrollbar away. So it may only be returned when the screen really did stand
+ * still, and NOT merely because nothing recognisable lined up.
+ *
+ * Those two came apart on a real transcript. When the scrolling region is
+ * short, look-alike rows — a column of numbers, a file tree, a wrapped list —
+ * every one of them fails the `identifiable` test above, the only rows left to
+ * vote are the prompt box and status line the application pins to the bottom,
+ * and those match at zero by construction. The screen had scrolled by three
+ * lines; the measurement reported that it had not moved at all, and the pane
+ * was recorded as having no history to scroll (measured 2026-07-27 against
+ * Claude Code 2.1.220, replaying a recorded session into a real terminal).
+ *
+ * Hence the last guard: if rows changed that no offset accounts for, the honest
+ * answer is null — we cannot say how far it went — and never zero.
*/
export function detectShift(before: string[], after: string[]): number | null {
const anchors = before.filter(identifiable).length;
@@ -214,7 +259,12 @@ export function detectShift(before: string[], after: string[]): number | null {
bestScore = score;
}
}
- return bestScore >= MIN_COMPARABLE_ROWS ? best : null;
+ if (bestScore < MIN_COMPARABLE_ROWS) return null;
+ // Zero only stands for a screen that stood still — see the header above.
+ if (best === 0 && restlessRows(before, after) >= MIN_COMPARABLE_ROWS) {
+ return null;
+ }
+ return best;
}
/**
@@ -318,14 +368,24 @@ export const PROBE_RETURN_MS = SETTLE_MS + 60;
export const PROBE_WAIT_MS = SETTLE_MS + 40;
/**
- * How long a "there is no history here" answer stands before it may be re-asked.
+ * How long an answer that found nothing stands before the pane may be re-asked.
*
* See {@link measuredNoHistory}: that answer is true of a moment, not of a pane.
- * A minute is long enough that nobody meets the probe twice in one reach for the
- * edge, and short enough that a pane which has since filled up gets its bar back
- * the next time somebody looks for it.
+ * The same goes for the probe that produced no answer at all — a terminal that
+ * was still being built, a relay that landed while the application was busy
+ * repainting. Both leave the pane exactly as it was: without a bar.
+ *
+ * A minute was far too long for that. Re-asking costs nothing precisely BECAUSE
+ * the last answer was "nothing here": a probe against a pane with no history
+ * moves nothing and is invisible, and one against a pane that has since filled
+ * up is the measurement that gives it its scrollbar back. Seconds, then — long
+ * enough that nobody meets the probe twice in one reach for the edge, short
+ * enough that the next reach after the pane fills up finds a working bar.
+ *
+ * "There IS history" is the one answer that never expires: a transcript does not
+ * get shorter.
*/
-export const PROBE_STALE_MS = 60_000;
+export const PROBE_STALE_MS = 5_000;
/**
* Ask a full-screen CLI whether it has a history — without moving the user.