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(agentic-ide): panel toggles in the caption and a thread terminal drawer

rubenluetke10-beepaf5242f66240
diff --git a/docs/agentic-ide-threads.md b/docs/agentic-ide-threads.md
index 4308a6488a..66919b171b 100644
--- a/docs/agentic-ide-threads.md
+++ b/docs/agentic-ide-threads.md
@@ -49,8 +49,21 @@ for an approval and a blue dot for news since it was last opened.
- **Under the composer:** a strip that says where the agent works — the
current checkout or a fresh git worktree for a new thread — and on which
branch (the base of the worktree, or the branch to switch the checkout to).
-- Changes, files, git and terminals live in the IDE's side panel, as in the
- grid layout.
+- **Caption buttons:** at the right end of the window caption, beside the
+ window buttons. In threads there are two: the terminal drawer, then the side
+ panel. The grid has only the side panel button, since its panes are
+ terminals already. A shut side panel leaves no rail on the window edge. Its
+ button gets an amber dot while an agent of the active workspace waits for
+ the person.
+- **Terminal drawer:** plain shells under the conversation, in the open
+ thread's folder, one tab each. The first press starts the folder's first
+ shell, the next one hides the drawer without ending anything, and the top
+ edge drags to resize. Threads that share a folder share its shells, and they
+ keep running while the person moves between threads or back to the grid.
+ Closing a tab ends that shell, and the drawer goes down with the folder's
+ last one.
+- Changes, files, git and more terminals live in the IDE's side panel, as in
+ the grid layout.
## Questions, approvals and plans
@@ -120,6 +133,8 @@ attach to the host. Logs: `logs/turn_host.log` in the Jarvis data folder.
## Platforms
Nothing in the thread layout is OS-specific: paths are compared
-case-insensitively only for Windows drive paths and the git calls run the same
-`git` everywhere. The layout choice and the last agent pick are kept in the
-browser's storage and fall back to defaults when storage is blocked.
+case-insensitively only for Windows drive paths, the terminal drawer opens the
+platform's default shell, and the git calls run the same `git` everywhere. The
+layout choice, the last agent pick and the drawer's height are kept in the
+browser's storage and fall back to defaults when storage is blocked. Drawer
+shells are never kept: a reload does not restart them.
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.test.tsx
index 99f3c5fc69..873f5ceff4 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.test.tsx
@@ -7,6 +7,7 @@ import { useEventStore } from "@/store/events";
import { useIdeProjectsStore } from "@/store/ideProjects";
import { useIdeSidePanelStore } from "@/store/ideSidePanel";
import { resetWorkspacePanesPoll, useWorkspacePanesStore } from "@/store/workspacePanes";
+import type { WorkspacePaneRow } from "@/lib/agenticIdeApi";
vi.mock("@/components/workspace/WorkspaceTerminal", () => ({
WorkspaceTerminal: ({ paneKey, workspaceId, active }: { paneKey: string; workspaceId: string; active: boolean }) => (
@@ -68,7 +69,7 @@ describe("IdeSidePanel", () => {
fireEvent.click(screen.getByTestId("ide-side-panel-toggle"));
expect(screen.getByTestId(`shell-${first.id}`)).toBe(firstNode);
expect(firstNode.dataset.active).toBe("false");
- fireEvent.click(screen.getByTestId("ide-side-panel-rail-agents"));
+ fireEvent.click(screen.getByTestId("ide-side-panel-toggle"));
fireEvent.click(screen.getByTestId(`ide-side-panel-tab-${first.id}`));
expect(firstNode.dataset.active).toBe("true");
fireEvent.click(screen.getByTestId(`ide-side-panel-close-${second.id}`));
@@ -103,12 +104,13 @@ describe("IdeSidePanel", () => {
expect((screen.getByTestId("ide-side-panel-add-terminal") as HTMLButtonElement).disabled).toBe(true);
});
- it("opens from its rail and closes from its own header", () => {
+ it("opens and closes from the caption toggle alone", () => {
render(<Harness />);
expect(screen.queryByTestId("ide-side-panel")).toBeNull();
expect(screen.getByTestId("ide-side-panel-host").style.width).toBe("0px");
- fireEvent.click(screen.getByTestId("ide-side-panel-rail-agents"));
+ fireEvent.click(screen.getByTestId("ide-side-panel-toggle"));
+ expect(screen.getByTestId("ide-side-panel-toggle").getAttribute("aria-expanded")).toBe("true");
expect(screen.getByTestId("ide-side-panel")).toBeTruthy();
expect(screen.getByTestId("ide-side-panel-tab-agents").getAttribute("aria-selected")).toBe("true");
expect(screen.getByTestId("ide-workspace-agents")).toBeTruthy();
@@ -123,7 +125,7 @@ describe("IdeSidePanel", () => {
it("keeps the grid mounted while the panel opens and closes", () => {
render(<Harness />);
const grid = screen.getByTestId("grid");
- fireEvent.click(screen.getByTestId("ide-side-panel-rail-agents"));
+ fireEvent.click(screen.getByTestId("ide-side-panel-toggle"));
fireEvent.click(screen.getByTestId("ide-side-panel-toggle"));
expect(screen.getByTestId("grid")).toBe(grid);
});
@@ -133,7 +135,7 @@ describe("IdeSidePanel", () => {
render(<Harness />);
fireEvent.click(screen.getByTestId("ide-side-panel-close-agents"));
expect(screen.queryByTestId("ide-side-panel")).toBeNull();
- fireEvent.click(screen.getByTestId("ide-side-panel-rail-agents"));
+ fireEvent.click(screen.getByTestId("ide-side-panel-toggle"));
expect(screen.getByTestId("ide-side-panel-tab-agents")).toBeTruthy();
});
@@ -169,15 +171,33 @@ describe("IdeSidePanel", () => {
expect(screen.getByTestId("ide-side-panel-tab-agents")).toBeTruthy();
});
- it("leaves a labelled rail on the right edge while closed, and opens at the tab picked there", () => {
+ it("leaves nothing on the right edge while closed and reopens at the tab in front", () => {
+ useIdeSidePanelStore.setState({ tabs: ["agents", "files"], active: "files" });
render(<Harness />);
- const rail = screen.getByTestId("ide-side-panel-rail");
- expect(rail.textContent).toContain("Agents");
- expect(rail.textContent).toContain("Changes");
- expect(rail.textContent).toContain("Folder");
- fireEvent.click(screen.getByTestId("ide-side-panel-rail-files"));
- expect(useIdeSidePanelStore.getState()).toMatchObject({ open: true, active: "files" });
expect(screen.queryByTestId("ide-side-panel-rail")).toBeNull();
+ expect(screen.queryByRole("navigation")).toBeNull();
+ fireEvent.click(screen.getByTestId("ide-side-panel-toggle"));
+ expect(useIdeSidePanelStore.getState()).toMatchObject({ open: true, active: "files" });
+ });
+
+ it("puts a dot on the shut panel's toggle while an agent of the workspace waits", () => {
+ const row = (name: string, workspaceId: string, activity: WorkspacePaneRow["activity"]) => ({
+ workspace_id: workspaceId, workspace_name: workspaceId, folder: "/code/app", workspace_active: workspaceId === "w1",
+ key: name, history_id: `${name}@${workspaceId}`, name, agent: "claude", display_name: "Claude Code",
+ accepts_prompts: true, status: "live", exit_code: null, activity, activity_since: 0, worked: true,
+ started_at: 1, last_output_at: 2, last_prompt: "", last_prompt_at: null, recap: "", has_resume: false,
+ readable: true, account: null, account_label: null, archived: false,
+ }) as WorkspacePaneRow;
+ useIdeProjectsStore.setState({ activeWorkspaceId: "w1" });
+ useWorkspacePanesStore.setState({ panes: [row("T1", "w1", "working"), row("T1", "w2", "asking")] });
+ render(<Harness />);
+ expect(screen.queryByTestId("ide-side-panel-waiting")).toBeNull();
+ act(() => useWorkspacePanesStore.setState({ panes: [row("T1", "w1", "asking"), row("T2", "w1", "asking")] }));
+ expect(screen.getByTestId("ide-side-panel-waiting")).toBeTruthy();
+ expect(screen.getByTestId("ide-side-panel-toggle").getAttribute("aria-label")).toBe("Open side panel (2 waiting for you)");
+ // The open panel lists the agents itself.
+ fireEvent.click(screen.getByTestId("ide-side-panel-toggle"));
+ expect(screen.queryByTestId("ide-side-panel-waiting")).toBeNull();
});
it("adds the Jarvis Verse tab from + and shows the coding floor in a compact stage", async () => {
@@ -243,12 +263,6 @@ describe("IdeSidePanel", () => {
expect(useIdeSidePanelStore.getState().maximized).toBe(false);
});
- it("lists Office on the closed panel's rail", () => {
- render(<Harness />);
- fireEvent.click(screen.getByTestId("ide-side-panel-rail-office"));
- expect(useIdeSidePanelStore.getState()).toMatchObject({ open: true, active: "office" });
- });
-
it("frames the panel in blue while the reader works in it", () => {
useIdeSidePanelStore.setState({ open: true });
const { rerender } = render(<IdeSidePanelFrame markInUse><div data-testid="grid">grid</div></IdeSidePanelFrame>);
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.tsx
index be24cc587b..f6d49b9096 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.tsx
@@ -1,6 +1,6 @@
import { useEffect, useRef, useState, type ReactNode } from "react";
import { Check, Maximize2, Minimize2, MoveHorizontal, Plus, SquareTerminal, X } from "lucide-react";
-import { fill, useT } from "@/i18n";
+import { useT } from "@/i18n";
import { cn } from "@/lib/utils";
import { useResizablePane } from "@/hooks/useResizablePane";
import { PaneResizer } from "@/components/layout/PaneResizer";
@@ -10,9 +10,6 @@ import { WorkspaceTerminal } from "@/components/workspace/WorkspaceTerminal";
import type { TerminalAppearance } from "../terminalThemes";
import { useExplorerPathRouting } from "@/store/ideExplorer";
import { usePaneReviewTracking } from "@/store/paneReviews";
-import { useIdeProjectsStore } from "@/store/ideProjects";
-import { useWorkspacePanes } from "@/store/workspacePanes";
-import { dotKindFor, workspaceAgents } from "./agentStatus";
import { SIDE_PANEL_TABS, sidePanelTab } from "./sidePanelTabs";
import { SIDE_PANEL_ID } from "./sidePanelIds";
@@ -161,63 +158,14 @@ export function IdeSidePanelFrame({ children, markInUse = false, appearance, onS
</>
)}
</div>
- {!open && <IdeSidePanelRail />}
</div>
);
}
-/**
- * The closed panel's edge: one labelled button per tab, always in view.
- *
- * The caption toggle alone was easy to miss (maintainer, 2026-09-28), so a
- * closed panel leaves this narrow rail on the right edge — the way an editor's
- * activity bar does — and an agent waiting for the user shows up here as a
- * count even while the panel is shut.
- */
-function IdeSidePanelRail() {
- const t = useT();
- const openTab = useIdeSidePanelStore((state) => state.openTab);
- const activeWorkspaceId = useIdeProjectsStore((state) => state.activeWorkspaceId);
- const panes = useWorkspacePanes();
- const waiting = workspaceAgents(panes, activeWorkspaceId).filter((pane) => dotKindFor(pane) === "waiting").length;
- return (
- <nav
- data-testid="ide-side-panel-rail"
- aria-label={t("ide_side_panel.rail_aria")}
- className="flex h-full w-12 shrink-0 flex-col items-center gap-1.5 border-l border-border/60 bg-card/40 py-2"
- >
- {SIDE_PANEL_TABS.map((tab) => {
- const label = t(tab.labelKey);
- const badge = tab.id === "agents" && waiting > 0 ? waiting : 0;
- return (
- <button
- key={tab.id}
- type="button"
- data-testid={`ide-side-panel-rail-${tab.id}`}
- onClick={() => openTab(tab.id)}
- title={label}
- aria-label={badge ? `${label} (${fill(t("ide_side_panel.rail_waiting"), { n: badge })})` : label}
- aria-controls={SIDE_PANEL_ID}
- aria-expanded={false}
- className="relative flex w-10 flex-col items-center gap-0.5 rounded-lg py-1.5 text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
- >
- <tab.icon className="h-[18px] w-[18px]" aria-hidden />
- <span className="max-w-full truncate text-[9.5px] font-medium leading-none">{label}</span>
- {badge > 0 && (
- <span className="absolute right-0.5 top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-warning px-1 text-[10px] font-semibold tabular-nums text-background">
- {badge}
- </span>
- )}
- </button>
- );
- })}
- </nav>
- );
-}
-
/**
* The panel itself: tab header ("+" and maximize) over the active tab's content.
- * It opens and closes from the window caption (`IdeSidePanelToggle`).
+ * It opens and closes from the window caption (`IdeSidePanelToggle`) only;
+ * a shut panel leaves no rail behind, so the grid or thread gets the full width.
*/
export function IdeSidePanel({ appearance, onScreen = true }: { appearance?: TerminalAppearance; onScreen?: boolean }) {
const t = useT();
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanelToggle.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanelToggle.tsx
index 3d8d10f21f..d06cf4f9a7 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanelToggle.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanelToggle.tsx
@@ -1,23 +1,32 @@
-import { PanelRightClose, PanelRightOpen } from "lucide-react";
-import { useT } from "@/i18n";
+import { PanelRight } from "lucide-react";
+import { fill, useT } from "@/i18n";
import { cn } from "@/lib/utils";
+import { useIdeProjectsStore } from "@/store/ideProjects";
import { useIdeSidePanelStore } from "@/store/ideSidePanel";
+import { useWorkspacePanes } from "@/store/workspacePanes";
+import { dotKindFor, workspaceAgents } from "./agentStatus";
import { SIDE_PANEL_ID } from "./sidePanelIds";
/**
* Opens and shuts the Agentic IDE's right-hand side panel.
*
* It lives at the right end of the window caption, beside the window buttons,
- * so it stays in the same place whether the panel is open or shut; the closed
- * panel's rail is the second way in. Kept free of the panel's own module: the
- * caption is in the startup chunk and must not pull the panel's tabs into it.
+ * so it stays in the same place whether the panel is open or shut, in the grid
+ * and in threads alike. The panel has no other way in while it is shut, so an
+ * agent of the active workspace waiting for the user puts an amber dot on this
+ * button. Kept free of the panel's own module: the caption is in the startup
+ * chunk and must not pull the panel's tabs into it.
*/
export function IdeSidePanelToggle({ className }: { className?: string }) {
const t = useT();
const open = useIdeSidePanelStore((state) => state.open);
const setOpen = useIdeSidePanelStore((state) => state.setOpen);
- const label = t(open ? "ide_side_panel.collapse" : "ide_side_panel.expand");
- const Icon = open ? PanelRightClose : PanelRightOpen;
+ const activeWorkspaceId = useIdeProjectsStore((state) => state.activeWorkspaceId);
+ // An open panel shows its agents itself; only a shut one needs the count.
+ const panes = useWorkspacePanes(!open);
+ const waiting = open ? 0 : workspaceAgents(panes, activeWorkspaceId).filter((pane) => dotKindFor(pane) === "waiting").length;
+ const action = t(open ? "ide_side_panel.collapse" : "ide_side_panel.expand");
+ const label = waiting > 0 ? `${action} (${fill(t("ide_side_panel.rail_waiting"), { n: waiting })})` : action;
return (
<button
type="button"
@@ -28,14 +37,18 @@ export function IdeSidePanelToggle({ className }: { className?: string }) {
aria-controls={SIDE_PANEL_ID}
data-testid="ide-side-panel-toggle"
className={cn(
- "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md",
+ "relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md",
"text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground",
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
- open && "text-foreground",
+ open && "bg-secondary text-foreground",
className,
)}
>
- <Icon aria-hidden className="h-4 w-4" />
+ <PanelRight aria-hidden className="h-4 w-4" />
+ {waiting > 0 && (
+ <span aria-hidden data-testid="ide-side-panel-waiting"
+ className="absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-warning ring-2 ring-background" />
+ )}
</button>
);
}
diff --git a/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTerminalDrawer.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTerminalDrawer.test.tsx
new file mode 100644
index 0000000000..4f5c20d24e
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTerminalDrawer.test.tsx
@@ -0,0 +1,131 @@
+import { act, cleanup, fireEvent, render, screen } from "@testing-library/react";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { DEFAULT_DRAWER_HEIGHT, MAX_FOLDER_SHELLS, useThreadTerminalsStore } from "@/store/threadTerminals";
+import { ThreadTerminalDrawer } from "./ThreadTerminalDrawer";
+import { ThreadTerminalToggle } from "./ThreadTerminalToggle";
+
+vi.mock("@/components/workspace/WorkspaceTerminal", () => ({
+ WorkspaceTerminal: ({ paneKey, folder, active, title }: { paneKey: string; folder: string; active: boolean; title: string }) => (
+ <div data-testid={`shell-${paneKey}`} data-folder={folder} data-active={String(active)}>{title}</div>
+ ),
+}));
+
+function Harness({ onScreen = true }: { onScreen?: boolean }) {
+ return (
+ <>
+ <ThreadTerminalToggle />
+ <ThreadTerminalDrawer onScreen={onScreen} />
+ </>
+ );
+}
+
+const toggle = () => screen.getByTestId("thread-terminal-toggle") as HTMLButtonElement;
+const shells = () => useThreadTerminalsStore.getState().shells;
+
+beforeEach(() => {
+ localStorage.clear();
+ useThreadTerminalsStore.setState({ folder: "/code/app", open: false, shells: [], active: {}, height: DEFAULT_DRAWER_HEIGHT });
+});
+
+afterEach(cleanup);
+
+describe("ThreadTerminalDrawer", () => {
+ it("starts the folder's first shell on the first press and hides it on the next", () => {
+ render(<Harness />);
+ expect(screen.queryByTestId("thread-terminal-drawer")).toBeNull();
+ expect(toggle().getAttribute("aria-pressed")).toBe("false");
+
+ fireEvent.click(toggle());
+ expect(shells()).toHaveLength(1);
+ const [first] = shells();
+ const node = screen.getByTestId(`shell-${first.id}`);
+ expect(node.dataset.folder).toBe("/code/app");
+ expect(node.dataset.active).toBe("true");
+ expect(screen.getByTestId("thread-terminal-drawer").className).toContain("flex");
+ expect(toggle().getAttribute("aria-pressed")).toBe("true");
+ expect(toggle().getAttribute("aria-label")).toBe("Hide terminal");
+
+ // Hidden, not ended: the same shell comes back on the next press.
+ fireEvent.click(toggle());
+ expect(screen.getByTestId("thread-terminal-drawer").className).toContain("hidden");
+ expect(screen.getByTestId(`shell-${first.id}`)).toBe(node);
+ expect(node.dataset.active).toBe("false");
+ fireEvent.click(toggle());
+ expect(shells()).toHaveLength(1);
+ expect(screen.getByTestId(`shell-${first.id}`)).toBe(node);
+ expect(node.dataset.active).toBe("true");
+ });
+
+ it("is unavailable without a project folder", () => {
+ useThreadTerminalsStore.setState({ folder: "" });
+ render(<Harness />);
+ expect(toggle().disabled).toBe(true);
+ fireEvent.click(toggle());
+ expect(shells()).toHaveLength(0);
+ });
+
+ it("adds shells as tabs and goes down with the folder's last one", () => {
+ render(<Harness />);
+ fireEvent.click(toggle());
+ fireEvent.click(screen.getByTestId("thread-terminal-new"));
+ expect(screen.getByRole("tab", { name: /Terminal 1/ })).toBeTruthy();
+ expect(screen.getByRole("tab", { name: /Terminal 2/ }).getAttribute("aria-selected")).toBe("true");
+
+ fireEvent.click(screen.getByTestId("thread-terminal-close-2"));
+ expect(shells()).toHaveLength(1);
+ expect(screen.getByRole("tab", { name: /Terminal 1/ }).getAttribute("aria-selected")).toBe("true");
+ fireEvent.click(screen.getByTestId("thread-terminal-close-1"));
+ expect(shells()).toHaveLength(0);
+ expect(useThreadTerminalsStore.getState().open).toBe(false);
+ expect(screen.queryByTestId("thread-terminal-drawer")).toBeNull();
+ });
+
+ it("keeps another folder's shells running but shows only the open thread's", () => {
+ render(<Harness />);
+ fireEvent.click(toggle());
+ const [app] = shells();
+ const appNode = screen.getByTestId(`shell-${app.id}`);
+
+ act(() => useThreadTerminalsStore.getState().setFolder("/code/worktree"));
+ // The new folder has no shell yet: the drawer stays down until asked.
+ expect(screen.getByTestId("thread-terminal-drawer").className).toContain("hidden");
+ expect(toggle().getAttribute("aria-pressed")).toBe("false");
+ expect(appNode.dataset.active).toBe("false");
+ fireEvent.click(toggle());
+ expect(shells().map((shell) => shell.folder)).toEqual(["/code/app", "/code/worktree"]);
+ expect(screen.getAllByRole("tab")).toHaveLength(1);
+
+ act(() => useThreadTerminalsStore.getState().setFolder("/code/app"));
+ expect(screen.getByTestId(`shell-${app.id}`)).toBe(appNode);
+ expect(appNode.dataset.active).toBe("true");
+ });
+
+ it("lets no shell take focus while the drawer is off screen", () => {
+ render(<Harness onScreen={false} />);
+ fireEvent.click(toggle());
+ expect(screen.getByTestId(`shell-${shells()[0].id}`).dataset.active).toBe("false");
+ });
+
+ it("caps the shells of one folder", () => {
+ render(<Harness />);
+ fireEvent.click(toggle());
+ for (let index = 1; index < MAX_FOLDER_SHELLS; index += 1) fireEvent.click(screen.getByTestId("thread-terminal-new"));
+ expect(shells()).toHaveLength(MAX_FOLDER_SHELLS);
+ expect((screen.getByTestId("thread-terminal-new") as HTMLButtonElement).disabled).toBe(true);
+ });
+
+ it("resizes from its top edge and keeps the height, but no shell, for the next session", () => {
+ render(<Harness />);
+ fireEvent.click(toggle());
+ const edge = screen.getByRole("separator", { name: "Resize the terminal" });
+ edge.setPointerCapture = () => {};
+ // jsdom has no PointerEvent; a MouseEvent of the pointer type carries the position.
+ const pointer = (type: string, clientY: number) => fireEvent(edge, new MouseEvent(type, { bubbles: true, button: 0, clientY }));
+ pointer("pointerdown", 600);
+ pointer("pointermove", 500);
+ pointer("pointerup", 500);
+ expect(useThreadTerminalsStore.getState().height).toBe(DEFAULT_DRAWER_HEIGHT + 100);
+ expect(localStorage.getItem("jarvis.ide.threadDrawerHeight.v1")).toBe(String(DEFAULT_DRAWER_HEIGHT + 100));
+ expect(JSON.stringify(localStorage)).not.toContain("thread-shell-");
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTerminalDrawer.tsx b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTerminalDrawer.tsx
new file mode 100644
index 0000000000..04f1b52833
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTerminalDrawer.tsx
@@ -0,0 +1,79 @@
+import { useCallback, useRef, type PointerEvent as ReactPointerEvent } from "react";
+import { Plus, SquareTerminal, X } from "lucide-react";
+import { WorkspaceTerminal } from "@/components/workspace/WorkspaceTerminal";
+import { cn } from "@/lib/utils";
+import { MAX_FOLDER_SHELLS, MIN_DRAWER_HEIGHT, drawerShown, shellsIn, useThreadTerminalsStore } from "@/store/threadTerminals";
+
+/**
+ * The thread layout's terminal drawer: plain shells in the open thread's
+ * folder under the conversation, one tab each. The window caption's terminal
+ * toggle pulls it up and down; the top edge drags to resize.
+ *
+ * Every shell stays mounted while the person moves between threads and back to
+ * the grid — a dev server keeps running — but only the open thread's folder
+ * has its tabs shown. Closing a tab ends that shell.
+ */
+export function ThreadTerminalDrawer({ onScreen }: { onScreen: boolean }) {
+ const shells = useThreadTerminalsStore((state) => state.shells);
+ const folder = useThreadTerminalsStore((state) => state.folder);
+ const activeByFolder = useThreadTerminalsStore((state) => state.active);
+ const height = useThreadTerminalsStore((state) => state.height);
+ const shown = useThreadTerminalsStore(drawerShown);
+ const addShell = useThreadTerminalsStore((state) => state.addShell);
+ const closeShell = useThreadTerminalsStore((state) => state.closeShell);
+ const select = useThreadTerminalsStore((state) => state.select);
+ const setHeight = useThreadTerminalsStore((state) => state.setHeight);
+ const drag = useRef<{ startY: number; startHeight: number } | null>(null);
+
+ const onPointerDown = useCallback((event: ReactPointerEvent<HTMLDivElement>) => {
+ if (event.button !== 0) return;
+ event.preventDefault();
+ drag.current = { startY: event.clientY, startHeight: height };
+ event.currentTarget.setPointerCapture(event.pointerId);
+ }, [height]);
+ const onPointerMove = useCallback((event: ReactPointerEvent<HTMLDivElement>) => {
+ if (!drag.current) return;
+ const next = drag.current.startHeight + (drag.current.startY - event.clientY);
+ setHeight(Math.max(MIN_DRAWER_HEIGHT, Math.min(next, Math.round(window.innerHeight * 0.75))));
+ }, [setHeight]);
+ const onPointerUp = useCallback(() => { drag.current = null; }, []);
+
+ if (shells.length === 0) return null;
+ const here = shellsIn(shells, folder);
+ const current = here.some((shell) => shell.id === activeByFolder[folder]) ? activeByFolder[folder] : here[here.length - 1]?.id ?? "";
+ // Never taller than most of the window, even when it shrank since the drag.
+ const drawerHeight = `min(${height}px, 75vh)`;
+
+ return <section aria-label="Terminal" data-testid="thread-terminal-drawer" style={{ height: drawerHeight }}
+ className={cn("relative shrink-0 flex-col border-t border-border bg-background", shown ? "flex" : "hidden")}>
+ <div role="separator" aria-orientation="horizontal" aria-label="Resize the terminal"
+ onPointerDown={onPointerDown} onPointerMove={onPointerMove} onPointerUp={onPointerUp} onPointerCancel={onPointerUp}
+ className="absolute inset-x-0 -top-1 z-10 h-2 cursor-row-resize" />
+ <div className="flex h-9 shrink-0 items-center gap-1 border-b border-border px-2">
+ <div role="tablist" aria-label="Terminals" className="flex min-w-0 flex-1 items-center gap-1 overflow-x-auto" style={{ scrollbarWidth: "none" }}>
+ {here.map((shell) => {
+ const title = `Terminal ${shell.number}`;
+ return <div key={shell.id} role="tab" aria-selected={shell.id === current}
+ className={cn("group/tab flex h-7 shrink-0 items-center gap-1.5 rounded-md pl-2 pr-1 text-xs transition-colors",
+ shell.id === current ? "bg-secondary text-foreground" : "text-muted-foreground hover:bg-secondary/60 hover:text-foreground")}>
+ <button type="button" onClick={() => select(shell.id)} className="flex items-center gap-1.5 focus-visible:outline-none">
+ <SquareTerminal aria-hidden className="h-3.5 w-3.5" /><span className="max-w-[160px] truncate">{title}</span>
+ </button>
+ <button type="button" aria-label={`Close ${title}`} title="Close terminal" onClick={() => closeShell(shell.id)}
+ data-testid={`thread-terminal-close-${shell.number}`}
+ className="rounded p-0.5 opacity-60 hover:bg-background hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"><X className="h-3 w-3" /></button>
+ </div>;
+ })}
+ <button type="button" aria-label="New terminal" title="New terminal" onClick={addShell}
+ disabled={here.length >= MAX_FOLDER_SHELLS} data-testid="thread-terminal-new"
+ className="flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default disabled:opacity-40 disabled:hover:bg-transparent"><Plus className="h-3.5 w-3.5" /></button>
+ </div>
+ </div>
+ <div className="relative min-h-0 flex-1">
+ {shells.map((shell) => <div key={shell.id} hidden={!shown || shell.id !== current} className="absolute inset-0 p-1">
+ <WorkspaceTerminal paneKey={shell.id} agentName="shell" folder={shell.folder}
+ title={`Terminal ${shell.number}`} bare active={onScreen && shown && shell.id === current} />
+ </div>)}
+ </div>
+ </section>;
+}
diff --git a/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTerminalToggle.tsx b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTerminalToggle.tsx
new file mode 100644
index 0000000000..b33ee66679
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadTerminalToggle.tsx
@@ -0,0 +1,40 @@
+import { PanelBottom } from "lucide-react";
+import { cn } from "@/lib/utils";
+import { drawerShown, useThreadTerminalsStore } from "@/store/threadTerminals";
+
+/**
+ * Pulls the thread layout's terminal drawer up and down.
+ *
+ * It sits at the right end of the window caption, before the side panel
+ * toggle, and only while the IDE shows threads: the terminal grid is all
+ * terminals already. The first press in a folder starts its first shell.
+ * Kept free of the drawer's own module: the caption is in the startup chunk
+ * and must not pull xterm into it.
+ */
+export function ThreadTerminalToggle({ className }: { className?: string }) {
+ const shown = useThreadTerminalsStore(drawerShown);
+ const available = useThreadTerminalsStore((state) => Boolean(state.folder));
+ const toggle = useThreadTerminalsStore((state) => state.toggle);
+ const label = !available ? "Terminal needs a project folder" : shown ? "Hide terminal" : "Show terminal";
+ return (
+ <button
+ type="button"
+ onClick={toggle}
+ disabled={!available}
+ title={label}
+ aria-label={label}
+ aria-pressed={shown}
+ data-testid="thread-terminal-toggle"
+ className={cn(
+ "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md",
+ "text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground",
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
+ "disabled:cursor-default disabled:opacity-40 disabled:hover:bg-transparent",
+ shown && "bg-secondary text-foreground",
+ className,
+ )}
+ >
+ <PanelBottom aria-hidden className="h-4 w-4" />
+ </button>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadView.tsx b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadView.tsx
index e0db61dff8..6a8cb54136 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadView.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadView.tsx
@@ -4,6 +4,7 @@ import { prepareGit } from "@/lib/gitApi";
import { useEventStore } from "@/store/events";
import { useIdeProjectsStore } from "@/store/ideProjects";
import { useIdeThreadsStore } from "@/store/ideThreads";
+import { useThreadTerminalsStore } from "@/store/threadTerminals";
import { ThreadBranchBar, type ThreadCheckout } from "./ThreadBranchBar";
import { ThreadComposer } from "./ThreadComposer";
import { ThreadMenuItem, ThreadPopover } from "./ThreadPopover";
@@ -60,6 +61,9 @@ export function ThreadView({ onScreen }: { onScreen: boolean }) {
const folder = session?.cwd || project?.path || "";
const isDraft = selection.sessionId === null;
+ // The terminal drawer and its caption toggle open shells in this folder.
+ useEffect(() => { useThreadTerminalsStore.getState().setFolder(folder); }, [folder]);
+
// Keep the store on what the sidebar picked. A draft's first message
// creates its session: that is this project's thread now — unless the
// person moved on while it was being created; then it only remembers where
diff --git a/jarvis/ui/web/frontend/src/components/layout/TopBar.test.tsx b/jarvis/ui/web/frontend/src/components/layout/TopBar.test.tsx
index 9e6d6bf025..1c0398cb9c 100644
--- a/jarvis/ui/web/frontend/src/components/layout/TopBar.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/layout/TopBar.test.tsx
@@ -4,6 +4,9 @@ import { TopBar } from "./TopBar";
import { useEventStore } from "@/store/events";
import { resetSectionHistory } from "@/hooks/useSectionHistory";
import { useIdeSidePanelStore } from "@/store/ideSidePanel";
+import { useIdeThreadsStore } from "@/store/ideThreads";
+import { useThreadTerminalsStore } from "@/store/threadTerminals";
+import { useWorkspacePanesStore } from "@/store/workspacePanes";
vi.mock("@/hooks/useUpdate", () => ({
useUpdate: () => ({ status: { managed: false, update_available: false } }),
@@ -20,6 +23,8 @@ beforeEach(() => {
solo: false,
detachedViews: [],
});
+ // The shut side panel's toggle counts waiting agents; no poll leaves the test.
+ useWorkspacePanesStore.setState({ panes: [], load: async () => {} });
});
afterEach(() => vi.restoreAllMocks());
@@ -48,6 +53,41 @@ describe("TopBar side panel toggle", () => {
it("stays out of every other section", () => {
render(<TopBar />);
expect(screen.queryByTestId("ide-side-panel-toggle")).toBeNull();
+ expect(screen.queryByTestId("thread-terminal-toggle")).toBeNull();
+ });
+});
+
+describe("TopBar terminal drawer toggle", () => {
+ beforeEach(() => {
+ useEventStore.setState({ activeSection: "agentic-ide" });
+ useIdeSidePanelStore.setState({ open: false, maximized: false });
+ useThreadTerminalsStore.setState({ folder: "/code/app", open: false, shells: [], active: {} });
+ });
+ afterEach(() => useIdeThreadsStore.setState({ layout: "grid" }));
+
+ it("sits before the side panel toggle in the thread layout and starts a shell", () => {
+ useIdeThreadsStore.setState({ layout: "threads" });
+ render(<TopBar />);
+ const terminal = screen.getByTestId("thread-terminal-toggle");
+ const panel = screen.getByTestId("ide-side-panel-toggle");
+ expect(terminal.compareDocumentPosition(panel) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
+ fireEvent.click(terminal);
+ expect(useThreadTerminalsStore.getState()).toMatchObject({ open: true });
+ expect(useThreadTerminalsStore.getState().shells).toHaveLength(1);
+ });
+
+ it("is not offered in the terminal grid", () => {
+ useIdeThreadsStore.setState({ layout: "grid" });
+ render(<TopBar />);
+ expect(screen.queryByTestId("thread-terminal-toggle")).toBeNull();
+ expect(screen.getByTestId("ide-side-panel-toggle")).toBeTruthy();
+ });
+
+ it("steps aside while a maximized side panel covers the thread", () => {
+ useIdeThreadsStore.setState({ layout: "threads" });
+ useIdeSidePanelStore.setState({ open: true, maximized: true });
+ render(<TopBar />);
+ expect(screen.queryByTestId("thread-terminal-toggle")).toBeNull();
});
});
diff --git a/jarvis/ui/web/frontend/src/components/layout/TopBar.tsx b/jarvis/ui/web/frontend/src/components/layout/TopBar.tsx
index 4d692633a2..5d2157409a 100644
--- a/jarvis/ui/web/frontend/src/components/layout/TopBar.tsx
+++ b/jarvis/ui/web/frontend/src/components/layout/TopBar.tsx
@@ -15,6 +15,9 @@ import { SectionNavButtons } from "@/components/layout/SectionNavButtons";
import { IdeLayoutSwitch } from "@/components/agentic/threads/IdeLayoutSwitch";
import { IDE_SECTIONS } from "@/lib/ideSections";
import { IdeSidePanelToggle } from "@/components/agentic/sidePanel/IdeSidePanelToggle";
+import { ThreadTerminalToggle } from "@/components/agentic/threads/ThreadTerminalToggle";
+import { useIdeSidePanelStore } from "@/store/ideSidePanel";
+import { useIdeThreadsStore } from "@/store/ideThreads";
import { WikiInspectorToggle } from "@/components/wiki/WikiInspectorToggle";
import { useDesktopChrome, WindowControls } from "@/components/layout/WindowControls";
@@ -25,7 +28,8 @@ import { useDesktopChrome, WindowControls } from "@/components/layout/WindowCont
* empty middle to drag the window, and minimize, maximize and close at the
* right. Theme, restart and the sidebar toggles are not caption buttons; the
* theme lives in Settings. On the Agentic IDE the caption also carries the
- * side panel toggle, beside the window buttons.
+ * panel toggles beside the window buttons: the thread layout's terminal
+ * drawer, then the side panel.
*
* The update button below (rendered in the sidebar) restarts through
* ``/api/settings/restart-app``, which spawns a detached relauncher (see
@@ -130,10 +134,22 @@ function WikiCaptionPanelToggle() {
return onWiki ? <WikiInspectorToggle /> : null;
}
-/** The IDE side panel's open / close button, only on the IDE. */
+/**
+ * The IDE's panel toggles, only on the IDE: the terminal drawer in the thread
+ * layout (the grid is all terminals already, and a maximized side panel covers
+ * the thread), then the side panel in every layout.
+ */
function IdeCaptionPanelToggle() {
const onIde = useEventStore((s) => IDE_SECTIONS.includes(s.activeSection));
- return onIde ? <IdeSidePanelToggle /> : null;
+ const threads = useIdeThreadsStore((s) => s.layout === "threads");
+ const panelCovers = useIdeSidePanelStore((s) => s.open && s.maximized);
+ if (!onIde) return null;
+ return (
+ <div className="flex items-center gap-0.5">
+ {threads && !panelCovers && <ThreadTerminalToggle />}
+ <IdeSidePanelToggle />
+ </div>
+ );
}
// The restart can fail transiently right after an apply (the backend is busy,
diff --git a/jarvis/ui/web/frontend/src/store/threadTerminals.ts b/jarvis/ui/web/frontend/src/store/threadTerminals.ts
new file mode 100644
index 0000000000..340c75b5f9
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/store/threadTerminals.ts
@@ -0,0 +1,133 @@
+import { create } from "zustand";
+
+/**
+ * The thread layout's terminal drawer: plain shells under the conversation,
+ * in the open thread's folder.
+ *
+ * The caption's terminal toggle and the drawer itself both need the answer,
+ * and the caption cannot reach the thread view by props, so it lives here.
+ * Shells are kept per folder: threads that share a checkout share its shells,
+ * and a dev server keeps running while the person moves between threads.
+ *
+ * Shells belong to this window and are never persisted — a reload must not
+ * start replacements for commands that were running before it. Only the
+ * drawer's height survives, through localStorage, which may be blocked.
+ */
+
+export interface ThreadShell {
+ id: string;
+ folder: string;
+ /** Shown as "Terminal N"; counted per folder. */
+ number: number;
+}
+
+const HEIGHT_KEY = "jarvis.ide.threadDrawerHeight.v1";
+export const DEFAULT_DRAWER_HEIGHT = 280;
+export const MIN_DRAWER_HEIGHT = 140;
+/** Most shells one folder holds; a tab strip past this is unreadable. */
+export const MAX_FOLDER_SHELLS = 8;
+
+function storedHeight(): number {
+ try {
+ const value = Number(localStorage.getItem(HEIGHT_KEY));
+ return Number.isFinite(value) && value >= MIN_DRAWER_HEIGHT ? value : DEFAULT_DRAWER_HEIGHT;
+ } catch {
+ return DEFAULT_DRAWER_HEIGHT;
+ }
+}
+
+interface ThreadTerminalsState {
+ /** The open thread's folder, published by the thread view; "" without one. */
+ folder: string;
+ /** The drawer is pulled up. It only shows when the folder has a shell. */
+ open: boolean;
+ shells: ThreadShell[];
+ /** The shell in front, per folder. */
+ active: Record<string, string>;
+ height: number;
+ setFolder: (folder: string) => void;
+ /**
+ * The caption toggle: hide a shown drawer, or show it — starting the
+ * folder's first shell when it has none yet.
+ */
+ toggle: () => void;
+ /** Open one more shell in the current folder and bring it forward. */
+ addShell: () => void;
+ /** End a shell; the drawer goes down with the folder's last one. */
+ closeShell: (id: string) => void;
+ select: (id: string) => void;
+ setHeight: (height: number) => void;
+}
+
+/** The current folder's shells, in the order they were opened. */
+export const shellsIn = (shells: readonly ThreadShell[], folder: string): ThreadShell[] =>
+ folder ? shells.filter((shell) => shell.folder === folder) : [];
+
+/** Whether the drawer is on screen: pulled up, and the folder has a shell to show. */
+export const drawerShown = (state: Pick<ThreadTerminalsState, "open" | "shells" | "folder">): boolean =>
+ state.open && shellsIn(state.shells, state.folder).length > 0;
+
+export const useThreadTerminalsStore = create<ThreadTerminalsState>((set, get) => ({
+ folder: "",
+ open: false,
+ shells: [],
+ active: {},
+ height: storedHeight(),
+ setFolder: (folder) => {
+ if (get().folder !== folder) set({ folder });
+ },
+ toggle: () => {
+ const state = get();
+ if (drawerShown(state)) {
+ set({ open: false });
+ return;
+ }
+ if (!state.folder) return;
+ if (shellsIn(state.shells, state.folder).length === 0) get().addShell();
+ else set({ open: true });
+ },
+ addShell: () => {
+ const { folder, shells, active } = get();
+ if (!folder) return;
+ const here = shellsIn(shells, folder);
+ if (here.length >= MAX_FOLDER_SHELLS) {
+ set({ open: true });
+ return;
+ }
+ const id = `thread-shell-${crypto.randomUUID()}`;
+ const number = Math.max(0, ...here.map((shell) => shell.number)) + 1;
+ set({ open: true, shells: [...shells, { id, folder, number }], active: { ...active, [folder]: id } });
+ },
+ closeShell: (id) => {
+ const { shells, active, folder, open } = get();
+ const closing = shells.find((shell) => shell.id === id);
+ if (!closing) return;
+ const siblings = shellsIn(shells, closing.folder);
+ const rest = shells.filter((shell) => shell.id !== id);
+ const left = siblings.filter((shell) => shell.id !== id);
+ const nextActive = { ...active };
+ if (left.length === 0) delete nextActive[closing.folder];
+ else if (active[closing.folder] === id) {
+ const index = siblings.findIndex((shell) => shell.id === id);
+ nextActive[closing.folder] = left[Math.max(0, index - 1)].id;
+ }
+ set({
+ shells: rest,
+ active: nextActive,
+ open: open && !(closing.folder === folder && left.length === 0),
+ });
+ },
+ select: (id) => {
+ const shell = get().shells.find((entry) => entry.id === id);
+ if (shell) set({ active: { ...get().active, [shell.folder]: id } });
+ },
+ setHeight: (height) => {
+ const next = Math.max(MIN_DRAWER_HEIGHT, Math.round(height));
+ set({ height: next });
+ try {
+ localStorage.setItem(HEIGHT_KEY, String(next));
+ } catch {
+ /* a convenience only: the height just does not survive this session */
+ }
+ },
+}));
diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
index 6cd2e64625..bac55b0ee0 100644
--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
@@ -31,6 +31,7 @@ import { useIdeSidePanelStore } from "@/store/ideSidePanel";
import { useIdeSkillsStore } from "@/store/ideSkills";
import { useIdeThreadsStore } from "@/store/ideThreads";
import { ThreadView } from "@/components/agentic/threads/ThreadView";
+import { ThreadTerminalDrawer } from "@/components/agentic/threads/ThreadTerminalDrawer";
import { CodeEditorStage } from "@/components/agentic/editor/CodeEditorStage";
import { useCodeEditorStore } from "@/store/codeEditor";
import { openProject } from "@/lib/chatLibraryApi";
@@ -578,7 +579,12 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
<main className="min-h-0 flex-1">
<IdeSidePanelFrame markInUse={paneStyle === "minimal"} appearance={appearance ?? undefined} onScreen={onScreen}>
<div className="relative h-full min-h-0">
- {threads && <ThreadView onScreen={onScreen && !editorShown} />}
+ {/* The thread over its terminal drawer. The drawer stays mounted in the
+ grid too, so its shells keep running while the layout switches. */}
+ <div className={cn("h-full min-h-0 flex-col", threads ? "flex" : "hidden")}>
+ {threads && <div className="min-h-0 flex-1"><ThreadView onScreen={onScreen && !editorShown} /></div>}
+ <ThreadTerminalDrawer onScreen={onScreen && threads && !editorShown && !panelCoversGrid} />
+ </div>
{/* The grid stays mounted behind the threads: its terminals keep running
and come back exactly as they were when the layout switches back. */}
<div hidden={threads} className="h-full min-h-0">