Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(ide): show pane titles at once after a workspace switch

rubenluetke10-beep1512e317d0f6
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/AgentsOverview.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/AgentsOverview.tsx
index 4a0d79f2f0..12f6076e7e 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/AgentsOverview.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/AgentsOverview.tsx
@@ -9,7 +9,7 @@ import { useIdeSidePanelStore } from "@/store/ideSidePanel";
import { useWorkspacePanes } from "@/store/workspacePanes";
import { usePaneReviewsStore } from "@/store/paneReviews";
import { AgentMark } from "@/components/agentic/AgentMark";
-import { paneTitleFrom, usePaneRecapPoll, usePaneRecapsStore } from "@/store/paneRecaps";
+import { paneTitleFrom, recapsFor, usePaneRecapPoll, usePaneRecapsStore } from "@/store/paneRecaps";
import { CheckCheck, Eye, Loader2, Search, X, type LucideIcon } from "lucide-react";
import { agentSearchDocument } from "./agentSearch";
import { useAgentSearch } from "./useAgentSearch";
@@ -126,7 +126,7 @@ export function AgentsOverview() {
const searching = query.trim().length > 0;
const search = useAgentSearch(query, mine.map((pane) => agentSearchDocument(
pane,
- paneTitleFrom(recaps.workspaceId === pane.workspace_id ? recaps.byName[pane.name] : undefined, pane),
+ paneTitleFrom(recapsFor(recaps, pane.workspace_id)?.[pane.name], pane),
)));
const byId = new Map(mine.map((pane) => [pane.history_id, pane]));
const matches = search.matches.flatMap(({ id }) => {
@@ -158,7 +158,7 @@ export function AgentsOverview() {
spotlight !== null && spotlight.workspaceId === pane.workspace_id && spotlight.pane === pane.name;
const stateSince = compactSince(pane.activity_since, now);
const lastOutput = compactSince(pane.last_output_at, now);
- const recap = recaps.workspaceId === pane.workspace_id ? recaps.byName[pane.name] : undefined;
+ const recap = recapsFor(recaps, pane.workspace_id)?.[pane.name];
const title = paneTitleFrom(recap, pane);
const elsewhere = pane.workspace_id !== activeWorkspaceId ? pane.workspace_name : "";
return (
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/explorer/ExplorerPanel.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/explorer/ExplorerPanel.tsx
index 4eef504a6f..db23ecf045 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/explorer/ExplorerPanel.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/explorer/ExplorerPanel.tsx
@@ -28,7 +28,7 @@ import { AgentMark } from "@/components/agentic/AgentMark";
import { useEventStore } from "@/store/events";
import { useIdeChatStore } from "@/store/ideChat";
import { useIdeExplorerStore, type ExplorerView } from "@/store/ideExplorer";
-import { paneTitleFrom, usePaneRecapPoll, usePaneRecapsStore } from "@/store/paneRecaps";
+import { paneTitleFrom, recapsFor, usePaneRecapPoll, usePaneRecapsStore } from "@/store/paneRecaps";
import { useWorkspacePanesStore } from "@/store/workspacePanes";
import { DiffView } from "./DiffView";
import {
@@ -136,7 +136,7 @@ function StatusLetter({ status }: { status: ChangeStatus }) {
*/
function ChangeAuthors({ authors, workspaceId }: { authors: ChangeAuthor[]; workspaceId: string }) {
const t = useT();
- const recaps = usePaneRecapsStore((state) => (state.workspaceId === workspaceId ? state.byName : undefined));
+ const recaps = usePaneRecapsStore((state) => recapsFor(state, workspaceId));
const rows = useWorkspacePanesStore((state) => state.panes);
if (authors.length === 0) return null;
const named = authors.map((author) => {
diff --git a/jarvis/ui/web/frontend/src/store/paneRecaps.test.ts b/jarvis/ui/web/frontend/src/store/paneRecaps.test.ts
index 3cf832c607..180400e277 100644
--- a/jarvis/ui/web/frontend/src/store/paneRecaps.test.ts
+++ b/jarvis/ui/web/frontend/src/store/paneRecaps.test.ts
@@ -1,5 +1,10 @@
-import { describe, expect, it } from "vitest";
-import { paneTitleFrom } from "./paneRecaps";
+import { act, cleanup, renderHook, waitFor } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import type { TerminalRecap } from "@/lib/agenticIdeApi";
+import { useEventStore } from "@/store/events";
+import { useIdeProjectsStore } from "@/store/ideProjects";
+import { useWorkspacePanesStore } from "@/store/workspacePanes";
+import { paneTitleFrom, recapsFor, usePaneRecapsStore, usePaneTitle } from "./paneRecaps";
const row = { recap: "", last_prompt: "", display_name: "Claude Code", name: "T1" };
@@ -21,3 +26,56 @@ describe("paneTitleFrom", () => {
expect(paneTitleFrom(undefined, undefined)).toBe("");
});
});
+
+const titled = (recap: string) => ({ recap, source: "cli" }) as TerminalRecap;
+
+describe("recapsFor", () => {
+ it("keeps a workspace's titles after another one answered", () => {
+ const state = {
+ workspaceId: "w2",
+ byName: { T1: titled("Second workspace") },
+ byWorkspace: { w1: { T1: titled("First workspace") }, w2: { T1: titled("Second workspace") } },
+ };
+ expect(recapsFor(state, "w1")?.T1.recap).toBe("First workspace");
+ expect(recapsFor(state, "w2")?.T1.recap).toBe("Second workspace");
+ expect(recapsFor(state, "w3")).toBeUndefined();
+ });
+});
+
+describe("usePaneTitle across a workspace switch", () => {
+ afterEach(() => {
+ cleanup();
+ vi.unstubAllGlobals();
+ useEventStore.setState({ activeSection: "chats" });
+ useIdeProjectsStore.setState({ activeWorkspaceId: null });
+ usePaneRecapsStore.setState({ workspaceId: null, byName: {}, byWorkspace: {} });
+ });
+
+ it("fetches the new workspace's titles at once instead of on the next tick", async () => {
+ const asked: string[] = [];
+ vi.stubGlobal("fetch", async (url: string) => {
+ asked.push(url);
+ const id = new URL(url, "http://x").searchParams.get("workspace_id") ?? "w1";
+ return new Response(
+ JSON.stringify({ workspace_id: id, terminals: [{ name: "T1", recap: `Title in ${id}`, source: "cli" }] }),
+ );
+ });
+ useWorkspacePanesStore.setState({ panes: [] });
+ useIdeProjectsStore.setState({ activeWorkspaceId: "w1" });
+ useEventStore.setState({ activeSection: "agentic-ide" });
+
+ const { result, rerender } = renderHook(({ id }) => usePaneTitle(id, "T1"), { initialProps: { id: "w1" } });
+ await waitFor(() => expect(result.current).toBe("Title in w1"));
+
+ act(() => useIdeProjectsStore.setState({ activeWorkspaceId: "w2" }));
+ rerender({ id: "w2" });
+ await waitFor(() => expect(result.current).toBe("Title in w2"));
+ expect(asked.some((url) => url.includes("workspace_id=w2"))).toBe(true);
+
+ // Back to the first workspace: its titles are already held, before any answer.
+ vi.stubGlobal("fetch", () => new Promise<Response>(() => {}));
+ act(() => useIdeProjectsStore.setState({ activeWorkspaceId: "w1" }));
+ rerender({ id: "w1" });
+ expect(result.current).toBe("Title in w1");
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/store/paneRecaps.ts b/jarvis/ui/web/frontend/src/store/paneRecaps.ts
index 5950322b61..84619c4f6a 100644
--- a/jarvis/ui/web/frontend/src/store/paneRecaps.ts
+++ b/jarvis/ui/web/frontend/src/store/paneRecaps.ts
@@ -3,6 +3,7 @@ import { create } from "zustand";
import { fetchTerminalRecaps, type TerminalRecap } from "@/lib/agenticIdeApi";
import { useEventStore } from "@/store/events";
+import { useIdeProjectsStore } from "@/store/ideProjects";
import { useWorkspacePanesStore } from "@/store/workspacePanes";
import { sessionTitle } from "@/components/agentic/sessionTitle";
@@ -23,47 +24,107 @@ const RECAP_POLL_MS = 8000;
/** Spread so several windows never fire on the same tick (AP-33). */
const RECAP_JITTER_MS = 1500;
+type RecapsByName = Record<string, TerminalRecap>;
+
interface PaneRecapsState {
+ /** The workspace the last answer was for, and its titles by pane name. */
workspaceId: string | null;
- byName: Record<string, TerminalRecap>;
- load: () => Promise<void>;
+ byName: RecapsByName;
+ /**
+ * Every workspace's last answer, kept after it leaves the front. Switching
+ * back to a workspace then shows the titles it had at once instead of the
+ * call-signs until the next poll (maintainer report 2026-10-05: "T1, T2" for
+ * several seconds after every workspace switch).
+ */
+ byWorkspace: Record<string, RecapsByName>;
+ load: (workspaceId?: string) => Promise<void>;
}
export const usePaneRecapsStore = create<PaneRecapsState>((set) => ({
workspaceId: null,
byName: {},
- load: async () => {
+ byWorkspace: {},
+ load: async (workspaceId) => {
try {
- const answer = await fetchTerminalRecaps();
- const byName: Record<string, TerminalRecap> = {};
+ const answer = await fetchTerminalRecaps(workspaceId);
+ if (!answer.workspace_id) return;
+ const byName: RecapsByName = {};
for (const row of answer.terminals) byName[row.name] = row;
- set({ workspaceId: answer.workspace_id, byName });
+ const id = answer.workspace_id;
+ set((state) => ({
+ workspaceId: id,
+ byName,
+ byWorkspace: { ...state.byWorkspace, [id]: byName },
+ }));
} catch {
/* keep the last titles; the next tick tries again */
}
},
}));
+/** The titles held for one workspace: the latest answer, else the cached one. */
+export function recapsFor(
+ state: Pick<PaneRecapsState, "workspaceId" | "byName" | "byWorkspace">,
+ workspaceId: string | null | undefined,
+): RecapsByName | undefined {
+ if (!workspaceId) return state.byName;
+ if (state.workspaceId === workspaceId) return state.byName;
+ return state.byWorkspace?.[workspaceId];
+}
+
let watchers = 0;
let timer: number | null = null;
+let unsubscribe: (() => void) | null = null;
+
+/** The workspace on screen, as the IDE published it; undefined before it has. */
+function frontWorkspace(): string | undefined {
+ return useIdeProjectsStore.getState().activeWorkspaceId ?? undefined;
+}
+
+function schedule(): void {
+ if (timer !== null) window.clearTimeout(timer);
+ timer = window.setTimeout(tick, RECAP_POLL_MS + Math.random() * RECAP_JITTER_MS);
+}
function tick(): void {
if (useEventStore.getState().activeSection === "agentic-ide") {
- void usePaneRecapsStore.getState().load();
+ void usePaneRecapsStore.getState().load(frontWorkspace());
}
- timer = window.setTimeout(tick, RECAP_POLL_MS + Math.random() * RECAP_JITTER_MS);
+ schedule();
}
-/** Subscribe to the shared recap poll for as long as the caller is mounted. */
+/**
+ * Subscribe to the shared recap poll for as long as the caller is mounted.
+ *
+ * Besides the relaxed clock, the poll fires at once when the user brings a
+ * workspace forward or opens the IDE: those are the moments a header shows a
+ * pane whose title this window has not fetched yet, and waiting a whole
+ * interval left it on its call-sign. A user's own click is one request, not a
+ * reconnect wave, so it needs no jitter; the clock restarts from it.
+ */
export function usePaneRecapPoll(): void {
useEffect(() => {
watchers += 1;
if (timer === null) tick();
+ if (unsubscribe === null) {
+ const offWorkspace = useIdeProjectsStore.subscribe((state, previous) => {
+ if (state.activeWorkspaceId !== previous.activeWorkspaceId && state.activeWorkspaceId) tick();
+ });
+ const offSection = useEventStore.subscribe((state, previous) => {
+ if (state.activeSection === "agentic-ide" && previous.activeSection !== "agentic-ide") tick();
+ });
+ unsubscribe = () => {
+ offWorkspace();
+ offSection();
+ };
+ }
return () => {
watchers -= 1;
- if (watchers <= 0 && timer !== null) {
- window.clearTimeout(timer);
+ if (watchers <= 0) {
+ if (timer !== null) window.clearTimeout(timer);
timer = null;
+ unsubscribe?.();
+ unsubscribe = null;
}
};
}, []);
@@ -92,9 +153,7 @@ export function paneTitleFrom(
/** One pane's title, live: the shared recap poll plus the pane list's topic. */
export function usePaneTitle(workspaceId: string | undefined, name: string): string {
usePaneRecapPoll();
- const recap = usePaneRecapsStore((state) =>
- !workspaceId || state.workspaceId === workspaceId ? state.byName[name] : undefined,
- );
+ const recap = usePaneRecapsStore((state) => recapsFor(state, workspaceId)?.[name]);
const row = useWorkspacePanesStore((state) =>
state.panes.find((pane) => pane.name === name && (!workspaceId || pane.workspace_id === workspaceId)),
);