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): resize workspace explorer

rubenluetke10-beep654f5b1db008
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx
index 5567cd9bbe..e75b8c9ee2 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx
@@ -2441,6 +2441,79 @@ describe("the workspace header row", () => {
expect(screen.queryByTestId("workspace-explorer")).toBeNull();
expect(screen.getByTestId("pane-Mika")).toBe(pane);
});
+
+ it("resizes the right-hand explorer from its left seam", async () => {
+ renderGrid();
+ fireEvent.click(screen.getByTestId("workspace-explorer-toggle"));
+ await screen.findByTestId("workspace-explorer");
+
+ const host = screen.getByTestId("workspace-explorer-host");
+ const seam = screen.getByTestId("workspace-explorer-resizer");
+ const pane = screen.getByTestId("pane-Mika");
+ expect(host.style.width).toBe("280px");
+ expect(seam.getAttribute("role")).toBe("separator");
+ expect(seam.getAttribute("aria-orientation")).toBe("vertical");
+ expect(seam.getAttribute("aria-controls")).toBe("workspace-explorer");
+ expect(seam.getAttribute("aria-valuemin")).toBe("220");
+ expect(seam.getAttribute("aria-valuemax")).toBe("640");
+ expect(seam.getAttribute("aria-valuenow")).toBe("280");
+
+ // The explorer sits to the RIGHT of this seam, so Left grows it and Right
+ // shrinks it — the inverse of a left sidebar's grip.
+ fireEvent.keyDown(seam, { key: "ArrowLeft" });
+ expect(host.style.width).toBe("296px");
+ expect(seam.getAttribute("aria-valuenow")).toBe("296");
+ fireEvent.keyDown(seam, { key: "ArrowRight" });
+ expect(host.style.width).toBe("280px");
+
+ // jsdom has no PointerEvent constructor. A MouseEvent dispatched under the
+ // pointer event's name carries the real clientX that the drag hook reads.
+ act(() => {
+ seam.dispatchEvent(
+ new MouseEvent("pointerdown", { bubbles: true, clientX: 1_000 }),
+ );
+ });
+ expect(pane.dataset.layoutBusy).toBe("yes");
+ act(() => window.dispatchEvent(new MouseEvent("pointercancel")));
+ expect(pane.dataset.layoutBusy).toBe("no");
+
+ act(() => {
+ seam.dispatchEvent(
+ new MouseEvent("pointerdown", { bubbles: true, clientX: 1_000 }),
+ );
+ });
+ act(() => {
+ window.dispatchEvent(new MouseEvent("pointermove", { clientX: 900 }));
+ window.dispatchEvent(new MouseEvent("pointerup"));
+ });
+
+ expect(host.style.width).toBe("380px");
+ expect(pane.dataset.layoutBusy).toBe("no");
+ expect(window.localStorage.getItem("jarvis.agenticIde.explorerWidth.v1")).toBe("380");
+
+ fireEvent.doubleClick(seam);
+ expect(host.style.width).toBe("280px");
+ });
+
+ it("keeps usable terminal space when a wide explorer preference meets a narrow frame", async () => {
+ const width = vi
+ .spyOn(HTMLElement.prototype, "clientWidth", "get")
+ .mockReturnValue(760);
+ window.localStorage.setItem("jarvis.agenticIde.explorerWidth.v1", "640");
+ try {
+ renderGrid();
+ fireEvent.click(screen.getByTestId("workspace-explorer-toggle"));
+ await waitFor(() =>
+ expect(screen.getByTestId("workspace-explorer-host").style.width).toBe("440px"),
+ );
+ const seam = screen.getByTestId("workspace-explorer-resizer");
+ expect(seam.getAttribute("aria-valuemax")).toBe("440");
+ expect(seam.getAttribute("aria-valuenow")).toBe("440");
+ expect(window.localStorage.getItem("jarvis.agenticIde.explorerWidth.v1")).toBe("640");
+ } finally {
+ width.mockRestore();
+ }
+ });
});
/**
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
index 8a43c9b072..42bb456490 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
@@ -28,6 +28,7 @@ import {
Loader2,
MessagesSquare,
Minus,
+ MoveHorizontal,
Moon,
Plus,
Power,
@@ -398,6 +399,14 @@ const COMPOSER_COLLAPSE_AT_PX = 96;
*/
const GRID_RESERVED_PX = 200;
+/** The file explorer starts compact, but its left seam can resize it. */
+const EXPLORER_WIDTH_KEY = "jarvis.agenticIde.explorerWidth.v1";
+const EXPLORER_DEFAULT_PX = 280;
+const EXPLORER_MIN_PX = 220;
+const EXPLORER_MAX_PX = 640;
+/** Terminal canvas kept visible while the right-hand explorer is open. */
+const EXPLORER_GRID_RESERVED_PX = 320;
+
/*
* How tightly the panes are packed.
*
@@ -1274,13 +1283,17 @@ export function AgenticGrid({
* everything except what the toolbar and a minimum grid need.
*/
const frameRef = useRef<HTMLDivElement | null>(null);
+ const [frameWidth, setFrameWidth] = useState(0);
const [frameHeight, setFrameHeight] = useState(0);
useEffect(() => {
const node = frameRef.current;
if (!node) return;
+ setFrameWidth(node.clientWidth);
setFrameHeight(node.clientHeight);
const observer = new ResizeObserver((entries) => {
+ const width = entries[0]?.contentRect.width ?? node.clientWidth;
const height = entries[0]?.contentRect.height ?? node.clientHeight;
+ setFrameWidth(Math.round(width));
setFrameHeight(Math.round(height));
});
observer.observe(node);
@@ -1303,6 +1316,25 @@ export function AgenticGrid({
// The grip is the bar's TOP edge: dragging up must make the bar taller.
handle: "start",
});
+ const explorerMax = Math.max(
+ EXPLORER_MIN_PX,
+ Math.min(
+ EXPLORER_MAX_PX,
+ frameWidth ? frameWidth - EXPLORER_GRID_RESERVED_PX : EXPLORER_MAX_PX,
+ ),
+ );
+ const explorerPane = useResizablePane({
+ storageKey: EXPLORER_WIDTH_KEY,
+ defaultSize: EXPLORER_DEFAULT_PX,
+ min: EXPLORER_MIN_PX,
+ max: explorerMax,
+ axis: "x",
+ // The explorer is on the right, so its grip is its LEFT edge: dragging
+ // left grows the panel and dragging right gives the terminals room back.
+ handle: "start",
+ });
+ // Keep a wider stored preference intact when the window temporarily narrows.
+ const requestedExplorer = Math.min(explorerPane.size, explorerMax);
// Clamped again on render, because the window can shrink under a height that
// was legal when it was stored — the remembered value stays untouched, so a
// maximised window gets the tall prompt bar back.
@@ -1539,7 +1571,8 @@ export function AgenticGrid({
* The prompt bar counts: dragging it changes the height of every pane above
* it just as a seam does.
*/
- const layoutBusy = sizes.dragging !== null || composer.isResizing;
+ const layoutBusy =
+ sizes.dragging !== null || composer.isResizing || explorerPane.isResizing;
const atLimit = session.terminals.length >= maxTerminals;
@@ -3195,17 +3228,50 @@ export function AgenticGrid({
<div
data-testid="workspace-explorer-host"
className={cn(
- "h-full shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none",
- explorerOpen ? "w-[280px]" : "w-0",
+ "relative h-full shrink-0",
+ !explorerPane.isResizing &&
+ "transition-[width] duration-200 motion-reduce:transition-none",
)}
+ style={{ width: explorerOpen ? requestedExplorer : 0 }}
aria-hidden={!explorerOpen}
>
{explorerOpen && (
- <WorkspaceExplorer
- workspaceId={session.id}
- rootName={project.name}
- onClose={() => setExplorerOpen(false)}
- />
+ <>
+ <div className="group absolute inset-y-0 left-0 z-20 flex -translate-x-1/2">
+ <PaneResizer
+ testId="workspace-explorer-resizer"
+ orientation="vertical"
+ active={explorerPane.isResizing}
+ title={t("agentic_grid.explorer.resize")}
+ onPointerDown={explorerPane.startResize}
+ onDoubleClick={explorerPane.reset}
+ // This is a start-edge grip: Left grows the explorer, Right
+ // shrinks it, so the shared seam's delta is inverted here.
+ onNudge={(delta) => explorerPane.nudge(-delta)}
+ valueNow={requestedExplorer}
+ valueMin={EXPLORER_MIN_PX}
+ valueMax={explorerMax}
+ controls="workspace-explorer"
+ className="h-full"
+ />
+ <MoveHorizontal
+ aria-hidden
+ className={cn(
+ "pointer-events-none absolute left-1/2 top-1/2 h-5 w-5 -translate-x-1/2 -translate-y-1/2 rounded-full border border-primary/35 bg-background/90 p-0.5 text-primary shadow-sm backdrop-blur transition-opacity",
+ explorerPane.isResizing
+ ? "opacity-100"
+ : "opacity-0 group-hover:opacity-100 group-focus-within:opacity-100",
+ )}
+ />
+ </div>
+ <div className="h-full overflow-hidden">
+ <WorkspaceExplorer
+ workspaceId={session.id}
+ rootName={project.name}
+ onClose={() => setExplorerOpen(false)}
+ />
+ </div>
+ </>
)}
</div>
diff --git a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceExplorer.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceExplorer.test.tsx
index 5e4634ed7a..e4f3ac4df8 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceExplorer.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceExplorer.test.tsx
@@ -95,7 +95,7 @@ describe("WorkspaceExplorer", () => {
expect(await screen.findByText(".gitignore")).toBeTruthy();
const explorer = screen.getByTestId("workspace-explorer");
- expect(explorer.className).toContain("border-l");
+ expect(explorer.className).toContain("w-full");
expect(explorer.style.background).toContain("0.22");
expect(screen.getByText("project")).toBeTruthy();
diff --git a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceExplorer.tsx b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceExplorer.tsx
index 912a3a903b..7a4fe52bce 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceExplorer.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceExplorer.tsx
@@ -148,7 +148,7 @@ export function WorkspaceExplorer({
<aside
id="workspace-explorer"
data-testid="workspace-explorer"
- className="flex h-full w-[280px] shrink-0 flex-col border-l border-border/55 backdrop-blur-md"
+ className="flex h-full w-full min-w-0 flex-col backdrop-blur-md"
style={{ background: "rgb(var(--shell-rgb) / 0.22)" }}
aria-label={t("agentic_grid.explorer.title")}
>
diff --git a/jarvis/ui/web/frontend/src/components/layout/PaneResizer.tsx b/jarvis/ui/web/frontend/src/components/layout/PaneResizer.tsx
index 36cd18154e..67886b031e 100644
--- a/jarvis/ui/web/frontend/src/components/layout/PaneResizer.tsx
+++ b/jarvis/ui/web/frontend/src/components/layout/PaneResizer.tsx
@@ -30,6 +30,14 @@ export interface PaneResizerProps {
onDoubleClick: () => void;
/** Keyboard equivalent of a drag, in px — wire to ``nudge``. */
onNudge?: (delta: number) => void;
+ /** Current pane size exposed to assistive technology. */
+ valueNow?: number;
+ /** Smallest pane size exposed to assistive technology. */
+ valueMin?: number;
+ /** Largest pane size exposed to assistive technology. */
+ valueMax?: number;
+ /** ID of the pane whose size this separator controls. */
+ controls?: string;
/** True while a drag is in progress, so the seam can light up. */
active: boolean;
/** Hover tooltip. Also used as the accessible name. */
@@ -69,6 +77,10 @@ export const PaneResizer = forwardRef<HTMLDivElement, PaneResizerProps>(function
onPointerDown,
onDoubleClick,
onNudge,
+ valueNow,
+ valueMin,
+ valueMax,
+ controls,
active,
title,
style,
@@ -99,6 +111,10 @@ export const PaneResizer = forwardRef<HTMLDivElement, PaneResizerProps>(function
role="separator"
aria-orientation={orientation}
aria-label={title}
+ aria-valuenow={valueNow}
+ aria-valuemin={valueMin}
+ aria-valuemax={valueMax}
+ aria-controls={controls}
title={title}
tabIndex={0}
data-testid={testId ?? `pane-resizer-${orientation}`}
diff --git a/jarvis/ui/web/frontend/src/hooks/useResizablePane.test.ts b/jarvis/ui/web/frontend/src/hooks/useResizablePane.test.ts
index 45f5dfa5d7..62f008b8c2 100644
--- a/jarvis/ui/web/frontend/src/hooks/useResizablePane.test.ts
+++ b/jarvis/ui/web/frontend/src/hooks/useResizablePane.test.ts
@@ -3,7 +3,11 @@ import { describe, expect, it, afterEach } from "vitest";
import { clampSize, useResizablePane } from "./useResizablePane";
-afterEach(() => window.localStorage.clear());
+afterEach(() => {
+ window.localStorage.clear();
+ document.body.style.cursor = "";
+ document.body.style.userSelect = "";
+});
/**
* One drag, start to finish, on whichever axis the pane uses.
@@ -77,6 +81,24 @@ describe("useResizablePane", () => {
expect(result.current.size).toBe(480);
});
+ it("keeps a wider preference while a measured maximum is temporarily smaller", () => {
+ window.localStorage.setItem("test.size", "460");
+ const { result, rerender } = renderHook(
+ ({ max }) => useResizablePane({ ...opts, max }),
+ { initialProps: { max: 480 } },
+ );
+ expect(result.current.size).toBe(460);
+
+ rerender({ max: 300 });
+ expect(result.current.size).toBe(300);
+ expect(window.localStorage.getItem("test.size")).toBe("460");
+
+ // Interaction starts from the visible ceiling, not the hidden preference.
+ drag(result.current, { x: 300, y: 0 }, { x: 280, y: 0 });
+ expect(result.current.size).toBe(280);
+ expect(window.localStorage.getItem("test.size")).toBe("280");
+ });
+
it("reset() returns to the default and persists it", () => {
window.localStorage.setItem("test.size", "300");
const { result } = renderHook(() => useResizablePane(opts));
@@ -156,6 +178,40 @@ describe("useResizablePane", () => {
expect(result.current.size).toBe(340);
});
+ it("finishes a drag on pointer cancellation or window blur", () => {
+ document.body.style.cursor = "crosshair";
+ document.body.style.userSelect = "text";
+ const { result } = renderHook(() => useResizablePane(opts));
+
+ act(() => {
+ result.current.startResize({
+ clientX: 260,
+ clientY: 0,
+ preventDefault: () => {},
+ } as unknown as React.PointerEvent);
+ });
+ expect(result.current.isResizing).toBe(true);
+ expect(document.body.style.cursor).toBe("col-resize");
+ expect(document.body.style.userSelect).toBe("none");
+
+ act(() => window.dispatchEvent(new MouseEvent("pointercancel")));
+ expect(result.current.isResizing).toBe(false);
+ expect(document.body.style.cursor).toBe("crosshair");
+ expect(document.body.style.userSelect).toBe("text");
+
+ act(() => {
+ result.current.startResize({
+ clientX: 260,
+ clientY: 0,
+ preventDefault: () => {},
+ } as unknown as React.PointerEvent);
+ });
+ act(() => window.dispatchEvent(new Event("blur")));
+ expect(result.current.isResizing).toBe(false);
+ expect(document.body.style.cursor).toBe("crosshair");
+ expect(document.body.style.userSelect).toBe("text");
+ });
+
it("nudge() moves the seam by whole pixels and stays inside the band", () => {
const { result } = renderHook(() => useResizablePane(opts));
act(() => result.current.nudge(16));
diff --git a/jarvis/ui/web/frontend/src/hooks/useResizablePane.ts b/jarvis/ui/web/frontend/src/hooks/useResizablePane.ts
index 97d8dfed88..0383d7e102 100644
--- a/jarvis/ui/web/frontend/src/hooks/useResizablePane.ts
+++ b/jarvis/ui/web/frontend/src/hooks/useResizablePane.ts
@@ -95,16 +95,21 @@ export function useResizablePane({
(e: React.PointerEvent) => {
e.preventDefault();
startPoint.current = axis === "x" ? e.clientX : e.clientY;
- startSize.current = size;
+ // A measured maximum can shrink under a stored preference. Anchor the
+ // gesture to the size actually on screen so it responds immediately.
+ startSize.current = clampSize(size, min, max);
setIsResizing(true);
},
- [axis, size],
+ [axis, size, min, max],
);
const reset = useCallback(() => setSize(defaultSize), [defaultSize]);
const nudge = useCallback(
- (delta: number) => setSize((current) => clampSize(current + delta, min, max)),
+ (delta: number) =>
+ setSize((current) =>
+ clampSize(clampSize(current, min, max) + delta, min, max),
+ ),
[min, max],
);
@@ -140,7 +145,10 @@ export function useResizablePane({
point = axis === "x" ? e.clientX : e.clientY;
if (frame === undefined) frame = requestAnimationFrame(apply);
};
- const onUp = () => {
+ let finished = false;
+ const finish = () => {
+ if (finished) return;
+ finished = true;
// Land the last move before the drag is declared over, so the settled
// size — the one that gets persisted — is the one under the pointer.
if (frame !== undefined) {
@@ -151,7 +159,9 @@ export function useResizablePane({
};
window.addEventListener("pointermove", onMove);
- window.addEventListener("pointerup", onUp);
+ window.addEventListener("pointerup", finish);
+ window.addEventListener("pointercancel", finish);
+ window.addEventListener("blur", finish);
// Lock the cursor + suppress text selection window-wide during the drag.
const prevCursor = document.body.style.cursor;
const prevSelect = document.body.style.userSelect;
@@ -161,7 +171,9 @@ export function useResizablePane({
return () => {
if (frame !== undefined) cancelAnimationFrame(frame);
window.removeEventListener("pointermove", onMove);
- window.removeEventListener("pointerup", onUp);
+ window.removeEventListener("pointerup", finish);
+ window.removeEventListener("pointercancel", finish);
+ window.removeEventListener("blur", finish);
document.body.style.cursor = prevCursor;
document.body.style.userSelect = prevSelect;
};
@@ -178,7 +190,11 @@ export function useResizablePane({
}
}, [size, isResizing, storageKey]);
- return { size, isResizing, startResize, reset, nudge, resize };
+ // Keep the stored preference in state while returning only the size that
+ // fits the current measured frame. Merely narrowing a window must not erase
+ // the user's wider layout preference.
+ const visibleSize = clampSize(size, min, max);
+ return { size: visibleSize, isResizing, startResize, reset, nudge, resize };
}
function loadSize(key: string, fallback: number): number {
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 890ebdaeb0..c3472ce50d 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -3925,6 +3925,7 @@
"explorer": {
"title": "Explorer",
"toggle": "Workspace-Explorer ein- oder ausblenden",
+ "resize": "Ziehen, um die Explorer-Breite zu ändern – Doppelklick zum Zurücksetzen",
"refresh": "Dateibaum aktualisieren",
"close": "Explorer schließen",
"loading": "Wird geladen…",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 913af3f05d..8ce67d32b3 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -3925,6 +3925,7 @@
"explorer": {
"title": "Explorer",
"toggle": "Show or hide the workspace explorer",
+ "resize": "Drag to resize the explorer — double-click to reset",
"refresh": "Refresh the file tree",
"close": "Close the explorer",
"loading": "Loading…",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 4f4c0b3553..ecf4c82fac 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -3925,6 +3925,7 @@
"explorer": {
"title": "Explorador",
"toggle": "Mostrar u ocultar el explorador del espacio de trabajo",
+ "resize": "Arrastra para cambiar el ancho del explorador; haz doble clic para restablecerlo",
"refresh": "Actualizar el árbol de archivos",
"close": "Cerrar el explorador",
"loading": "Cargando…",