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-read the scroll position on an idle pane
rubenluetke10-beepc4cde3199384
diff --git a/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.test.tsxindex 4b4d830df5..9204f0406c 100644--- a/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.test.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.test.tsx@@ -52,16 +52,21 @@ interface TerminalHarness {scrollLines: ReturnType<typeof vi.fn>;scrollToTop: ReturnType<typeof vi.fn>;scrollToBottom: ReturnType<typeof vi.fn>;+ /** Grow the scrollback WITHOUT firing an event — a pane that already wrote. */+ loadHistory: (next: { maxLine: number; line: number }) => void;}function fakeTerminal({type = "normal",line = 100,maxLine = 100,+ normalMaxLine = 0,}: {type?: "normal" | "alternate";line?: number;maxLine?: number;+ /** Scrollback in the normal buffer while an alternate screen is displayed. */+ normalMaxLine?: number;} = {}): TerminalHarness {const scroll = signal<number>();const parsed = signal<void>();@@ -84,6 +89,7 @@ function fakeTerminal({rows: 20,buffer: {active,+ normal: { baseY: normalMaxLine, viewportY: normalMaxLine },onBufferChange: changed.event,},onScroll: scroll.event,@@ -93,7 +99,17 @@ function fakeTerminal({scrollToTop,scrollToBottom,} as unknown as Terminal;- return { term, scrollToLine, scrollLines, scrollToTop, scrollToBottom };+ return {+ term,+ scrollToLine,+ scrollLines,+ scrollToTop,+ scrollToBottom,+ loadHistory: ({ maxLine: nextMax, line: nextLine }) => {+ active.baseY = nextMax;+ active.viewportY = nextLine;+ },+ };}function RailHarness({ name, term }: { name: string; term: Terminal }) {@@ -242,12 +258,54 @@ describe("PaneScrollRail", () => {const rail = giveTrackGeometry("Ida");const thumb = screen.getByTestId("pane-scroll-thumb-Ida");- // No history to scroll: the thumb honestly fills the whole track, and the- // tooltip explains who owns the screen. One rail shape for every pane —- // the owner-switching rail (grip, caps, strokes) is gone.+ // No history to scroll: the track is a faint full-length line, never a+ // bright bar that reads as a grip stuck at full height.+ expect(rail.dataset.scrollState).toBe("app");expect(thumb.style.height).toBe("200px");+ expect(thumb.className).toContain("bg-[#e7c46e]/20");expect(rail.title).toBe("Scroll Ida: a full-screen app owns this pane right now",);});++ it("points at the pane history when an app hides real scrollback", () => {+ const harness = fakeTerminal({+ type: "alternate",+ line: 0,+ maxLine: 0,+ normalMaxLine: 420,+ });+ render(<RailHarness name="Sora" term={harness.term} />);+ const rail = giveTrackGeometry("Sora");++ expect(rail.title).toBe(+ "Scroll Sora: a full-screen app owns this pane — its earlier history is in the pane history above",+ );+ });++ it("re-reads an idle pane whose history arrived before it subscribed", () => {+ vi.useFakeTimers({ toFake: ["setInterval", "clearInterval"] });+ try {+ // The regression this pins: a replayed pane writes its whole scrollback+ // in one burst, and an idle pane emits nothing afterwards. Reading once+ // and waiting for an event left the rail showing a full-track thumb on+ // a pane full of history — "the scrollbar is just gone".+ const harness = fakeTerminal({ line: 0, maxLine: 0 });+ render(<RailHarness name="Rex" term={harness.term} />);+ const rail = giveTrackGeometry("Rex");+ expect(rail.dataset.scrollState).toBe("empty");++ harness.loadHistory({ maxLine: 300, line: 300 });+ act(() => {+ vi.advanceTimersByTime(600);+ });++ expect(rail.dataset.scrollState).toBe("history");+ const thumb = screen.getByTestId("pane-scroll-thumb-Rex");+ expect(Number.parseFloat(thumb.style.height)).toBeLessThan(200);+ expect(rail.title).toBe("Terminal line 300 of 300");+ } finally {+ vi.useRealTimers();+ }+ });});diff --git a/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.tsx b/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.tsxindex 8501f2cb29..451e6d4da4 100644--- a/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.tsx@@ -55,6 +55,19 @@ interface PaneScrollRailProps {onFocus?: () => void;}+/**+ * How often the rail re-reads the terminal without being told to.+ *+ * xterm's events cover output and scrolling, but a pane that has STOPPED+ * emitting output still has a position to state, and the events that would+ * have announced it can land before this rail subscribes — a replayed session+ * writes its whole scrollback in one burst at mount. Without this the rail+ * kept whatever it read first, which on an idle pane was "no history yet", and+ * a full-track thumb on a pane full of history reads as a broken scrollbar+ * (reported 2026-08-09). `sameView` keeps a tick that changes nothing free.+ */+const RESYNC_MS = 500;+function sameView(left: TerminalScrollView | null,right: TerminalScrollView,@@ -63,7 +76,8 @@ function sameView(left?.rows === right.rows &&left.maxLine === right.maxLine &&left.line === right.line &&- left.altScreen === right.altScreen+ left.altScreen === right.altScreen &&+ left.hiddenHistory === right.hiddenHistory);}@@ -120,6 +134,14 @@ export function PaneScrollRail({};}, [epoch, scheduleSync, sync, terminalRef]);+ useEffect(() => {+ // Deliberately `sync`, not `scheduleSync`: the whole point of this timer is+ // to be the path that cannot be starved, and the rAF gate is exactly what+ // an unpainted or throttled pane withholds.+ const timer = window.setInterval(sync, RESYNC_MS);+ return () => window.clearInterval(timer);+ }, [sync]);+useEffect(() => {const region = regionRef.current;if (!region) return;@@ -273,11 +295,18 @@ export function PaneScrollRail({);if (!view) return null;- const valueText = view.altScreen- ? `Scroll ${name}: a full-screen app owns this pane right now`- : view.maxLine === 0- ? "No terminal history yet"- : `Terminal line ${view.line} of ${view.maxLine}`;+ // Three honest states, and the rail LOOKS different in each — a full-track+ // thumb that means "nothing to scroll" is indistinguishable from a stuck one+ // unless it also stops looking like a grip.+ const state = view.altScreen ? "app" : view.maxLine === 0 ? "empty" : "history";+ const valueText =+ state === "app"+ ? view.hiddenHistory > 0+ ? `Scroll ${name}: a full-screen app owns this pane — its earlier history is in the pane history above`+ : `Scroll ${name}: a full-screen app owns this pane right now`+ : state === "empty"+ ? `Scroll ${name}: nothing has scrolled out of view yet`+ : `Terminal line ${view.line} of ${view.maxLine}`;const shell = PANE_CHROME[appearance].shell;return (@@ -293,6 +322,7 @@ export function PaneScrollRail({aria-valuetext={valueText}tabIndex={0}data-testid={`pane-scroll-rail-${name}`}+ data-scroll-state={state}title={valueText}onPointerDown={onPointerDown}onPointerMove={onPointerMove}@@ -318,10 +348,14 @@ export function PaneScrollRail({data-pane-scroll-thumb="true"data-testid={`pane-scroll-thumb-${name}`}className={cn(- "absolute right-[3px] w-1.5 rounded-full bg-[#e7c46e]/65",+ "absolute right-[3px] w-1.5 rounded-full","shadow-[0_0_0_1px_rgba(0,0,0,0.18)] transition-[background-color,top]",- "group-hover:bg-[#e7c46e]/90 group-focus-visible:bg-[#e7c46e]/90",- dragging && "bg-[#e7c46e] transition-none",+ state === "history"+ ? "bg-[#e7c46e]/65 group-hover:bg-[#e7c46e]/90 group-focus-visible:bg-[#e7c46e]/90"+ : // Nothing to scroll: a faint full-length track, never a bright+ // bar that reads as a grip stuck at full height.+ "bg-[#e7c46e]/20",+ dragging && state === "history" && "bg-[#e7c46e] transition-none",)}style={{ top: geometry.top, height: geometry.height }}/>diff --git a/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.test.ts b/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.test.tsindex 1daa055168..c73904915a 100644--- a/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.test.ts+++ b/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.test.ts@@ -34,12 +34,15 @@ async function newTerminal(): Promise<Terminal> {function terminalDouble(tracking: "none" | "any",type: "normal" | "alternate",- { baseY = 0, viewportY = 0 } = {},+ { baseY = 0, viewportY = 0, normalBaseY = 0 } = {},): Terminal & { scrollLines: ReturnType<typeof vi.fn> } {return {rows: 24,modes: { mouseTrackingMode: tracking },- buffer: { active: { type, baseY, viewportY } },+ buffer: {+ active: { type, baseY, viewportY },+ normal: { baseY: normalBaseY, viewportY: normalBaseY },+ },scrollLines: vi.fn(),} as unknown as Terminal & { scrollLines: ReturnType<typeof vi.fn> };}@@ -53,7 +56,13 @@ describe("terminalScrollSurface", () => {const term = terminalDouble("none", "normal", { baseY: 80, viewportY: 40 });const view = readTerminalScrollView(term);- expect(view).toEqual({ rows: 24, maxLine: 80, line: 40, altScreen: false });+ expect(view).toEqual({+ rows: 24,+ maxLine: 80,+ line: 40,+ altScreen: false,+ hiddenHistory: 0,+ });expect(scrollThumbGeometry(view, 208)).toEqual({ top: 80, height: 48 });expect(lineAtThumbTop(view, 0, 208)).toBe(0);expect(lineAtThumbTop(view, 80, 208)).toBe(40);@@ -70,6 +79,21 @@ describe("terminalScrollSurface", () => {expect(scrollThumbGeometry(alt, 200)).toEqual({ top: 0, height: 200 });});+ it("reports scrollback an alternate-screen app is standing in front of", () => {+ // The alt buffer has no history of its own, but the conversation the app+ // covered is still in the normal buffer — the rail says where it went+ // instead of implying it is gone.+ const alt = readTerminalScrollView(+ terminalDouble("any", "alternate", { normalBaseY: 420 }),+ );+ expect(alt.hiddenHistory).toBe(420);+ // A normal-buffer pane never reports hidden history: its own is reachable.+ const plain = readTerminalScrollView(+ terminalDouble("none", "normal", { baseY: 80, normalBaseY: 80 }),+ );+ expect(plain.hiddenHistory).toBe(0);+ });+it("keeps the wheel on xterm history while a normal-buffer CLI tracks the mouse", () => {const term = terminalDouble("any", "normal", { baseY: 300, viewportY: 300 });const handler = captureWheelForTerminalHistory(term);diff --git a/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.ts b/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.tsindex cc1817d961..e7794c8274 100644--- a/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.ts+++ b/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.ts@@ -32,6 +32,13 @@ export interface TerminalScrollView {line: number;/** True while an alternate-screen app (vim, less) owns the screen. */altScreen: boolean;+ /**+ * Scrollback sitting in the NORMAL buffer while an alternate-screen app has+ * the display. It exists but cannot be scrolled to until that app exits —+ * knowing it is there is what lets the rail point at the pane history+ * instead of implying the conversation is gone.+ */+ hiddenHistory: number;}export interface ScrollThumbGeometry {@@ -57,14 +64,17 @@ function finiteWhole(value: unknown): number {/** The exact xterm viewport position — the only scroll truth this UI shows. */export function readTerminalScrollView(term: Terminal): TerminalScrollView {- const active = term.buffer?.active;+ const buffer = term.buffer;+ const active = buffer?.active;const rows = Math.max(1, finiteWhole(term.rows));const maxLine = finiteWhole(active?.baseY);+ const altScreen = (active?.type ?? "normal") === "alternate";return {rows,maxLine,line: clamp(finiteWhole(active?.viewportY), 0, maxLine),- altScreen: (active?.type ?? "normal") === "alternate",+ altScreen,+ hiddenHistory: altScreen ? finiteWhole(buffer?.normal?.baseY) : 0,};}