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): the narrow-pane notice can be waved away

rubenluetke10-beep144111ec083c
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 91e515c9b9..88b96f64c4 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
@@ -1655,6 +1655,57 @@ describe("pane refit while the agent is drawing", () => {
expect(screen.queryByTestId("pane-width-maximize-Dana")).toBeNull();
});
+ it("can be waved away, and stays away while the pane stays narrow", () => {
+ // A crowded workspace shows this on every pane at once, and the trade may
+ // well be one the user made on purpose. A warning they cannot switch off
+ // would be the next thing reported.
+ terminalHarness.size = { cols: 22, rows: 30 };
+ render(pane());
+ act(() => {
+ vi.advanceTimersByTime(600);
+ });
+
+ act(() => {
+ screen.getByTestId("pane-width-dismiss-Dana").click();
+ });
+ expect(screen.queryByTestId("pane-width-notice-Dana")).toBeNull();
+
+ // Narrower still, and still acknowledged.
+ terminalHarness.size = { cols: 14, rows: 30 };
+ act(() => {
+ window.dispatchEvent(new Event("resize"));
+ vi.advanceTimersByTime(600);
+ });
+ expect(screen.queryByTestId("pane-width-notice-Dana")).toBeNull();
+ });
+
+ it("speaks up again when a widened pane is crowded a second time", () => {
+ terminalHarness.size = { cols: 22, rows: 30 };
+ render(pane());
+ act(() => {
+ vi.advanceTimersByTime(600);
+ });
+ act(() => {
+ screen.getByTestId("pane-width-dismiss-Dana").click();
+ });
+
+ // Given room…
+ terminalHarness.size = { cols: 120, rows: 30 };
+ act(() => {
+ window.dispatchEvent(new Event("resize"));
+ vi.advanceTimersByTime(600);
+ });
+ // …and crowded again. A screen that has started shredding a second time is
+ // worth a second sentence.
+ terminalHarness.size = { cols: 22, rows: 30 };
+ act(() => {
+ window.dispatchEvent(new Event("resize"));
+ vi.advanceTimersByTime(600);
+ });
+
+ expect(screen.getByTestId("pane-width-notice-Dana")).toBeTruthy();
+ });
+
it("stays quiet on a pane with room to work", () => {
terminalHarness.size = { cols: 80, rows: 24 };
render(pane());
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
index 666dc8ad4e..9d7d5f6b24 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
@@ -589,6 +589,18 @@ export function AgenticTerminal({
* tile re-renders nothing.
*/
const [paneCols, setPaneCols] = useState<number | null>(null);
+ /*
+ * Has the reader waved the width notice away for this pane?
+ *
+ * A notice that cannot be dismissed becomes furniture, and this one would be
+ * on every pane of a crowded workspace at once — a row of identical warnings
+ * about a trade the user may well have made on purpose. One click retires it.
+ *
+ * Reset below once the pane has room again, so a workspace that is widened
+ * and later crowded a second time is told a second time rather than staying
+ * quiet about a screen that has started shredding again.
+ */
+ const [widthNoticeDismissed, setWidthNoticeDismissed] = useState(false);
// A parked chat pane may have a large asynchronous xterm write to parse when
// it takes the stage again. Keep its terminal surface out of the paint until
// that write and the final viewport restoration have both landed; otherwise xterm
@@ -1875,6 +1887,14 @@ export function AgenticTerminal({
term.clearTextureAtlas?.();
}, [appearance, terminalEpoch]);
+ // A pane that has been given room again forgets that its narrowness was
+ // acknowledged — see `widthNoticeDismissed`.
+ useEffect(() => {
+ if (paneCols !== null && paneCols >= WORKABLE_COLS) {
+ setWidthNoticeDismissed(false);
+ }
+ }, [paneCols]);
+
useEffect(() => {
const term = termRef.current;
if (!term) return;
@@ -2121,16 +2141,19 @@ export function AgenticTerminal({
cannot be reached has a more specific answer and only one row to say it
in. See PaneWidthNotice.
*/}
- {visibleStatus !== "exited" && visibleStatus !== "error" && (
- <PaneWidthNotice
- name={name}
- displayName={displayName}
- cols={paneCols}
- light={appearance === "light"}
- maximized={maximized}
- onToggleMaximize={onToggleMaximize}
- />
- )}
+ {visibleStatus !== "exited" &&
+ visibleStatus !== "error" &&
+ !widthNoticeDismissed && (
+ <PaneWidthNotice
+ name={name}
+ displayName={displayName}
+ cols={paneCols}
+ light={appearance === "light"}
+ maximized={maximized}
+ onToggleMaximize={onToggleMaximize}
+ onDismiss={() => setWidthNoticeDismissed(true)}
+ />
+ )}
{/*
Keep the visual inset OUTSIDE xterm's measured host. FitAddon reads the
host's border-box but does not subtract padding on that host, so putting
@@ -2935,6 +2958,7 @@ function PaneWidthNotice({
light,
maximized,
onToggleMaximize,
+ onDismiss,
}: {
name: string;
displayName: string;
@@ -2942,6 +2966,7 @@ function PaneWidthNotice({
light: boolean;
maximized: boolean;
onToggleMaximize?: () => void;
+ onDismiss: () => void;
}) {
// Nothing measured yet, or a tile that gives its agent room to work.
if (cols === null || cols >= WORKABLE_COLS) return null;
@@ -2993,6 +3018,29 @@ function PaneWidthNotice({
Widen
</button>
)}
+ {/*
+ Retire it. A crowded workspace shows this on every pane at once, and
+ the trade may well be one the user made on purpose — a warning they
+ cannot switch off would be the next thing reported.
+ */}
+ <button
+ type="button"
+ aria-label={`Stop telling me that ${name} is narrow`}
+ title="I know — leave it"
+ data-testid={`pane-width-dismiss-${name}`}
+ onClick={(e) => {
+ e.stopPropagation();
+ onDismiss();
+ }}
+ onMouseDown={(e) => e.stopPropagation()}
+ className={cn(
+ "flex h-4 w-4 shrink-0 items-center justify-center rounded",
+ "transition-colors duration-150 hover:bg-foreground/10",
+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/70",
+ )}
+ >
+ <X className="h-3 w-3" aria-hidden="true" />
+ </button>
</div>
);
}
diff --git a/jarvis/ui/web/frontend/src/views/VisualizationView.test.tsx b/jarvis/ui/web/frontend/src/views/VisualizationView.test.tsx
index d6207eec34..d583d6acff 100644
--- a/jarvis/ui/web/frontend/src/views/VisualizationView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/VisualizationView.test.tsx
@@ -298,6 +298,82 @@ describe("VisualizationView", () => {
await screen.findByTestId("visualization-empty");
expect(screen.queryByTestId("visualization-canvas")).toBeNull();
});
+
+ it("zooms with ctrl+wheel and leaves plain scrolling alone", async () => {
+ installFetchMock(
+ [{ slug: "run-new", utterance: "Draw the architecture", status: "success" }],
+ { "run-new": [] },
+ { "run-new": CHART_PLAN },
+ );
+
+ renderView();
+
+ const canvas = await screen.findByTestId("visualization-canvas");
+ // A bare wheel is scrolling, not zooming — it must stay untouched.
+ fireEvent.wheel(canvas, { deltaY: -100 });
+ expect(screen.getByText("100%")).toBeTruthy();
+ // Ctrl+wheel (also how browsers deliver a trackpad pinch) zooms in.
+ fireEvent.wheel(canvas, { deltaY: -100, ctrlKey: true });
+ expect(screen.getByText("122%")).toBeTruthy();
+ });
+
+ it("pans the canvas with a pointer drag on the background", async () => {
+ installFetchMock(
+ [{ slug: "run-new", utterance: "Draw the architecture", status: "success" }],
+ { "run-new": [] },
+ { "run-new": CHART_PLAN },
+ );
+
+ renderView();
+
+ const canvas = await screen.findByTestId("visualization-canvas");
+ // jsdom has no PointerEvent constructor — a MouseEvent under the pointer
+ // event's name carries the coordinates the pan handlers read.
+ fireEvent(
+ canvas,
+ new MouseEvent("pointerdown", { bubbles: true, clientX: 100, clientY: 90 }),
+ );
+ fireEvent(
+ canvas,
+ new MouseEvent("pointermove", { bubbles: true, clientX: 60, clientY: 70 }),
+ );
+ expect(canvas.scrollLeft).toBe(40);
+ expect(canvas.scrollTop).toBe(20);
+
+ // Releasing ends the pan: further movement no longer scrolls.
+ fireEvent(canvas, new MouseEvent("pointerup", { bubbles: true }));
+ fireEvent(
+ canvas,
+ new MouseEvent("pointermove", { bubbles: true, clientX: 0, clientY: 0 }),
+ );
+ expect(canvas.scrollLeft).toBe(40);
+ });
+
+ it("keeps a press on a node a click, never a pan", async () => {
+ installFetchMock(
+ [{ slug: "run-new", utterance: "Draw the architecture", status: "success" }],
+ { "run-new": [] },
+ { "run-new": CHART_PLAN },
+ );
+
+ renderView();
+
+ const canvas = await screen.findByTestId("visualization-canvas");
+ const node = await screen.findByTestId("graph-node-start");
+ fireEvent(
+ node,
+ new MouseEvent("pointerdown", { bubbles: true, clientX: 100, clientY: 90 }),
+ );
+ fireEvent(
+ canvas,
+ new MouseEvent("pointermove", { bubbles: true, clientX: 60, clientY: 70 }),
+ );
+ // The press began on a card, so the canvas never grabbed it…
+ expect(canvas.scrollLeft).toBe(0);
+ // …and the click still opens the inspector.
+ fireEvent.click(node);
+ await screen.findByTestId("visualization-inspector");
+ });
});
describe("SectionStage", () => {
diff --git a/jarvis/ui/web/frontend/src/views/VisualizationView.tsx b/jarvis/ui/web/frontend/src/views/VisualizationView.tsx
index 32a01a16f8..95b331508e 100644
--- a/jarvis/ui/web/frontend/src/views/VisualizationView.tsx
+++ b/jarvis/ui/web/frontend/src/views/VisualizationView.tsx
@@ -1,4 +1,11 @@
-import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import {
+ useCallback,
+ useEffect,
+ useLayoutEffect,
+ useMemo,
+ useRef,
+ useState,
+} from "react";
import {
Download,
ExternalLink,
@@ -252,21 +259,70 @@ export function VisualizationView() {
}, [graph, selectedNodeId]);
const [zoom, setZoom] = useState<number>(1);
- /* Once the user has zoomed by hand, the automatic fit keeps its hands off
- * until another run is selected — an explicit choice must never be fought. */
+ /* Once the user has zoomed or panned by hand, the automatic fit keeps its
+ * hands off until another run is selected — an explicit choice must never
+ * be fought. */
const userZoomed = useRef(false);
const [canvasEl, setCanvasEl] = useState<HTMLDivElement | null>(null);
- const stepZoom = useCallback((direction: 1 | -1) => {
- userZoomed.current = true;
- setZoom((current) => {
- if (direction > 0) {
- return ZOOM_STEPS.find((s) => s > current + 0.001) ?? MAX_ZOOM;
+ /*
+ * Anchored zoom: every zoom keeps ONE canvas point where it is on screen —
+ * the cursor for the wheel, the viewport centre for the buttons. Without an
+ * anchor the scale pivots on the canvas origin and the node being looked at
+ * slides out of view. The anchor is recorded in content coordinates and the
+ * scroll correction lands right after the rescaled canvas hits the DOM,
+ * before paint — no one-frame jump.
+ */
+ const zoomRef = useRef(1);
+ const zoomAnchor = useRef<{
+ px: number;
+ py: number;
+ cx: number;
+ cy: number;
+ } | null>(null);
+
+ useLayoutEffect(() => {
+ zoomRef.current = zoom;
+ const pending = zoomAnchor.current;
+ if (pending === null || canvasEl === null) return;
+ zoomAnchor.current = null;
+ canvasEl.scrollLeft = pending.px * zoom - pending.cx;
+ canvasEl.scrollTop = pending.py * zoom - pending.cy;
+ }, [zoom, canvasEl]);
+
+ /** Zoom to `next`, keeping the given viewport point (default: centre) put. */
+ const zoomTo = useCallback(
+ (next: number, at?: { cx: number; cy: number }) => {
+ const clamped = clampZoom(next);
+ const current = zoomRef.current;
+ if (canvasEl !== null && clamped !== current) {
+ const cx = at?.cx ?? canvasEl.clientWidth / 2;
+ const cy = at?.cy ?? canvasEl.clientHeight / 2;
+ zoomAnchor.current = {
+ px: (canvasEl.scrollLeft + cx) / current,
+ py: (canvasEl.scrollTop + cy) / current,
+ cx,
+ cy,
+ };
}
- const smaller = [...ZOOM_STEPS].reverse().find((s) => s < current - 0.001);
- return smaller ?? Math.min(current, MIN_ZOOM);
- });
- }, []);
+ setZoom(clamped);
+ },
+ [canvasEl],
+ );
+
+ const stepZoom = useCallback(
+ (direction: 1 | -1) => {
+ userZoomed.current = true;
+ const current = zoomRef.current;
+ const next =
+ direction > 0
+ ? (ZOOM_STEPS.find((s) => s > current + 0.001) ?? MAX_ZOOM)
+ : ([...ZOOM_STEPS].reverse().find((s) => s < current - 0.001) ??
+ Math.min(current, MIN_ZOOM));
+ zoomTo(next);
+ },
+ [zoomTo],
+ );
/* Scale the whole story into the visible canvas — never above 100%, so a
* two-node run stays a pair of cards instead of a pair of billboards. The
@@ -280,6 +336,11 @@ export function VisualizationView() {
(clientHeight - 16) / graph.height,
1,
);
+ // Fit means "show the whole story": the viewport returns to the origin,
+ // by plain assignment (no pending anchor — fit IS the anchor decision).
+ zoomAnchor.current = null;
+ canvasEl.scrollLeft = 0;
+ canvasEl.scrollTop = 0;
setZoom(clampZoom(scale));
}, [canvasEl, graph]);
@@ -302,10 +363,76 @@ export function VisualizationView() {
if (!event.ctrlKey && !event.metaKey) return;
event.preventDefault();
userZoomed.current = true;
- setZoom((current) => clampZoom(current * Math.exp(-event.deltaY * 0.002)));
+ const rect = canvasEl.getBoundingClientRect();
+ zoomTo(zoomRef.current * Math.exp(-event.deltaY * 0.002), {
+ cx: event.clientX - rect.left,
+ cy: event.clientY - rect.top,
+ });
};
canvasEl.addEventListener("wheel", onWheel, { passive: false });
return () => canvasEl.removeEventListener("wheel", onWheel);
+ }, [canvasEl, zoomTo]);
+
+ /*
+ * Drag-to-pan. The scroll container follows a held primary/middle button on
+ * canvas background; a press on a node stays a click. Pointer capture keeps
+ * a fast drag alive outside the canvas (guarded: jsdom has no capture API).
+ */
+ const [panning, setPanning] = useState(false);
+ const panState = useRef<{
+ pointerId: number;
+ originX: number;
+ originY: number;
+ scrollLeft: number;
+ scrollTop: number;
+ } | null>(null);
+
+ const onPanStart = useCallback(
+ (event: React.PointerEvent<HTMLDivElement>) => {
+ if (canvasEl === null) return;
+ if (event.button !== 0 && event.button !== 1) return;
+ if ((event.target as Element).closest("button") !== null) return;
+ // Middle button would otherwise start the browser's own autoscroll.
+ if (event.button === 1) event.preventDefault();
+ panState.current = {
+ pointerId: event.pointerId,
+ originX: event.clientX,
+ originY: event.clientY,
+ scrollLeft: canvasEl.scrollLeft,
+ scrollTop: canvasEl.scrollTop,
+ };
+ setPanning(true);
+ // Capture keeps a fast drag alive outside the canvas. Guarded twice:
+ // jsdom neither constructs PointerEvents (pointerId undefined) nor
+ // accepts capture for a pointer it never saw.
+ if (typeof event.pointerId === "number")
+ canvasEl.setPointerCapture?.(event.pointerId);
+ },
+ [canvasEl],
+ );
+
+ const onPanMove = useCallback(
+ (event: React.PointerEvent<HTMLDivElement>) => {
+ const pan = panState.current;
+ if (pan === null || canvasEl === null) return;
+ const dx = event.clientX - pan.originX;
+ const dy = event.clientY - pan.originY;
+ // A real drag (not a sloppy click) is a viewport choice like a manual
+ // zoom: the auto-fit stops following a live run's growth.
+ if (Math.abs(dx) + Math.abs(dy) > 4) userZoomed.current = true;
+ canvasEl.scrollLeft = pan.scrollLeft - dx;
+ canvasEl.scrollTop = pan.scrollTop - dy;
+ },
+ [canvasEl],
+ );
+
+ const onPanEnd = useCallback(() => {
+ const pan = panState.current;
+ if (pan === null) return;
+ panState.current = null;
+ setPanning(false);
+ if (typeof pan.pointerId === "number")
+ canvasEl?.releasePointerCapture?.(pan.pointerId);
}, [canvasEl]);
const refetch = useCallback(() => {
@@ -433,8 +560,15 @@ export function VisualizationView() {
<>
<div
ref={setCanvasEl}
- className="min-h-0 flex-1 overflow-auto"
+ className={cn(
+ "min-h-0 flex-1 overflow-auto",
+ panning ? "cursor-grabbing" : "cursor-grab",
+ )}
data-testid="visualization-canvas"
+ onPointerDown={onPanStart}
+ onPointerMove={onPanMove}
+ onPointerUp={onPanEnd}
+ onPointerCancel={onPanEnd}
>
<GraphCanvas
graph={graph}
@@ -470,7 +604,7 @@ export function VisualizationView() {
type="button"
onClick={() => {
userZoomed.current = true;
- setZoom(1);
+ zoomTo(1);
}}
title={t("visualization.zoom_reset")}
aria-label={t("visualization.zoom_reset")}