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): remove terminal scroll rail

rubenluetke10-beep1f3f83f32583
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
index d759a39494..31f2add5b1 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
@@ -248,6 +248,21 @@ describe("AgenticTerminal layout", () => {
expect(terminalHarness.wheel.current).not.toBeNull();
});
+ it("keeps conversation history in the header without a scrollbar overlay", () => {
+ render(
+ <AgenticTerminal
+ name="Dana"
+ displayName="Claude Code"
+ appearance="dark"
+ fontSize={13}
+ />,
+ );
+
+ expect(screen.getByTestId("pane-conversation-Dana")).toBeTruthy();
+ expect(screen.queryByRole("scrollbar")).toBeNull();
+ expect(screen.queryByTestId("pane-scroll-history-Dana")).toBeNull();
+ });
+
it("keeps the wheel on terminal history even while the CLI tracks the mouse", () => {
render(
<AgenticTerminal
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
index 31d58ee816..4e537433a7 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
@@ -115,8 +115,10 @@ import {
PARKED_RECHECK_MS,
} from "./offscreenBuffer";
import { installQuerySuppression } from "./terminalQueries";
-import { PaneScrollRail } from "./PaneScrollRail";
-import { captureWheelForTerminalHistory } from "./terminalScrollSurface";
+import {
+ bindTerminalScrollRegion,
+ captureWheelForTerminalHistory,
+} from "./terminalScrollSurface";
import {
openPaneSocket,
type PaneSocket,
@@ -488,8 +490,8 @@ export function AgenticTerminal({
// briefly shows the pane's old viewport (often its first prompt) and visibly
// jumps to the live prompt one frame later.
const [tailReady, setTailReady] = useState(active);
- // The terminal itself stays in a ref. This small epoch only tells the scroll
- // rail that the ref now points at a new instance after a restart.
+ // The terminal itself stays in a ref. This small epoch tells appearance and
+ // font effects that the ref now points at a new instance after a restart.
const [terminalEpoch, setTerminalEpoch] = useState(0);
/*
* Is a replay currently rebuilding this pane behind the curtain?
@@ -541,9 +543,7 @@ export function AgenticTerminal({
const [dismissedAt, setDismissedAt] = useState<number | null>(null);
/** Briefly true right after a delivery — draws the eye to the right pane. */
const [justDelivered, setJustDelivered] = useState(false);
- /** The pane's recorded conversation, opened from the header book button or
- * a click on the scroll rail's grip. Lives HERE and not in the rail so the
- * entry point survives the CLI flipping its scroll-owner mode mid-session. */
+ /** The pane's recorded conversation, opened from the header book button. */
const [historyOpen, setHistoryOpen] = useState(false);
// Latest callbacks/appearance without re-running the connect effect.
const onStatusRef = useRef(onStatus);
@@ -584,6 +584,12 @@ export function AgenticTerminal({
focusedRef.current = focused;
layoutBusyRef.current = layoutBusy;
+ useEffect(() => {
+ const region = terminalRegionRef.current;
+ if (!region) return;
+ return bindTerminalScrollRegion(region);
+ }, []);
+
useEffect(() => {
if (!geometryReady) return;
const container = containerRef.current;
@@ -1774,17 +1780,6 @@ export function AgenticTerminal({
data-layout-busy={layoutBusy ? "true" : "false"}
className="agentic-terminal-host h-full min-h-0 w-full overflow-hidden"
/>
- <PaneScrollRail
- name={name}
- controlsId={terminalRegionId}
- regionRef={terminalRegionRef}
- hostRef={containerRef}
- terminalRef={termRef}
- epoch={terminalEpoch}
- appearance={appearance}
- onFocus={onFocus}
- onOpenHistory={() => setHistoryOpen(true)}
- />
<PaneConversationDialog
terminal={name}
open={historyOpen}
diff --git a/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.test.tsx
deleted file mode 100644
index 8584195d87..0000000000
--- a/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.test.tsx
+++ /dev/null
@@ -1,332 +0,0 @@
-import { useRef } from "react";
-import { act, fireEvent, render, screen } from "@testing-library/react";
-import type { Terminal } from "@xterm/xterm";
-import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
-import { PaneScrollRail } from "./PaneScrollRail";
-
-const nativePointerEvent = globalThis.PointerEvent;
-
-class PointerEventHarness extends MouseEvent {
- readonly pointerId: number;
-
- constructor(type: string, init: PointerEventInit = {}) {
- super(type, init);
- this.pointerId = init.pointerId ?? 0;
- }
-}
-
-beforeAll(() => {
- // jsdom has pointer event names but no PointerEvent constructor, so Testing
- // Library would otherwise create an event with none of the drag coordinates.
- Object.defineProperty(globalThis, "PointerEvent", {
- configurable: true,
- value: PointerEventHarness,
- });
-});
-
-afterAll(() => {
- Object.defineProperty(globalThis, "PointerEvent", {
- configurable: true,
- value: nativePointerEvent,
- });
-});
-
-type Listener<T> = (value: T) => void;
-
-function signal<T>() {
- const listeners = new Set<Listener<T>>();
- return {
- event(listener: Listener<T>) {
- listeners.add(listener);
- return { dispose: () => listeners.delete(listener) };
- },
- fire(value: T) {
- for (const listener of listeners) listener(value);
- },
- };
-}
-
-interface TerminalHarness {
- term: Terminal;
- scrollToLine: ReturnType<typeof vi.fn>;
- 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>();
- const changed = signal<unknown>();
- const active = { type, baseY: maxLine, viewportY: line };
- const scrollToLine = vi.fn((next: number) => {
- active.viewportY = next;
- scroll.fire(next);
- });
- const scrollLines = vi.fn((amount: number) => {
- active.viewportY = Math.max(
- 0,
- Math.min(active.baseY, active.viewportY + amount),
- );
- scroll.fire(active.viewportY);
- });
- const scrollToTop = vi.fn(() => scrollToLine(0));
- const scrollToBottom = vi.fn(() => scrollToLine(active.baseY));
- const term = {
- rows: 20,
- buffer: {
- active,
- normal: { baseY: normalMaxLine, viewportY: normalMaxLine },
- onBufferChange: changed.event,
- },
- onScroll: scroll.event,
- onWriteParsed: parsed.event,
- scrollToLine,
- scrollLines,
- scrollToTop,
- scrollToBottom,
- } as unknown as Terminal;
- return {
- term,
- scrollToLine,
- scrollLines,
- scrollToTop,
- scrollToBottom,
- loadHistory: ({ maxLine: nextMax, line: nextLine }) => {
- active.baseY = nextMax;
- active.viewportY = nextLine;
- },
- };
-}
-
-function RailHarness({
- name,
- term,
- onOpenHistory,
-}: {
- name: string;
- term: Terminal;
- onOpenHistory?: () => void;
-}) {
- const regionRef = useRef<HTMLDivElement | null>(null);
- const hostRef = useRef<HTMLDivElement | null>(null);
- const terminalRef = useRef<Terminal | null>(term);
- return (
- <div ref={regionRef} id={`terminal-${name}`}>
- <div ref={hostRef}>
- <div className="xterm-screen" data-testid={`xterm-screen-${name}`} />
- </div>
- <PaneScrollRail
- name={name}
- controlsId={`terminal-${name}`}
- regionRef={regionRef}
- hostRef={hostRef}
- terminalRef={terminalRef}
- epoch={1}
- appearance="dark"
- onOpenHistory={onOpenHistory}
- />
- </div>
- );
-}
-
-function giveTrackGeometry(name: string, height = 200): HTMLElement {
- const rail = screen.getByTestId(`pane-scroll-rail-${name}`);
- Object.defineProperty(rail, "clientHeight", {
- configurable: true,
- value: height,
- });
- rail.getBoundingClientRect = () =>
- ({
- top: 0,
- left: 0,
- right: 12,
- bottom: height,
- width: 12,
- height,
- x: 0,
- y: 0,
- toJSON: () => ({}),
- }) as DOMRect;
- act(() => fireEvent.resize(window));
- return rail;
-}
-
-describe("PaneScrollRail", () => {
- it("drags the exact xterm history independently for each terminal ID", () => {
- const mika = fakeTerminal();
- const nova = fakeTerminal();
- render(
- <>
- <RailHarness name="Mika" term={mika.term} />
- <RailHarness name="Nova" term={nova.term} />
- </>,
- );
- const rail = giveTrackGeometry("Mika");
- giveTrackGeometry("Nova");
- const thumb = screen.getByTestId("pane-scroll-thumb-Mika");
-
- fireEvent.pointerDown(thumb, { button: 0, clientY: 180, pointerId: 1 });
- fireEvent.pointerMove(rail, { clientY: 35, pointerId: 1 });
- fireEvent.pointerUp(rail, { clientY: 35, pointerId: 1 });
-
- expect(mika.scrollToLine).toHaveBeenCalled();
- expect(mika.scrollToLine.mock.calls.at(-1)?.[0]).toBeLessThan(30);
- expect(nova.scrollToLine).not.toHaveBeenCalled();
- expect(thumb.style.top).not.toBe("");
- expect(
- screen
- .getByRole("scrollbar", { name: "Scroll Mika" })
- .getAttribute("aria-controls"),
- ).toBe("terminal-Mika");
- });
-
- it("jumps to a pressed track spot and keeps dragging from there", () => {
- const harness = fakeTerminal({ line: 100, maxLine: 100 });
- render(<RailHarness name="Odo" term={harness.term} />);
- const rail = giveTrackGeometry("Odo");
-
- fireEvent.pointerDown(rail, { button: 0, clientY: 20, pointerId: 2 });
- expect(harness.scrollToLine).toHaveBeenCalled();
- expect(harness.scrollToLine.mock.calls.at(-1)?.[0]).toBeLessThan(30);
-
- fireEvent.pointerMove(rail, { clientY: 190, pointerId: 2 });
- fireEvent.pointerUp(rail, { clientY: 190, pointerId: 2 });
- expect(harness.scrollToLine.mock.calls.at(-1)?.[0]).toBe(100);
- });
-
- it("scrolls with the keyboard on every pane the same way", () => {
- const harness = fakeTerminal({ line: 50 });
- render(<RailHarness name="Vera" term={harness.term} />);
- const rail = giveTrackGeometry("Vera");
-
- fireEvent.keyDown(rail, { key: "ArrowUp" });
- fireEvent.keyDown(rail, { key: "ArrowDown" });
- fireEvent.keyDown(rail, { key: "PageUp" });
- fireEvent.keyDown(rail, { key: "PageDown" });
- fireEvent.keyDown(rail, { key: "Home" });
- fireEvent.keyDown(rail, { key: "End" });
-
- expect(harness.scrollLines.mock.calls.map((call) => call[0])).toEqual([
- -1, 1, -20, 20,
- ]);
- expect(harness.scrollToTop).toHaveBeenCalledOnce();
- expect(harness.scrollToBottom).toHaveBeenCalledOnce();
- });
-
- it("forwards a wheel over the rail unchanged to its own terminal", () => {
- const harness = fakeTerminal();
- render(<RailHarness name="Nia" term={harness.term} />);
- const rail = giveTrackGeometry("Nia");
- const xtermScreen = screen.getByTestId("xterm-screen-Nia");
- const received = vi.fn();
- xtermScreen.addEventListener("wheel", received);
-
- fireEvent.wheel(rail, {
- deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 5,
- deltaY: 120,
- shiftKey: true,
- });
-
- expect(received).toHaveBeenCalledOnce();
- const forwarded = received.mock.calls[0][0] as WheelEvent;
- expect(forwarded.deltaX).toBe(5);
- expect(forwarded.deltaY).toBe(120);
- expect(forwarded.shiftKey).toBe(true);
- });
-
- it("cancels an uncaptured drag when the pointer leaves the rail", () => {
- const harness = fakeTerminal({ line: 50 });
- render(<RailHarness name="Lumi" term={harness.term} />);
- const rail = giveTrackGeometry("Lumi");
- const thumb = screen.getByTestId("pane-scroll-thumb-Lumi");
-
- fireEvent.pointerDown(thumb, { button: 0, clientY: 100, pointerId: 6 });
- expect(rail.className).toContain("cursor-grabbing");
- fireEvent.pointerLeave(rail, { pointerId: 6 });
- expect(rail.className).not.toContain("cursor-grabbing");
- });
-
- it("says honestly when a full-screen app owns the pane", () => {
- const harness = fakeTerminal({ type: "alternate", line: 0, maxLine: 0 });
- render(<RailHarness name="Ida" term={harness.term} />);
- const rail = giveTrackGeometry("Ida");
- const thumb = screen.getByTestId("pane-scroll-thumb-Ida");
-
- // 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]/30");
- expect(rail.title).toBe(
- "Scroll Ida: this CLI draws a full screen and keeps its own history — open the pane history to scroll it",
- );
- });
-
- it("offers the pane history where a full-screen CLI keeps its own", () => {
- // Claude Code 2.1.226 takes the alternate screen (measured 2026-08-09), so
- // xterm holds no history for it and no thumb can ever be honest. Rather
- // than a dead track, the rail carries a visible door to the one scrollable
- // copy — an empty rail is what reads as "the scrollbar is broken".
- const harness = fakeTerminal({ type: "alternate", line: 0, maxLine: 0 });
- const onOpenHistory = vi.fn();
- render(
- <RailHarness name="Sora" term={harness.term} onOpenHistory={onOpenHistory} />,
- );
- const rail = giveTrackGeometry("Sora");
-
- expect(rail.dataset.scrollState).toBe("app");
- fireEvent.click(screen.getByTestId("pane-scroll-history-Sora"));
- expect(onOpenHistory).toHaveBeenCalledOnce();
- // The press must not also be read as a track seek.
- expect(harness.scrollToLine).not.toHaveBeenCalled();
- });
-
- it("carries no history door on a pane whose own history is scrollable", () => {
- const harness = fakeTerminal({ line: 40, maxLine: 100 });
- render(<RailHarness name="Kai" term={harness.term} onOpenHistory={vi.fn()} />);
- giveTrackGeometry("Kai");
-
- expect(screen.queryByTestId("pane-scroll-history-Kai")).toBeNull();
- });
-
- 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.tsx
deleted file mode 100644
index a937345db6..0000000000
--- a/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.tsx
+++ /dev/null
@@ -1,402 +0,0 @@
-/**
- * One scroll rail for one Agentic-IDE terminal pane — the SAME rail for every
- * provider and every CLI mode.
- *
- * It draws xterm's exact viewport position as a conventional thumb: dragging
- * seeks, clicking the track jumps, arrow/page keys scroll, and the wheel
- * passes through to the terminal. There is no second regime. The previous
- * owner-switching rail (grip, stroke gestures, key relays, live-view opt-in)
- * accumulated eight confirmed defects across four iterations and was removed
- * whole on the maintainer's verdict — see ./terminalScrollSurface for why the
- * single xterm-owned rule is honest for today's coding CLIs.
- *
- * While an alternate-screen app (vim, less) holds the screen, xterm has no
- * history: the thumb fills the track and the rail says so in its tooltip.
- */
-import {
- useCallback,
- useEffect,
- useLayoutEffect,
- useMemo,
- useRef,
- useState,
- type KeyboardEvent as ReactKeyboardEvent,
- type PointerEvent as ReactPointerEvent,
- type RefObject,
-} from "react";
-import type { Terminal } from "@xterm/xterm";
-import { BookOpenText } from "lucide-react";
-import { useT } from "@/i18n";
-import { cn } from "@/lib/utils";
-import { PANE_CHROME, type TerminalAppearance } from "./terminalThemes";
-import {
- bindTerminalScrollRegion,
- forwardWheelToTerminal,
- lineAtThumbTop,
- readTerminalScrollView,
- scrollThumbGeometry,
- type TerminalScrollView,
-} from "./terminalScrollSurface";
-
-interface DragSession {
- pointerId: number;
- /** Pixel offset between the grab point and the thumb's top edge. */
- grabOffset: number;
- captured: boolean;
-}
-
-interface PaneScrollRailProps {
- name: string;
- controlsId: string;
- regionRef: RefObject<HTMLElement | null>;
- hostRef: RefObject<HTMLElement | null>;
- terminalRef: RefObject<Terminal | null>;
- /** Bumped whenever the ref above receives a new xterm instance. */
- epoch: number;
- appearance: TerminalAppearance;
- onFocus?: () => void;
- /**
- * Open the pane's recorded conversation. The rail offers this where it has
- * nothing to scroll — an alternate-screen CLI owns its history, and a
- * pointer at the one scrollable copy beats a dead track.
- */
- onOpenHistory?: () => 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,
-): boolean {
- return (
- left?.rows === right.rows &&
- left.maxLine === right.maxLine &&
- left.line === right.line &&
- left.altScreen === right.altScreen &&
- left.hiddenHistory === right.hiddenHistory
- );
-}
-
-export function PaneScrollRail({
- name,
- controlsId,
- regionRef,
- hostRef,
- terminalRef,
- epoch,
- appearance,
- onFocus,
- onOpenHistory,
-}: PaneScrollRailProps) {
- const t = useT();
- const trackRef = useRef<HTMLDivElement | null>(null);
- const thumbRef = useRef<HTMLDivElement | null>(null);
- const dragRef = useRef<DragSession | null>(null);
- const frameRef = useRef<number | null>(null);
- const [view, setView] = useState<TerminalScrollView | null>(null);
- const [trackPx, setTrackPx] = useState(0);
- const [dragging, setDragging] = useState(false);
-
- const sync = useCallback(() => {
- frameRef.current = null;
- const term = terminalRef.current;
- if (!term) {
- setView(null);
- return;
- }
- const next = readTerminalScrollView(term);
- setView((current) => (sameView(current, next) ? current : next));
- }, [terminalRef]);
-
- const scheduleSync = useCallback(() => {
- if (frameRef.current !== null) return;
- frameRef.current = requestAnimationFrame(sync);
- }, [sync]);
-
- useEffect(() => {
- const term = terminalRef.current;
- if (!term) {
- setView(null);
- return;
- }
- sync();
- const subscriptions = [
- term.onScroll?.(scheduleSync),
- term.onWriteParsed?.(scheduleSync),
- term.buffer?.onBufferChange?.(scheduleSync),
- ];
- return () => {
- if (frameRef.current !== null) cancelAnimationFrame(frameRef.current);
- frameRef.current = null;
- for (const subscription of subscriptions) subscription?.dispose();
- };
- }, [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;
- return bindTerminalScrollRegion(region);
- }, [regionRef]);
-
- useEffect(() => {
- const track = trackRef.current;
- if (!track) return;
- const forward = (event: WheelEvent) => {
- forwardWheelToTerminal(hostRef.current, event);
- };
- // Passive by design: this listener only clones the input. The terminal
- // region contains the browser default after xterm has received the clone.
- track.addEventListener("wheel", forward, { passive: true });
- return () => track.removeEventListener("wheel", forward);
- }, [hostRef, view !== null]);
-
- useLayoutEffect(() => {
- const track = trackRef.current;
- if (!track) return;
- const measure = () => {
- const height = track.clientHeight || track.getBoundingClientRect().height;
- setTrackPx((current) => (current === height ? current : height));
- };
- measure();
- const observer =
- typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
- observer?.observe(track);
- window.addEventListener("resize", measure);
- return () => {
- observer?.disconnect();
- window.removeEventListener("resize", measure);
- };
- }, [view !== null]);
-
- const liveTrack = useCallback(() => {
- const track = trackRef.current;
- if (!track) return { top: 0, height: 0 };
- const box = track.getBoundingClientRect();
- return { top: box.top, height: track.clientHeight || box.height };
- }, []);
-
- const moveTo = useCallback(
- (clientY: number, grabOffset: number) => {
- const term = terminalRef.current;
- if (!term) return;
- const current = readTerminalScrollView(term);
- const track = liveTrack();
- if (track.height <= 0) return;
- const thumbTop = clientY - track.top - grabOffset;
- term.scrollToLine(lineAtThumbTop(current, thumbTop, track.height));
- scheduleSync();
- },
- [liveTrack, scheduleSync, terminalRef],
- );
-
- const onPointerDown = useCallback(
- (event: ReactPointerEvent<HTMLDivElement>) => {
- if (event.button !== 0) return;
- const term = terminalRef.current;
- if (!term) return;
- const track = liveTrack();
- if (track.height <= 0) return;
- event.preventDefault();
- event.stopPropagation();
- onFocus?.();
-
- const current = readTerminalScrollView(term);
- const geometry = scrollThumbGeometry(current, track.height);
- const grabbedThumb = event.target === thumbRef.current;
- const grabOffset = grabbedThumb
- ? event.clientY - track.top - geometry.top
- : geometry.height / 2;
- dragRef.current = {
- pointerId: event.pointerId,
- grabOffset,
- captured: false,
- };
- setDragging(true);
- try {
- event.currentTarget.setPointerCapture(event.pointerId);
- dragRef.current.captured =
- event.currentTarget.hasPointerCapture?.(event.pointerId) ?? true;
- } catch {
- // Older WebViews and jsdom have no pointer-capture implementation.
- }
- // A press on the bare track is a jump to that spot; the drag continues
- // from there. A press on the thumb keeps the line under the hand.
- if (!grabbedThumb) moveTo(event.clientY, grabOffset);
- },
- [liveTrack, moveTo, onFocus, terminalRef],
- );
-
- const onPointerMove = useCallback(
- (event: ReactPointerEvent<HTMLDivElement>) => {
- const drag = dragRef.current;
- if (!drag || drag.pointerId !== event.pointerId) return;
- event.preventDefault();
- moveTo(event.clientY, drag.grabOffset);
- },
- [moveTo],
- );
-
- const finishDrag = useCallback((pointerId?: number) => {
- const drag = dragRef.current;
- if (!drag || (pointerId !== undefined && pointerId !== drag.pointerId)) {
- return;
- }
- dragRef.current = null;
- setDragging(false);
- }, []);
-
- const onPointerUp = useCallback(
- (event: ReactPointerEvent<HTMLDivElement>) => {
- finishDrag(event.pointerId);
- try {
- event.currentTarget.releasePointerCapture(event.pointerId);
- } catch {
- // No capture was available; the drag still completed on this event.
- }
- },
- [finishDrag],
- );
-
- const onKeyDown = useCallback(
- (event: ReactKeyboardEvent<HTMLDivElement>) => {
- const term = terminalRef.current;
- if (!term) return;
- const current = readTerminalScrollView(term);
- let handled = true;
- if (event.key === "ArrowUp") term.scrollLines(-1);
- else if (event.key === "ArrowDown") term.scrollLines(1);
- else if (event.key === "PageUp") term.scrollLines(-current.rows);
- else if (event.key === "PageDown") term.scrollLines(current.rows);
- else if (event.key === "Home") term.scrollToTop();
- else if (event.key === "End") term.scrollToBottom();
- else handled = false;
- if (!handled) return;
- event.preventDefault();
- event.stopPropagation();
- onFocus?.();
- scheduleSync();
- },
- [onFocus, scheduleSync, terminalRef],
- );
-
- const geometry = useMemo(
- () => (view ? scrollThumbGeometry(view, trackPx) : { top: 0, height: 0 }),
- [trackPx, view],
- );
- if (!view) return null;
-
- // 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"
- ? `Scroll ${name}: this CLI draws a full screen and keeps its own history — open the pane history to scroll it`
- : state === "empty"
- ? `Scroll ${name}: nothing has scrolled out of view yet`
- : `Terminal line ${view.line} of ${view.maxLine}`;
- const shell = PANE_CHROME[appearance].shell;
- // An alternate-screen pane has no position and never will — the CLI holds
- // the history inside its own process. Rather than a dead track, the rail
- // becomes the doorway to the one scrollable copy Jarvis owns.
- const offerHistory = state === "app" && onOpenHistory !== undefined;
-
- return (
- <div
- ref={trackRef}
- role="scrollbar"
- aria-label={`Scroll ${name}`}
- aria-controls={controlsId}
- aria-orientation="vertical"
- aria-valuemin={0}
- aria-valuemax={Math.max(1, view.maxLine)}
- aria-valuenow={view.line}
- aria-valuetext={valueText}
- tabIndex={0}
- data-testid={`pane-scroll-rail-${name}`}
- data-scroll-state={state}
- title={valueText}
- onPointerDown={onPointerDown}
- onPointerMove={onPointerMove}
- onPointerUp={onPointerUp}
- onPointerCancel={(event) => finishDrag(event.pointerId)}
- onLostPointerCapture={(event) => finishDrag(event.pointerId)}
- onPointerLeave={() => {
- if (dragRef.current && !dragRef.current.captured) finishDrag();
- }}
- onKeyDown={onKeyDown}
- className={cn(
- "group absolute inset-y-1 right-0 z-10 w-3 touch-none select-none rounded-full outline-none",
- "opacity-65 transition-opacity hover:opacity-100 focus-visible:opacity-100",
- "focus-visible:ring-1 focus-visible:ring-[#e7c46e]/80",
- // `!` so a drag that carries the pointer out of the pane does not
- // fade the rail out from under the hand still holding it.
- dragging ? "cursor-grabbing !opacity-100" : "cursor-grab",
- )}
- style={{ background: shell }}
- >
- <div
- ref={thumbRef}
- data-pane-scroll-thumb="true"
- data-testid={`pane-scroll-thumb-${name}`}
- className={cn(
- "absolute right-[3px] w-1.5 rounded-full",
- "shadow-[0_0_0_1px_rgba(0,0,0,0.18)] transition-[background-color,top]",
- state === "history"
- ? "bg-[#e7c46e]/65 group-hover:bg-[#e7c46e]/90 group-focus-visible:bg-[#e7c46e]/90"
- : // Nothing to scroll: a quiet full-length track. Visible enough to
- // read as "this rail is present and has nothing to point at",
- // never bright enough to read as a grip stuck at full height.
- "bg-[#e7c46e]/30",
- dragging && state === "history" && "bg-[#e7c46e] transition-none",
- )}
- style={{ top: geometry.top, height: geometry.height }}
- />
- {offerHistory && (
- <button
- type="button"
- data-testid={`pane-scroll-history-${name}`}
- aria-label={t("agentic_grid.conversation.open").replace("{0}", name)}
- title={t("agentic_grid.conversation.open").replace("{0}", name)}
- // The rail's own pointer handlers would read this as a track press
- // and seek a position that does not exist.
- onPointerDown={(event) => event.stopPropagation()}
- onClick={(event) => {
- event.stopPropagation();
- onOpenHistory?.();
- }}
- className={cn(
- "absolute left-1/2 top-1/2 flex h-6 w-6 -translate-x-1/2 -translate-y-1/2",
- "items-center justify-center rounded-full border border-[#e7c46e]/45",
- "text-[#e7c46e]/85 outline-none transition-colors",
- "hover:border-[#e7c46e] hover:text-[#e7c46e]",
- "focus-visible:ring-1 focus-visible:ring-[#e7c46e]",
- )}
- style={{ background: shell }}
- >
- <BookOpenText className="h-3.5 w-3.5" aria-hidden="true" />
- </button>
- )}
- </div>
- );
-}
diff --git a/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.test.ts b/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.test.ts
index c73904915a..72a1ff881e 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.test.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.test.ts
@@ -3,10 +3,6 @@ import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
import {
bindTerminalScrollRegion,
captureWheelForTerminalHistory,
- forwardWheelToTerminal,
- lineAtThumbTop,
- readTerminalScrollView,
- scrollThumbGeometry,
} from "./terminalScrollSurface";
function write(term: Terminal, data: string): Promise<void> {
@@ -52,48 +48,6 @@ function wheel(init: WheelEventInit): WheelEvent {
}
describe("terminalScrollSurface", () => {
- it("reads the exact xterm position for every pane the same way", () => {
- const term = terminalDouble("none", "normal", { baseY: 80, viewportY: 40 });
- const view = readTerminalScrollView(term);
-
- 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);
- expect(lineAtThumbTop(view, 160, 208)).toBe(80);
- });
-
- it("fills the whole track before any history exists — never a fake position", () => {
- const empty = readTerminalScrollView(terminalDouble("none", "normal"));
- expect(empty.maxLine).toBe(0);
- expect(scrollThumbGeometry(empty, 200)).toEqual({ top: 0, height: 200 });
-
- const alt = readTerminalScrollView(terminalDouble("any", "alternate"));
- expect(alt.altScreen).toBe(true);
- 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);
@@ -159,25 +113,6 @@ describe("terminalScrollSurface", () => {
}
});
- it("forwards a rail wheel to the xterm screen unchanged", () => {
- const host = document.createElement("div");
- const screen = document.createElement("div");
- screen.className = "xterm-screen";
- host.append(screen);
- const seen: WheelEvent[] = [];
- screen.addEventListener("wheel", (event) => seen.push(event));
-
- forwardWheelToTerminal(
- host,
- wheel({ deltaY: 120, deltaX: 5, shiftKey: true }),
- );
-
- expect(seen).toHaveLength(1);
- expect(seen[0].deltaY).toBe(120);
- expect(seen[0].deltaX).toBe(5);
- expect(seen[0].shiftKey).toBe(true);
- });
-
it("contains wheel input inside the terminal region", () => {
const region = document.createElement("div");
const parentSaw = vi.fn();
diff --git a/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.ts b/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.ts
index b035d9955a..95ef07338b 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.ts
@@ -1,129 +1,22 @@
/**
- * Terminal scrolling with ONE rule: xterm owns scrolling, always.
+ * Invisible terminal scrolling helpers.
*
- * Every pane, every provider, every CLI mode shows the same scrollbar — the
- * exact xterm viewport position — and the wheel always moves xterm's own
- * scrollback. This file used to hold a second "application-owned" regime
- * (owner switching, stroke gestures, PageUp/arrow-key relays, a self-centring
- * grip, an opt-in live-view navigation). Four iterations of it produced eight
- * confirmed defects in one review (2026-08-08, xhigh) — mode flips mid-drag
- * typed keys into the CLI, a 3px stroke step catapulted alternate-screen
- * apps, the rail morphed shapes on a 750ms poll, and a second native
- * scrollbar double-drew next to this one. The maintainer's verdict after
- * living with it was to remove the whole regime.
+ * Agentic IDE panes intentionally draw no scrollbar. xterm still owns the
+ * scroll position, wheel input remains contained inside the pane, and the
+ * recorded conversation is opened from the book button in the pane header.
*
- * MEASURED, and the measurement is the whole map (ConPTY probe, 2026-08-09):
- *
- * * **Codex** paints the NORMAL buffer. xterm's scrollback IS its transcript,
- * so the exact thumb is the exact truth and dragging it seeks.
- * * **Claude Code 2.1.226** takes the ALTERNATE screen (`?1049h`) plus full
- * mouse tracking (`?1000/1002/1003/1006h`) as soon as its UI is up. An
- * alternate buffer HAS NO SCROLLBACK — not in this app, not in Windows
- * Terminal, not anywhere — so there is no position to show and no history
- * to seek. The CLI scrolls its own view from the mouse reports xterm sends
- * it. (An earlier probe missed this: run in an untrusted directory, the CLI
- * stops at its trust prompt and never reaches the UI that switches buffer.)
- *
- * So the rail states what each pane can honestly answer, and the pane history
- * dialog — Jarvis's own recording, with a real scrollbar — is what an
- * alternate-screen pane points at instead of a fake thumb.
- *
- * `captureWheelForTerminalHistory` covers the third shape: a NORMAL-buffer CLI
- * that has negotiated mouse tracking. There xterm has real history, so the
- * wheel scrolls it rather than being handed to the app as mouse reports —
- * otherwise scrolling would work only while that CLI felt like it.
+ * `captureWheelForTerminalHistory` covers the one awkward input shape: a
+ * NORMAL-buffer CLI that has negotiated mouse tracking. There xterm has real
+ * history, so the wheel scrolls it rather than being handed to the app as
+ * mouse reports. Alternate-screen apps keep their native wheel protocol.
*/
import type { Terminal } from "@xterm/xterm";
-export interface TerminalScrollView {
- rows: number;
- /** Last xterm viewport line. Zero while no history has scrolled off yet. */
- maxLine: number;
- /** Current xterm viewport line. */
- 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 {
- top: number;
- height: number;
-}
-
-export const MIN_THUMB_PX = 28;
-
/** Pixels of wheel travel per scrolled row when the wheel reports pixels. */
const WHEEL_PIXELS_PER_ROW = 40;
/** Ceiling per wheel event, so one coalesced trackpad burst cannot teleport. */
const MAX_ROWS_PER_WHEEL = 40;
-function clamp(value: number, low: number, high: number): number {
- return Math.min(high, Math.max(low, value));
-}
-
-function finiteWhole(value: unknown): number {
- const number = typeof value === "number" ? value : Number(value);
- return Number.isFinite(number) ? Math.max(0, Math.floor(number)) : 0;
-}
-
-/** The exact xterm viewport position — the only scroll truth this UI shows. */
-export function readTerminalScrollView(term: Terminal): TerminalScrollView {
- 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,
- hiddenHistory: altScreen ? finiteWhole(buffer?.normal?.baseY) : 0,
- };
-}
-
-/** Thumb geometry. With no history yet the thumb honestly fills the track. */
-export function scrollThumbGeometry(
- view: TerminalScrollView,
- trackPx: number,
- minThumbPx = MIN_THUMB_PX,
-): ScrollThumbGeometry {
- const track = Math.max(0, trackPx);
- if (track === 0) return { top: 0, height: 0 };
- if (view.maxLine === 0) return { top: 0, height: track };
- const contentLines = view.maxLine + view.rows;
- const height = clamp(
- track * (view.rows / Math.max(1, contentLines)),
- Math.min(minThumbPx, track),
- track,
- );
- const travel = Math.max(0, track - height);
- return {
- top: travel * (view.line / view.maxLine),
- height,
- };
-}
-
-/** Map a dragged thumb back to xterm's absolute viewport line. */
-export function lineAtThumbTop(
- view: TerminalScrollView,
- topPx: number,
- trackPx: number,
-): number {
- if (view.maxLine === 0) return 0;
- const thumb = scrollThumbGeometry(view, trackPx);
- const travel = Math.max(0, trackPx - thumb.height);
- if (travel === 0) return view.maxLine;
- return Math.round(view.maxLine * (clamp(topPx, 0, travel) / travel));
-}
-
/**
* Keep the wheel on xterm's history even when a normal-buffer CLI has
* negotiated mouse tracking.
@@ -187,37 +80,6 @@ export function captureWheelForTerminalHistory(
};
}
-/**
- * Forward a wheel that landed on the overlay rail to xterm unchanged.
- *
- * The rail observes this passively; the containing terminal region owns the
- * separate job of preventing the workspace behind it from scrolling too.
- */
-export function forwardWheelToTerminal(
- host: HTMLElement | null,
- event: WheelEvent,
-): boolean {
- const screen = host?.querySelector<HTMLElement>(".xterm-screen");
- if (!screen || typeof WheelEvent === "undefined") return false;
- screen.dispatchEvent(
- new WheelEvent("wheel", {
- bubbles: true,
- cancelable: true,
- clientX: event.clientX,
- clientY: event.clientY,
- deltaMode: event.deltaMode,
- deltaX: event.deltaX,
- deltaY: event.deltaY,
- deltaZ: event.deltaZ,
- ctrlKey: event.ctrlKey,
- shiftKey: event.shiftKey,
- altKey: event.altKey,
- metaKey: event.metaKey,
- }),
- );
- return true;
-}
-
/** Keep terminal wheel input from falling through to the workspace scroller. */
export function bindTerminalScrollRegion(region: HTMLElement): () => void {
const containWheel = (event: WheelEvent) => {
diff --git a/jarvis/ui/web/frontend/src/index.css b/jarvis/ui/web/frontend/src/index.css
index e73d15f909..d4cdcab7e8 100644
--- a/jarvis/ui/web/frontend/src/index.css
+++ b/jarvis/ui/web/frontend/src/index.css
@@ -215,13 +215,10 @@
display: none;
}
-/* Agentic IDE panes draw exactly ONE scrollbar: the golden PaneScrollRail.
- The native viewport scrollbar is hidden unconditionally — when it was only
- hidden for application-owned panes, every normal-buffer pane double-drew
- an 8px grey native thumb underneath the rail, at a different position and
- with its hit area eaten by the rail overlay (confirmed review finding,
- 2026-08-08). Keep these rules top-level because xterm creates the viewport
- at runtime. */
+/* Agentic IDE panes intentionally show no scrollbar. Scrolling still works
+ through xterm's wheel handling, while recorded conversation history opens
+ from the book button in the pane header. Keep these rules top-level because
+ xterm creates the viewport at runtime. */
.agentic-terminal-host .xterm-viewport {
overscroll-behavior: contain;
scrollbar-width: none;