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): navigate windowed live agent views
rubenluetke10-beepfb404c3d4cba
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.offscreen.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.offscreen.test.tsxindex 12e2f3efe0..9d49ef7e1c 100644--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.offscreen.test.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.offscreen.test.tsx@@ -44,6 +44,7 @@ vi.mock("@xterm/xterm", () => ({parser = {registerOscHandler: () => ({ dispose() {} }),registerCsiHandler: () => ({ dispose() {} }),+ registerEscHandler: () => ({ dispose() {} }),};loadAddon() {}@@ -54,6 +55,7 @@ vi.mock("@xterm/xterm", () => ({// ./terminalNewline) — a stand-in without these is a terminal xterm never// shipped either.attachCustomKeyEventHandler() {}+ attachCustomWheelEventHandler() {}input() {}getSelection() {return "";diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsxindex aa0b28ac4c..d0584b7962 100644--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx@@ -15,6 +15,13 @@ const terminalHarness = vi.hoisted(() => ({input: vi.fn<(data: string) => void>(),/** xterm's single custom key handler, so a test can press a key. */keys: { current: null as ((event: KeyboardEvent) => boolean) | null },+ /** xterm's wheel arbiter, which bridges a live inline TUI at its tail. */+ wheel: { current: null as ((event: WheelEvent) => boolean) | null },+ /** Custom CSI observers installed on xterm's parser. */+ csiHandlers: [] as {+ id: { prefix?: string; final: string };+ callback: (params: (number | number[])[]) => boolean;+ }[],focus: vi.fn(),scrollToBottom: vi.fn(),write: vi.fn(),@@ -52,7 +59,20 @@ vi.mock("@xterm/xterm", () => ({// (see ./terminalQueries). The double only has to accept the handlers.parser = {registerOscHandler: () => ({ dispose() {} }),- registerCsiHandler: () => ({ dispose() {} }),+ registerEscHandler: () => ({ dispose() {} }),+ registerCsiHandler: (+ id: { prefix?: string; final: string },+ callback: (params: (number | number[])[]) => boolean,+ ) => {+ const entry = { id, callback };+ terminalHarness.csiHandlers.push(entry);+ return {+ dispose() {+ const index = terminalHarness.csiHandlers.indexOf(entry);+ if (index >= 0) terminalHarness.csiHandlers.splice(index, 1);+ },+ };+ },};loadAddon() {}@@ -66,6 +86,9 @@ vi.mock("@xterm/xterm", () => ({attachCustomKeyEventHandler(handler: (event: KeyboardEvent) => boolean) {terminalHarness.keys.current = handler;}+ attachCustomWheelEventHandler(handler: (event: WheelEvent) => boolean) {+ terminalHarness.wheel.current = handler;+ }input(data: string) {terminalHarness.input(data);}@@ -142,6 +165,8 @@ describe("AgenticTerminal layout", () => {terminalHarness.write.mockClear();terminalHarness.deferWrite = false;terminalHarness.writeCallbacks = [];+ terminalHarness.wheel.current = null;+ terminalHarness.csiHandlers = [];globalThis.ResizeObserver = ResizeObserverHarness;});@@ -177,6 +202,62 @@ describe("AgenticTerminal layout", () => {expect(host.className).not.toMatch(/(?:^|\s)p[trblxy]?-/);expect(terminalHarness.open).toHaveBeenCalledWith(host);expect(terminalHarness.observe).toHaveBeenCalledWith(host);+ expect(terminalHarness.wheel.current).not.toBeNull();+ });++ it("requires explicit live-view activation and revokes it on exit", () => {+ render(+ <AgenticTerminal+ name="Dana"+ displayName="Claude Code"+ appearance="dark"+ fontSize={13}+ />,+ );+ const host = screen.getByTestId("agentic-terminal-host-Dana");+ const hide = terminalHarness.csiHandlers.find(+ ({ id }) => id.prefix === "?" && id.final === "l",+ );+ const show = terminalHarness.csiHandlers.find(+ ({ id }) => id.prefix === "?" && id.final === "h",+ );++ expect(host.dataset.liveTuiCandidate).toBe("false");+ expect(host.dataset.liveTuiNavigation).toBe("false");+ expect(hide?.callback([25])).toBe(false);+ expect(host.dataset.liveTuiCandidate).toBe("true");+ expect(host.dataset.liveTuiNavigation).toBe("false");+ expect(+ terminalHarness.wheel.current?.(+ new WheelEvent("wheel", { deltaY: 120 }),+ ),+ ).toBe(true);+ expect(terminalHarness.input).not.toHaveBeenCalled();++ host.dataset.liveTuiNavigation = "true";+ expect(+ terminalHarness.wheel.current?.(+ new WheelEvent("wheel", { deltaY: 120 }),+ ),+ ).toBe(false);+ expect(terminalHarness.input).toHaveBeenCalledWith("\x1b[B".repeat(3));+ expect(show?.callback([25])).toBe(false);+ expect(host.dataset.liveTuiCandidate).toBe("false");+ expect(host.dataset.liveTuiNavigation).toBe("false");++ expect(hide?.callback([25])).toBe(false);+ host.dataset.liveTuiNavigation = "true";+ terminalHarness.input.mockClear();+ act(() => terminalHarness.handlers.current?.onExit?.(1 as never));+ expect(host.dataset.liveTuiCandidate).toBe("false");+ expect(host.dataset.liveTuiNavigation).toBe("false");+ expect(terminalHarness.write).toHaveBeenLastCalledWith(+ expect.stringContaining("\x1b[?25h"),+ );+ expect(terminalHarness.wheel.current?.(new WheelEvent("wheel", { deltaY: 120 }))).toBe(+ true,+ );+ expect(terminalHarness.input).not.toHaveBeenCalled();});it("waits for the area-aware grid measurement before opening the PTY", () => {diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsxindex 102757e023..895865a2eb 100644--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx@@ -116,6 +116,10 @@ import {} from "./offscreenBuffer";import { installQuerySuppression } from "./terminalQueries";import { PaneScrollRail } from "./PaneScrollRail";+import {+ createLiveTuiWheelHandler,+ installLiveTuiCursorTracking,+} from "./terminalScrollSurface";import {openPaneSocket,type PaneSocket,@@ -524,6 +528,21 @@ export function AgenticTerminal({// before reaching it — too late, and then visible as junk in its prompt.// The backend answers those instead. See ./terminalQueries.const disposeQuerySuppression = installQuerySuppression(term.parser);+ // A hidden cursor is only a CANDIDATE for a keyboard-owned live drawing:+ // progress spinners use the same terminal mode. The rail exposes an+ // explicit activation control for that candidate; only that user choice+ // may turn wheel/drag input into cursor keys.+ let cursorHidden = false;+ const setCursorHidden = (hidden: boolean) => {+ cursorHidden = hidden;+ container.dataset.liveTuiCandidate = hidden ? "true" : "false";+ if (!hidden) container.dataset.liveTuiNavigation = "false";+ };+ setCursorHidden(false);+ const liveTuiTracking = installLiveTuiCursorTracking(+ term.parser,+ setCursorHidden,+ );const fit = new FitAddon();term.loadAddon(fit);term.loadAddon(new WebLinksAddon(activateLink));@@ -542,6 +561,19 @@ export function AgenticTerminal({/* proposed API unavailable in this build — widths stay at Unicode 6 */}term.open(container);+ // A normal-buffer coding CLI can draw a windowed live block inside ordinary+ // terminal history. xterm can scroll that history, but rows omitted by the+ // live block only exist in the CLI and need cursor navigation. The handler+ // is active only after the rail's explicit live-view activation, and that+ // opt-in is revoked as soon as the CLI restores the cursor.+ term.attachCustomWheelEventHandler(+ createLiveTuiWheelHandler(+ term,+ () =>+ cursorHidden &&+ container.dataset.liveTuiNavigation === "true",+ ),+ );// Canvas rather than the DOM renderer: a coding agent's TUI redraws its// prompt box on every keystroke, and per-cell DOM elements both lag and// land on fractional pixel offsets. Loaded AFTER open() because it needs@@ -817,6 +849,7 @@ export function AgenticTerminal({// screen this replay just replaced.cancelHoldTimer();offscreen.drain();+ liveTuiTracking.reset();term.reset();// Through the ordinary path, so a replay arriving while nobody is looking// is parked and un-parked by the same rules as anything else — and so it@@ -994,9 +1027,12 @@ export function AgenticTerminal({}},onExit: (code) => {+ // A crash cannot be trusted to restore cursor visibility. End live+ // TUI ownership before drawing the terminal's definitive exit row.+ liveTuiTracking.reset();report("exited", explainExit(code));writeToPane(- `\r\n\x1b[33m${describeExit(displayName, code)}\x1b[0m\r\n`,+ `\r\n\x1b[?25h\x1b[33m${describeExit(displayName, code)}\x1b[0m\r\n`,);},onTrouble: (message, retrying) => {@@ -1142,6 +1178,7 @@ export function AgenticTerminal({disposeCopyBridge();disposePasteBridge();disposeNewlineBridge();+ liveTuiTracking.dispose();disposeQuerySuppression();try {socket?.close();diff --git a/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.test.tsxindex e7d1634a10..dfa4abc764 100644--- a/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.test.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.test.tsx@@ -124,10 +124,12 @@ function fakeTerminal({function RailHarness({name,term,+ liveTuiCandidate = false,onOpenHistory,}: {name: string;term: Terminal;+ liveTuiCandidate?: boolean;onOpenHistory?: () => void;}) {const regionRef = useRef<HTMLDivElement | null>(null);@@ -135,7 +137,11 @@ function RailHarness({const terminalRef = useRef<Terminal | null>(term);return (<div ref={regionRef} id={`terminal-${name}`}>- <div ref={hostRef}>+ <div+ ref={hostRef}+ data-live-tui-candidate={liveTuiCandidate ? "true" : "false"}+ data-live-tui-navigation="false"+ ><div className="xterm-screen" data-testid={`xterm-screen-${name}`} /></div><PaneScrollRail@@ -206,6 +212,72 @@ describe("PaneScrollRail", () => {).toBe("terminal-Mika");});+ it("strokes a positionless live inline TUI in both directions", () => {+ const harness = fakeTerminal({ owner: "terminal" });+ render(<RailHarness name="Mira" term={harness.term} liveTuiCandidate />);+ const rail = giveTrackGeometry("Mira");++ // Cursor-hidden is only a candidate. Until the user explicitly activates+ // the live view, the exact terminal thumb and its keyboard behavior win.+ expect(screen.getByTestId("pane-scroll-thumb-Mira")).toBeTruthy();+ const candidateButton = screen.getByRole("button", {+ name: "Control live view in Mira",+ });+ const nativeWheel: number[] = [];+ screen+ .getByTestId("xterm-screen-Mira")+ .addEventListener("wheel", (event) => nativeWheel.push(event.deltaY));+ fireEvent.wheel(candidateButton, { deltaY: 120 });+ expect(nativeWheel).toEqual([120]);+ fireEvent.keyDown(rail, { key: "ArrowDown" });+ expect(harness.scrollLines).toHaveBeenCalledWith(1);+ expect(harness.input).not.toHaveBeenCalled();++ fireEvent.click(candidateButton);+ const grip = screen.getByTestId("pane-scroll-grip-Mira");++ fireEvent.pointerDown(grip, { button: 0, clientY: 100, pointerId: 21 });+ fireEvent.pointerMove(rail, { clientY: 115, pointerId: 21 });+ fireEvent.pointerMove(rail, { clientY: 109, pointerId: 21 });+ fireEvent.pointerUp(rail, { clientY: 109, pointerId: 21 });++ expect(harness.input.mock.calls.map((call) => call[0])).toEqual([+ "\x1b[B".repeat(5),+ "\x1b[A".repeat(2),+ ]);+ expect(screen.queryByTestId("pane-scroll-thumb-Mira")).toBeNull();+ expect(rail.dataset.scrollPosition).toBe("none");+ });++ it("hands ArrowDown and PageDown to an explicit live inline TUI", () => {+ const harness = fakeTerminal({ owner: "terminal" });+ render(<RailHarness name="Tali" term={harness.term} liveTuiCandidate />);+ const rail = giveTrackGeometry("Tali");+ fireEvent.click(+ screen.getByRole("button", { name: "Control live view in Tali" }),+ );++ fireEvent.keyDown(rail, { key: "ArrowDown" });+ fireEvent.keyDown(rail, { key: "PageDown" });++ expect(harness.scrollLines).not.toHaveBeenCalled();+ expect(harness.input.mock.calls.map((call) => call[0])).toEqual([+ "\x1b[B",+ "\x1b[B".repeat(7),+ ]);+ });++ it("keeps ArrowDown native at a visible-cursor prompt, including its tail", () => {+ const harness = fakeTerminal({ owner: "terminal" });+ render(<RailHarness name="Niko" term={harness.term} />);+ const rail = giveTrackGeometry("Niko");++ fireEvent.keyDown(rail, { key: "ArrowDown" });++ expect(harness.scrollLines).toHaveBeenCalledWith(1);+ expect(harness.input).not.toHaveBeenCalled();+ });+it("strokes a mouse-aware full-screen IDE both ways and shows no position at all", () => {const harness = fakeTerminal({ owner: "mouse-app" });render(<RailHarness name="Aria" term={harness.term} />);diff --git a/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.tsx b/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.tsxindex 026c168e99..d95f7036db 100644--- a/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/PaneScrollRail.tsx@@ -3,6 +3,9 @@** Normal terminal history gets a conventional absolute thumb: xterm knows the* line and the extent, so the thumb is the truth and dragging it is a seek.+ * A cursor-hidden normal-buffer view stays in that exact mode until the user+ * activates the live-view control; cursor visibility alone never authorizes+ * synthetic keyboard input.** A full-screen coding TUI keeps its history inside the application, and this* rail then draws NO POSITION AT ALL. It becomes what it can honestly be —@@ -40,6 +43,7 @@ import {lineAtThumbTop,readTerminalScrollView,scrollApplication,+ scrollLiveCursor,scrollThumbGeometry,strokeUnits,type TerminalScrollView,@@ -117,21 +121,51 @@ export function PaneScrollRail({const [view, setView] = useState<TerminalScrollView | null>(null);const [trackPx, setTrackPx] = useState(0);const [dragging, setDragging] = useState(false);+ const [liveTuiCandidate, setLiveTuiCandidate] = useState(false);+ const [liveTuiNavigation, setLiveTuiNavigation] = useState(false);/** The application grip's travel from centre while a stroke is held. */const [gripOffset, setGripOffset] = useState(0);+ const readView = useCallback(+ (term: Terminal) =>+ readTerminalScrollView(+ term,+ hostRef.current?.dataset.liveTuiNavigation === "true",+ ),+ [hostRef],+ );++ const canActivateLiveTui = useCallback(+ (term: Terminal) =>+ hostRef.current?.dataset.liveTuiCandidate === "true" &&+ (term.buffer?.active?.type ?? "normal") === "normal" &&+ (term.modes?.mouseTrackingMode ?? "none") === "none",+ [hostRef],+ );+const sync = useCallback(() => {frameRef.current = null;const term = terminalRef.current;const host = hostRef.current;if (!term) {setView(null);+ setLiveTuiCandidate(false);+ setLiveTuiNavigation(false);return;}- const next = readTerminalScrollView(term);+ const candidate = canActivateLiveTui(term);+ if (!candidate && host) host.dataset.liveTuiNavigation = "false";+ const navigation = candidate && host?.dataset.liveTuiNavigation === "true";+ const next = readView(term);if (host) host.dataset.scrollOwner = next.owner;+ setLiveTuiCandidate((current) =>+ current === candidate ? current : candidate,+ );+ setLiveTuiNavigation((current) =>+ current === navigation ? current : navigation,+ );setView((current) => (sameView(current, next) ? current : next));- }, [hostRef, terminalRef]);+ }, [canActivateLiveTui, hostRef, readView, terminalRef]);const scheduleSync = useCallback(() => {if (frameRef.current !== null) return;@@ -143,11 +177,31 @@ export function PaneScrollRail({(direction: -1 | 1, notches: number) => {const term = terminalRef.current;if (!term) return;- scrollApplication(term, hostRef.current, direction, notches);+ const bufferType = term.buffer?.active?.type ?? "normal";+ const tracking = term.modes?.mouseTrackingMode ?? "none";+ const keyboardOwnedLiveView =+ hostRef.current?.dataset.liveTuiCandidate === "true" &&+ hostRef.current?.dataset.liveTuiNavigation === "true" &&+ bufferType === "normal" &&+ tracking === "none";+ if (keyboardOwnedLiveView) {+ scrollLiveCursor(term, direction, notches);+ } else if (bufferType === "alternate" || tracking !== "none") {+ scrollApplication(term, hostRef.current, direction, notches);+ }},[hostRef, terminalRef],);+ const activateLiveTuiNavigation = useCallback(() => {+ const term = terminalRef.current;+ const host = hostRef.current;+ if (!term || !host || !canActivateLiveTui(term)) return;+ host.dataset.liveTuiNavigation = "true";+ onFocus?.();+ sync();+ }, [canActivateLiveTui, hostRef, onFocus, sync, terminalRef]);+useEffect(() => {const term = terminalRef.current;if (!term) {@@ -257,7 +311,7 @@ export function PaneScrollRail({if (event.button !== 0) return;const term = terminalRef.current;if (!term) return;- const current = readTerminalScrollView(term);+ const current = readView(term);const track = liveTrack();if (track.height <= 0) return;event.preventDefault();@@ -298,7 +352,7 @@ export function PaneScrollRail({// pressing must not teleport the transcript to a place the press did not// mean, and there is no position for it to have meant.},- [liveTrack, moveExact, onFocus, terminalRef],+ [liveTrack, moveExact, onFocus, readView, terminalRef],);const onPointerMove = useCallback(@@ -307,13 +361,14 @@ export function PaneScrollRail({const term = terminalRef.current;if (!drag || !term || drag.pointerId !== event.pointerId) return;event.preventDefault();- const current = readTerminalScrollView(term);+ const current = readView(term);drag.movedPx = Math.max(drag.movedPx,Math.abs(event.clientY - drag.originY),);if (drag.owner === "terminal" && current.owner === "terminal") {moveExact(current, event.clientY, drag.grabOffset);+ drag.lastY = event.clientY;} else {strokeApplication(event.clientY);// The grip follows the hand, clamped so it never slides under an@@ -324,7 +379,7 @@ export function PaneScrollRail({);}},- [liveTrack, moveExact, strokeApplication, terminalRef],+ [liveTrack, moveExact, readView, strokeApplication, terminalRef],);const finishDrag = useCallback(@@ -344,11 +399,11 @@ export function PaneScrollRail({const thumb = thumbRef.current;const track = liveTrack();if (term && thumb && track.height > 0) {- const current = readTerminalScrollView(term);+ const current = readView(term);thumb.style.top = `${scrollThumbGeometry(current, track.height).top}px`;}},- [liveTrack, terminalRef],+ [liveTrack, readView, terminalRef],);const onPointerUp = useCallback(@@ -378,7 +433,7 @@ export function PaneScrollRail({(event: ReactKeyboardEvent<HTMLDivElement>) => {const term = terminalRef.current;if (!term) return;- const current = readTerminalScrollView(term);+ const current = readView(term);let handled = true;if (current.owner === "terminal") {if (event.key === "ArrowUp") term.scrollLines(-1);@@ -405,20 +460,20 @@ export function PaneScrollRail({onFocus?.();scheduleSync();},- [onFocus, relayApplication, scheduleSync, terminalRef],+ [onFocus, readView, relayApplication, scheduleSync, terminalRef],);const scrollApplicationPage = useCallback((direction: -1 | 1) => {const term = terminalRef.current;if (!term) return;- const current = readTerminalScrollView(term);+ const current = readView(term);if (current.owner !== "application") return;relayApplication(direction, applicationPageNotches(current.rows));onFocus?.();scheduleSync();},- [onFocus, relayApplication, scheduleSync, terminalRef],+ [onFocus, readView, relayApplication, scheduleSync, terminalRef],);const geometry = useMemo(@@ -432,150 +487,192 @@ export function PaneScrollRail({? view.maxLine === 0? "No terminal history yet": `Terminal line ${view.line} of ${view.maxLine}`- : `Scroll ${name}: this app keeps its own history, so there is no position to show`;+ : liveTuiNavigation+ ? `Scroll ${name}: live-view navigation is active; use Shift+wheel for terminal history`+ : `Scroll ${name}: this app keeps its own history, so there is no position to show`;const shell = PANE_CHROME[appearance].shell;return (- <div- ref={trackRef}- role={exact ? "scrollbar" : "group"}- aria-label={exact ? `Scroll ${name}` : `Scroll ${name} application history`}- aria-controls={controlsId}- aria-orientation={exact ? "vertical" : undefined}- aria-valuemin={exact ? 0 : undefined}- aria-valuemax={exact ? Math.max(1, view.maxLine) : undefined}- aria-valuenow={exact ? view.line : undefined}- aria-valuetext={exact ? valueText : undefined}- tabIndex={exact ? 0 : undefined}- data-testid={`pane-scroll-rail-${name}`}- data-scroll-mode={view.owner}- data-scroll-position={exact ? "exact" : "none"}- 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",- "transition-opacity hover:opacity-100 focus-visible:opacity-100 focus-within:opacity-100",- // BOTH rail kinds stay legible at rest, at the same level. The- // application rail used to hide until the pointer entered its pane,- // and a control that is invisible next to a sibling pane's visible- // thumb reads as "the scrollbar is broken in this CLI".- "opacity-65",- "focus-visible:ring-1 focus-visible:ring-[#e7c46e]/80 focus-within:ring-1 focus-within:ring-[#e7c46e]/80",- // `!` so a stroke 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 }}- >- {!exact && (- <>- <button- type="button"- aria-label={`Scroll older in ${name}`}- aria-controls={controlsId}- onPointerDown={(event) => event.stopPropagation()}- onClick={() => scrollApplicationPage(-1)}- className={cn(- "absolute inset-x-0 top-0 flex h-4 items-start justify-center rounded-t-full pt-1",- "text-[#e7c46e]/70 outline-none hover:text-[#e7c46e] focus-visible:text-[#e7c46e]",- )}- >- <svg viewBox="0 0 8 5" className="h-[5px] w-2 fill-current" aria-hidden="true">- <path d="M4 0 8 5H0Z" />- </svg>- </button>- <button- type="button"- aria-label={`Scroll newer in ${name}`}- aria-controls={controlsId}- onPointerDown={(event) => event.stopPropagation()}- onClick={() => scrollApplicationPage(1)}- className={cn(- "absolute inset-x-0 bottom-0 flex h-4 items-end justify-center rounded-b-full pb-1",- "text-[#e7c46e]/70 outline-none hover:text-[#e7c46e] focus-visible:text-[#e7c46e]",- )}+ <>+ {liveTuiCandidate && exact && (+ <button+ type="button"+ data-testid={`pane-live-navigation-${name}`}+ aria-label={`Control live view in ${name}`}+ aria-controls={controlsId}+ title="Enable live-view navigation with the wheel and scroll rail"+ onWheelCapture={(event) =>+ forwardWheelToTerminal(hostRef.current, event.nativeEvent)+ }+ onClick={activateLiveTuiNavigation}+ className={cn(+ "absolute right-0 top-1/2 z-20 flex h-8 w-6 -translate-y-1/2 items-center justify-end rounded-l-md border border-r-0 pr-0.5",+ "border-[#e7c46e]/55 text-[#e7c46e]/85 shadow-sm outline-none",+ "hover:text-[#e7c46e] focus-visible:ring-1 focus-visible:ring-[#e7c46e]",+ )}+ style={{ background: shell }}+ >+ <svg+ viewBox="0 0 8 16"+ className="h-4 w-2 fill-current"+ aria-hidden="true">- <svg viewBox="0 0 8 5" className="h-[5px] w-2 fill-current" aria-hidden="true">- <path d="M4 5 0 0h8Z" />- </svg>- </button>- </>+ <path d="M4 0 8 5H0Z" />+ <path d="M4 16 0 11h8Z" />+ </svg>+ </button>)}- {/*+ <div+ ref={trackRef}+ role={exact ? "scrollbar" : "group"}+ aria-label={+ exact ? `Scroll ${name}` : `Scroll ${name} application history`+ }+ aria-controls={controlsId}+ aria-orientation={exact ? "vertical" : undefined}+ aria-valuemin={exact ? 0 : undefined}+ aria-valuemax={exact ? Math.max(1, view.maxLine) : undefined}+ aria-valuenow={exact ? view.line : undefined}+ aria-valuetext={exact ? valueText : undefined}+ tabIndex={exact ? 0 : undefined}+ data-testid={`pane-scroll-rail-${name}`}+ data-scroll-mode={view.owner}+ data-scroll-position={exact ? "exact" : "none"}+ 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",+ "transition-opacity hover:opacity-100 focus-visible:opacity-100 focus-within:opacity-100",+ // BOTH rail kinds stay legible at rest, at the same level. The+ // application rail used to hide until the pointer entered its pane,+ // and a control that is invisible next to a sibling pane's visible+ // thumb reads as "the scrollbar is broken in this CLI".+ "opacity-65",+ "focus-visible:ring-1 focus-visible:ring-[#e7c46e]/80 focus-within:ring-1 focus-within:ring-[#e7c46e]/80",+ // `!` so a stroke 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 }}+ >+ {!exact && (+ <>+ <button+ type="button"+ aria-label={`Scroll older in ${name}`}+ aria-controls={controlsId}+ onPointerDown={(event) => event.stopPropagation()}+ onClick={() => scrollApplicationPage(-1)}+ className={cn(+ "absolute inset-x-0 top-0 flex h-4 items-start justify-center rounded-t-full pt-1",+ "text-[#e7c46e]/70 outline-none hover:text-[#e7c46e] focus-visible:text-[#e7c46e]",+ )}+ >+ <svg+ viewBox="0 0 8 5"+ className="h-[5px] w-2 fill-current"+ aria-hidden="true"+ >+ <path d="M4 0 8 5H0Z" />+ </svg>+ </button>+ <button+ type="button"+ aria-label={`Scroll newer in ${name}`}+ aria-controls={controlsId}+ onPointerDown={(event) => event.stopPropagation()}+ onClick={() => scrollApplicationPage(1)}+ className={cn(+ "absolute inset-x-0 bottom-0 flex h-4 items-end justify-center rounded-b-full pb-1",+ "text-[#e7c46e]/70 outline-none hover:text-[#e7c46e] focus-visible:text-[#e7c46e]",+ )}+ >+ <svg+ viewBox="0 0 8 5"+ className="h-[5px] w-2 fill-current"+ aria-hidden="true"+ >+ <path d="M4 5 0 0h8Z" />+ </svg>+ </button>+ </>+ )}+ {/*The application grip: grabbable, but positionless. It rests in themiddle, rides along while a stroke is held, and springs back onrelease — see the module docstring for why it must never stay wherethe drag left it. Pointer events bubble to the track's strokehandlers; the grip itself adds nothing but a place to hold.*/}- {!exact && (- <div- ref={gripRef}- data-testid={`pane-scroll-grip-${name}`}- role="presentation"- title={t("agentic_grid.conversation.grip_hint")}- className={cn(- "absolute left-1/2 top-1/2 w-2 rounded-full bg-[#e7c46e]/45",- "shadow-[0_0_0_1px_rgba(0,0,0,0.18)]",- "group-hover:bg-[#e7c46e]/80 group-focus-within:bg-[#e7c46e]/80",- dragging- ? "bg-[#e7c46e] transition-none"- : "transition-transform duration-200",- )}- style={{- height: GRIP_PX,- transform: `translate(-50%, calc(-50% + ${gripOffset}px))`,- }}- >- <svg- viewBox="0 0 8 28"- className="h-full w-full fill-[#141210]/70"- aria-hidden="true"+ {!exact && (+ <div+ ref={gripRef}+ data-testid={`pane-scroll-grip-${name}`}+ role="presentation"+ title={t("agentic_grid.conversation.grip_hint")}+ className={cn(+ "absolute left-1/2 top-1/2 w-2 rounded-full bg-[#e7c46e]/45",+ "shadow-[0_0_0_1px_rgba(0,0,0,0.18)]",+ "group-hover:bg-[#e7c46e]/80 group-focus-within:bg-[#e7c46e]/80",+ dragging+ ? "bg-[#e7c46e] transition-none"+ : "transition-transform duration-200",+ )}+ style={{+ height: GRIP_PX,+ transform: `translate(-50%, calc(-50% + ${gripOffset}px))`,+ }}>- {/* While held, the dots become an arrow in the direction the hand+ <svg+ viewBox="0 0 8 28"+ className="h-full w-full fill-[#141210]/70"+ aria-hidden="true"+ >+ {/* While held, the dots become an arrow in the direction the handis moving — the gesture's receipt, since the grip itself willnot stay anywhere. */}- {dragging && gripOffset < 0 ? (- <path d="M4 9 7 15H1Z" />- ) : dragging && gripOffset > 0 ? (- <path d="M4 19 1 13h6Z" />- ) : (- <>- <circle cx="4" cy="10" r="1.1" />- <circle cx="4" cy="14" r="1.1" />- <circle cx="4" cy="18" r="1.1" />- </>- )}- </svg>- </div>- )}- {/*+ {dragging && gripOffset < 0 ? (+ <path d="M4 9 7 15H1Z" />+ ) : dragging && gripOffset > 0 ? (+ <path d="M4 19 1 13h6Z" />+ ) : (+ <>+ <circle cx="4" cy="10" r="1.1" />+ <circle cx="4" cy="14" r="1.1" />+ <circle cx="4" cy="18" r="1.1" />+ </>+ )}+ </svg>+ </div>+ )}+ {/*The thumb exists only where a position does — an application pane getsthe self-centring grip above instead, never a shape that stays wherethe drag left it.*/}- {exact && (- <div- ref={thumbRef}- data-pane-scroll-thumb="true"- data-testid={`pane-scroll-thumb-${name}`}- className={cn(- "absolute right-[3px] w-1.5 rounded-full bg-[#e7c46e]/65",- "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",- )}- style={{ top: geometry.top, height: geometry.height }}- />- )}- </div>+ {exact && (+ <div+ ref={thumbRef}+ data-pane-scroll-thumb="true"+ data-testid={`pane-scroll-thumb-${name}`}+ className={cn(+ "absolute right-[3px] w-1.5 rounded-full bg-[#e7c46e]/65",+ "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",+ )}+ style={{ top: geometry.top, height: geometry.height }}+ />+ )}+ </div>+ </>);}diff --git a/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.test.ts b/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.test.tsindex 15c0ca2348..e51b0a8535 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,13 @@ import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";import {applicationPageNotches,bindTerminalScrollRegion,+ createLiveTuiWheelHandler,forwardWheelToTerminal,+ installLiveTuiCursorTracking,lineAtThumbTop,readTerminalScrollView,scrollApplication,+ scrollLiveCursor,scrollThumbGeometry,strokeUnits,terminalScrollOwner,@@ -85,6 +88,45 @@ describe("terminalScrollSurface", () => {expect(lineAtThumbTop(view, 160, 200)).toBe(80);});+ it("tracks hidden-cursor live views through the real xterm parser", async () => {+ const term = await newTerminal();+ const states: boolean[] = [];+ const tracking = installLiveTuiCursorTracking(term.parser, (active) =>+ states.push(active),+ );+ try {+ await write(term, "\x1b[?25l");+ await write(term, "\x1b[?25l");+ expect(states).toEqual([true]);++ tracking.reset();+ expect(states).toEqual([true, false]);+ await write(term, "\x1b[?25l");+ await write(term, "\x1b[?25h");+ expect(states).toEqual([true, false, true, false]);++ await write(term, "\x1b[?25l");+ await write(term, "\x1b[!p");+ expect(states).toEqual([true, false, true, false, true, false]);++ await write(term, "\x1b[?25l");+ await write(term, "\x1bc");+ expect(states).toEqual([+ true,+ false,+ true,+ false,+ true,+ false,+ true,+ false,+ ]);+ } finally {+ tracking.dispose();+ term.dispose();+ }+ });+it("offers NO thumb geometry for an application-owned screen", () => {// The regression this pins: twice a shape was drawn in this track — once// parked in the middle, once at a measured offset — and both times the@@ -136,6 +178,108 @@ describe("terminalScrollSurface", () => {]);});+ it("reveals all eight rows after explicit live-view activation", () => {+ const term = terminalDouble("none", "normal");+ const agents = Array.from(+ { length: 8 },+ (_, index) => `agent-${index + 1}`,+ );+ let selected = 4;+ term.input.mockImplementation((data: string) => {+ for (const sequence of data.matchAll(/\x1b\[([AB])/g)) {+ selected = Math.max(+ 0,+ Math.min(+ agents.length - 1,+ selected + (sequence[1] === "B" ? 1 : -1),+ ),+ );+ }+ });+ const visible = () => {+ const start = Math.min(Math.max(0, selected - 4), agents.length - 5);+ return agents.slice(start, start + 5);+ };+ const handleWheel = createLiveTuiWheelHandler(term, () => true);++ expect(visible()).toEqual(agents.slice(0, 5));++ expect(+ handleWheel(+ new WheelEvent("wheel", {+ deltaMode: WheelEvent.DOM_DELTA_PIXEL,+ deltaY: 120,+ }),+ ),+ ).toBe(false);+ expect(term.input).toHaveBeenCalledWith("\x1b[B".repeat(3), true);+ expect(visible()).toEqual(agents.slice(3, 8));++ expect(handleWheel(new WheelEvent("wheel", { deltaY: -40 }))).toBe(false);+ expect(term.input).toHaveBeenLastCalledWith("\x1b[A", true);+ });++ it("keeps both wheel directions native without explicit activation", () => {+ const term = terminalDouble("none", "normal");+ const handleWheel = createLiveTuiWheelHandler(term, () => false);++ expect(handleWheel(new WheelEvent("wheel", { deltaY: 120 }))).toBe(true);+ expect(handleWheel(new WheelEvent("wheel", { deltaY: -120 }))).toBe(true);+ expect(term.input).not.toHaveBeenCalled();+ });++ it("keeps Shift+wheel as access to exact xterm history", () => {+ const term = terminalDouble("none", "normal");+ const handleWheel = createLiveTuiWheelHandler(term, () => true);++ expect(+ handleWheel(new WheelEvent("wheel", { deltaY: -120, shiftKey: true })),+ ).toBe(true);+ expect(term.input).not.toHaveBeenCalled();+ });++ it("leaves negotiated normal-buffer mouse tracking untouched", () => {+ const term = terminalDouble("any", "normal");+ Object.assign(term.modes, { applicationCursorKeysMode: true });+ const handleWheel = createLiveTuiWheelHandler(term, () => true);++ expect(+ handleWheel(+ new WheelEvent("wheel", {+ deltaMode: WheelEvent.DOM_DELTA_LINE,+ deltaY: -2,+ }),+ ),+ ).toBe(true);+ expect(term.input).not.toHaveBeenCalled();+ });++ it("leaves alternate-screen mouse protocols untouched", () => {+ const term = terminalDouble("any", "alternate");+ const handleWheel = createLiveTuiWheelHandler(term, () => true);++ expect(handleWheel(new WheelEvent("wheel", { deltaY: 120 }))).toBe(true);+ expect(term.input).not.toHaveBeenCalled();+ });++ it("accumulates fine trackpad input without moving two histories", () => {+ const term = terminalDouble("none", "normal");+ const handleWheel = createLiveTuiWheelHandler(term, () => true);++ expect(handleWheel(new WheelEvent("wheel", { deltaY: 20 }))).toBe(false);+ expect(term.input).not.toHaveBeenCalled();+ expect(handleWheel(new WheelEvent("wheel", { deltaY: 20 }))).toBe(false);+ expect(term.input).toHaveBeenCalledWith("\x1b[B", true);+ });++ it("emits no more cursor rows than one bounded wheel action", () => {+ const term = terminalDouble("none", "normal");++ expect(scrollLiveCursor(term, 1, 100)).toBe(12);+ expect(term.input).toHaveBeenCalledOnce();+ expect(term.input).toHaveBeenCalledWith("\x1b[B".repeat(12), true);+ });+it("forwards the wheel over a rail unchanged and contains the workspace", () => {const workspace = document.createElement("div");const region = document.createElement("div");diff --git a/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.ts b/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.tsindex 7f4427cfbd..beea2732f7 100644--- a/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.ts+++ b/jarvis/ui/web/frontend/src/components/agentic/terminalScrollSurface.ts@@ -4,8 +4,9 @@* A terminal has one of two scroll owners:** * xterm owns a normal buffer, so its exact line and extent are public;- * * a full-screen application owns an alternate/mouse-tracking buffer, so the- * only truthful operation is to relay scroll input to that application.+ * * a full-screen application owns an alternate/mouse-tracking buffer, or the+ * user explicitly activates a keyboard-owned inline view, so the only+ * truthful operation is to relay scroll input to that application.** In the second case there is NO POSITION. Not an estimated one — none, so* that nothing on screen can be read as an answer to "where am I". The rail@@ -49,10 +50,34 @@ export interface ScrollThumbGeometry {height: number;}+/** The CSI slice used to observe cursor visibility without handling the mode. */+export interface TerminalModeParser {+ registerCsiHandler(+ id: { prefix?: string; intermediates?: string; final: string },+ callback: (params: (number | number[])[]) => boolean,+ ): { dispose(): void };+ registerEscHandler(+ id: { intermediates?: string; final: string },+ callback: () => boolean,+ ): { dispose(): void };+}++export interface LiveTuiCursorTracking {+ /** Reset local mode state before a terminal replay/reset boundary. */+ reset(): void;+ dispose(): void;+}+export const MIN_THUMB_PX = 28;const MAX_RELAY_NOTCHES = 80;const PAGE_UP = "\x1b[5~";const PAGE_DOWN = "\x1b[6~";+const CURSOR_UP = "\x1b[A";+const CURSOR_DOWN = "\x1b[B";+const APPLICATION_CURSOR_UP = "\x1bOA";+const APPLICATION_CURSOR_DOWN = "\x1bOB";+const WHEEL_PIXELS_PER_CURSOR_ROW = 40;+const MAX_CURSOR_ROWS_PER_WHEEL = 12;/*** Pixels of pointer travel per relayed unit when stroking an application rail.@@ -76,17 +101,23 @@ function finiteWhole(value: unknown): number {}/** Which side can truthfully answer where this pane is scrolled. */-export function terminalScrollOwner(term: Terminal): TerminalScrollOwner {+export function terminalScrollOwner(+ term: Terminal,+ liveTuiActive = false,+): TerminalScrollOwner {const tracking = term.modes?.mouseTrackingMode ?? "none";const bufferType = term.buffer?.active?.type ?? "normal";- return bufferType === "alternate" || tracking !== "none"+ return liveTuiActive || bufferType === "alternate" || tracking !== "none"? "application": "terminal";}/** Read a scroll view without inspecting or interpreting terminal content. */-export function readTerminalScrollView(term: Terminal): TerminalScrollView {- const owner = terminalScrollOwner(term);+export function readTerminalScrollView(+ term: Terminal,+ liveTuiActive = false,+): TerminalScrollView {+ const owner = terminalScrollOwner(term, liveTuiActive);const rows = Math.max(1, finiteWhole(term.rows));if (owner === "application") {return { owner, rows, maxLine: 0, line: 0 };@@ -162,6 +193,165 @@ export function applicationPageNotches(rows: number): number {return Math.max(1, Math.ceil(Math.max(1, rows) / 3));}+/**+ * Track cursor visibility as a candidate signal for a live drawn view.+ *+ * This is deliberately NOT an input-ownership decision: progress indicators+ * and disabled prompts also hide the cursor. A separate explicit user action+ * must activate cursor-key navigation while this candidate remains present.+ *+ * The handlers return false, so xterm still performs DECSET/DECRST itself. The+ * caller owns reset boundaries because `Terminal.reset()` is a local API call+ * and therefore does not pass through the parser.+ */+export function installLiveTuiCursorTracking(+ parser: TerminalModeParser,+ onActive: (active: boolean) => void,+): LiveTuiCursorTracking {+ let active = false;+ const update = (next: boolean) => {+ if (next === active) return;+ active = next;+ onActive(next);+ };+ const carriesCursorMode = (params: (number | number[])[]) =>+ params.some((param) =>+ Array.isArray(param) ? param.includes(25) : param === 25,+ );+ const handlers = [+ parser.registerCsiHandler({ prefix: "?", final: "l" }, (params) => {+ if (carriesCursorMode(params)) update(true);+ return false;+ }),+ parser.registerCsiHandler({ prefix: "?", final: "h" }, (params) => {+ if (carriesCursorMode(params)) update(false);+ return false;+ }),+ // DECSTR and RIS restore cursor visibility without emitting `?25h`.+ // Observe both while leaving xterm's reset implementation in charge.+ parser.registerCsiHandler({ intermediates: "!", final: "p" }, () => {+ update(false);+ return false;+ }),+ parser.registerEscHandler({ final: "c" }, () => {+ update(false);+ return false;+ }),+ ];+ return {+ reset: () => update(false),+ dispose: () => {+ update(false);+ for (const handler of handlers) handler.dispose();+ },+ };+}++/**+ * Move the selection/viewport of a keyboard-driven live TUI by whole rows.+ *+ * Inline coding-agent views are often drawn in the normal terminal buffer but+ * keep a windowed list of their own. Claude Code's workflow agent list is one+ * example: xterm can scroll the surrounding transcript, while the rows omitted+ * from that live list exist only inside Claude Code and are reached with cursor+ * keys. Use xterm's current cursor-key mode so the bytes match what a physical+ * ArrowUp/ArrowDown press would have produced.+ */+export function scrollLiveCursor(+ term: Terminal,+ direction: -1 | 1,+ rows = 1,+): number {+ const count = Math.min(+ MAX_CURSOR_ROWS_PER_WHEEL,+ Math.max(0, Math.floor(rows)),+ );+ if (count === 0) return 0;+ const applicationKeys = term.modes?.applicationCursorKeysMode === true;+ const sequence =+ direction < 0+ ? applicationKeys+ ? APPLICATION_CURSOR_UP+ : CURSOR_UP+ : applicationKeys+ ? APPLICATION_CURSOR_DOWN+ : CURSOR_DOWN;+ // One user action, one PTY/WebSocket frame. Repeating term.input here would+ // recreate the frame-count amplification that made long prompt delivery lag.+ term.input(sequence.repeat(count), true);+ return count;+}++/**+ * Give wheel input to an explicitly activated inline TUI view.+ *+ * Two histories can share a normal xterm buffer:+ *+ * * xterm's exact transcript, which keeps ordinary wheel behaviour; and+ * * a live, windowed block owned by the coding CLI, whose omitted rows are not+ * terminal scrollback at all.+ *+ * `isLiveTuiActive` is an explicit user opt-in, not a guess derived from output+ * or cursor visibility. While it is active, both directions belong to the live+ * view. Shift+wheel is deliberately left native as the escape hatch to exact+ * terminal history. Plain prompts and every negotiated mouse protocol also+ * remain native.+ */+export function createLiveTuiWheelHandler(+ term: Terminal,+ isLiveTuiActive: () => boolean,+): (event: WheelEvent) => boolean {+ let pixelRemainder = 0;++ return (event: WheelEvent): boolean => {+ if (+ event.deltaY === 0 ||+ Math.abs(event.deltaX) > Math.abs(event.deltaY) ||+ event.ctrlKey ||+ event.metaKey ||+ event.shiftKey+ ) {+ pixelRemainder = 0;+ return true;+ }++ const active = term.buffer?.active;+ const bufferType = active?.type ?? "normal";+ const tracking = term.modes?.mouseTrackingMode ?? "none";+ const direction: -1 | 1 = event.deltaY < 0 ? -1 : 1;+ const keyboardOwnedLiveView =+ bufferType === "normal" && tracking === "none" && isLiveTuiActive();++ if (!keyboardOwnedLiveView) {+ pixelRemainder = 0;+ return true;+ }++ let rows: number;+ if (event.deltaMode === WheelEvent.DOM_DELTA_PAGE) {+ rows = applicationPageNotches(term.rows);+ pixelRemainder = 0;+ } else if (event.deltaMode === WheelEvent.DOM_DELTA_LINE) {+ rows = Math.max(1, Math.ceil(Math.abs(event.deltaY)));+ pixelRemainder = 0;+ } else {+ if (pixelRemainder !== 0 && Math.sign(pixelRemainder) !== direction) {+ pixelRemainder = 0;+ }+ pixelRemainder += event.deltaY;+ rows = Math.floor(Math.abs(pixelRemainder) / WHEEL_PIXELS_PER_CURSOR_ROW);+ if (rows > 0) {+ pixelRemainder -= direction * rows * WHEEL_PIXELS_PER_CURSOR_ROW;+ }+ }++ if (rows > 0) scrollLiveCursor(term, direction, rows);+ // Even a sub-row trackpad delta belongs to the accumulator above. Letting+ // xterm also process it would emit a mouse report or move a second history.+ return false;+ };+}+/*** Relay older/newer movement to the application that owns the screen.*