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
feat(agentic-ide): the chat view IS the chat UI — one stage, the sessions in the sidebar
rubenluetke10-beep2dfdeeab3d5d
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsxindex b4356401f3..2a3de3ca89 100644--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.test.tsx@@ -1741,10 +1741,15 @@ describe("session recaps", () => {);});- it("asks the fast activity feed too, and wears its answer on the badge", async () => {+ it("asks the fast activity feed too, and wears its answer on the stage", async () => {// The badge has its own poll beside the recap one — one stamped word per// pane, quick enough that a pane that starts working is SEEN to start// working rather than reported a recap-interval later.+ //+ // The word is worn by the pane on the chat stage. It used to be worn by a+ // row in the grid's own chat rail; that rail is now the app sidebar's+ // session list, which draws its dots from the workspace feed rather than+ // from this poll — so the stage is where this poll's answer shows up.vi.mocked(api.fetchTerminalActivity).mockResolvedValue({workspace_id: "ide_test",terminals: [@@ -1764,10 +1769,10 @@ describe("session recaps", () => {await waitFor(() =>expect(api.fetchTerminalActivity).toHaveBeenCalledWith("ide_test"),);- await waitFor(() => {- const badges = screen.getAllByTestId("pane-activity");- expect(badges.some((badge) => badge.dataset.activity === "working")).toBe(true);- });+ fireEvent.click(screen.getByTestId("agentic-view-mode-toggle"));+ await waitFor(() =>+ expect(screen.getByTestId("pane-chat-Mika").dataset.activity).toBe("working"),+ );});});@@ -2376,11 +2381,13 @@ describe("renaming a pane", () => {describe("chat view", () => {/*- * The workspace read like a conversation: a rail of agents on the left, one- * pane on a centred stage, the prompt bar as the composer. What these tests- * pin is not the styling but the two contracts underneath it — switching- * modes must not remount a pane (a remount kills the coding agent), and- * every action the grid offers keeps working from the other mode.+ * The workspace read like a conversation: one pane on a centred stage, read+ * as a chat by default, its terminal one click away; the list of sessions+ * is the app sidebar's (WorkspaceChats), which asks for a pane through the+ * view's `jumpTo`. What these tests pin is not the styling but the two+ * contracts underneath it — switching modes must not remount a pane (a+ * remount kills the coding agent), and every action the grid offers keeps+ * working from the other mode.*/const FOUR = sessionWith([["Mika", 0],@@ -2400,39 +2407,16 @@ describe("chat view", () => {const toChat = () => fireEvent.click(screen.getByTestId("agentic-view-mode-toggle"));const toGrid = () => fireEvent.click(screen.getByTestId("agentic-view-mode-grid"));- const railOrder = () =>- screen- .getAllByTestId(/^chat-rail-item-/)- .map((item) => item.dataset.terminal);-- function placeRailItem(name: string, top: number) {- const item = screen.getByTestId(`chat-rail-item-${name}`);- item.getBoundingClientRect = () =>- ({- left: 0,- top,- width: 200,- height: 36,- right: 200,- bottom: top + 36,- x: 0,- y: top,- toJSON: () => ({}),- }) as DOMRect;- }-- it("starts in the grid, with the rail hidden", () => {+ it("starts in the grid, every pane on screen", () => {renderGrid(FOUR);- expect(screen.getByTestId("agentic-chat-rail").className).toContain("hidden");for (const name of ["Mika", "Nova", "Aria", "Kai"]) {expect(cellClass(name)).not.toContain("hidden");}});- it("shows one pane on the stage and the rest in the rail", () => {+ it("shows one pane on the stage and hides the rest, alive", () => {renderGrid(FOUR);toChat();- expect(screen.getByTestId("agentic-chat-rail").className).not.toContain("hidden");// Mika is the prompt target, so it takes the stage — read as a chat by// default, its terminal cell hidden like the others' and one click away.expect(screen.getByTestId("pane-chat-Mika")).toBeTruthy();@@ -2444,61 +2428,9 @@ describe("chat view", () => {expect(cellClass(name)).toContain("hidden");// Hidden, never unmounted — the agent behind the pane lives on.expect(screen.getByTestId(`pane-${name}`)).toBeTruthy();- expect(screen.getByTestId(`chat-rail-${name}`)).toBeTruthy();}});- it("uses the live task recap as the rail title, behind the agent's mark", async () => {- const mixed = sessionWith([- ["Mika", 0],- ["Nova", 1],- ]);- mixed.terminals[1] = {- ...mixed.terminals[1],- agent: "codex",- display_name: "Codex",- };- vi.mocked(api.fetchTerminalRecaps).mockResolvedValue({- workspace_id: "ide_test",- terminals: [- {- key: "nova",- name: "Nova",- status: "live",- recap: "Fix provider selection priority",- recap_detail: "Correct the fallback order used by the provider picker.",- },- ],- });-- renderGrid(mixed);- toChat();-- const title = await screen.findByTestId("chat-rail-title-Nova");- expect(title.textContent).toBe("Fix provider selection priority");- // The mark LEADS the row and the title follows it, the way a list of- // conversations reads: the title is the subject, the mark says which CLI- // is having it. The title sits inside its tooltip anchor, so the mark is- // the ANCHOR's previous sibling.- const mark = title.parentElement?.previousElementSibling;- expect(mark?.getAttribute("data-testid")).toBe("agent-mark-codex");- // `data-logo` rather than the <img>: a single-colour mark is drawn as a- // CSS mask so it follows the theme's ink, and jsdom does not model masks.- expect(mark?.getAttribute("data-logo")).toBe("/provider-logos/openai.svg");- });-- it("uses the last prompt as the title while a recap is not available", () => {- const session = sessionWith([["Mika", 0]]);- session.terminals[0].last_prompt = "Analyze transcription omissions";-- renderGrid(session);- toChat();-- expect(screen.getByTestId("chat-rail-title-Mika").textContent).toBe(- "Analyze transcription omissions",- );- });-it("keeps the very same pane elements across every mode and back", () => {// The iron rule of this component, and the one a new reading mode is most// likely to break: element identity is the mounting guarantee. A remounted@@ -2512,22 +2444,21 @@ describe("chat view", () => {toGrid();expect(screen.getByTestId("pane-Nova")).toBe(before);- expect(screen.getByTestId("agentic-chat-rail").className).toContain("hidden");expect(cellClass("Kai")).not.toContain("hidden");});- it("a rail click puts that pane on the stage", () => {- renderGrid(FOUR);+ it("a pane asked for from the sidebar takes the stage", () => {+ const { rerender } = renderGrid(FOUR);toChat();- fireEvent.click(screen.getByTestId("chat-rail-Aria"));+ rerender({ jumpTo: { pane: "Aria", nonce: 1 } });expect(screen.getByTestId("pane-chat-Aria")).toBeTruthy();expect(screen.queryByTestId("pane-chat-Mika")).toBeNull();// The reading sticks: once the terminal is what is on stage, the next- // rail click shows the next pane's terminal, not its chat.+ // pane asked for shows its terminal, not its chat.fireEvent.click(screen.getByTestId("pane-chat-show-terminal"));expect(cellClass("Aria")).not.toContain("hidden");expect(cellClass("Mika")).toContain("hidden");- fireEvent.click(screen.getByTestId("chat-rail-Mika"));+ rerender({ jumpTo: { pane: "Mika", nonce: 2 } });expect(screen.queryByTestId("pane-chat-Mika")).toBeNull();expect(cellClass("Mika")).not.toContain("hidden");expect(cellClass("Aria")).toContain("hidden");@@ -2559,65 +2490,8 @@ describe("chat view", () => {);});- it("swaps two rail positions by dragging without moving or remounting the panes", async () => {- renderGrid(FOUR);- const paneBefore = screen.getByTestId("pane-Mika");- toChat();- placeRailItem("Mika", 0);- placeRailItem("Nova", 36);- placeRailItem("Aria", 72);- placeRailItem("Kai", 108);-- fireEvent(- screen.getByTestId("chat-rail-Mika"),- new MouseEvent("pointerdown", {- bubbles: true,- clientX: 40,- clientY: 18,- button: 0,- }),- );- act(() => {- window.dispatchEvent(- new MouseEvent("pointermove", { clientX: 40, clientY: 90 }),- );- });-- expect(screen.getByTestId("chat-rail-arrange-ghost").textContent).toContain(- "Mika",- );- expect(screen.getByTestId("chat-rail-item-Aria").className).toContain(- "ring-primary/70",- );-- await act(async () => {- window.dispatchEvent(new MouseEvent("pointerup"));- });-- expect(railOrder()).toEqual(["Aria", "Nova", "Mika", "Kai"]);- expect(api.moveTerminal).not.toHaveBeenCalled();- expect(screen.getByTestId("pane-Mika")).toBe(paneBefore);- // Chromium follows a drag release with a compatibility click on the row- // below it. That click belongs to the drag and must not switch the stage.- fireEvent.click(screen.getByTestId("chat-rail-Aria"));- expect(screen.getByTestId("pane-chat-Mika")).toBeTruthy();- expect(screen.queryByTestId("pane-chat-Aria")).toBeNull();- await waitFor(() =>- expect(- JSON.parse(- window.localStorage.getItem("jarvis.agenticIde.chatOrder.v1.ide_test") ??- "[]",- ),- ).toEqual(["aria@0", "nova@0", "mika@0", "kai@0"]),- );-- cleanup();- renderGrid(FOUR);- expect(railOrder()).toEqual(["Aria", "Nova", "Mika", "Kai"]);- });-it("grounds deictic voice references in the pane visibly on stage", async () => {- renderGrid(FOUR);+ const { rerender } = renderGrid(FOUR);await waitFor(() =>expect(api.syncAgenticIdeSurface).toHaveBeenLastCalledWith({workspaceId: "ide_test",@@ -2629,7 +2503,7 @@ describe("chat view", () => {);toChat();- fireEvent.click(screen.getByTestId("chat-rail-Aria"));+ rerender({ jumpTo: { pane: "Aria", nonce: 1 } });await waitFor(() =>expect(api.syncAgenticIdeSurface).toHaveBeenLastCalledWith({@@ -2697,30 +2571,17 @@ describe("chat view", () => {toChat();cleanup();renderGrid(FOUR);- expect(screen.getByTestId("agentic-chat-rail").className).not.toContain("hidden");+ expect(screen.getByTestId("pane-chat-Mika")).toBeTruthy();});it("maximize on the stage hands over to the grid, maximized", () => {renderGrid(FOUR);toChat();fireEvent.click(screen.getByTestId("pane-maximize-Mika"));- expect(screen.getByTestId("agentic-chat-rail").className).toContain("hidden");+ expect(screen.queryByTestId("pane-chat-Mika")).toBeNull();expect(screen.getByTestId("pane-Mika").getAttribute("data-maximized")).toBe("yes");});- it("the rail's plus opens a terminal at the end of the row", async () => {- renderGrid(FOUR);- toChat();- fireEvent.click(screen.getByTestId("chat-rail-new-terminal"));- await waitFor(() =>- expect(api.addTerminal).toHaveBeenCalledWith({- anchor: undefined,- direction: "right",- agent: undefined,- }),- );- });-/** The rail's plus offers the same choice the grid's split buttons do.*@@ -2739,56 +2600,6 @@ describe("chat view", () => {},];- it("the rail's plus asks which CLI when more than one is installed", async () => {- renderGrid(FOUR, { agents: CLI_CHOICES });- toChat();- fireEvent.click(screen.getByTestId("chat-rail-new-terminal"));-- // Uninstalled entries stay listed but disabled, so the absence is visible.- expect(- (screen.getByTestId("chat-rail-new-shell") as HTMLButtonElement).disabled,- ).toBe(true);-- fireEvent.click(screen.getByTestId("chat-rail-new-codex"));- await waitFor(() =>- expect(api.addTerminal).toHaveBeenCalledWith({- anchor: undefined,- direction: "right",- agent: "codex",- }),- );- // The menu closes with the pick — it was a question, and it was answered.- expect(screen.queryByTestId("chat-rail-agent-menu")).toBeNull();- });-- it("the rail's plus just opens one when a single CLI is installed", async () => {- // A menu with one entry is a click tax, not a choice.- renderGrid(FOUR, {- agents: [CLI_CHOICES[0], { ...CLI_CHOICES[1], installed: false }],- });- toChat();- fireEvent.click(screen.getByTestId("chat-rail-new-terminal"));- expect(screen.queryByTestId("chat-rail-agent-menu")).toBeNull();- await waitFor(() =>- expect(api.addTerminal).toHaveBeenCalledWith({- anchor: undefined,- direction: "right",- agent: undefined,- }),- );- });-- it("leaving chat view closes an open picker", () => {- renderGrid(FOUR, { agents: CLI_CHOICES });- toChat();- fireEvent.click(screen.getByTestId("chat-rail-new-terminal"));- expect(screen.getByTestId("chat-rail-agent-menu")).toBeTruthy();- toChat();- // The button that opened it just left the screen; it must not be waiting- // there on the way back.- expect(screen.queryByTestId("chat-rail-agent-menu")).toBeNull();- });-/** Closing ONE terminal from the rail.*@@ -2797,42 +2608,6 @@ describe("chat view", () => {* carries its own, and it goes through the same confirmation as the header:* closing a pane kills whatever its agent was doing, and there is no undo.*/- it("closes one terminal from its row in the rail", async () => {- const survivors = sessionWith([- ["Mika", 0],- ["Nova", 1],- ["Kai", 3],- ]);- vi.mocked(api.closeTerminal).mockResolvedValue(survivors);- const { onSessionChanged } = renderGrid(FOUR);- toChat();-- fireEvent.click(screen.getByTestId("chat-rail-close-Aria"));- // Asked, never done on the spot — closing a pane kills a working agent.- expect(api.closeTerminal).not.toHaveBeenCalled();- expect(screen.getByText(/Close Aria\?/)).toBeTruthy();-- fireEvent.click(screen.getByTestId("confirm-close-terminal-confirm"));- await waitFor(() => expect(api.closeTerminal).toHaveBeenCalledWith("Aria"));- // The grid does not own the workspace; it reports the new one upwards.- await waitFor(() => expect(onSessionChanged).toHaveBeenCalledWith(survivors));- await waitFor(() =>- expect(screen.queryByTestId("confirm-close-terminal")).toBeNull(),- );- });-- it("keeps the rail's close out of selection mode", () => {- // That mode is here to close SEVERAL panes; a per-row close beside a- // checkbox is two answers to one question.- renderGrid(FOUR);- toChat();- expect(screen.getByTestId("chat-rail-close-Nova")).toBeTruthy();-- fireEvent.click(screen.getByTestId("terminal-selection-toggle"));-- expect(screen.queryByTestId("chat-rail-close-Nova")).toBeNull();- });-it("an emptied workspace asks the same question", async () => {// The message shown when every pane is closed opens a terminal too, and it// is the only way back — so it offers the same list rather than guessing.diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsxindex 0a8e78486e..f796d00573 100644--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx@@ -18,7 +18,6 @@ import {Check,Files,FolderGit2,- FolderPlus,GripVertical,LayoutGrid,ListChecks,@@ -29,9 +28,7 @@ import {MoreHorizontal,Plus,Power,- Search,SlidersHorizontal,- SquarePen,Sun,Trash2,Type,@@ -44,11 +41,8 @@ import { useThemeValue } from "@/hooks/useTheme";import { useDocumentVisible } from "@/hooks/useDocumentVisible";import { useResizablePane } from "@/hooks/useResizablePane";import { PaneResizer } from "@/components/layout/PaneResizer";-import { QuickTooltip } from "@/components/ui/tooltip";import { useEventStore, type VoiceState } from "@/store/events";-import { AgenticTerminal, type PaneStatus, type SplitDirection } from "./AgenticTerminal";-import { AgentMark } from "./AgentMark";-import { PaneActivityPill } from "./PaneActivityPill";+import { AgenticTerminal, type SplitDirection } from "./AgenticTerminal";import { AgentPickerMenu, offersAgentChoice, type SplitAgentChoice } from "./AgentPicker";import type { TerminalAppearance } from "./terminalThemes";import { installZoomKeyBridge, type ZoomIntent } from "./terminalZoom";@@ -84,14 +78,7 @@ import { WorkspaceFileViewer } from "./WorkspaceFileViewer";import { PaneChat } from "./PaneChat";import { useIdeChatStore } from "@/store/ideChat";import type { WorkspaceView } from "@/components/agentic/workspaceView";-import {- chatTerminalIdentity,- initialChatOrder,- orderChatTerminals,- reconcileChatOrder,- sameRows,- swapChatOrder,-} from "./chatState";+import { sameRows } from "./chatState";import { usePaneArrange, type DropZone } from "./paneArrange";import {addTerminal,@@ -179,22 +166,6 @@ interface AgenticGridProps {* a frontend change reaches the user through that Restart button.*/appActions?: React.ReactNode;- /**- * Open another workspace, choosing its folder — the rail's "Add project".- *- * Absent = the row is not offered. Owned by the view above this one, because- * opening a workspace is a thing that happens BESIDE this one rather than- * inside it.- */- onAddProject?: () => void;- /**- * Start a workspace with no project folder chosen — the rail's "New session".- *- * A question, a quick script, "what is in this file" are all worth asking- * without first naming a repository to ask them in. The agent still runs- * somewhere (the home folder); what the user is spared is the decision.- */- onNewSession?: () => void;/*** Take the user to a pane in ANOTHER workspace, on behalf of the header bell.*@@ -535,25 +506,6 @@ export {type WorkspaceView,} from "@/components/agentic/workspaceView";-const CHAT_ORDER_KEY_PREFIX = "jarvis.agenticIde.chatOrder.v1";--function storedChatOrder(workspaceId: string): readonly string[] | null {- return readStored(`${CHAT_ORDER_KEY_PREFIX}.${workspaceId}`, (raw) => {- try {- const parsed: unknown = JSON.parse(raw);- return Array.isArray(parsed) && parsed.every((item) => typeof item === "string")- ? parsed- : null;- } catch {- return null;- }- });-}--function rememberChatOrder(workspaceId: string, identities: readonly string[]): void {- writeStored(`${CHAT_ORDER_KEY_PREFIX}.${workspaceId}`, JSON.stringify(identities));-}-function readStored<T>(key: string, parse: (raw: string) => T | null): T | null {try {const raw = window.localStorage.getItem(key);@@ -624,8 +576,6 @@ export function AgenticGrid({onStateChanged,workspaceBar,appActions,- onAddProject,- onNewSession,onJumpToWorkspace,jumpTo = null,onScreen = true,@@ -727,9 +677,6 @@ export function AgenticGrid({useEffect(() => {onPromptTargetChange?.(target);}, [onPromptTargetChange, target]);- const [statuses, setStatuses] = useState<Record<string, { status: PaneStatus; detail?: string }>>(- {},- );// What each pane is doing, by call-sign, as the header shows it. Kept beside// the session rather than inside it because it changes on a completely// different clock: the layout changes when a pane is opened or closed, a@@ -762,7 +709,7 @@ export function AgenticGrid({* panes of that one agent while the grid's split buttons were asking properly* (maintainer report 2026-07-31).*/- const [picking, setPicking] = useState<"rail" | "empty" | null>(null);+ const [picking, setPicking] = useState<"empty" | null>(null);/** Grid or chat — remembered per browser profile, like the appearance above:@@ -832,14 +779,6 @@ export function AgenticGrid({// selected during render, before its terminal's connection effect measures// the otherwise-hidden grid cell.const knownPanes = useRef<Set<string> | null>(null);- const [chatOrder, setChatOrder] = useState<{- workspaceId: string;- keys: readonly string[];- }>(() => ({- workspaceId: session.id,- keys: storedChatOrder(session.id) ?? initialChatOrder(session.terminals),- }));- const chatRailRef = useRef<HTMLDivElement | null>(null);const [pendingClose, setPendingClose] = useState<string | null>(null);const [selectionMode, setSelectionMode] = useState(false);const [selectedTerminals, setSelectedTerminals] = useState<Set<string>>(() => new Set());@@ -1070,26 +1009,6 @@ export function AgenticGrid({return { activity, since, worked };};- /*- * The status the badge leans on when this window has no socket view yet.- *- * `statuses` is written by each pane's own socket, which exists only after- * the pane has mounted and connected — so on the first seconds of a- * workspace (and for panes a view keeps off screen) the rail showed a grey- * "connecting" spinner for terminals the backend already reported live. The- * backend's word is the truthful fallback, and one of the two backend- * sources always has one — every pane in the workspace state carries a- * status — so this never comes back empty.- */- const statusOf = (term: TerminalState) => {- const socket = statuses[term.name];- if (socket) return socket;- return {- status: (liveActivity[term.name]?.status ?? term.status) as PaneStatus,- detail: undefined,- };- };-/** The three things a user may do about a pane's recap.*@@ -1381,89 +1300,6 @@ export function AgenticGrid({const atLimit = session.terminals.length >= maxTerminals;- /*- * Chat is a conversation history, so its rail follows ARRIVAL order. The- * backend's terminal array follows grid coordinates and is deliberately- * re-sorted after every split or drag; rendering that array directly made a- * newly spawned Codex session appear in the middle of an existing chat.- */- const stableChatKeys = useMemo(- () =>- reconcileChatOrder(- chatOrder.workspaceId === session.id- ? chatOrder.keys- : (storedChatOrder(session.id) ?? initialChatOrder(session.terminals)),- session.terminals,- ),- [chatOrder, session.id, session.terminals],- );- const chatTerminals = useMemo(- () => orderChatTerminals(session.terminals, stableChatKeys),- [session.terminals, stableChatKeys],- );- /*- * The rail's own filter over those panes.- *- * Matched against what the row SHOWS — its headline, the prompt behind it,- * the CLI's name — rather than against the internal call-sign, because- * "T7" is not what anybody is looking for when they type into a search box.- * Purely local: no request fires, so it stays instant with a dozen panes.- */- const [railFilter, setRailFilter] = useState("");- const railTerminals = useMemo(() => {- const needle = railFilter.trim().toLowerCase();- if (!needle) return chatTerminals;- return chatTerminals.filter((term) =>- [term.recap, term.last_prompt, term.display_name, term.agent, term.name]- .filter(Boolean)- .some((field) => String(field).toLowerCase().includes(needle)),- );- }, [chatTerminals, railFilter]);-- /*- * The chat rail is a user's reading order, independent of the pane grid.- * Dropping one row on another exchanges only their stable lifetime keys: no- * terminal moves, remounts or reconnects, and the existing storage effect- * below makes the chosen order survive the next visit.- */- const suppressRailClickUntil = useRef(0);- const swapRailTerminals = useCallback(- (moved: string, targetName: string) => {- const movedTerminal = session.terminals.find((terminal) => terminal.name === moved);- const targetTerminal = session.terminals.find(- (terminal) => terminal.name === targetName,- );- if (!movedTerminal || !targetTerminal) return;- const next = swapChatOrder(- stableChatKeys,- chatTerminalIdentity(movedTerminal),- chatTerminalIdentity(targetTerminal),- );- if (next === stableChatKeys) return;- // Releasing over a row also produces a click in Chromium. Suppress that- // compatibility click so a reorder does not unexpectedly change stages.- suppressRailClickUntil.current = Date.now() + 250;- setChatOrder({ workspaceId: session.id, keys: next });- },- [session.id, session.terminals, stableChatKeys],- );- const railArrange = usePaneArrange(- useCallback(- (moved: string, targetName: string) => swapRailTerminals(moved, targetName),- [swapRailTerminals],- ),- );- const canReorderRail =- chatView && !selectionMode && !busy && !working && railTerminals.length > 1;-- useEffect(() => {- rememberChatOrder(session.id, stableChatKeys);- if (chatOrder.workspaceId === session.id && chatOrder.keys === stableChatKeys) {- return;- }- setChatOrder({ workspaceId: session.id, keys: stableChatKeys });- }, [chatOrder, session.id, stableChatKeys]);-/** A pane can arrive through voice, the CLI, or another client. Effects run* after child effects, which is too late to put that pane on the chat stage:@@ -1497,6 +1333,21 @@ export function AgenticGrid({// and its conversation is drawn over the canvas instead.const chatStage = stagedTerm !== null && stageMode === "chat";+ /*+ * On the chat stage, the pane being READ is the pane being TYPED and+ * SPOKEN to. Every route onto the stage moves the prompt target with it —+ * a click, a jump from the header bell or the sidebar, a pane that opened+ * by voice — so "this terminal" never resolves to a pane the person+ * cannot see. The grid is deliberately the other way round: a dozen panes+ * are visible at once there and none of them is THE one, so the target+ * stays where it was last put. A pane that takes no prompts leaves the+ * target alone: there is nothing to send it.+ */+ useEffect(() => {+ if (!chatView || !stagedTerm || !takesPrompts(stagedTerm)) return;+ setTarget((current) => (current === stagedTerm.name ? current : stagedTerm.name));+ }, [chatView, stagedTerm]);+/*** One click from any pane to its conversation: the chat view, this pane on* the stage, the stage in chat mode. From the grid's header buttons and@@ -1539,12 +1390,6 @@ export function AgenticGrid({});}, [onScreen, session.id, stagedPane, target, viewMode]);- /** Rail click: show the pane, and aim voice at it when it can listen. */- const selectChatPane = useCallback((name: string, promptable: boolean) => {- setChatPane(name);- if (promptable) setTarget(name);- }, []);-const split = async (anchor: string | null, direction: SplitDirection, agent?: string) => {setWorking(true);try {@@ -1582,7 +1427,7 @@ export function AgenticGrid({* has more than one CLI installed. With a single one there is nothing to pick,* so the click opens it straight away rather than showing a one-entry menu.*/- const openTerminal = (surface: "rail" | "empty") => {+ const openTerminal = (surface: "empty") => {if (offersChoice) setPicking((current) => (current === surface ? null : surface));else void split(null, "right");};@@ -1879,30 +1724,17 @@ export function AgenticGrid({if (fresh.length === 0) return;setJustOpened(new Set(fresh));// On the chat stage, "seen appearing" means TAKING the stage: a pane- // opened by voice would otherwise exist only as a rail entry behind the+ // opened by voice would otherwise exist only as a sidebar row behind the// one being read, which is the 2026-07-28 "terminals just don't load"// report in new clothes.- let frame: number | undefined;- if (chatView) {- setChatPane(fresh[fresh.length - 1]);- // Chat rows are arrival-ordered, so the new session belongs at the rail's- // tail. Scrolling the hidden grid cell used to move the whole workspace- // and then snap the terminal again after its delayed fit.- frame = requestAnimationFrame(() => {- const rail = chatRailRef.current;- if (rail) rail.scrollTop = rail.scrollHeight;- });- }+ if (chatView) setChatPane(fresh[fresh.length - 1]);// In the grid there is nothing to scroll to: the workspace is one screenful// by rule, so a pane that just opened is already in view and the ring below// is the whole announcement. This used to call `scrollIntoView` on the// newest pane, which was the honest answer while a workspace could be wider// or taller than its window.const timer = window.setTimeout(() => setJustOpened(new Set()), 2600);- return () => {- if (frame !== undefined) cancelAnimationFrame(frame);- window.clearTimeout(timer);- };+ return () => window.clearTimeout(timer);}, [session.terminals]);/*@@ -1979,7 +1811,6 @@ export function AgenticGrid({// rather than assumed from the input — the key is what survives a// rename, which is exactly why it is the thing to look the pane up by.const to = next.terminals.find((term) => term.key === pane.key)?.name ?? cleaned;- setStatuses((current) => rekey(current, from, to));setRecapCache((current) =>current.workspaceId === session.id? { ...current, rows: rekey(current.rows, from, to) }@@ -2095,10 +1926,6 @@ export function AgenticGrid({}};- const setStatus = useCallback((name: string, status: PaneStatus, detail?: string) => {- setStatuses((prev) => ({ ...prev, [name]: { status, detail } }));- }, []);-const project = session.project;const branchLabel = useMemo(() => (project.is_repo && project.branch ? `on ${project.branch}` : ""),@@ -2397,288 +2224,13 @@ export function AgenticGrid({CSS, never removed, and the maximized one is told to fill the containerinstead of keeping its own rectangle.- Chat view is the same trick one step further: the rail on the left is- ALWAYS in the tree (hidden in grid mode), and switching modes only- flips class names — the scroller and every cell keep their place in- the element tree, so React re-parents nothing and no agent dies for a- change of clothes.+ Chat view is the same trick one step further: switching modes only+ flips class names — every cell keeps its place in the element tree,+ so React re-parents nothing and no agent dies for a change of+ clothes. The list of sessions is the app sidebar's (WorkspaceChats),+ not a second column here.*/}<div className="flex min-h-0 flex-1">- {/* ------------------------------------------------------ chat rail */}- <aside- data-testid="agentic-chat-rail"- className={cn(- /*- * 224 px, and the header is the same 44 px rule-under-a-label as- * the voice column opposite it. Chat view puts THREE vertical- * bands in front of the one pane being read — the app's own- * navigation, this list, and the voice column — so the two this- * view owns at least agree with each other about how a column- * begins.- */- "w-56 shrink-0 flex-col border-r border-border",- chatView ? "flex" : "hidden",- )}- >- {/*- The column's own head and name.-- Not "AGENTS" in small caps any more. This column lists the- conversations you are having, grouped by the folder they are in —- "Chat" is what that is.- */}- <div className="flex h-11 shrink-0 items-center gap-1 px-2">- <span className="flex-1 truncate px-1 text-sm font-semibold tracking-tight">- Chat- </span>- </div>-- <div className="px-2 pb-2">- <div className="relative flex items-center">- <Search className="pointer-events-none absolute left-2 h-3.5 w-3.5 text-muted-foreground/70" />- <input- value={railFilter}- onChange={(event) => setRailFilter(event.target.value)}- placeholder="Search"- aria-label="Search chats"- className="h-8 w-full rounded-md border border-transparent bg-foreground/[0.045] pl-7 pr-2 text-xs outline-none placeholder:text-muted-foreground/60 focus-visible:border-border focus-visible:bg-transparent"- />- </div>- </div>-- {/*- The three things a person arrives wanting to do, as rows with words- on them. They used to be one bare "+" in the header, which cannot- say which of the three it is.- */}- <div className="relative px-1.5 pb-1">- <RailAction- icon={SquarePen}- label="New chat"- testId="chat-rail-new-terminal"- disabled={atLimit || busy || working}- onClick={() => openTerminal("rail")}- />- {onNewSession && (- <RailAction- icon={Plus}- label="New session"- hint="A workspace with no project folder"- testId="chat-rail-new-session"- disabled={busy || working}- onClick={onNewSession}- />- )}- {onAddProject && (- <RailAction- icon={FolderPlus}- label="Add project"- testId="chat-rail-add-project"- disabled={busy || working}- onClick={onAddProject}- />- )}- {picking === "rail" && (- <AgentPickerMenu- title="Open a terminal — what?"- ariaLabel="What should run in the new terminal?"- agents={agents ?? []}- testId="chat-rail-agent-menu"- itemTestId={(agent) => `chat-rail-new-${agent}`}- className="left-2 top-full"- onDismiss={() => setPicking(null)}- onInstalled={() => onAgentsChanged?.()}- onPick={(agent) => {- setPicking(null);- void split(null, "right", agent);- }}- />- )}- </div>-- <div- ref={chatRailRef}- className="min-h-0 flex-1 overflow-y-auto scrollbar-jarvis px-1.5 pb-2"- >- <RailBand>Projects</RailBand>- {/*- The folder these panes are in, named and coloured like the- project it is. Every row under it belongs to it — which is the- whole reason this band exists: with two workspaces open, a flat- list of eleven conversations says nothing about which repository- any of them is touching.- */}- <div className="flex items-center gap-1.5 rounded-md px-2 py-1.5">- <span- className="h-1.5 w-1.5 shrink-0 rounded-full"- style={{ background: folderColor(project.path || project.name) }}- aria-hidden- />- <span className="min-w-0 flex-1 truncate text-xs font-medium">- {project.name}- </span>- </div>-- {railTerminals.map((term) => {- const state = statusOf(term);- const headline = recaps[term.name]?.recap ?? term.recap;- const title =- headline?.trim() ||- term.last_prompt?.trim() ||- `${term.display_name || term.name} session`;- const marked = selectedTerminals.has(term.name);- const active = chatSelected === term.name;- return (- /*- * The row and its close button are SIBLINGS, never nested: a- * button inside a button is invalid HTML, and browsers resolve- * it by dropping one of them — usually the one you wanted.- */- <div- key={term.key}- ref={railArrange.registerCell(term.name)}- data-testid={`chat-rail-item-${term.name}`}- data-terminal={term.name}- className={cn(- "group relative ml-3 mb-0.5 rounded-md transition-[opacity,box-shadow,background-color]",- railArrange.held === term.name && "opacity-50",- railArrange.hover?.target === term.name &&- "bg-primary/10 ring-2 ring-inset ring-primary/70",- )}- >- <button- type="button"- data-testid={`chat-rail-${term.name}`}- aria-label={`${title}, ${term.display_name || term.agent}`}- aria-pressed={selectionMode ? marked : active}- onPointerDown={- canReorderRail- ? (event) => railArrange.start(term.name, event)- : undefined- }- onClick={(event) => {- if (Date.now() < suppressRailClickUntil.current) {- event.preventDefault();- return;- }- // Selection mode borrows the rail: in chat view the grid's- // per-pane overlays are hidden with their panes, so the- // rail is where a multi-close is composed.- selectionMode- ? toggleTerminalSelection(term.name)- : selectChatPane(term.name, takesPrompts(term));- }}- /*- * Selection is a barely-there lift of the surface — no hue,- * no border, no fill. Eleven rows of tinted boxes turn a- * list into a heat map and leave the accent with nothing- * distinct to say when a row actually wants attention. The- * one exception is a MARKED row in selection mode, which is- * a deliberate armed state and should look like one.- */- className={cn(- "w-full rounded-md px-2 py-[5px] text-left transition-colors",- selectionMode && marked- ? "bg-primary/15"- : active && !selectionMode- ? "bg-foreground/[0.09]"- : "hover:bg-foreground/[0.055]",- canReorderRail &&- (railArrange.held === term.name- ? "cursor-grabbing"- : "cursor-grab"),- )}- style={{ touchAction: canReorderRail ? "none" : undefined }}- >- {/* The right padding is permanent, not applied on hover:- the close button appears where the badge would otherwise- be, and a status pill that jumps sideways under the- cursor is a row nobody can aim at. */}- <span className="flex items-center gap-1.5 pr-5">- {selectionMode && (- <Check- className={cn(- "h-3.5 w-3.5 shrink-0",- marked ? "text-primary" : "text-transparent",- )}- />- )}- <span className="flex min-w-0 flex-1 items-center gap-2">- {/* The mark leads, at the weight of the text beside it- — it says which CLI this is, it is not the subject- of the row. The title is. */}- <AgentMark- agent={term.agent}- label={term.display_name || term.agent}- size="sm"- variant="plain"- />- {/* The app's own bubble, not `title=`: the native- tooltip takes over a second to appear and is drawn- in the OS's grey box — a foreign artifact over a- rail whose whole point is the title. */}- <QuickTooltip- content={title}- side="right"- className="min-w-0 flex-1"- >- <span- data-testid={`chat-rail-title-${term.name}`}- className={cn(- "block truncate text-[12px]",- active ? "text-foreground" : "text-foreground/75",- )}- >- {title}- </span>- </QuickTooltip>- </span>- {/* Not "live". Every pane in this list is live, all day —- what the user is scanning for is which of them still- owes them something. See ./PaneActivityPill. */}- <PaneActivityPill- status={state.status}- detail={state.detail}- {...activityOf(term)}- />- </span>- </button>- {/*- Closing one terminal from the list itself.- Chat view hides every pane but the one on the stage, and with- it the header that used to be the only place a single- terminal could be closed — so the eleven panes you are NOT- looking at could only be closed by switching to the grid or- by composing a multi-select. This is the row's own button.-- Left out of selection mode on purpose: that mode is here to- close SEVERAL, and a per-row close beside a checkbox is two- answers to one question.- */}- {!selectionMode && (- <button- type="button"- data-testid={`chat-rail-close-${term.name}`}- disabled={busy || working}- onClick={() => setPendingClose(term.name)}- title={`Close ${term.name} and stop what is running in it`}- aria-label={`Close ${term.name}`}- className={cn(- "absolute right-1 top-1.5 flex h-5 w-5 items-center justify-center rounded",- "text-muted-foreground opacity-0 transition-opacity",- "hover:bg-destructive/20 hover:text-destructive",- "group-hover:opacity-100 group-focus-within:opacity-100",- "focus-visible:opacity-100 disabled:cursor-not-allowed",- )}- >- <X className="h-3.5 w-3.5" />- </button>- )}- </div>- );- })}- </div>- </aside><divref={gridRef}data-testid="agentic-grid"@@ -2840,7 +2392,6 @@ export function AgenticGrid({onFocus={() => {if (takesPrompts(term)) setTarget(term.name);}}- onStatus={(status, detail) => setStatus(term.name, status, detail)}onToggleMaximize={() => {// On the chat stage the pane already fills the surface, so// "maximize" honestly means "give me the full-width grid@@ -2953,12 +2504,14 @@ export function AgenticGrid({key={`${session.id}:${stagedTerm.name}`}terminal={stagedTerm.name}workspaceId={session.id}+ historyId={stagedTerm.history_id ?? `${stagedTerm.key}@${stagedTerm.started_at ?? "pending"}`}+ agent={stagedTerm.agent}+ folder={session.folder}agentLabel={agents?.find((choice) => choice.name === stagedTerm.agent)?.displayName ??stagedTerm.agent}activity={activityOf(stagedTerm).activity}- promptable={takesPrompts(stagedTerm)}onShowTerminal={() => setStageMode("terminal")}/>)}@@ -3165,24 +2718,6 @@ export function AgenticGrid({)}</div>)}- {railArrange.held !== null && railArrange.point !== null && (- <div- data-testid="chat-rail-arrange-ghost"- className="pointer-events-none fixed z-50 flex items-center gap-1.5 rounded-lg border border-primary/60 bg-card px-2.5 py-1.5 text-xs font-semibold shadow-xl"- style={{ left: railArrange.point.x + 14, top: railArrange.point.y + 14 }}- >- <GripVertical className="h-3.5 w-3.5 text-primary" />- {railArrange.held}- <span className="font-normal text-muted-foreground">- {railArrange.hover === null- ? t("agentic_grid.arrange.carrying")- : t("agentic_grid.arrange.swap").replace(- "{0}",- railArrange.hover.target,- )}- </span>- </div>- )}</div>);}@@ -3617,76 +3152,3 @@ function ConfirmClose({);}-/**- * One of the rail's standing actions — a word, an icon, a whole row to hit.- *- * Rows rather than a toolbar of glyphs: these are the three things a person- * arrives wanting to do, and each has to be able to say which one it is- * without being hovered first.- */-function RailAction({- icon: Icon,- label,- hint,- onClick,- disabled,- testId,-}: {- icon: LucideIcon;- label: string;- hint?: string;- onClick: () => void;- disabled?: boolean;- testId?: string;-}) {- return (- <button- type="button"- data-testid={testId}- onClick={onClick}- disabled={disabled}- title={hint ?? label}- className={cn(- "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs font-medium",- "text-foreground/85 transition-colors hover:bg-foreground/[0.055]",- "disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent",- )}- >- <Icon className="h-3.5 w-3.5 shrink-0 text-muted-foreground" aria-hidden />- {label}- </button>- );-}--/** A section heading in the rail. Quiet enough to be scanned past. */-function RailBand({ children }: { children: React.ReactNode }) {- return (- <div className="px-2 pb-1 pt-3 text-[10px] font-medium uppercase tracking-wider text-muted-foreground/60">- {children}- </div>- );-}--/**- * A stable colour for a folder, so the same project reads the same everywhere.- *- * Derived from the path rather than stored, which means it needs no setting and- * survives a lost store. The palette is fixed rather than a free hue rotation:- * arbitrary HSL produces colours that vanish against one of the two themes.- */-const FOLDER_COLORS = [- "#e7c46e",- "#7dd3fc",- "#a5b4fc",- "#86efac",- "#fca5a5",- "#f0abfc",- "#fdba74",- "#5eead4",-] as const;--function folderColor(key: string): string {- let sum = 0;- for (const char of key) sum = (sum + char.charCodeAt(0)) % 4096;- return FOLDER_COLORS[sum % FOLDER_COLORS.length];-}diff --git a/jarvis/ui/web/frontend/src/components/agentic/IdeChatSurface.tsx b/jarvis/ui/web/frontend/src/components/agentic/IdeChatSurface.tsxdeleted file mode 100644index 781f80363b..0000000000--- a/jarvis/ui/web/frontend/src/components/agentic/IdeChatSurface.tsx+++ /dev/null@@ -1,65 +0,0 @@-import { useEffect } from "react";--import { AgentChatStoreProvider } from "@/components/agentchat/AgentChatStoreContext";-import { ChatStage } from "@/components/home/ChatStage";-import { useAgentSessionStore } from "@/store/agentChat";-import type { IdeWorkspace } from "@/store/ideChat";--/**- * The Agentic IDE's chat surface — a coding-agent session in this workspace's folder.- *- * It wears the front page's face — same `ChatStage`, same composer — and is a- * DIFFERENT chat: the front page is Jarvis with a keyboard, this is a coding- * agent (Claude Code, Codex, the API loop) working in the folder. So it runs- * on its own store (`useAgentSessionStore`, surface `agent`): its own- * sessions, draft and socket, handed to the shared components through- * `AgentChatStoreProvider`. Opening a chat here never changes what the front- * page shows, and the other way round (maintainer, 2026-08-25). What this- * component adds on top is the one thing the IDE knows and the front page- * does not — WHICH FOLDER you are working in. The workspace you opened is the- * working directory of every chat started on this surface, which is what- * "logged into your workspace" means in practice: the agent runs there, on- * those files, under that folder's credentials.- *- * A chat belonging to another folder is not silently re-pointed. Moving an- * existing conversation to a new working directory mid-thread would change- * what its own history refers to, so the surface opens a fresh chat instead- * and leaves the old one in the sidebar where it was.- *- * This surface replaced the old "chat view", which read the terminal panes one- * at a time behind a rail. That was a way of LOOKING at the grid; this is a- * different thing to be doing (maintainer, 2026-08-24).- */-export function IdeChatSurface({ workspace }: { workspace: IdeWorkspace }) {- const folder = workspace.path;- const activeSession = useAgentSessionStore((s) => s.activeSession);- const draftCwd = useAgentSessionStore((s) => s.draft.cwd);- const setDraft = useAgentSessionStore((s) => s.setDraft);- const newChat = useAgentSessionStore((s) => s.newChat);-- useEffect(() => {- if (!folder) return;- // Order matters: dropping the open session FIRST means the cwd change is a- // change to the draft for the next chat, not a PATCH that would move a- // running conversation into a different folder.- if (activeSession && activeSession.cwd !== folder) {- newChat();- void setDraft({ cwd: folder });- return;- }- if (!activeSession && draftCwd !== folder) void setDraft({ cwd: folder });- }, [folder, activeSession, draftCwd, newChat, setDraft]);-- return (- <div- className="flex h-full min-h-0 flex-col"- data-testid="ide-chat-surface"- data-workspace={workspace.id}- data-folder={folder}- >- <AgentChatStoreProvider store={useAgentSessionStore}>- <ChatStage />- </AgentChatStoreProvider>- </div>- );-}diff --git a/jarvis/ui/web/frontend/src/components/agentic/PaneChat.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/PaneChat.test.tsxindex b95d6d6818..2e9d618383 100644--- a/jarvis/ui/web/frontend/src/components/agentic/PaneChat.test.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/PaneChat.test.tsx@@ -1,30 +1,25 @@/**- * The chat stage: a terminal's transcript, drawn with the agent chat's timeline.+ * The chat stage: a terminal's transcript through the front page's own chat.*- * Pinned here: the poll's cadence follows the pane's state, an unchanged poll- * re-renders nothing, the transcript's events come out as the same turn the- * front page's chat would draw (thinking, tool call with result, answer, the- * closing line), the composer types what was written into the pane verbatim,- * and a CLI without a readable record says so instead of showing a blank.+ * What the store folds is pinned in store/paneChat.test.ts; here it is the+ * stage around it — the same `ChatStage`, so the turn, the byline and the+ * composer with its pills are the chat's own; the empty states; the way back+ * to the terminal; the notice when the pane is asking something.*/-import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";+import { cleanup, fireEvent, render, screen } from "@testing-library/react";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import * as api from "@/lib/agenticIdeApi";-import type { TerminalTimelineResponse } from "@/lib/agenticIdeApi";import type { AgentChatEvent } from "@/lib/agentChatApi";-import {- eventsSignature,- PaneChat,- POLL_IDLE_MS,- POLL_WORKING_MS,- pollIntervalFor,-} from "@/components/agentic/PaneChat";+import type { TerminalTimelineResponse } from "@/lib/agenticIdeApi";+import { PaneChat } from "@/components/agentic/PaneChat";+import { useAgentSessionStore, type ProviderOption } from "@/store/agentChat";vi.mock("@/lib/agenticIdeApi", async (importOriginal) => ({...(await importOriginal<typeof import("@/lib/agenticIdeApi")>()),fetchTerminalTimeline: vi.fn(),promptTerminal: vi.fn(),+ interruptTerminal: vi.fn(),}));const T0 = 1_787_800_000_000;@@ -33,52 +28,50 @@ function ev(seq: number, kind: string, payload: Record<string, unknown>, at = 0)return { seq, ts_ms: T0 + at, kind, payload };}-/** One finished exchange, the way `agent_transcript.read_events` writes it. */const EXCHANGE: AgentChatEvent[] = [ev(1, "user_message", { text: "Fix the login bug" }),- ev(2, "turn_started", {- turn_id: "turn-1",- provider: "claude",- model: "claude-opus-5",- effort: "xhigh",- runner: "cli",- }, 1000),+ ev(2, "turn_started", { turn_id: "turn-1", provider: "claude", model: "claude-opus-5", effort: "xhigh", runner: "cli" }, 1000),ev(3, "reasoning", { turn_id: "turn-1", message_id: "m1", text: "", duration_ms: 3500 }, 1000),ev(4, "assistant_text", { turn_id: "turn-1", message_id: "r1", text: "Looking at it now." }, 4500),- ev(5, "tool_call", {- turn_id: "turn-1",- call_id: "call-1",- name: "Read",- input: { file_path: "src/login.ts" },- summary: "src/login.ts",- }, 5000),- ev(6, "tool_result", {- turn_id: "turn-1",- call_id: "call-1",- output: "export const login = 1;",- is_error: false,- duration_ms: 2000,- }, 7000),+ ev(5, "tool_call", { turn_id: "turn-1", call_id: "call-1", name: "Read", input: { file_path: "src/login.ts" }, summary: "src/login.ts" }, 5000),+ ev(6, "tool_result", { turn_id: "turn-1", call_id: "call-1", output: "export const login = 1;", is_error: false, duration_ms: 2000 }, 7000),ev(7, "assistant_text", { turn_id: "turn-1", message_id: "r2", text: "Found it." }, 9000),- ev(8, "turn_finished", {- turn_id: "turn-1",- status: "done",- duration_ms: 8000,- usage: { output_tokens: 80 },- error: null,- cost_usd: null,- }, 9000),+ ev(8, "turn_finished", { turn_id: "turn-1", status: "done", duration_ms: 8000, usage: { output_tokens: 80 }, error: null, cost_usd: null }, 9000),];+const CLAUDE_CLI = {+ id: "claude-api",+ label: "Anthropic Claude",+ family: "claude",+ runner: "claude-cli",+ models_source: "curated",+ curated_models: [{ id: "claude-opus-5", label: "Opus 5" }],+ default_model: "",+ effort_levels: ["low", "medium", "high", "xhigh"],+ default_effort: "high",+ permission_modes: [+ { id: "default", label: "Ask", description: "" },+ { id: "auto", label: "Auto", description: "" },+ ],+ default_permission_mode: "default",+ cli_installed: true,+ keyless: false,+ connected: true,+ active: false,+} as unknown as ProviderOption;+function answer(overrides: Partial<TerminalTimelineResponse> = {}): TerminalTimelineResponse {return {- terminal: "T1",+ terminal: "T7",agent: "claude",readable: true,available: true,live: false,activity: "",events: EXCHANGE,+ model: "claude-opus-5",+ effort: "xhigh",+ permission_mode: "auto",...overrides,};}@@ -87,11 +80,13 @@ function renderStage(props: Partial<React.ComponentProps<typeof PaneChat>> = {})const onShowTerminal = vi.fn();const utils = render(<PaneChat- terminal="T1"+ terminal="T7"workspaceId="ide_test"+ historyId="t7@1"+ agent="claude"agentLabel="Claude Code"+ folder="C:\\dev\\Personal Jarvis"activity=""- promptableonShowTerminal={onShowTerminal}{...props}/>,@@ -102,154 +97,92 @@ function renderStage(props: Partial<React.ComponentProps<typeof PaneChat>> = {})beforeEach(() => {vi.mocked(api.fetchTerminalTimeline).mockReset();vi.mocked(api.promptTerminal).mockReset();-});--afterEach(() => {- vi.useRealTimers();-});--describe("pollIntervalFor", () => {- it("reads quickly while the agent works and slowly once it stops", () => {- expect(pollIntervalFor(true, "")).toBe(POLL_WORKING_MS);- expect(pollIntervalFor(false, "working")).toBe(POLL_WORKING_MS);- expect(pollIntervalFor(false, "starting")).toBe(POLL_WORKING_MS);- expect(pollIntervalFor(false, "waiting")).toBe(POLL_IDLE_MS);- expect(pollIntervalFor(false, "")).toBe(POLL_IDLE_MS);+ useAgentSessionStore.setState({+ catalog: { providers: [CLAUDE_CLI], runners: [] } as never,+ providerOptions: () => [CLAUDE_CLI],+ providerById: (id: string) => (id === CLAUDE_CLI.id ? CLAUDE_CLI : null),+ loadCatalog: async () => {},+ loadHealth: async () => {},+ loadModels: async () => {},});});-describe("eventsSignature", () => {- it("tells a grown transcript from an unchanged one", () => {- const same = eventsSignature(EXCHANGE, false);- expect(eventsSignature([...EXCHANGE], false)).toBe(same);- expect(eventsSignature(EXCHANGE.slice(0, -1), false)).not.toBe(same);- expect(eventsSignature(EXCHANGE, true)).not.toBe(same);- // A record that grew in place — the same seq, more text — is a change.- const grown = EXCHANGE.map((e) =>- e.seq === 7 ? { ...e, payload: { ...e.payload, text: "Found it, and fixed it." } } : e,- );- expect(eventsSignature(grown, false)).not.toBe(same);- });-});+afterEach(cleanup);describe("PaneChat", () => {- it("draws the transcript as the chat's own turn", async () => {+ it("draws the transcript with the chat's own stage, byline and composer", async () => {vi.mocked(api.fetchTerminalTimeline).mockResolvedValue(answer());renderStage();- await screen.findByTestId("pane-chat-timeline");- expect(api.fetchTerminalTimeline).toHaveBeenCalledWith("T1", "ide_test");- // The person's line, and ONE assistant turn under the pane's byline.+ const turn = await screen.findByTestId("agent-turn");+ expect(api.fetchTerminalTimeline).toHaveBeenCalledWith("T7", "ide_test");+ expect(screen.getByTestId("chat-stage").getAttribute("data-empty")).toBe("false");expect(screen.getByTestId("agent-message-user").textContent).toContain("Fix the login bug");- const turns = screen.getAllByTestId("agent-turn");- expect(turns).toHaveLength(1);- expect(turns[0].getAttribute("data-status")).toBe("done");- expect(turns[0].textContent).toContain("Claude Code");- expect(turns[0].textContent).toContain("claude-opus-5");- expect(turns[0].textContent).toContain("Looking at it now.");- expect(turns[0].textContent).toContain("Found it.");- // The tool call is a row under the name the CLI's own log uses.- expect(turns[0].textContent).toContain("Read");- expect(turns[0].textContent).toContain("src/login.ts");- // The closing line says the turn ended, with its output tokens.+ expect(turn.getAttribute("data-status")).toBe("done");+ expect(turn.textContent).toContain("Anthropic Claude");+ expect(turn.textContent).toContain("claude-opus-5");+ expect(turn.textContent).toContain("Looking at it now.");+ expect(turn.textContent).toContain("Found it.");+ expect(turn.textContent).toContain("src/login.ts");expect(screen.getByTestId("agent-turn-footer").getAttribute("data-outcome")).toBe("done");+ // The chat's composer, not a plain box: its pills show what the pane runs on.+ expect(screen.getByTestId("agent-composer")).toBeTruthy();+ expect(screen.getByTestId("composer-surface").getAttribute("data-surface")).toBe("agent");+ expect(screen.getByTestId("composer-model").textContent).toContain("Opus 5");+ expect(screen.getByTestId("composer-permission").textContent).toContain("Auto");});- it("says when the CLI keeps no readable record, with the way to the terminal", async () => {- vi.mocked(api.fetchTerminalTimeline).mockResolvedValue(- answer({ readable: false, available: false, events: [] }),- );- const { onShowTerminal } = renderStage({ agentLabel: "Grok Build" });-- const empty = await screen.findByTestId("pane-chat-not-readable");- expect(empty.textContent).toContain("No readable record");- // No composer either: there is no conversation to add to.- expect(screen.queryByTestId("pane-chat-composer")).toBeNull();- fireEvent.click(screen.getByTestId("pane-chat-show-terminal"));- expect(onShowTerminal).toHaveBeenCalledTimes(1);- });-- it("waits, rather than gives up, while the record has not appeared yet", async () => {- vi.mocked(api.fetchTerminalTimeline).mockResolvedValue(- answer({ available: false, events: [] }),- );- renderStage();- await screen.findByTestId("pane-chat-waiting");- expect(screen.getByTestId("pane-chat-composer")).toBeTruthy();- });-- it("flags a pane that is asking something only the terminal can answer", async () => {- vi.mocked(api.fetchTerminalTimeline).mockResolvedValue(answer());- renderStage({ activity: "asking" });- await screen.findByTestId("pane-chat-timeline");- expect(screen.getByTestId("pane-chat-asking").textContent).toContain(- "The agent is asking you something",- );- });-- it("types what was written into the pane, verbatim, and reads again", async () => {+ it("sends what is typed through the pane store", async () => {vi.mocked(api.fetchTerminalTimeline).mockResolvedValue(answer());vi.mocked(api.promptTerminal).mockResolvedValue({- terminal: "T1",+ terminal: "T7",sent: "Now the tests",composed_by: "raw",files: [],submitted: true,});renderStage();- await screen.findByTestId("pane-chat-timeline");- const before = vi.mocked(api.fetchTerminalTimeline).mock.calls.length;+ await screen.findByTestId("agent-turn");- const box = screen.getByPlaceholderText(/Message T1/) as HTMLTextAreaElement;+ const box = screen.getByTestId("agent-composer").querySelector("textarea")!;fireEvent.change(box, { target: { value: "Now the tests" } });fireEvent.keyDown(box, { key: "Enter" });-- await waitFor(() =>- expect(api.promptTerminal).toHaveBeenCalledWith("T1", "Now the tests", { compose: false }),- );- await waitFor(() => expect(box.value).toBe(""));- // A send re-reads the record at once instead of waiting for the next poll.- await waitFor(() =>- expect(vi.mocked(api.fetchTerminalTimeline).mock.calls.length).toBeGreaterThan(before),+ await vi.waitFor(() =>+ expect(api.promptTerminal).toHaveBeenCalledWith("T7", "Now the tests", {+ compose: false,+ attachments: [],+ }),);});- it("says so when the pane did not take the message", async () => {- vi.mocked(api.fetchTerminalTimeline).mockResolvedValue(answer());- vi.mocked(api.promptTerminal).mockResolvedValue({- terminal: "T1",- sent: "hi",- composed_by: "raw",- files: [],- submitted: false,- detail: "still in the input box",- });+ it("shows the empty page — folder headline and composer — before anything was said", async () => {+ vi.mocked(api.fetchTerminalTimeline).mockResolvedValue(answer({ events: [] }));renderStage();- await screen.findByTestId("pane-chat-timeline");- const box = screen.getByPlaceholderText(/Message T1/);- fireEvent.change(box, { target: { value: "hi" } });- fireEvent.click(screen.getByTestId("pane-chat-send"));- const notice = await screen.findByTestId("pane-chat-notice-warning");- expect(notice.textContent).toContain("T1 did not take the message: still in the input box");+ const stage = await screen.findByTestId("chat-stage");+ expect(stage.getAttribute("data-empty")).toBe("true");+ expect(screen.getByTestId("chat-folder-headline").textContent).toContain("Personal Jarvis");+ expect(screen.getByTestId("agent-composer")).toBeTruthy();});- it("keeps the column on one failed poll and re-polls on the working cadence", async () => {- vi.useFakeTimers();- vi.mocked(api.fetchTerminalTimeline).mockResolvedValueOnce(answer({ live: true }));- renderStage();- await act(async () => {- await Promise.resolve();- });- expect(screen.getByTestId("pane-chat-timeline")).toBeTruthy();+ it("says when the CLI keeps no readable record, with the way to the terminal", async () => {+ vi.mocked(api.fetchTerminalTimeline).mockResolvedValue(+ answer({ readable: false, available: false, events: [] }),+ );+ const { onShowTerminal } = renderStage({ agent: "grok", agentLabel: "Grok Build" });- vi.mocked(api.fetchTerminalTimeline).mockRejectedValueOnce(new Error("offline"));- await act(async () => {- vi.advanceTimersByTime(POLL_WORKING_MS);- await Promise.resolve();- });- // Still there: a column that empties itself on one failed read would say- // the conversation is gone.- expect(screen.getByTestId("pane-chat-timeline")).toBeTruthy();- expect(api.fetchTerminalTimeline).toHaveBeenCalledTimes(2);+ const empty = await screen.findByTestId("pane-chat-not-readable");+ expect(empty.textContent).toContain("No readable record");+ expect(screen.queryByTestId("agent-composer")).toBeNull();+ fireEvent.click(screen.getByTestId("pane-chat-show-terminal"));+ expect(onShowTerminal).toHaveBeenCalledTimes(1);+ });++ it("flags a pane that is asking something only the terminal can answer", async () => {+ vi.mocked(api.fetchTerminalTimeline).mockResolvedValue(answer());+ renderStage({ activity: "asking" });+ await screen.findByTestId("agent-turn");+ expect(screen.getByTestId("pane-chat-asking").textContent).toContain(+ "The agent is asking you something",+ );});});diff --git a/jarvis/ui/web/frontend/src/components/agentic/PaneChat.tsx b/jarvis/ui/web/frontend/src/components/agentic/PaneChat.tsxindex d337b010e7..5f1f1654a5 100644--- a/jarvis/ui/web/frontend/src/components/agentic/PaneChat.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/PaneChat.tsx@@ -5,193 +5,40 @@* it cannot be read as a conversation off the screen. What CAN be read is the* record the CLI keeps for itself, which the backend serves in the agent* chat's own event vocabulary (`GET /terminals/{name}/timeline`). Those events- * fold through the same reducer and draw through the same `AgentTimeline` as- * the front page's chat — the thinking where it happened (or how long it took- * where the vendor redacts it), each tool call with its result, the answer as- * Markdown, the turn's state and its output tokens. One renderer, so the two- * chats cannot drift apart (maintainer, 2026-08-26: the terminals should turn- * into the chat view we built, with one click).+ * fold through the same reducer and draw through the same `ChatStage` as the+ * front page's chat — the thinking where it happened, each tool call with its+ * result, the answer as Markdown, the composer with its pills — because that+ * chat interface is the one the maintainer built for this and the one they+ * asked for here (2026-08-26: the old interface, not a plain box). The+ * pane's answers behind every field live in `store/paneChat.ts`.** The terminal is never gone. Questions and permission prompts are asked in* the TUI and answered there, so the stage keeps one button back to the pane* itself, and says so out loud the moment the pane's activity reads "asking".- * The composer types what is written into that pane, verbatim — this is a- * conversation with the agent, not a brief Jarvis writes on the user's behalf.- *- * Polling, not a socket: the record is a file the CLI appends to, and a poll- * every couple of seconds while the agent works (slower once it stops) is the- * honest cadence for that. The backend says which of the two it is (`live`).*/-import {- useCallback,- useEffect,- useLayoutEffect,- useMemo,- useRef,- useState,- type KeyboardEvent,-} from "react";-import {- ArrowUp,- CircleAlert,- MessageSquare,- RefreshCw,- SquareTerminal,-} from "lucide-react";+import { useEffect, useMemo } from "react";+import { CircleAlert, MessageSquare, RefreshCw, SquareTerminal } from "lucide-react";-import { AgentTimeline } from "@/components/agentchat/AgentTimeline";-import {- EMPTY_TIMELINE,- reduceEvents,- type Timeline,-} from "@/components/agentchat/reduce";-import { ScrollArea } from "@/components/ui/scroll-area";-import {- fetchTerminalTimeline,- promptTerminal,- type PaneActivity,- type TerminalTimelineResponse,-} from "@/lib/agenticIdeApi";-import type { AgentChatEvent } from "@/lib/agentChatApi";+import { AgentChatStoreProvider } from "@/components/agentchat/AgentChatStoreContext";+import { ChatStage } from "@/components/home/ChatStage";+import { createPaneChatStore, type PaneChatStoreHook } from "@/store/paneChat";+import type { PaneActivity } from "@/lib/agenticIdeApi";import { useT } from "@/i18n";import { cn } from "@/lib/utils";-/** Poll cadence while the agent is working — a tool result every couple of seconds is what it produces. */-export const POLL_WORKING_MS = 2000;-/** Poll cadence once it has stopped — only a new message from elsewhere could change the file. */-export const POLL_IDLE_MS = 6000;--/** How soon the next read follows, from what the last one said about the pane. */-export function pollIntervalFor(live: boolean, activity: PaneActivity): number {- return live || activity === "working" || activity === "starting"- ? POLL_WORKING_MS- : POLL_IDLE_MS;-}--/**- * A cheap fingerprint of an event list, so an unchanged poll re-renders nothing.- *- * The file only ever grows, and a record is written whole (a finished block,- * a tool result), so length plus the last event's identity plus the text- * volume tells the two lists apart — without folding sixty turns to find out- * that nothing happened.- */-export function eventsSignature(events: AgentChatEvent[], live: boolean): string {- const last = events[events.length - 1];- let chars = 0;- for (const ev of events) {- const p = ev.payload;- if (typeof p.text === "string") chars += p.text.length;- if (typeof p.output === "string") chars += p.output.length;- }- return `${events.length}:${last?.seq ?? 0}:${last?.ts_ms ?? 0}:${last?.kind ?? ""}:${chars}:${live ? 1 : 0}`;-}--export interface PaneTimelineState {- timeline: Timeline;- /** Null until the first answer; false is a settled "this CLI keeps no record". */- readable: boolean | null;- available: boolean;- live: boolean;- activity: PaneActivity;- /** True until the first answer for THIS pane has arrived. */- loading: boolean;- error: string;- /** Read again now — the composer calls it right after a send. */- reload: () => void;-}--/**- * Keep one pane's timeline current.- *- * Re-armed per pane: switching the stage to another terminal starts from an- * empty column rather than showing the previous pane's conversation under- * the new pane's name for a poll interval.- */-export function usePaneTimeline(- terminal: string,- workspaceId: string | undefined,- enabled: boolean,-): PaneTimelineState {- const [timeline, setTimeline] = useState<Timeline>(EMPTY_TIMELINE);- const [readable, setReadable] = useState<boolean | null>(null);- const [available, setAvailable] = useState(false);- const [live, setLive] = useState(false);- const [activity, setActivity] = useState<PaneActivity>("");- const [loading, setLoading] = useState(true);- const [error, setError] = useState("");- const [reloadToken, setReloadToken] = useState(0);- const signatureRef = useRef("");-- useEffect(() => {- // A new pane: forget the old one's answer before the first read lands.- setTimeline(EMPTY_TIMELINE);- setReadable(null);- setAvailable(false);- setLive(false);- setActivity("");- setLoading(true);- setError("");- signatureRef.current = "";- }, [terminal, workspaceId]);-- useEffect(() => {- if (!enabled) return;- let cancelled = false;- let timer: number | null = null;-- const apply = (res: TerminalTimelineResponse) => {- setReadable(res.readable);- setAvailable(res.available);- setLive(res.live);- setActivity(res.activity);- setError("");- setLoading(false);- const signature = eventsSignature(res.events, res.live);- if (signature !== signatureRef.current) {- signatureRef.current = signature;- setTimeline(reduceEvents(EMPTY_TIMELINE, res.events));- }- return pollIntervalFor(res.live, res.activity);- };-- const tick = async () => {- let next = POLL_IDLE_MS;- try {- const res = await fetchTerminalTimeline(terminal, workspaceId);- if (cancelled) return;- next = apply(res);- } catch (reason: unknown) {- if (cancelled) return;- // Keep what is on screen: a column that empties itself on one failed- // poll would read as "the conversation is gone".- setError(reason instanceof Error ? reason.message : String(reason));- setLoading(false);- }- if (!cancelled) timer = window.setTimeout(() => void tick(), next);- };-- void tick();- return () => {- cancelled = true;- if (timer !== null) window.clearTimeout(timer);- };- }, [enabled, terminal, workspaceId, reloadToken]);-- const reload = useCallback(() => setReloadToken((token) => token + 1), []);- return { timeline, readable, available, live, activity, loading, error, reload };-}-export interface PaneChatProps {/** The pane's call-sign — T1, or a name the user gave it. */terminal: string;workspaceId: string;- /** What the CLI is called — "Claude Code", "Codex" — the turns' byline. */+ /** The pane's lifetime id; the chat's "session id". */+ historyId: string;+ agent: string;+ /** What the CLI is called — "Claude Code", "Codex". */agentLabel: string;+ /** The workspace folder — the composer's chip and the empty page's headline. */+ folder: string;/** The grid's own reading of the pane: working, waiting, asking… */activity: PaneActivity;- /** Can this pane be typed into at all? A plain shell cannot. */- promptable: boolean;/** Back to the terminal itself — the question it is asking lives there. */onShowTerminal: () => void;}@@ -199,20 +46,39 @@ export interface PaneChatProps {export function PaneChat({terminal,workspaceId,+ historyId,+ agent,agentLabel,+ folder,activity,- promptable,onShowTerminal,}: PaneChatProps) {const t = useT();- const state = usePaneTimeline(terminal, workspaceId, true);- const items = state.timeline.items;- const providerLabel = useCallback(() => agentLabel, [agentLabel]);- // Approvals never come out of a transcript — the CLI asks in its own TUI.- const noDecision = useCallback(() => undefined, []);+ // One store per staged pane. The stage is keyed by workspace and pane, so a+ // stage change is a remount and a fresh store — never the last pane's+ // conversation under the new pane's name.+ const store: PaneChatStoreHook = useMemo(+ () =>+ createPaneChatStore({+ terminal,+ workspaceId,+ historyId,+ agent,+ displayName: agentLabel,+ folder,+ }),+ [terminal, workspaceId, historyId, agent, agentLabel, folder],+ );+ useEffect(() => {+ store.getState().start();+ return () => store.getState().stop();+ }, [store]);++ const pane = store((s) => s.pane);+ const reload = store((s) => s.reload);// The grid's reading is fresher than the poll's (it has the socket); the// poll's is the fallback for a pane the grid has not read yet.- const paneActivity = activity || state.activity;+ const paneActivity = activity || pane.activity;const asking = paneActivity === "asking";return (@@ -226,15 +92,25 @@ export function PaneChat({<MessageSquare className="h-4 w-4 shrink-0 text-primary" aria-hidden /><span className="font-mono text-xs font-semibold text-foreground">{terminal}</span><span className="min-w-0 flex-1 truncate text-sm text-muted-foreground">{agentLabel}</span>+ {pane.pollError && (+ <span+ role="status"+ data-testid="pane-chat-poll-error"+ title={pane.pollError}+ className="max-w-[18rem] truncate text-xs text-destructive"+ >+ {t("agentic_grid.pane_chat.load_failed")}+ </span>+ )}<buttontype="button"- onClick={state.reload}+ onClick={reload}title={t("agentic_grid.pane_chat.reload")}aria-label={t("agentic_grid.pane_chat.reload")}data-testid="pane-chat-reload"className="flex h-8 w-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground">- <RefreshCw className={cn("h-4 w-4", state.loading && "animate-spin")} aria-hidden />+ <RefreshCw className={cn("h-4 w-4", pane.loading && "animate-spin")} aria-hidden /></button><buttontype="button"@@ -266,301 +142,47 @@ export function PaneChat({</div>)}- <PaneChatBody- state={state}- terminal={terminal}- agentLabel={agentLabel}- providerLabel={providerLabel}- onDecide={noDecision}- onShowTerminal={onShowTerminal}- />-- {state.readable !== false && (- <div className="w-full max-w-[760px] self-center px-6 pb-5 pt-2">- <PaneComposer- terminal={terminal}- promptable={promptable}- onSent={state.reload}- hasContent={items.length > 0}- />- </div>- )}- </div>- );-}--function PaneChatBody({- state,- terminal,- agentLabel,- providerLabel,- onDecide,- onShowTerminal,-}: {- state: PaneTimelineState;- terminal: string;- agentLabel: string;- providerLabel: (id: string) => string;- onDecide: () => void;- onShowTerminal: () => void;-}) {- const t = useT();- const items = state.timeline.items;- const rootRef = useRef<HTMLDivElement | null>(null);- // Follow the conversation unless the person scrolled up to read: the- // column sticks to its end while it is at the end, and stays put otherwise.- const stickRef = useRef(true);- const lastId = items[items.length - 1]?.id ?? null;- const lastCount = useMemo(() => {- const last = items[items.length - 1];- return last && last.type === "turn" ? last.blocks.length : 0;- }, [items]);-- useLayoutEffect(() => {- const viewport = viewportOf(rootRef.current);- if (!viewport || !stickRef.current) return;- viewport.scrollTop = viewport.scrollHeight;- }, [lastId, lastCount, terminal]);-- useEffect(() => {- stickRef.current = true;- }, [terminal]);-- const onScroll = useCallback(() => {- const viewport = viewportOf(rootRef.current);- if (!viewport) return;- const gap = viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight;- stickRef.current = gap < 80;- }, []);-- if (state.readable === false) {- return (- <Empty- icon={<SquareTerminal className="h-5 w-5 text-muted-foreground" aria-hidden />}- title={t("agentic_grid.pane_chat.not_readable_title")}- detail={t("agentic_grid.pane_chat.not_readable_detail")}- testId="pane-chat-not-readable"- >- <button- type="button"- onClick={onShowTerminal}- className="mt-4 inline-flex h-9 items-center gap-2 rounded-lg border border-border px-3 text-xs font-medium text-foreground transition-colors hover:bg-muted"+ {pane.readable === false ? (+ <div+ className="flex flex-1 flex-col items-center justify-center px-6 text-center"+ data-testid="pane-chat-not-readable">- <SquareTerminal className="h-3.5 w-3.5" aria-hidden />- {t("agentic_grid.pane_chat.show_terminal")}- </button>- </Empty>- );- }-- if (state.loading) {- return (- <div className="mx-auto w-full max-w-[760px] flex-1 space-y-4 overflow-hidden px-6 py-8" data-testid="pane-chat-loading">- {["w-2/3", "w-full", "w-5/6", "w-1/2", "w-full", "w-4/5"].map((width, row) => (- <div key={row} className={cn("h-3 animate-pulse rounded bg-muted/70", width)} />- ))}- </div>- );- }-- if (state.error && items.length === 0) {- return (- <Empty- icon={<CircleAlert className="h-5 w-5 text-destructive" aria-hidden />}- title={t("agentic_grid.pane_chat.load_failed")}- detail={state.error}- testId="pane-chat-error"- >- <button- type="button"- onClick={state.reload}- className="mt-4 inline-flex h-9 items-center gap-2 rounded-lg border border-border px-3 text-xs font-medium text-foreground transition-colors hover:bg-muted"+ <div className="mb-4 flex h-12 w-12 items-center justify-center rounded-2xl border border-border bg-muted/30">+ <SquareTerminal className="h-5 w-5 text-muted-foreground" aria-hidden />+ </div>+ <p className="text-sm font-medium text-foreground">+ {t("agentic_grid.pane_chat.not_readable_title")}+ </p>+ <p className="mt-1 max-w-sm text-xs leading-relaxed text-muted-foreground">+ {t("agentic_grid.pane_chat.not_readable_detail")}+ </p>+ <button+ type="button"+ onClick={onShowTerminal}+ className="mt-4 inline-flex h-9 items-center gap-2 rounded-lg border border-border px-3 text-xs font-medium text-foreground transition-colors hover:bg-muted"+ >+ <SquareTerminal className="h-3.5 w-3.5" aria-hidden />+ {t("agentic_grid.pane_chat.show_terminal")}+ </button>+ </div>+ ) : pane.loading ? (+ <div+ className="mx-auto w-full max-w-[760px] flex-1 space-y-4 overflow-hidden px-6 py-8"+ data-testid="pane-chat-loading">- <RefreshCw className="h-3.5 w-3.5" aria-hidden />- {t("agentic_grid.pane_chat.retry")}- </button>- </Empty>- );- }-- if (!state.available || items.length === 0) {- return (- <Empty- icon={<MessageSquare className="h-5 w-5 text-muted-foreground" aria-hidden />}- title={t("agentic_grid.pane_chat.waiting_title")}- detail={t("agentic_grid.pane_chat.waiting_detail")}- testId="pane-chat-waiting"- />- );- }-- return (- <ScrollArea ref={rootRef} className="min-h-0 w-full flex-1" onScrollCapture={onScroll}>- <div- className="relative mx-auto flex w-full max-w-[760px] flex-col gap-5 px-6 pb-6 pt-8"- data-testid="pane-chat-timeline"- >- <AgentTimeline- items={items}- assistantName={agentLabel}- providerLabel={providerLabel}- onDecide={onDecide}- />- </div>- </ScrollArea>- );-}--function Empty({- icon,- title,- detail,- testId,- children,-}: {- icon: React.ReactNode;- title: string;- detail: string;- testId: string;- children?: React.ReactNode;-}) {- return (- <div- className="flex flex-1 flex-col items-center justify-center px-6 text-center"- data-testid={testId}- >- <div className="mb-4 flex h-12 w-12 items-center justify-center rounded-2xl border border-border bg-muted/30">- {icon}- </div>- <p className="text-sm font-medium text-foreground">{title}</p>- <p className="mt-1 max-w-sm text-xs leading-relaxed text-muted-foreground">{detail}</p>- {children}- </div>- );-}--/**- * The stage's composer: what is written is typed into the pane, as written.- *- * The same card the agent chat's composer draws — border, radius, shadow, the- * arrow — minus the picks that make no sense for a PTY (provider, model,- * effort, permission mode: the CLI in the pane decided those when it- * started). Enter sends, Shift+Enter breaks the line, like every chat.- */-function PaneComposer({- terminal,- promptable,- onSent,- hasContent,-}: {- terminal: string;- promptable: boolean;- onSent: () => void;- hasContent: boolean;-}) {- const t = useT();- const [value, setValue] = useState("");- const [busy, setBusy] = useState(false);- const [notice, setNotice] = useState<{ tone: "error" | "warning"; text: string } | null>(null);- const canSend = promptable && !busy && value.trim().length > 0;-- const send = useCallback(async () => {- const text = value.trim();- if (!text || busy || !promptable) return;- setBusy(true);- setNotice(null);- try {- // Verbatim: `compose` off. A brief written FOR the person belongs to the- // voice path; here the person is talking to the agent themselves.- const result = await promptTerminal(terminal, text, { compose: false });- setValue("");- if (result.submitted === false) {- setNotice({- tone: "warning",- text: t("agentic_grid.pane_chat.not_taken")- .replace("{0}", terminal)- .replace("{1}", result.detail ?? ""),- });- }- onSent();- } catch (reason: unknown) {- setNotice({- tone: "error",- text: t("agentic_grid.pane_chat.send_failed")- .replace("{0}", terminal)- .replace("{1}", reason instanceof Error ? reason.message : String(reason)),- });- } finally {- setBusy(false);- }- }, [value, busy, promptable, terminal, onSent, t]);-- const onKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {- if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {- e.preventDefault();- void send();- }- };-- return (- <div- data-testid="pane-chat-composer"- className={cn(- "relative flex flex-col gap-2 rounded-2xl border border-border bg-card p-3 shadow-[0_1px_2px_rgb(var(--scrim-rgb)/0.05),0_8px_24px_rgb(var(--scrim-rgb)/0.06)] transition-[border-color,box-shadow]",- "focus-within:border-primary/40",+ {["w-2/3", "w-full", "w-5/6", "w-1/2", "w-full", "w-4/5"].map((width, row) => (+ <div key={row} className={cn("h-3 animate-pulse rounded bg-muted/70", width)} />+ ))}+ </div>+ ) : (+ // The front page's chat, on the pane's store: the same stage, the same+ // timeline, the same composer with its pills. An empty transcript is+ // the same empty page a fresh chat shows — the folder's name and the+ // composer in the middle — which is what "nothing said yet" looks like.+ <AgentChatStoreProvider store={store}>+ <ChatStage />+ </AgentChatStoreProvider>)}- >- <textarea- data-jarvis-chat-input=""- autoFocus={!hasContent}- value={value}- onChange={(e) => setValue(e.target.value)}- onKeyDown={onKeyDown}- placeholder={- promptable- ? t("agentic_grid.pane_chat.placeholder").replace("{0}", terminal)- : t("agentic_grid.pane_chat.not_promptable")- }- disabled={!promptable}- rows={2}- className="max-h-48 w-full resize-none bg-transparent px-1 py-1 text-[15px] leading-relaxed text-foreground placeholder:text-muted-foreground focus-visible:outline-none disabled:opacity-50"- />- <div className="flex items-center gap-2">- <span className="min-w-0 flex-1 truncate px-1 text-xs text-muted-foreground" role="status">- {busy- ? t("agentic_grid.pane_chat.sending")- : notice && (- <span- data-testid={`pane-chat-notice-${notice.tone}`}- className={cn(notice.tone === "error" ? "text-destructive" : "text-foreground")}- >- {notice.text}- </span>- )}- </span>- <button- type="button"- onClick={() => void send()}- disabled={!canSend}- aria-label={t("agentic_grid.pane_chat.send").replace("{0}", terminal)}- title={t("agentic_grid.pane_chat.send").replace("{0}", terminal)}- data-testid="pane-chat-send"- className={cn(- "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition-colors",- canSend- ? "bg-primary text-primary-foreground hover:bg-primary/90"- : "bg-secondary text-muted-foreground/60",- )}- >- <ArrowUp className="h-4 w-4" />- </button>- </div></div>);}--/** Radix renders the scrolling element as the viewport inside our ScrollArea root. */-function viewportOf(root: HTMLElement | null): HTMLElement | null {- if (!root) return null;- return (root.querySelector("[data-radix-scroll-area-viewport]") as HTMLElement | null) ?? root;-}diff --git a/jarvis/ui/web/frontend/src/components/agentic/ViewSwitch.tsx b/jarvis/ui/web/frontend/src/components/agentic/ViewSwitch.tsxdeleted file mode 100644index 9a902351a6..0000000000--- a/jarvis/ui/web/frontend/src/components/agentic/ViewSwitch.tsx+++ /dev/null@@ -1,96 +0,0 @@-import { LayoutGrid, MessageSquare } from "lucide-react";--import { cn } from "@/lib/utils";-import { useT } from "@/i18n";-import type { WorkspaceView } from "@/components/agentic/workspaceView";--/**- * `Chat | Grid` — the Agentic IDE's one switch, at the top of the view.- *- * A segmented control in a pill rather than two toolbar glyphs, because the- * two halves are no longer two ways of LOOKING at the same thing: since- * 2026-08-24 they are two surfaces. Grid is the wall of terminals; Chat is the- * agent chat, in this workspace's folder. A control that switches what the- * page IS has to say so in words — an icon pair asks the user to remember- * which glyph meant which surface.- *- * Chat sits first, matching the maintainer's sketch and the reading order of- * the sidebar underneath it, which is chats in chat mode.- */-export function ViewSwitch({- view,- onView,- className,-}: {- view: WorkspaceView;- onView: (next: WorkspaceView) => void;- className?: string;-}) {- const t = useT();- return (- <div- role="tablist"- aria-label={t("agentic_grid.view_switch.hint")}- data-testid="agentic-view-switch"- className={cn(- "flex shrink-0 items-center gap-0.5 rounded-full border border-border bg-secondary p-0.5",- className,- )}- >- <ViewTab- active={view === "chat"}- onClick={() => onView("chat")}- icon={<MessageSquare aria-hidden className="h-3.5 w-3.5" />}- label={t("agentic_grid.view_switch.chat")}- title={t("agentic_grid.view_switch.chat_hint")}- testId="agentic-view-mode-toggle"- />- <ViewTab- active={view === "grid"}- onClick={() => onView("grid")}- icon={<LayoutGrid aria-hidden className="h-3.5 w-3.5" />}- label={t("agentic_grid.view_switch.grid")}- title={t("agentic_grid.view_switch.grid_hint")}- testId="agentic-view-mode-grid"- />- </div>- );-}--function ViewTab({- active,- onClick,- icon,- label,- title,- testId,-}: {- active: boolean;- onClick: () => void;- icon: React.ReactNode;- label: string;- title: string;- testId: string;-}) {- return (- <button- type="button"- role="tab"- aria-selected={active}- aria-pressed={active}- data-testid={testId}- onClick={onClick}- title={title}- className={cn(- "flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-medium transition-colors",- "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",- active- ? "bg-card text-foreground shadow-sm"- : "text-muted-foreground hover:text-foreground",- )}- >- {icon}- {label}- </button>- );-}diff --git a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceChats.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceChats.test.tsxindex ba01c5f4b4..643985094e 100644--- a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceChats.test.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceChats.test.tsx@@ -1,35 +1,18 @@+/**+ * The sidebar's chat face: every open workspace as a band — number, folder,+ * sessions, a way to open one more — the active one marked, and every click+ * travelling through the store to the view that performs it.+ */import { cleanup, fireEvent, render, screen } from "@testing-library/react";-import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { afterEach, beforeEach, describe, expect, it } from "vitest";-import { WorkspaceChats, groupByFolder } from "@/components/agentic/WorkspaceChats";-import { useAgentSessionStore } from "@/store/agentChat";+import { WorkspaceChats } from "@/components/agentic/WorkspaceChats";import { useIdeChatStore } from "@/store/ideChat";-import {- resetWorkspacePanesPoll,- useWorkspacePanesStore,-} from "@/store/workspacePanes";-import type { AgentChatSession } from "@/lib/agentChatApi";+import { resetWorkspacePanesPoll, useWorkspacePanesStore } from "@/store/workspacePanes";import type { WorkspacePaneRow } from "@/lib/agenticIdeApi";const HERE = "C:\\Users\\dev\\Personal Jarvis";-const THERE = "C:\\Users\\dev\\AiGrokAgents";--function chat(id: string, title: string, cwd: string, updated: number): AgentChatSession {- return {- session_id: id,- title,- provider: "claude-cli",- model: "",- effort: "",- cwd,- permission_mode: "acceptEdits",- vendor_session: null,- created_ms: updated - 100,- updated_ms: updated,- message_count: 2,- preview: title,- };-}+const THERE = "C:\\Users\\dev\\Jarvis Web UI";function pane(name: string,@@ -39,8 +22,8 @@ function pane(): WorkspacePaneRow {return {workspace_id: workspaceId,- workspace_name: "Personal Jarvis",- folder: HERE,+ workspace_name: workspaceId === "w1" ? "Personal Jarvis" : "Jarvis Web UI",+ folder: workspaceId === "w1" ? HERE : THERE,workspace_active: workspaceId === "w1",key: name,history_id: `${name}@${workspaceId}`,@@ -67,24 +50,14 @@ function pane(const PANES = [pane("T1", "Claude Code", "w1"),pane("T2", "Codex", "w1", "exited"),- // Another workspace's pane: it belongs to that tab's list, not this one.- pane("T9", "Elsewhere", "w2"),+ pane("T1", "Claude Code", "w2"),];-const SESSIONS = [- chat("a", "Restore Command Deck", HERE, 9_000),- chat("b", "Plan the marketing", HERE, 8_000),- chat("c", "Find five leads", THERE, 7_000),-];--const openSession = vi.fn();-const removeSession = vi.fn();-const setDraft = vi.fn();-const newChat = vi.fn();+const CLAUDE = { name: "claude", displayName: "Claude Code", installed: true, kind: "cli" as const };+const CODEX = { name: "codex", displayName: "Codex", installed: true, kind: "cli" as const };describe("the sidebar's chat face", () => {beforeEach(() => {- vi.clearAllMocks();resetWorkspacePanesPoll();useWorkspacePanesStore.setState({panes: PANES,@@ -96,122 +69,134 @@ describe("the sidebar's chat face", () => {});useIdeChatStore.setState({paneRequest: null,- stagedPane: null,+ terminalRequest: null,+ workspaceRequest: null,+ sessionRequest: null,+ addWorkspaceRequest: null,+ stagedPane: "T1",view: "chat",sidebarFace: "chats",workspace: { id: "w1", name: "Personal Jarvis", path: HERE },- });- useAgentSessionStore.setState({- sessions: SESSIONS,- activeSessionId: "a",- loadSessions: async () => {},- openSession,- removeSession: async (id: string) => {- removeSession(id);- },- newChat,- setDraft: async (patch) => {- setDraft(patch);- },+ workspaces: [+ { id: "w1", name: "Personal Jarvis", folder: HERE, active: true },+ { id: "w2", name: "Jarvis Web UI", folder: THERE, active: false },+ ],+ agents: [CLAUDE],});});afterEach(cleanup);- it("lists the coding sessions running in the open workspace", () => {- // The complaint this guards (maintainer, 2026-08-25): switching from the- // terminal grid to chat left the workspace's sessions behind, because this- // column knew only about chat sessions.+ it("draws every open workspace as a numbered band with its folder, the active one marked", () => {render(<WorkspaceChats />);- const rows = screen.getAllByTestId("workspace-session-row");- expect(rows.map((row) => row.dataset.pane)).toEqual(["T1", "T2"]);- expect(rows[0].textContent).toContain("Claude Code");- // Another workspace's pane belongs to that tab, not to this column.- expect(rows.map((row) => row.dataset.pane)).not.toContain("T9");+ const bands = screen.getAllByTestId("workspace-chats-band");+ expect(bands.map((b) => b.dataset.workspace)).toEqual(["w1", "w2"]);+ expect(bands[0].textContent).toContain("Workspace 1");+ expect(bands[1].textContent).toContain("Workspace 2");+ expect(bands[0].dataset.active).toBe("true");+ expect(bands[1].dataset.active).toBe("false");+ // The folder under the band, its full path within reach.+ const folders = screen.getAllByTestId("workspace-chats-folder");+ expect(folders[0].textContent).toContain("Personal Jarvis");+ expect(folders[0].getAttribute("title")).toBe(HERE);+ expect(folders[1].textContent).toContain("Jarvis Web UI");+ // One "Active" badge, on the tab at the front.+ expect(screen.getAllByTestId("workspace-chats-active")).toHaveLength(1);});- it("asks the view to bring the session that was clicked to the front", () => {+ it("lists each workspace's sessions under it, and marks the one on stage", () => {render(<WorkspaceChats />);- fireEvent.click(screen.getByText("Codex"));-- const asked = useIdeChatStore.getState().paneRequest;- expect(asked?.workspaceId).toBe("w1");- expect(asked?.pane).toBe("T2");+ const bands = screen.getAllByTestId("workspace-chats-band");+ const rowsOf = (band: HTMLElement) =>+ Array.from(band.querySelectorAll<HTMLElement>("[data-testid='workspace-session-row']"));+ expect(rowsOf(bands[0]).map((r) => r.dataset.pane)).toEqual(["T1", "T2"]);+ expect(rowsOf(bands[1]).map((r) => r.dataset.pane)).toEqual(["T1"]);+ // Every workspace numbers its panes from T1; only the ACTIVE workspace's+ // T1 is the pane on stage.+ expect(rowsOf(bands[0])[0].className).toContain("bg-card");+ expect(rowsOf(bands[1])[0].className).not.toContain("bg-card");});- it("marks the session the chat view has on stage", () => {- useIdeChatStore.setState({ stagedPane: "T2" });+ it("asks the view to bring the clicked session to the front, workspace and all", () => {render(<WorkspaceChats />);-- const rows = screen.getAllByTestId("workspace-session-row");- const staged = rows.find((row) => row.dataset.pane === "T2");- expect(staged?.className).toContain("bg-card");- expect(rows.find((row) => row.dataset.pane === "T1")?.className).not.toContain("bg-card");+ const bands = screen.getAllByTestId("workspace-chats-band");+ const row = bands[1].querySelector<HTMLElement>("[data-testid='workspace-session-row']")!;+ fireEvent.click(row);+ expect(useIdeChatStore.getState().paneRequest).toMatchObject({ workspaceId: "w2", pane: "T1" });});- it("puts the open workspace's folder first, its chats under it", () => {+ it("brings a workspace to the front from its folder row", () => {render(<WorkspaceChats />);-- const folders = screen- .getAllByTestId("workspace-chats-folder")- .map((node) => node.dataset.folder);- expect(folders[0]).toBe(HERE);- expect(folders).toContain(THERE);- expect(screen.getByText("Restore Command Deck")).toBeTruthy();- expect(screen.getByText("Find five leads")).toBeTruthy();+ fireEvent.click(screen.getAllByTestId("workspace-chats-folder")[1]);+ expect(useIdeChatStore.getState().workspaceRequest).toMatchObject({ workspaceId: "w2" });});- it("opens the chat that was clicked", () => {+ it("opens a terminal straight away when only one CLI is installed", () => {render(<WorkspaceChats />);-- fireEvent.click(screen.getByText("Plan the marketing"));-- expect(openSession).toHaveBeenCalledWith("b");+ fireEvent.click(screen.getByTestId("workspace-chats-new-terminal-w2"));+ expect(screen.queryByTestId("workspace-chats-agent-menu-w2")).toBeNull();+ expect(useIdeChatStore.getState().terminalRequest).toMatchObject({+ workspaceId: "w2",+ agent: undefined,+ });});- it("hands the navigation back through a button that says so", () => {+ it("asks which CLI first when the machine offers more than one", () => {+ useIdeChatStore.setState({ agents: [CLAUDE, CODEX] });render(<WorkspaceChats />);-- fireEvent.click(screen.getByTestId("workspace-chats-back"));-- expect(useIdeChatStore.getState().sidebarFace).toBe("sections");+ fireEvent.click(screen.getByTestId("workspace-chats-new-terminal-w1"));+ expect(useIdeChatStore.getState().terminalRequest).toBeNull();+ fireEvent.click(screen.getByTestId("workspace-chats-new-w1-codex"));+ expect(useIdeChatStore.getState().terminalRequest).toMatchObject({+ workspaceId: "w1",+ agent: "codex",+ });});- it("starts a new chat in the folder it was asked from", () => {+ /*+ * The menu must leave the column it was opened from.+ *+ * It used to hang INSIDE the list with a z-index of its own, which put the+ * picker's full-window dismiss layer on top of it: the entries were on+ * screen, every click on one hit that layer, and the menu closed without+ * opening anything. jsdom has no layout and so cannot see an overlap — what+ * it can check is the fact that rules it out, which is that the menu is+ * detached into a portal and owns its own stacking. The same detachment is+ * what keeps it from being clipped by the column's scroll box.+ */+ it("hangs the CLI menu outside the scrolling column", () => {+ useIdeChatStore.setState({ agents: [CLAUDE, CODEX] });render(<WorkspaceChats />);-- fireEvent.click(screen.getByTestId(`workspace-chats-new-in-${THERE}`));-- expect(newChat).toHaveBeenCalled();- expect(setDraft).toHaveBeenCalledWith({ cwd: THERE });+ fireEvent.click(screen.getByTestId("workspace-chats-new-terminal-w1"));+ const menu = screen.getByTestId("workspace-chats-agent-menu-w1");+ expect(menu.dataset.detached).toBe("true");+ expect(screen.getByTestId("workspace-chats").contains(menu)).toBe(false);});-});-describe("grouping chats by folder", () => {- it("names each group after the folder's last segment, on either platform", () => {- const groups = groupByFolder(SESSIONS, HERE);-- expect(groups[0].label).toBe("Personal Jarvis");- expect(groups[1].label).toBe("AiGrokAgents");- expect(groupByFolder([chat("x", "t", "/home/dev/site", 1)], "")[0].label).toBe("site");+ it("opens the launcher for one more workspace, folder and all", () => {+ render(<WorkspaceChats />);+ fireEvent.click(screen.getByTestId("workspace-chats-new-workspace"));+ expect(useIdeChatStore.getState().addWorkspaceRequest).toMatchObject({ nonce: 1 });});- it("shows the open workspace even before it has a single chat", () => {- // The column has to say where a new chat would land. A folder that appears- // only once it has history leaves a fresh workspace looking folderless.- const groups = groupByFolder([chat("c", "elsewhere", THERE, 5)], HERE);-- expect(groups[0].folder).toBe(HERE);- expect(groups[0].chats).toEqual([]);+ it("offers a session with no folder, last", () => {+ render(<WorkspaceChats />);+ fireEvent.click(screen.getByTestId("workspace-chats-new-session"));+ expect(useIdeChatStore.getState().sessionRequest).toMatchObject({ nonce: 1 });});- it("orders the other folders by the chat touched last", () => {- const older = chat("old", "older", "/a", 10);- const newer = chat("new", "newer", "/b", 900);- const groups = groupByFolder([older, newer], "");+ it("hands the navigation back through a button that says so", () => {+ render(<WorkspaceChats />);+ fireEvent.click(screen.getByTestId("workspace-chats-back"));+ expect(useIdeChatStore.getState().sidebarFace).toBe("sections");+ });- expect(groups.map((g) => g.folder)).toEqual(["/b", "/a"]);+ it("says so when nothing is open", () => {+ useIdeChatStore.setState({ workspaces: [] });+ render(<WorkspaceChats />);+ expect(screen.queryAllByTestId("workspace-chats-band")).toHaveLength(0);+ expect(screen.getByTestId("workspace-chats").textContent).toContain("No workspace is open");});});diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneRows.test.ts b/jarvis/ui/web/frontend/src/components/agentic/paneRows.test.tsdeleted file mode 100644index 517a9737f1..0000000000--- a/jarvis/ui/web/frontend/src/components/agentic/paneRows.test.ts+++ /dev/null@@ -1,33 +0,0 @@-import { describe, expect, it } from "vitest";-import type { TerminalRecap } from "@/lib/agenticIdeApi";-import { sameRows } from "./paneRows";--function recap(name: string, activity = "waiting"): TerminalRecap {- return {- key: name.toLowerCase(),- name,- status: "live",- recap: "Waiting for work",- recap_detail: "The terminal is ready.",- activity: activity as TerminalRecap["activity"],- activity_since: 10,- worked: true,- };-}--describe("recap poll equality", () => {- it("recognizes a repeated response", () => {- const current = { T1: recap("T1") };- expect(sameRows(current, { T1: { ...current.T1 } })).toBe(true);- });-- it("detects an activity transition", () => {- expect(sameRows({ T1: recap("T1") }, { T1: recap("T1", "working") })).toBe(false);- });-- it("detects a changed optional field even when both values are undefined", () => {- const before: Record<string, TerminalRecap> = { T1: { ...recap("T1"), note: undefined } };- const after: Record<string, TerminalRecap> = { T1: { ...recap("T1"), writer: undefined } };- expect(sameRows(before, after)).toBe(false);- });-});diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneRows.ts b/jarvis/ui/web/frontend/src/components/agentic/paneRows.tsdeleted file mode 100644index fec7e471b5..0000000000--- a/jarvis/ui/web/frontend/src/components/agentic/paneRows.ts+++ /dev/null@@ -1,36 +0,0 @@-/**- * Avoid repainting every terminal when a poll returns unchanged rows.- *- * Generic over the row type because two polls need it for the same reason:- * the recap poll (sentences, every 5s) and the activity poll (status words,- * every 1.5s) both replace a per-pane map on a timer inside a very large- * component, and a fresh-but-equal object every tick is a full re-render- * bought for nothing.- *- * This module was `chatState.ts` while the Agentic IDE read its terminals as a- * chat: it also held the rail's arrival order. That reading mode is gone — the- * IDE's chat is the agent chat now — and what is left is this one helper, so- * the file is named after what it actually does.- */-export function sameRows<T extends object>(- current: Readonly<Record<string, T>>,- next: Readonly<Record<string, T>>,-): boolean {- const currentNames = Object.keys(current);- const nextNames = Object.keys(next);- if (currentNames.length !== nextNames.length) return false;- return nextNames.every((name) => {- const before = current[name];- const after = next[name];- if (!before || !after) return false;- const beforeFields = Object.keys(before) as (keyof T)[];- const afterFields = Object.keys(after) as (keyof T)[];- if (- beforeFields.length !== afterFields.length ||- afterFields.some((field) => !Object.hasOwn(before, field))- ) {- return false;- }- return afterFields.every((field) => Object.is(before[field], after[field]));- });-}diff --git a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsxindex 1117ce564b..79bf1fe2b4 100644--- a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx+++ b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx@@ -151,10 +151,23 @@ export function Sidebar({const ideView = useIdeChatStore((s) => s.view);const ideSidebarFace = useIdeChatStore((s) => s.sidebarFace);const setIdeSidebarFace = useIdeChatStore((s) => s.setSidebarFace);- // No open workspace means the IDE is showing its wizard, not a chat — and a- // column of chats headed "This workspace" would be naming one that is not- // there.- const ideWorkspaceOpen = useIdeChatStore((s) => s.workspace !== null);+ /*+ * Is there anything for this column to list?+ *+ * Measured on the OPEN WORKSPACES, not on the active one. The two differ in+ * exactly one state and it is a state the user reaches on purpose: opening+ * one more workspace deactivates the front tab while the launcher asks for+ * a folder. Gated on the active workspace, the whole chat navigation+ * vanished at that moment and came back when the new workspace started —+ * so asking for a second project threw away the list of the first, which+ * reads as the sidebar breaking rather than a wizard opening.+ *+ * The old reading ("no workspace open means the wizard, not a chat") was+ * written when this column was headed "This workspace". It lists every open+ * workspace as its own band now, so it has something true to say for as+ * long as any of them is running.+ */+ const ideWorkspaceOpen = useIdeChatStore((s) => s.workspaces.length > 0);const onIdeSection = IDE_SECTIONS.includes(active);const chatFace =onIdeSection && ideWorkspaceOpen && ideView === "chat" && ideSidebarFace === "chats";diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex 8940fd521b..cb64ddb5e5 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -595,6 +595,12 @@"group_local": "Auf deiner eigenen Hardware","provider_connect": "verbinden","provider_not_installed": "nicht installiert",+ "provider_health_bad_key": "Schlüssel abgelehnt",+ "provider_health_no_credits": "Kein Guthaben",+ "provider_health_unreachable": "Nicht erreichbar",+ "provider_health_error": "Antwortet nicht",+ "provider_health_slow": "Zu langsam",+ "provider_health_ok": "Antwortet","model_default": "Standardmodell","effort_default": "Standard-Aufwand","effort_none": "Kein Nachdenken",@@ -4826,17 +4832,16 @@},"ide_chats": {"back_to_sections": "Bereiche",- "this_workspace": "Dieser Workspace",- "other_workspaces": "Andere Workspaces",- "new_session": "Neue Session",- "no_workspace": "Kein Workspace geöffnet.",- "no_sessions_here": "Noch keine Coding-Sessions in diesem Workspace",- "other_folders": "Andere Ordner",- "new_chat_here": "Neuer Chat hier",- "no_chats_here": "Noch keine Chats hier",- "running_sessions": "Coding-Sessions",- "session_here": "Läuft in diesem Workspace",- "show_more": "Mehr anzeigen"+ "workspace_band": "Workspace {n}",+ "active": "Aktiv",+ "no_folder": "Kein Ordner",+ "no_workspaces": "Kein Workspace ist geöffnet.",+ "no_sessions": "Noch keine Coding-Sitzungen hier",+ "new_terminal": "Neues Terminal hier",+ "pick_cli_title": "Terminal öffnen — womit?",+ "new_session": "Neue Sitzung — ein Workspace ohne Projektordner",+ "new_workspace": "Neuer Workspace — einen Projektordner wählen",+ "pick_cli_aria": "Was soll im neuen Terminal laufen?"},"agentic_grid": {"view_switch": {@@ -4956,22 +4961,14 @@"pane_chat": {"open": "{0} als Chat lesen","show_terminal": "Terminal zeigen",- "show_chat": "Chat zeigen","asking_title": "Der Agent fragt dich etwas","asking_detail": "Rückfragen und Berechtigungsanfragen beantwortest du im Terminal selbst.","not_readable_title": "Keine lesbare Aufzeichnung","not_readable_detail": "Dieses CLI führt keine Gesprächsdatei — es lässt sich nur als Terminal beobachten.",- "waiting_title": "Warten auf den ersten Austausch",- "waiting_detail": "Das Gespräch erscheint hier, sobald der Agent es aufgezeichnet hat.","load_failed": "Das Gespräch konnte nicht geladen werden.",- "retry": "Erneut versuchen","reload": "Gespräch neu laden",- "placeholder": "Nachricht an {0} — wird wörtlich ins Terminal getippt",- "send": "An {0} senden",- "sending": "Wird gesendet…",- "send_failed": "Senden an {0} fehlgeschlagen: {1}","not_taken": "{0} hat die Nachricht nicht angenommen: {1}",- "not_promptable": "Dieses Fenster nimmt keine getippten Nachrichten an."+ "pick_in_terminal": "{0}: Das entscheidet das CLI im Fenster — ändere es im Terminal."},"selection": {"start": "Terminals auswählen",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex 09326f24c6..0100b28f2e 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -595,6 +595,12 @@"group_local": "On your own hardware","provider_connect": "connect","provider_not_installed": "not installed",+ "provider_health_bad_key": "Key rejected",+ "provider_health_no_credits": "Out of credit",+ "provider_health_unreachable": "Unreachable",+ "provider_health_error": "Not answering",+ "provider_health_slow": "Too slow",+ "provider_health_ok": "Answering","model_default": "Default model","effort_default": "Default effort","effort_none": "No reasoning",@@ -4826,17 +4832,16 @@},"ide_chats": {"back_to_sections": "Sections",- "this_workspace": "This workspace",- "other_workspaces": "Other workspaces",- "new_session": "New session",- "no_workspace": "No workspace is open.",- "no_sessions_here": "No coding sessions in this workspace yet",- "other_folders": "Other folders",- "new_chat_here": "New chat here",- "no_chats_here": "No chats here yet",- "running_sessions": "Coding sessions",- "session_here": "Running in this workspace",- "show_more": "Show more"+ "workspace_band": "Workspace {n}",+ "active": "Active",+ "no_folder": "No folder",+ "no_workspaces": "No workspace is open.",+ "no_sessions": "No coding sessions here yet",+ "new_terminal": "New terminal here",+ "pick_cli_title": "Open a terminal — what?",+ "new_session": "New session — a workspace with no project folder",+ "new_workspace": "New workspace — pick a project folder",+ "pick_cli_aria": "What should run in the new terminal?"},"agentic_grid": {"view_switch": {@@ -4956,22 +4961,14 @@"pane_chat": {"open": "Read {0} as a chat","show_terminal": "Show terminal",- "show_chat": "Show chat","asking_title": "The agent is asking you something","asking_detail": "Questions and permission prompts are answered in the terminal itself.","not_readable_title": "No readable record","not_readable_detail": "This CLI keeps no conversation file, so it can only be watched as a terminal.",- "waiting_title": "Waiting for the first exchange",- "waiting_detail": "The conversation appears here as soon as the agent has recorded it.","load_failed": "The conversation could not be loaded.",- "retry": "Try again","reload": "Reload the conversation",- "placeholder": "Message {0} — typed into the terminal as written",- "send": "Send to {0}",- "sending": "Sending…",- "send_failed": "Could not send to {0}: {1}","not_taken": "{0} did not take the message: {1}",- "not_promptable": "This pane does not take typed messages."+ "pick_in_terminal": "{0}: the CLI in the pane decides this — change it in the terminal."},"selection": {"start": "Select terminals",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex 7c3f017a34..0656636315 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -595,6 +595,12 @@"group_local": "En tu propio hardware","provider_connect": "conectar","provider_not_installed": "no instalado",+ "provider_health_bad_key": "Clave rechazada",+ "provider_health_no_credits": "Sin saldo",+ "provider_health_unreachable": "Inaccesible",+ "provider_health_error": "No responde",+ "provider_health_slow": "Demasiado lento",+ "provider_health_ok": "Responde","model_default": "Modelo predeterminado","effort_default": "Esfuerzo predeterminado","effort_none": "Sin razonamiento",@@ -4826,17 +4832,16 @@},"ide_chats": {"back_to_sections": "Secciones",- "this_workspace": "Este espacio de trabajo",- "other_workspaces": "Otros espacios de trabajo",- "new_session": "Nueva sesión",- "no_workspace": "No hay ningún espacio de trabajo abierto.",- "no_sessions_here": "Aún no hay sesiones de programación en este espacio de trabajo",- "other_folders": "Otras carpetas",- "new_chat_here": "Nuevo chat aquí",- "no_chats_here": "Aún no hay chats aquí",- "running_sessions": "Sesiones de código",- "session_here": "En ejecución en este workspace",- "show_more": "Mostrar más"+ "workspace_band": "Workspace {n}",+ "active": "Activo",+ "no_folder": "Sin carpeta",+ "no_workspaces": "No hay ningún workspace abierto.",+ "no_sessions": "Aún no hay sesiones de código aquí",+ "new_terminal": "Nuevo terminal aquí",+ "pick_cli_title": "Abrir un terminal — ¿con qué?",+ "new_session": "Nueva sesión — un workspace sin carpeta de proyecto",+ "new_workspace": "Nuevo workspace — elegir una carpeta de proyecto",+ "pick_cli_aria": "¿Qué debe ejecutarse en el nuevo terminal?"},"agentic_grid": {"view_switch": {@@ -4956,22 +4961,14 @@"pane_chat": {"open": "Leer {0} como chat","show_terminal": "Mostrar terminal",- "show_chat": "Mostrar chat","asking_title": "El agente te está preguntando algo","asking_detail": "Las preguntas y solicitudes de permiso se responden en el propio terminal.","not_readable_title": "Sin registro legible","not_readable_detail": "Esta CLI no guarda un archivo de conversación, así que solo puede verse como terminal.",- "waiting_title": "Esperando el primer intercambio",- "waiting_detail": "La conversación aparece aquí en cuanto el agente la haya registrado.","load_failed": "No se pudo cargar la conversación.",- "retry": "Reintentar","reload": "Recargar la conversación",- "placeholder": "Mensaje para {0} — se escribe en el terminal tal cual",- "send": "Enviar a {0}",- "sending": "Enviando…",- "send_failed": "No se pudo enviar a {0}: {1}","not_taken": "{0} no aceptó el mensaje: {1}",- "not_promptable": "Este panel no acepta mensajes escritos."+ "pick_in_terminal": "{0}: lo decide la CLI del panel — cámbialo en el terminal."},"selection": {"start": "Seleccionar terminales",diff --git a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.tsindex 5627feea30..36bbff207b 100644--- a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts+++ b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts@@ -734,6 +734,10 @@ export interface TerminalTimelineResponse {live: boolean;activity: PaneActivity;events: AgentChatEvent[];+ /** What the pane runs on, by the CLI's own account — the composer's pills. */+ model: string;+ effort: string;+ permission_mode: string;}export function fetchTerminalTimeline(@@ -746,6 +750,19 @@ export function fetchTerminalTimeline();}+/**+ * Press Escape in the pane — the chat stage's Stop. The CLI ends its turn and+ * comes back to its prompt; nothing is closed.+ */+export async function interruptTerminal(name: string, workspaceId?: string): Promise<void> {+ const query = workspaceId ? `?workspace=${encodeURIComponent(workspaceId)}` : "";+ const res = await fetch(+ `/api/agentic-ide/terminals/${encodeURIComponent(name)}/interrupt${query}`,+ { method: "POST" },+ );+ if (!res.ok) throw new Error(await detail(res));+}+/*** One coding session running in a workspace — a line, not a workspace state.*diff --git a/jarvis/ui/web/frontend/src/store/ideChat.ts b/jarvis/ui/web/frontend/src/store/ideChat.tsindex 9b66a852e0..bae46e8d35 100644--- a/jarvis/ui/web/frontend/src/store/ideChat.ts+++ b/jarvis/ui/web/frontend/src/store/ideChat.ts@@ -5,6 +5,7 @@ import {storedViewMode,type WorkspaceView,} from "@/components/agentic/workspaceView";+import type { SplitAgentChoice } from "@/components/agentic/AgentPicker";/*** Which face the Agentic IDE is wearing, for everyone who has to know.@@ -52,11 +53,59 @@ export interface PaneRequest {nonce: number;}+/**+ * One open workspace, as the sidebar's session list draws it: a numbered+ * band, its folder, and whether it is the tab at the front. Published by the+ * IDE view from the same list the workspace bar draws, so the two agree.+ */+export interface IdeWorkspaceRow {+ id: string;+ name: string;+ /** Absolute project folder; "" for a workspace with no folder. */+ folder: string;+ active: boolean;+}++/**+ * The sidebar asking for a new terminal in one workspace.+ *+ * `agent` is the CLI picked from the menu, or undefined when the machine+ * offers no choice; the IDE view opens it — switching workspace first when+ * the ask names another tab — because the grid's own "open a pane" lives+ * inside the view and the sidebar cannot reach it by props.+ */+export interface TerminalRequest {+ workspaceId: string;+ agent?: string;+ nonce: number;+}+interface IdeChatStore {view: WorkspaceView;workspace: IdeWorkspace | null;sidebarFace: IdeSidebarFace;paneRequest: PaneRequest | null;+ /** Every open workspace, in the bar's order — the sidebar's bands. */+ workspaces: IdeWorkspaceRow[];+ /** The CLIs a new terminal can run, as the grid's split menus offer them. */+ agents: SplitAgentChoice[];+ terminalRequest: TerminalRequest | null;+ /** A workspace the sidebar asked to bring to the front (its folder row). */+ workspaceRequest: { workspaceId: string; nonce: number } | null;+ /** The sidebar asking for a workspace with no project folder (a scratch session). */+ sessionRequest: { nonce: number } | null;+ /**+ * The sidebar asking to open ANOTHER workspace — folder and all.+ *+ * The session list is the whole navigation while chat mode is on, and it+ * offered exactly two ways forward: another terminal inside a workspace+ * that already exists, or a folderless scratch session. "Open a second+ * project" was reachable only from the workspace bar above the grid, which+ * is the surface chat mode replaces — so from where the user sits a new+ * workspace could not be started at all (maintainer report 2026-08-27).+ * The view answers this with the same launcher its own "+" opens.+ */+ addWorkspaceRequest: { nonce: number } | null;/*** The pane the chat view currently has on its stage, or null in grid view.*@@ -72,6 +121,15 @@ interface IdeChatStore {/** Bring a pane to the front, switching workspace first when it lives elsewhere. */requestPane: (workspaceId: string, pane: string) => void;setStagedPane: (pane: string | null) => void;+ setWorkspaces: (rows: IdeWorkspaceRow[]) => void;+ setAgents: (agents: SplitAgentChoice[]) => void;+ /** Open a new terminal in `workspaceId`, running `agent` when one was picked. */+ requestTerminal: (workspaceId: string, agent?: string) => void;+ /** Bring `workspaceId`'s tab to the front. */+ requestWorkspace: (workspaceId: string) => void;+ requestSession: () => void;+ /** Open the launcher for one more workspace — the bar's "+", from the sidebar. */+ requestAddWorkspace: () => void;}export const useIdeChatStore = create<IdeChatStore>((set) => ({@@ -80,6 +138,12 @@ export const useIdeChatStore = create<IdeChatStore>((set) => ({sidebarFace: "chats",paneRequest: null,stagedPane: null,+ workspaces: [],+ agents: [],+ terminalRequest: null,+ workspaceRequest: null,+ sessionRequest: null,+ addWorkspaceRequest: null,setView: (next) => {rememberViewMode(next);@@ -99,4 +163,39 @@ export const useIdeChatStore = create<IdeChatStore>((set) => ({// Guarded: the grid publishes this from an effect that runs on every poll,// and an unconditional set would wake every subscriber each time.set((state) => (state.stagedPane === pane ? state : { stagedPane: pane })),+ setWorkspaces: (rows) =>+ set((state) => (sameRows(state.workspaces, rows) ? state : { workspaces: rows })),+ setAgents: (agents) => set({ agents }),+ requestTerminal: (workspaceId, agent) =>+ set((state) => ({+ terminalRequest: {+ workspaceId,+ agent,+ nonce: (state.terminalRequest?.nonce ?? 0) + 1,+ },+ })),+ requestWorkspace: (workspaceId) =>+ set((state) => ({+ workspaceRequest: { workspaceId, nonce: (state.workspaceRequest?.nonce ?? 0) + 1 },+ })),+ requestSession: () =>+ set((state) => ({ sessionRequest: { nonce: (state.sessionRequest?.nonce ?? 0) + 1 } })),+ requestAddWorkspace: () =>+ set((state) => ({+ addWorkspaceRequest: { nonce: (state.addWorkspaceRequest?.nonce ?? 0) + 1 },+ })),}));++/** The IDE view republishes on every render of its list; equal rows are no change. */+function sameRows(left: IdeWorkspaceRow[], right: IdeWorkspaceRow[]): boolean {+ if (left.length !== right.length) return false;+ return left.every((row, i) => {+ const other = right[i];+ return (+ row.id === other.id &&+ row.name === other.name &&+ row.folder === other.folder &&+ row.active === other.active+ );+ });+}diff --git a/jarvis/ui/web/frontend/src/store/paneChat.test.ts b/jarvis/ui/web/frontend/src/store/paneChat.test.tsnew file mode 100644index 0000000000..edade40894--- /dev/null+++ b/jarvis/ui/web/frontend/src/store/paneChat.test.ts@@ -0,0 +1,284 @@+/**+ * The pane store: a terminal wearing the agent chat's store.+ *+ * Pinned here: the poll's cadence follows the pane's state, an unchanged read+ * re-renders nothing, the transcript comes out as the chat's own turn under+ * the catalog's provider, the pills say what the pane runs on, sending types+ * verbatim into the pane and reads again, Stop presses Escape, and the picks a+ * pane cannot take from outside say where to take them.+ */+import { act } from "@testing-library/react";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";++import * as api from "@/lib/agenticIdeApi";+import type { AgentChatEvent } from "@/lib/agentChatApi";+import type { TerminalTimelineResponse } from "@/lib/agenticIdeApi";+import { useAgentSessionStore, type ProviderOption } from "@/store/agentChat";+import { useEventStore } from "@/store/events";+import {+ createPaneChatStore,+ eventsSignature,+ POLL_IDLE_MS,+ POLL_WORKING_MS,+ pollIntervalFor,+ providerForAgent,+} from "@/store/paneChat";++vi.mock("@/lib/agenticIdeApi", async (importOriginal) => ({+ ...(await importOriginal<typeof import("@/lib/agenticIdeApi")>()),+ fetchTerminalTimeline: vi.fn(),+ promptTerminal: vi.fn(),+ interruptTerminal: vi.fn(),+}));++const T0 = 1_787_800_000_000;++function ev(seq: number, kind: string, payload: Record<string, unknown>, at = 0): AgentChatEvent {+ return { seq, ts_ms: T0 + at, kind, payload };+}++/** One finished exchange, the way `agent_transcript.read_events` writes it. */+const EXCHANGE: AgentChatEvent[] = [+ ev(1, "user_message", { text: "Fix the login bug" }),+ ev(2, "turn_started", { turn_id: "turn-1", provider: "claude", model: "claude-opus-5", effort: "xhigh", runner: "cli" }, 1000),+ ev(3, "reasoning", { turn_id: "turn-1", message_id: "m1", text: "", duration_ms: 3500 }, 1000),+ ev(4, "assistant_text", { turn_id: "turn-1", message_id: "r1", text: "Looking at it now." }, 4500),+ ev(5, "tool_call", { turn_id: "turn-1", call_id: "call-1", name: "Read", input: { file_path: "src/login.ts" }, summary: "src/login.ts" }, 5000),+ ev(6, "tool_result", { turn_id: "turn-1", call_id: "call-1", output: "export const login = 1;", is_error: false, duration_ms: 2000 }, 7000),+ ev(7, "assistant_text", { turn_id: "turn-1", message_id: "r2", text: "Found it." }, 9000),+ ev(8, "turn_finished", { turn_id: "turn-1", status: "done", duration_ms: 8000, usage: { output_tokens: 80 }, error: null, cost_usd: null }, 9000),+];++const CLAUDE_CLI: ProviderOption = {+ id: "claude-api",+ label: "Anthropic Claude",+ family: "claude",+ runner: "claude-cli",+ models_source: "curated",+ curated_models: [{ id: "claude-opus-5", label: "Opus 5" }],+ default_model: "",+ effort_levels: ["low", "medium", "high", "xhigh"],+ default_effort: "high",+ permission_modes: [+ { id: "default", label: "Ask", description: "" },+ { id: "auto", label: "Auto", description: "" },+ ],+ default_permission_mode: "default",+ cli_installed: true,+ keyless: false,+ connected: true,+ active: false,+} as unknown as ProviderOption;++function answer(overrides: Partial<TerminalTimelineResponse> = {}): TerminalTimelineResponse {+ return {+ terminal: "T7",+ agent: "claude",+ readable: true,+ available: true,+ live: false,+ activity: "",+ events: EXCHANGE,+ model: "claude-opus-5",+ effort: "xhigh",+ permission_mode: "auto",+ ...overrides,+ };+}++function makeStore() {+ return createPaneChatStore({+ terminal: "T7",+ workspaceId: "ide_test",+ historyId: "t7@1",+ agent: "claude",+ displayName: "Claude Code",+ folder: "C:\\dev\\Personal Jarvis",+ });+}++async function flush() {+ await act(async () => {+ await Promise.resolve();+ await Promise.resolve();+ });+}++beforeEach(() => {+ vi.mocked(api.fetchTerminalTimeline).mockReset();+ vi.mocked(api.promptTerminal).mockReset();+ vi.mocked(api.interruptTerminal).mockReset();+ useAgentSessionStore.setState({+ providerOptions: () => [CLAUDE_CLI],+ providerById: (id: string) => (id === CLAUDE_CLI.id ? CLAUDE_CLI : null),+ loadCatalog: async () => {},+ loadHealth: async () => {},+ });+ useEventStore.setState({ toasts: [] });+});++afterEach(() => {+ vi.useRealTimers();+});++describe("pollIntervalFor", () => {+ it("reads quickly while the agent works and slowly once it stops", () => {+ expect(pollIntervalFor(true, "")).toBe(POLL_WORKING_MS);+ expect(pollIntervalFor(false, "working")).toBe(POLL_WORKING_MS);+ expect(pollIntervalFor(false, "starting")).toBe(POLL_WORKING_MS);+ expect(pollIntervalFor(false, "waiting")).toBe(POLL_IDLE_MS);+ expect(pollIntervalFor(false, "")).toBe(POLL_IDLE_MS);+ });+});++describe("eventsSignature", () => {+ it("tells a grown transcript from an unchanged one", () => {+ const same = eventsSignature(EXCHANGE, false);+ expect(eventsSignature([...EXCHANGE], false)).toBe(same);+ expect(eventsSignature(EXCHANGE.slice(0, -1), false)).not.toBe(same);+ expect(eventsSignature(EXCHANGE, true)).not.toBe(same);+ const grown = EXCHANGE.map((e) =>+ e.seq === 7 ? { ...e, payload: { ...e.payload, text: "Found it, and fixed it." } } : e,+ );+ expect(eventsSignature(grown, false)).not.toBe(same);+ });+});++describe("providerForAgent", () => {+ it("matches a pane's CLI to the catalog row that runs that binary", () => {+ expect(providerForAgent("claude", [CLAUDE_CLI])?.id).toBe("claude-api");+ expect(providerForAgent("codex", [CLAUDE_CLI])).toBeNull();+ expect(providerForAgent("", [CLAUDE_CLI])).toBeNull();+ });+});++describe("createPaneChatStore", () => {+ it("folds the transcript into the chat's turn, under the catalog provider", async () => {+ vi.mocked(api.fetchTerminalTimeline).mockResolvedValue(answer());+ const store = makeStore();+ store.getState().start();+ await flush();+ store.getState().stop();++ const s = store.getState();+ expect(api.fetchTerminalTimeline).toHaveBeenCalledWith("T7", "ide_test");+ expect(s.pane.loading).toBe(false);+ expect(s.timeline.items.map((i) => i.type)).toEqual(["user", "turn"]);+ const turn = s.timeline.items[1];+ expect(turn.type === "turn" && turn.provider).toBe("claude-api");+ expect(turn.type === "turn" && turn.status).toBe("done");+ // The pills say what the pane runs on, in the CLI's own words.+ expect(s.draft).toMatchObject({+ provider: "claude-api",+ model: "claude-opus-5",+ effort: "xhigh",+ permissionMode: "auto",+ cwd: "C:\\dev\\Personal Jarvis",+ });+ expect(s.activeSessionId).toBe("t7@1");+ expect(s.activeSession?.model).toBe("claude-opus-5");+ });++ it("types the sentence into the pane verbatim, with its files, and reads again", async () => {+ vi.mocked(api.fetchTerminalTimeline).mockResolvedValue(answer());+ vi.mocked(api.promptTerminal).mockResolvedValue({+ terminal: "T7",+ sent: "Now the tests",+ composed_by: "raw",+ files: [],+ submitted: true,+ });+ const store = makeStore();+ store.getState().start();+ await flush();+ const before = vi.mocked(api.fetchTerminalTimeline).mock.calls.length;++ const file = {+ name: "shot.png",+ reference: "@shot.png",+ kind: "image" as const,+ detail: "",+ described_by: "none" as const,+ note: "",+ };+ await store.getState().send("Now the tests", [file]);+ await flush();+ store.getState().stop();++ expect(api.promptTerminal).toHaveBeenCalledWith("T7", "Now the tests", {+ compose: false,+ attachments: [file],+ });+ expect(store.getState().busy).toBe(false);+ expect(store.getState().lastError).toBeNull();+ expect(vi.mocked(api.fetchTerminalTimeline).mock.calls.length).toBeGreaterThan(before);+ });++ it("says so when the pane did not take the message", async () => {+ vi.mocked(api.fetchTerminalTimeline).mockResolvedValue(answer());+ vi.mocked(api.promptTerminal).mockResolvedValue({+ terminal: "T7",+ sent: "hi",+ composed_by: "raw",+ files: [],+ submitted: false,+ detail: "still in the input box",+ });+ const store = makeStore();+ await store.getState().send("hi");+ const toasts = useEventStore.getState().toasts;+ expect(toasts.at(-1)?.message).toContain("T7 did not take the message: still in the input box");+ });++ it("Stop presses Escape in the pane", async () => {+ vi.mocked(api.fetchTerminalTimeline).mockResolvedValue(answer({ live: true }));+ vi.mocked(api.interruptTerminal).mockResolvedValue();+ const store = makeStore();+ await store.getState().cancel();+ expect(api.interruptTerminal).toHaveBeenCalledWith("T7", "ide_test");+ });++ it("a model pick is typed in as the CLI's own command; the other picks say where to go", async () => {+ vi.mocked(api.fetchTerminalTimeline).mockResolvedValue(answer());+ vi.mocked(api.promptTerminal).mockResolvedValue({+ terminal: "T7",+ sent: "/model claude-sonnet-5",+ composed_by: "raw",+ files: [],+ submitted: true,+ });+ const store = makeStore();+ store.getState().start();+ await flush();++ await store.getState().setDraft({ model: "claude-sonnet-5" });+ expect(api.promptTerminal).toHaveBeenCalledWith("T7", "/model claude-sonnet-5", { compose: false });+ expect(store.getState().draft.model).toBe("claude-sonnet-5");++ await store.getState().setDraft({ permissionMode: "default" });+ expect(store.getState().draft.permissionMode).toBe("auto");+ const toasts = useEventStore.getState().toasts;+ expect(toasts.at(-1)?.message).toContain("change it in the terminal");+ store.getState().stop();+ });++ it("keeps the column on one failed poll and re-polls on the working cadence", async () => {+ vi.useFakeTimers();+ vi.mocked(api.fetchTerminalTimeline).mockResolvedValueOnce(answer({ live: true }));+ const store = makeStore();+ store.getState().start();+ await flush();+ expect(store.getState().timeline.items).toHaveLength(2);++ vi.mocked(api.fetchTerminalTimeline).mockRejectedValueOnce(new Error("offline"));+ await act(async () => {+ vi.advanceTimersByTime(POLL_WORKING_MS);+ await Promise.resolve();+ await Promise.resolve();+ });+ expect(store.getState().timeline.items).toHaveLength(2);+ expect(store.getState().pane.pollError).toBe("offline");+ expect(api.fetchTerminalTimeline).toHaveBeenCalledTimes(2);+ store.getState().stop();+ });+});diff --git a/jarvis/ui/web/frontend/src/store/paneChat.ts b/jarvis/ui/web/frontend/src/store/paneChat.tsnew file mode 100644index 0000000000..33c9584826--- /dev/null+++ b/jarvis/ui/web/frontend/src/store/paneChat.ts@@ -0,0 +1,433 @@+import { create } from "zustand";++import {+ EMPTY_TIMELINE,+ reduceEvent,+ reduceEvents,+ type Timeline,+ type TimelineItem,+} from "@/components/agentchat/reduce";+import {+ fetchTerminalTimeline,+ interruptTerminal,+ promptTerminal,+ type PaneActivity,+ type TerminalTimelineResponse,+} from "@/lib/agenticIdeApi";+import type {+ AgentChatCatalog,+ AgentChatEvent,+ AgentChatSession,+ ChatAttachment,+} from "@/lib/agentChatApi";+import {+ useAgentSessionStore,+ type AgentChatStore,+ type ComposerDraft,+ type ProviderOption,+} from "@/store/agentChat";+import { useEventStore } from "@/store/events";+import { translate } from "@/i18n";++/**+ * A terminal pane wearing the agent chat's store — what the chat stage runs on.+ *+ * The Agentic IDE's chat stage draws ONE pane with the front page's exact+ * chat: `ChatStage`, its timeline, its composer with the provider, model,+ * effort and permission pills (maintainer, 2026-08-26: the interface we+ * built, not a plain box). Those components read an `AgentChatStore` through+ * `AgentChatStoreProvider`, so a pane gets a store of that shape — this one —+ * with the pane's own answers behind every field:+ *+ * * the timeline is the CLI's transcript, polled and folded through the same+ * reducer as a chat session's event log (`GET /terminals/{name}/timeline`);+ * * the draft's pills say what the pane RUNS ON, in the CLI's own words —+ * the model and effort of its last reply, the permission stance its record+ * declares — where a session the chat runs itself shows its picks;+ * * `send` types the sentence into the pane, verbatim, with the files that+ * went with it; `cancel` presses Escape there.+ *+ * What a pane cannot do is switch what it runs on from outside: the CLI in+ * the pane chose its provider when it started and keeps its own controls for+ * the rest. A model pick is typed in as the CLI's own `/model` command where+ * the CLI has one; the other picks say where to change them instead of+ * pretending. The catalog, the connections and the model lists are the agent+ * store's — mirrored here so the pickers list what they always list.+ *+ * One store per staged pane, made by the stage and dropped with it.+ */++/** Poll cadence while the agent is working — a tool result every couple of seconds is what it produces. */+export const POLL_WORKING_MS = 2000;+/** Poll cadence once it has stopped — only a new message from elsewhere could change the file. */+export const POLL_IDLE_MS = 6000;++/** How soon the next read follows, from what the last one said about the pane. */+export function pollIntervalFor(live: boolean, activity: PaneActivity): number {+ return live || activity === "working" || activity === "starting"+ ? POLL_WORKING_MS+ : POLL_IDLE_MS;+}++/**+ * A cheap fingerprint of an event list, so an unchanged poll re-renders nothing.+ *+ * The file only ever grows, and a record is written whole (a finished block,+ * a tool result), so length plus the last event's identity plus the text+ * volume tells the two lists apart — without folding sixty turns to find out+ * that nothing happened.+ */+export function eventsSignature(events: AgentChatEvent[], live: boolean): string {+ const last = events[events.length - 1];+ let chars = 0;+ for (const ev of events) {+ const p = ev.payload;+ if (typeof p.text === "string") chars += p.text.length;+ if (typeof p.output === "string") chars += p.output.length;+ }+ return `${events.length}:${last?.seq ?? 0}:${last?.ts_ms ?? 0}:${last?.kind ?? ""}:${chars}:${live ? 1 : 0}`;+}++/**+ * Which catalog provider a pane's CLI is.+ *+ * By the RUNNER, not by a table of names: the catalog's CLI rows name the+ * binary they run (`claude-cli`, `codex-cli`, `agy-cli`, `grok-cli`), and a+ * pane names its agent the same way (`claude`, `codex`, `agy`, `grok`). A CLI+ * added later matches on the same rule.+ */+export function providerForAgent(+ agent: string,+ providers: readonly ProviderOption[],+): ProviderOption | null {+ const key = agent.trim().toLowerCase();+ if (!key) return null;+ const aliases = key === "antigravity" ? ["agy", "antigravity"] : [key];+ return (+ providers.find((p) =>+ aliases.some((a) => p.runner === `${a}-cli` || p.runner === a || p.id === a),+ ) ?? null+ );+}++/** The timeline with every turn's byline pointing at the catalog provider. */+function withProvider(timeline: Timeline, providerId: string): Timeline {+ if (!providerId) return timeline;+ const items: TimelineItem[] = timeline.items.map((item) =>+ item.type === "turn" && item.provider !== providerId ? { ...item, provider: providerId } : item,+ );+ return { ...timeline, items };+}++export interface PaneChatStoreOptions {+ terminal: string;+ workspaceId: string;+ /** The pane's lifetime id — the "session id" the chat components see. */+ historyId: string;+ agent: string;+ /** What the CLI is called — "Claude Code" — the session's title. */+ displayName: string;+ /** The workspace folder: the composer's folder chip and the empty page's headline. */+ folder: string;+}++export interface PaneChatState extends AgentChatStore {+ /** The pane's own facts, beside the chat store's fields. */+ pane: {+ terminal: string;+ workspaceId: string;+ agent: string;+ /** Null until the first answer; false is a settled "this CLI keeps no record". */+ readable: boolean | null;+ available: boolean;+ live: boolean;+ activity: PaneActivity;+ /** True until the first answer for this pane has arrived. */+ loading: boolean;+ /** The last failed read, "" while reads succeed. */+ pollError: string;+ };+ /** Read the transcript again now — the composer's send calls it. */+ reload: () => void;+ /** Start polling (the stage mounts) / stop (the stage unmounts). */+ start: () => void;+ stop: () => void;+}++export type PaneChatStoreHook = ReturnType<typeof createPaneChatStore>;++function toast(kind: "info" | "warning" | "error", message: string): void {+ useEventStore.getState().pushToast(kind, message);+}++export function createPaneChatStore(options: PaneChatStoreOptions) {+ const agentStore = useAgentSessionStore;+ let timer: number | null = null;+ let running = false;+ let signature = "";+ const lastReported = { model: "" };+ let unsubscribe: (() => void) | null = null;++ const mirror = () => {+ const src = agentStore.getState();+ return {+ catalog: src.catalog,+ connections: src.connections,+ catalogError: src.catalogError,+ backendOutdated: src.backendOutdated,+ liveModels: src.liveModels,+ health: src.health,+ };+ };++ const session = (patch: Partial<AgentChatSession> = {}): AgentChatSession => ({+ session_id: options.historyId,+ title: options.displayName,+ provider: "",+ model: "",+ effort: "",+ cwd: options.folder,+ permission_mode: "",+ surface: "agent",+ vendor_session: null,+ created_ms: 0,+ updated_ms: 0,+ message_count: 0,+ preview: "",+ running: false,+ ...patch,+ });++ const store = create<PaneChatState>((set, get) => {+ const providerId = () =>+ providerForAgent(options.agent, agentStore.getState().providerOptions())?.id ?? "";++ const apply = (res: TerminalTimelineResponse) => {+ const pid = providerId();+ // A model picked here is typed into the pane and shows up in the record+ // only with the CLI's next reply; until the record SAYS something new,+ // the pill keeps the pick rather than flipping back for a poll or two.+ const reportedBefore = lastReported.model;+ lastReported.model = res.model;+ const model = res.model !== reportedBefore ? res.model : get().draft.model || res.model;+ const next: Partial<PaneChatState> = {+ pane: {+ ...get().pane,+ readable: res.readable,+ available: res.available,+ live: res.live,+ activity: res.activity,+ loading: false,+ pollError: "",+ },+ draft: {+ ...get().draft,+ provider: pid,+ model,+ effort: res.effort,+ permissionMode: res.permission_mode,+ buildMode: res.permission_mode === "plan" ? get().draft.buildMode : res.permission_mode,+ },+ activeSession: session({+ provider: pid,+ model,+ effort: res.effort,+ permission_mode: res.permission_mode,+ running: res.live,+ }),+ };+ const sig = eventsSignature(res.events, res.live);+ if (sig !== signature) {+ signature = sig;+ next.timeline = withProvider(reduceEvents(EMPTY_TIMELINE, res.events), pid);+ }+ set(next);+ return pollIntervalFor(res.live, res.activity);+ };++ const tick = async () => {+ if (!running) return;+ let next = POLL_IDLE_MS;+ try {+ const res = await fetchTerminalTimeline(options.terminal, options.workspaceId);+ if (!running) return;+ next = apply(res);+ } catch (reason: unknown) {+ if (!running) return;+ // Keep what is on screen: a column that empties itself on one failed+ // poll would read as "the conversation is gone".+ set({+ pane: {+ ...get().pane,+ loading: false,+ pollError: reason instanceof Error ? reason.message : String(reason),+ },+ });+ }+ if (running) timer = window.setTimeout(() => void tick(), next);+ };++ const restart = () => {+ if (timer !== null) window.clearTimeout(timer);+ timer = null;+ if (running) void tick();+ };++ const cannotPick = (what: string) => {+ toast("info", translate("agentic_grid.pane_chat.pick_in_terminal").replace("{0}", what));+ };++ return {+ surface: "agent",+ ...mirror(),+ sessions: [],+ activeSessionId: options.historyId,+ activeSession: session(),+ timeline: EMPTY_TIMELINE,+ socketState: "open",+ draft: {+ provider: providerId(),+ model: "",+ effort: "",+ permissionMode: "",+ buildMode: "",+ cwd: options.folder,+ },+ busy: false,+ lastError: null,+ pane: {+ terminal: options.terminal,+ workspaceId: options.workspaceId,+ agent: options.agent,+ readable: null,+ available: false,+ live: false,+ activity: "",+ loading: true,+ pollError: "",+ },++ loadCatalog: async () => {+ await agentStore.getState().loadCatalog();+ set({ ...mirror(), draft: { ...get().draft, provider: providerId() } });+ },+ loadSessions: async () => undefined,+ loadModels: (id) => agentStore.getState().loadModels(id),+ loadHealth: async (refresh) => {+ await agentStore.getState().loadHealth(refresh);+ set(mirror());+ },+ providerOptions: () => agentStore.getState().providerOptions(),+ providerById: (id) => agentStore.getState().providerById(id),++ setDraft: async (patch: Partial<ComposerDraft>) => {+ // What the pane runs on is the CLI's to change. A model pick is typed+ // in where the CLI takes it as a command; everything else says where+ // to go rather than showing a pick the pane never received.+ if (patch.provider !== undefined && patch.provider !== get().draft.provider) {+ cannotPick(translate("agent_chat.pick_provider"));+ return;+ }+ if (patch.model !== undefined && patch.model !== get().draft.model) {+ if (options.agent === "claude" && patch.model) {+ try {+ await promptTerminal(options.terminal, `/model ${patch.model}`, { compose: false });+ set({ draft: { ...get().draft, model: patch.model } });+ get().reload();+ } catch (reason: unknown) {+ set({ lastError: reason instanceof Error ? reason.message : String(reason) });+ }+ } else {+ cannotPick(translate("agent_chat.pick_model"));+ }+ return;+ }+ if (patch.effort !== undefined && patch.effort !== get().draft.effort) {+ // The composer snaps an off-ladder effort to the nearest level on+ // its own; that is bookkeeping, not a pick, and gets no toast.+ const ladder = get().providerById(get().draft.provider)?.effort_levels ?? [];+ if (get().draft.effort && ladder.includes(get().draft.effort)) {+ cannotPick(translate("agent_chat.pick_effort"));+ }+ return;+ }+ if (+ patch.permissionMode !== undefined &&+ patch.permissionMode !== get().draft.permissionMode+ ) {+ cannotPick(translate("agent_chat.pick_permission"));+ return;+ }+ // `cwd` is the workspace's folder; a pane does not move.+ },+ setPlan: async () => {+ cannotPick(translate("agent_chat.plan"));+ },+ newChat: () => undefined,+ openSession: () => undefined,+ removeSession: async () => undefined,++ send: async (text: string, attachments: ChatAttachment[] = []) => {+ if (get().busy) return;+ set({ busy: true, lastError: null });+ try {+ // Verbatim: `compose` off. A brief written FOR the person belongs to+ // the voice path; here the person is talking to the agent themselves.+ const result = await promptTerminal(options.terminal, text, {+ compose: false,+ attachments,+ });+ if (result.submitted === false) {+ toast(+ "warning",+ translate("agentic_grid.pane_chat.not_taken")+ .replace("{0}", options.terminal)+ .replace("{1}", result.detail ?? ""),+ );+ }+ // The pane echoes the line before the CLI records it; polling+ // starts at once so the answer is seen forming.+ get().reload();+ } catch (reason: unknown) {+ set({ lastError: reason instanceof Error ? reason.message : String(reason) });+ } finally {+ set({ busy: false });+ }+ },+ cancel: async () => {+ try {+ await interruptTerminal(options.terminal, options.workspaceId);+ get().reload();+ } catch (reason: unknown) {+ set({ lastError: reason instanceof Error ? reason.message : String(reason) });+ }+ },+ // Approvals never come out of a transcript — the CLI asks in its own TUI.+ decide: async () => undefined,+ ingest: (event: AgentChatEvent) => set({ timeline: reduceEvent(get().timeline, event) }),+ disconnect: () => get().stop(),++ reload: restart,+ start: () => {+ if (running) return;+ running = true;+ unsubscribe = agentStore.subscribe(() => {+ set({ ...mirror(), draft: { ...get().draft, provider: providerId() } });+ });+ void tick();+ },+ stop: () => {+ running = false;+ if (timer !== null) window.clearTimeout(timer);+ timer = null;+ unsubscribe?.();+ unsubscribe = null;+ },+ };+ });++ return store;+}++/** Test seam: a catalog the mirror can read without a backend. */+export type { AgentChatCatalog };diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsxindex 9621fbf74b..f6ddee5167 100644--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx@@ -42,6 +42,10 @@ const launcherEnglish = vi.hoisted<Record<string, string>>(() => ({}));vi.mock("@/i18n", () => ({useT: () => (key: string) => launcherEnglish[key] ?? key,+ // The chat stage inside the grid reads these two as well.+ translate: (key: string) => launcherEnglish[key] ?? key,+ fill: (template: string, vars: Record<string, string | number>) =>+ template.replace(/\{(\w+)\}/g, (_m, name: string) => String(vars[name] ?? `{${name}}`)),}));// The workspace grid follows the app theme for its terminal colours; this test@@ -512,9 +516,13 @@ describe("Agentic IDE launcher", () => {expect(window.localStorage.getItem("jarvis.agenticIde.workspaceView"),).toBe("chat");- const rail = screen.getByTestId("agentic-chat-rail");- expect(rail.className).toContain("flex");- expect(rail.className).not.toContain("hidden");+ // Chat is the reading mode the workspace comes up in. The list of+ // sessions that used to sit in a rail beside the panes is the app+ // sidebar's now, which this view does not draw — so the claim is carried+ // by the switch itself.+ expect(+ screen.getByTestId("agentic-view-mode-toggle").getAttribute("aria-pressed"),+ ).toBe("true");});it("keeps every reading-mode miniature visible on the dark workspace", async () => {diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsxindex 8a275cf781..4013f98a54 100644--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx@@ -45,6 +45,7 @@ import {} from "@/components/agentic/paneDrop";import {activateWorkspace,+ addTerminal,attachToTerminal,closeWorkspace,endIdeSession,@@ -173,6 +174,12 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {const setView = useIdeChatStore((s) => s.setView);const publishWorkspace = useIdeChatStore((s) => s.setWorkspace);const paneRequest = useIdeChatStore((s) => s.paneRequest);+ const terminalRequest = useIdeChatStore((s) => s.terminalRequest);+ const workspaceRequest = useIdeChatStore((s) => s.workspaceRequest);+ const sessionRequest = useIdeChatStore((s) => s.sessionRequest);+ const addWorkspaceRequest = useIdeChatStore((s) => s.addWorkspaceRequest);+ const publishWorkspaces = useIdeChatStore((s) => s.setWorkspaces);+ const publishAgents = useIdeChatStore((s) => s.setAgents);// The registered subscriptions per CLI. Only ever used to OFFER a choice, so// a failed load costs the picker, never the wizard: with none loaded every// pane simply opens on the active account, exactly as before.@@ -693,6 +700,84 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {void jumpToPane(paneRequest.workspaceId, paneRequest.pane);}, [jumpToPane, paneRequest]);+ /*+ * The sidebar's session list draws every open workspace as a band — the+ * same list the workspace bar draws, with the folder and which tab is at+ * the front — and offers a new terminal under each, from the CLIs the+ * grid's own split menus offer. Both are published from here because this+ * view is the one place that holds them.+ */+ useEffect(() => {+ publishWorkspaces(+ onScreen+ ? workspaces.map((w) => ({+ id: w.id,+ name: w.name,+ folder: w.folder,+ active: session ? w.id === session.id : w.active,+ }))+ : [],+ );+ }, [onScreen, publishWorkspaces, workspaces, session]);+ useEffect(() => {+ publishAgents(splitChoices);+ }, [publishAgents, splitChoices]);++ /*+ * The sidebar asked for a new terminal in one workspace, or for one+ * workspace's tab. Switching first when the ask names another tab, the+ * way a pane request does; the grid then sees the new pane arrive and, in+ * chat view, puts it on the stage.+ */+ const lastTerminalRequest = useRef(0);+ useEffect(() => {+ if (!terminalRequest || terminalRequest.nonce === lastTerminalRequest.current) return;+ lastTerminalRequest.current = terminalRequest.nonce;+ const { workspaceId, agent } = terminalRequest;+ void (async () => {+ try {+ if (workspaceId !== session?.id) await switchTo(workspaceId);+ setSession(await addTerminal({ agent }));+ } catch (error) {+ pushToast("error", error instanceof Error ? error.message : String(error));+ }+ })();+ // `session` and `switchTo` are read at the moment of the ask, on purpose.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [terminalRequest]);+ const lastWorkspaceRequest = useRef(0);+ useEffect(() => {+ if (!workspaceRequest || workspaceRequest.nonce === lastWorkspaceRequest.current) return;+ lastWorkspaceRequest.current = workspaceRequest.nonce;+ if (workspaceRequest.workspaceId !== session?.id) void switchTo(workspaceRequest.workspaceId);+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [workspaceRequest]);+ // A workspace with no project folder, asked for from the sidebar's last row.+ const lastSessionRequest = useRef(0);+ useEffect(() => {+ if (!sessionRequest || sessionRequest.nonce === lastSessionRequest.current) return;+ lastSessionRequest.current = sessionRequest.nonce;+ void startSession();+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [sessionRequest]);+ /*+ * "Open one more workspace", asked for from the sidebar.+ *+ * The same act as the workspace bar's "+", performed by the same function,+ * because it must be the same thing: chat mode hides the bar behind its own+ * navigation, and a second, thinner "new workspace" reachable only from the+ * sidebar would be one more flow to keep in step with this one. The launcher+ * that comes up carries the folder picker, the pane count and the agents.+ */+ const lastAddWorkspaceRequest = useRef(0);+ useEffect(() => {+ if (!addWorkspaceRequest || addWorkspaceRequest.nonce === lastAddWorkspaceRequest.current)+ return;+ lastAddWorkspaceRequest.current = addWorkspaceRequest.nonce;+ void startAdding();+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [addWorkspaceRequest]);+/** A file dropped on a workspace TAB.*@@ -934,8 +1019,6 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {session={session}workspaceBar={renderBar(true)}appActions={<TopBarActions />}- onAddProject={() => void startAdding()}- onNewSession={() => void startSession()}onJumpToWorkspace={(id, pane) => void jumpToPane(id, pane)}jumpTo={jumpTo}focusMode={focusMode}