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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(agentic-ide): re-ask a pane that had no history once it has had time to fill
Ruben Lütkebf41e2d80fa4
diff --git a/jarvis/ui/web/frontend/src/components/agentic/PaneScrollbar.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/PaneScrollbar.test.tsxindex 36e4eae8f5..35adb0ef8d 100644--- a/jarvis/ui/web/frontend/src/components/agentic/PaneScrollbar.test.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/PaneScrollbar.test.tsx@@ -3,7 +3,12 @@ import { act, fireEvent, render, screen } from "@testing-library/react";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import type { Terminal } from "@xterm/xterm";import { PaneScrollbar } from "./PaneScrollbar";-import { PROBE_RETURN_MS, PROBE_WAIT_MS, SETTLE_MS } from "./paneAppScroll";+import {+ PROBE_RETURN_MS,+ PROBE_STALE_MS,+ PROBE_WAIT_MS,+ SETTLE_MS,+} from "./paneAppScroll";const REGION = { top: 0, bottom: 300, left: 0, right: 400 };const TRACK_PX = 300;@@ -287,6 +292,80 @@ describe("PaneScrollbar", () => {}});+ /*+ * The one answer that expires. A pane opened a minute ago holds a single screen+ * and nothing above it, so the first probe honestly finds no history — and a+ * pane is at its emptiest exactly when somebody first reaches for its edge. Ten+ * minutes of an agent printing later there are pages of it, and treating that+ * first reading as final would leave the pane bar-less for good: the original+ * bug arriving through a different door.+ */+ it("asks again once a pane that had no history has had time to fill up", () => {+ vi.useFakeTimers();+ try {+ const pane = fakeTerminal({+ type: "alternate",+ length: 24,+ mouseTrackingMode: "any",+ });+ const relayed: number[] = [];+ let hasHistory = false;+ render(<Harness term={pane.term} />);+ document+ .querySelector(".xterm-screen")!+ .addEventListener("wheel", (event) => {+ const delta = (event as WheelEvent).deltaY;+ relayed.push(delta);+ // Nothing above the screen at first, so the CLI repaints unchanged.+ if (!hasHistory) return;+ pane.show(+ delta < 0+ ? [...transcript(0, 1), ...transcript(1, 23)]+ : transcript(1, 24),+ );+ });++ const reachAndWait = () => {+ reachForTheBar();+ act(() =>+ vi.advanceTimersByTime(+ PROBE_WAIT_MS + PROBE_RETURN_MS + SETTLE_MS * 2,+ ),+ );+ // Pointer away again, so the next reach is a fresh one.+ fireEvent.mouseMove(screen.getByTestId("region"), {+ clientX: 40,+ clientY: 150,+ });+ act(() => vi.advanceTimersByTime(1000));+ };++ reachAndWait();+ expect(relayed).toEqual([-1, 1]);+ expect(screen.queryByTestId("pane-scrollbar-Dana")).toBeNull();++ // Straight away, the answer still stands — no second probe.+ reachAndWait();+ expect(relayed).toEqual([-1, 1]);++ // A while later the pane has printed, and the question is worth asking+ // again.+ hasHistory = true;+ act(() => vi.advanceTimersByTime(PROBE_STALE_MS));+ reachForTheBar();+ act(() =>+ vi.advanceTimersByTime(PROBE_WAIT_MS + PROBE_RETURN_MS + SETTLE_MS * 2),+ );++ expect(relayed).toEqual([-1, 1, -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 woulddiff --git a/jarvis/ui/web/frontend/src/components/agentic/PaneScrollbar.tsx b/jarvis/ui/web/frontend/src/components/agentic/PaneScrollbar.tsxindex 49e2dba053..8ad5679a9a 100644--- a/jarvis/ui/web/frontend/src/components/agentic/PaneScrollbar.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/PaneScrollbar.tsx@@ -57,8 +57,10 @@ import {appTakesWheel,AT_LIVE_END,hasMeasuredHistory,+ measuredNoHistory,notchesForLines,probeAppHistory,+ PROBE_STALE_MS,PROBE_WAIT_MS,trackAppScroll,type AppScrollPosition,@@ -208,25 +210,38 @@ export function PaneScrollbar({// for why waiting for a wheel turn instead left the bar unreachable in exactly// the panes it exists for.//- // Asked once per terminal, only while nothing is known, and only after the pane- // has been quiet for `PROBE_WAIT_MS`: a probe moves the application by a notch- // and back, which is invisible once but would be a twitch on every pass of the- // pointer — and a probe folded into a burst of the user's own scrolling measures- // neither of them. `probedEpoch` rather than the position alone, because the- // answer lands a settle period later and a pointer crossing the hot zone twice- // in that time must not ask twice.- const probedEpoch = useRef<number | null>(null);+ // Asked only while nothing is known, and only after the pane has been quiet for+ // `PROBE_WAIT_MS`: a probe moves the application by a notch and back, which is+ // invisible once but would be a twitch on every pass of the pointer — and a+ // probe folded into a burst of the user's own scrolling measures neither of+ // them. `probedAt` rather than the position alone, because the answer lands a+ // 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.+ const probedAt = useRef<{ epoch: number; at: number } | null>(null);useEffect(() => {if (!nearEdge) return;const host = hostRef.current;const term = getTerminal();if (!host || !term || !appTakesWheel(term)) return;- if (- hasMeasuredHistory(positionRef.current) ||- probedEpoch.current === epoch- ) {- return;- }++ const stale = () => {+ const last = probedAt.current;+ if (!last || last.epoch !== epoch) return true;+ return (+ measuredNoHistory(positionRef.current) &&+ 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.+ const settled = () =>+ hasMeasuredHistory(positionRef.current) &&+ !measuredNoHistory(positionRef.current);+ if (settled() || !stale()) return;let stopProbe: (() => void) | undefined;let wait: number | undefined;@@ -236,8 +251,8 @@ export function PaneScrollbar({host.removeEventListener("wheel", defer, { capture: true });// The wait may have been all it took: a wheel turn measures the pane// better than any probe, so if one landed there is nothing left to ask.- if (hasMeasuredHistory(positionRef.current)) return;- probedEpoch.current = epoch;+ if (settled()) return;+ probedAt.current = { epoch, at: Date.now() };stopProbe = probeAppHistory((direction) =>relayWheelNotch(host, direction),);diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneAppScroll.ts b/jarvis/ui/web/frontend/src/components/agentic/paneAppScroll.tsindex 96fe458daa..f173434057 100644--- a/jarvis/ui/web/frontend/src/components/agentic/paneAppScroll.ts+++ b/jarvis/ui/web/frontend/src/components/agentic/paneAppScroll.ts@@ -115,6 +115,24 @@ export function hasMeasuredHistory(position: AppScrollPosition): boolean {return position.spanKnown || position.span > 0 || position.offset > 0;}+/**+ * Did the measurement come back saying there is no history at all?+ *+ * A real answer, but only about the moment it was taken — and that is the whole+ * point of asking it separately. A pane opened a minute ago holds one screen and+ * nothing above it, so the first probe honestly finds nothing; ten minutes of an+ * agent printing later there are pages of it, and a measurement kept as final+ * would leave that pane without a bar for the rest of its life. Which is the bug+ * the probe exists to fix, arriving through a different door.+ *+ * So the caller re-asks a pane that answered this way once it has had time to+ * produce something (`PROBE_STALE_MS`). "There is history" needs no such+ * expiry: a transcript does not get shorter.+ */+export function measuredNoHistory(position: AppScrollPosition): boolean {+ return position.spanKnown && position.span === 0 && position.offset === 0;+}+/*** Fewest recognisable rows two screens need before they may be compared.*@@ -299,6 +317,16 @@ 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.+ *+ * 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.+ */+export const PROBE_STALE_MS = 60_000;+/*** Ask a full-screen CLI whether it has a history — without moving the user.*