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.

feat(ide): close the side panel by pushing its grip against the right edge (#885)

Ruben Lütkebb662e929b66
diff --git a/dodaios/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.test.tsx b/dodaios/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.test.tsx
index e3ad8f7b09..3333c56123 100644
--- a/dodaios/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.test.tsx
+++ b/dodaios/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.test.tsx
@@ -327,6 +327,21 @@ describe("IdeSidePanel", () => {
expect(screen.getByTestId("office-stage")).toBe(stage);
});
+ it("closes when its grip is pushed against the right edge", async () => {
+ vi.stubGlobal("PointerEvent", PointerEventStub);
+ act(() => useIdeSidePanelStore.setState({ open: true, tabs: ["agents"], active: "agents" }));
+ render(<Harness />);
+ fireEvent.pointerDown(screen.getByTestId("ide-side-panel-resizer"), { clientX: 1000, clientY: 10 });
+ await act(async () => {
+ window.dispatchEvent(new MouseEvent("pointermove", { clientX: 1900, clientY: 10 }));
+ await new Promise((resolve) => requestAnimationFrame(() => resolve(null)));
+ });
+ expect(screen.getByTestId("ide-side-panel-body").dataset.closing).toBe("true");
+ act(() => { window.dispatchEvent(new MouseEvent("pointerup")); });
+ expect(useIdeSidePanelStore.getState().open).toBe(false);
+ expect(localStorage.getItem("jarvis.agenticIde.sidePanelOpen")).toBe("0");
+ });
+
it("drops the full view when the panel closes", () => {
act(() => useIdeSidePanelStore.setState({ open: true, tabs: ["agents"], active: "agents" }));
render(<Harness />);
diff --git a/dodaios/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.tsx b/dodaios/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.tsx
index 72682b1894..73fb46ad7e 100644
--- a/dodaios/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.tsx
+++ b/dodaios/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.tsx
@@ -32,6 +32,8 @@ const SPLIT_MIN_PX = 720;
const TAB_DRAG_SLOP_PX = 6;
/** Strip of terminal grid kept beside the panel, so its grip always stays reachable. */
const GRID_RESERVED_PX = 120;
+/** Dragging the grip toward the right edge past this width and letting go closes the panel. */
+const COLLAPSE_BELOW_PX = 160;
// Preserve the existing public export without coupling caption chrome to the panel.
export { SIDE_PANEL_ID } from "./sidePanelIds";
@@ -60,6 +62,7 @@ export function IdeSidePanelFrame({ children, markInUse = false, appearance, onS
const open = useIdeSidePanelStore((state) => state.open);
const inUse = useIdeSidePanelStore((state) => state.inUse);
const setInUse = useIdeSidePanelStore((state) => state.setInUse);
+ const setOpen = useIdeSidePanelStore((state) => state.setOpen);
const active = useIdeSidePanelStore((state) => state.active);
const split = useIdeSidePanelStore((state) => state.split);
const maximized = useIdeSidePanelStore((state) => state.maximized);
@@ -88,7 +91,13 @@ export function IdeSidePanelFrame({ children, markInUse = false, appearance, onS
axis: "x",
// The panel sits on the right, so its grip is its LEFT edge.
handle: "start",
+ // Push the grip against the right edge to close the panel; it reopens at
+ // the width it had before the drag.
+ collapseBelow: COLLAPSE_BELOW_PX,
+ onCollapse: () => setOpen(false),
});
+ // Past this point a release closes the panel: fade it as the hint.
+ const closing = pane.isResizing && pane.size < COLLAPSE_BELOW_PX;
// Keep a wider stored preference intact while the window is narrow.
const width = Math.min(pane.size, max);
@@ -159,7 +168,8 @@ export function IdeSidePanelFrame({ children, markInUse = false, appearance, onS
{/* Same element either way, so the live office scene is never remounted.
A press anywhere in it (capture phase: the office canvas and the
terminals in it stop their own events) makes it the area in use. */}
- <div hidden={!open} data-testid="ide-side-panel-body" className={maximized ? "absolute inset-0 z-30" : "relative h-full"}
+ <div hidden={!open} data-testid="ide-side-panel-body" data-closing={closing ? "true" : undefined}
+ className={cn(maximized ? "absolute inset-0 z-30" : "relative h-full", closing && "opacity-40")}
onPointerDownCapture={() => setInUse(true)}>
<IdeSidePanel appearance={appearance} onScreen={onScreen} />
{/* The "you are here" frame, drawn over everything in the panel so
diff --git a/dodaios/ui/web/frontend/src/hooks/useResizablePane.test.ts b/dodaios/ui/web/frontend/src/hooks/useResizablePane.test.ts
index 62f008b8c2..5cdd40e5e3 100644
--- a/dodaios/ui/web/frontend/src/hooks/useResizablePane.test.ts
+++ b/dodaios/ui/web/frontend/src/hooks/useResizablePane.test.ts
@@ -220,3 +220,35 @@ describe("useResizablePane", () => {
expect(result.current.size).toBe(200);
});
});
+
+describe("useResizablePane drag-to-close", () => {
+ const opts = { storageKey: "test.collapse", defaultSize: 340, min: 260, max: 1000, axis: "x" as const, handle: "start" as const, collapseBelow: 160 };
+
+ it("closes when the start-edge grip is pushed to the far edge, and keeps the old width", () => {
+ let closed = 0;
+ const { result } = renderHook(() => useResizablePane({ ...opts, onCollapse: () => { closed += 1; } }));
+ drag(result.current, { x: 1000, y: 0 }, { x: 1300, y: 0 });
+ expect(closed).toBe(1);
+ expect(result.current.size).toBe(340);
+ expect(window.localStorage.getItem("test.collapse")).toBe("340");
+ });
+
+ it("follows the pointer below the minimum during the drag", async () => {
+ const { result } = renderHook(() => useResizablePane({ ...opts, onCollapse: () => {} }));
+ act(() => { result.current.startResize({ clientX: 1000, clientY: 0, preventDefault: () => {} } as unknown as React.PointerEvent); });
+ await act(async () => {
+ window.dispatchEvent(new MouseEvent("pointermove", { clientX: 1240, clientY: 0 }));
+ await new Promise((resolve) => requestAnimationFrame(() => resolve(null)));
+ });
+ expect(result.current.size).toBe(100);
+ act(() => { window.dispatchEvent(new MouseEvent("pointerup")); });
+ });
+
+ it("settles at the minimum when let go short of the close point", () => {
+ let closed = 0;
+ const { result } = renderHook(() => useResizablePane({ ...opts, onCollapse: () => { closed += 1; } }));
+ drag(result.current, { x: 1000, y: 0 }, { x: 1150, y: 0 });
+ expect(closed).toBe(0);
+ expect(result.current.size).toBe(260);
+ });
+});
diff --git a/dodaios/ui/web/frontend/src/hooks/useResizablePane.ts b/dodaios/ui/web/frontend/src/hooks/useResizablePane.ts
index 0383d7e102..f59219fb60 100644
--- a/dodaios/ui/web/frontend/src/hooks/useResizablePane.ts
+++ b/dodaios/ui/web/frontend/src/hooks/useResizablePane.ts
@@ -27,6 +27,14 @@ export interface ResizablePaneOptions {
axis?: ResizeAxis;
/** Edge the grip sits on — see `ResizeHandleEdge`. Defaults to ``end``. */
handle?: ResizeHandleEdge;
+ /**
+ * Drag-to-close. When set, a drag past `min` keeps following the pointer
+ * down to 0, and a release below this size calls `onCollapse` instead of
+ * settling: the stored size stays what it was before the drag, so the pane
+ * reopens at its old width.
+ */
+ collapseBelow?: number;
+ onCollapse?: () => void;
}
export interface ResizablePane {
@@ -81,11 +89,17 @@ export function useResizablePane({
max,
axis = "x",
handle = "end",
+ collapseBelow,
+ onCollapse,
}: ResizablePaneOptions): ResizablePane {
const [size, setSize] = useState<number>(() =>
clampSize(loadSize(storageKey, defaultSize), min, max),
);
const [isResizing, setIsResizing] = useState(false);
+ // Size under the pointer while a collapsible drag is below `min`.
+ const [overshoot, setOvershoot] = useState<number | null>(null);
+ const collapse = useRef({ below: collapseBelow, run: onCollapse });
+ collapse.current = { below: collapseBelow, run: onCollapse };
// Drag anchors — refs so the move handler never reads a stale closure.
const startPoint = useRef(0);
@@ -133,12 +147,16 @@ export function useResizablePane({
*/
let frame: number | undefined;
let point = startPoint.current;
+ let raw = startSize.current;
const apply = () => {
frame = undefined;
const travelled = point - startPoint.current;
const grown = handle === "end" ? travelled : -travelled;
- setSize(clampSize(startSize.current + grown, min, max));
+ raw = startSize.current + grown;
+ const below = collapse.current.below !== undefined && raw < min;
+ setOvershoot(below ? Math.max(0, Math.round(raw)) : null);
+ setSize(clampSize(raw, min, max));
};
const onMove = (e: PointerEvent) => {
@@ -155,6 +173,12 @@ export function useResizablePane({
cancelAnimationFrame(frame);
apply();
}
+ setOvershoot(null);
+ const { below, run } = collapse.current;
+ if (below !== undefined && raw < below) {
+ setSize(startSize.current);
+ run?.();
+ }
setIsResizing(false);
};
@@ -194,7 +218,7 @@ export function useResizablePane({
// 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 };
+ return { size: overshoot ?? visibleSize, isResizing, startResize, reset, nudge, resize };
}
function loadSize(key: string, fallback: number): number {