Skip to content

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

feat(agentic-ide): offer to resume every terminal when the IDE opens

Ruben Lütke691e1eaca3ce
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
index 1147de8443..c06aab35f1 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
@@ -280,7 +280,14 @@ export function AgenticTerminal({
requestAnimationFrame(sendResize);
};
ws.onmessage = (ev) => {
- let msg: { t?: string; d?: string; code?: number; message?: string };
+ let msg: {
+ t?: string;
+ d?: string;
+ code?: number;
+ message?: string;
+ /** On "ready": did this pane continue its previous conversation? */
+ resumed?: boolean;
+ };
try {
msg = JSON.parse(ev.data as string);
} catch {
@@ -289,7 +296,16 @@ export function AgenticTerminal({
if (msg.t === "o") term.write(msg.d ?? "");
else if (msg.t === "ready") {
everLive = true;
- report("live");
+ // Say whether this pane picked up where it left off. A continued agent
+ // and one that started empty look identical on screen until the moment
+ // somebody asks the empty one a follow-up question — so the pane itself
+ // carries the answer rather than leaving it to be discovered.
+ report(
+ "live",
+ msg.resumed
+ ? "continued its previous conversation"
+ : "started a new conversation",
+ );
term.focus();
} else if (msg.t === "exit") {
report("exited", `exit code ${msg.code ?? "?"}`);
diff --git a/jarvis/ui/web/frontend/src/components/agentic/ResumeCard.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/ResumeCard.test.tsx
new file mode 100644
index 0000000000..aa83e3341b
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/ResumeCard.test.tsx
@@ -0,0 +1,158 @@
+import { cleanup, fireEvent, render, screen } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+import { ResumeCard, resumeSummary, savedAgo } from "./ResumeCard";
+import type { ResumeOffer } from "@/lib/agenticIdeApi";
+
+const OFFER: ResumeOffer = {
+ available: true,
+ folder: "/home/ruben/code/project",
+ folder_name: "project",
+ folder_exists: true,
+ saved_at: 1_753_473_600,
+ session_id: "ide_1",
+ resumable_count: 1,
+ terminals: [
+ {
+ key: "mika",
+ name: "Mika",
+ agent: "claude",
+ display_name: "Claude Code",
+ column: 0,
+ slot: 0,
+ available: true,
+ resumable: true,
+ prompts_sent: 3,
+ },
+ {
+ key: "nova",
+ name: "Nova",
+ agent: "codex",
+ display_name: "Codex",
+ column: 1,
+ slot: 0,
+ available: true,
+ resumable: false,
+ prompts_sent: 0,
+ },
+ ],
+};
+
+afterEach(cleanup);
+
+/** The project has no jest-dom matchers, so buttons are inspected directly. */
+function button(testId: string): HTMLButtonElement {
+ return screen.getByTestId(testId) as HTMLButtonElement;
+}
+
+describe("ResumeCard", () => {
+ it("names the workspace and every pane that comes back", () => {
+ render(
+ <ResumeCard offer={OFFER} busy={false} onResume={vi.fn()} onDismiss={vi.fn()} />,
+ );
+ expect(screen.getByText("project")).toBeTruthy();
+ expect(screen.getByText("Mika")).toBeTruthy();
+ expect(screen.getByText("Nova")).toBeTruthy();
+ expect(screen.getByText("Claude Code")).toBeTruthy();
+ });
+
+ it("says which conversations will NOT come back, before the click", () => {
+ // The honesty requirement: an empty pane and a continued one look identical
+ // until the agent is asked a follow-up question, so the difference has to be
+ // visible while the choice is still being made.
+ render(
+ <ResumeCard offer={OFFER} busy={false} onResume={vi.fn()} onDismiss={vi.fn()} />,
+ );
+ expect(screen.getByTestId("resume-pane-nova").textContent).toMatch(/starts fresh/i);
+ expect(screen.getByTestId("resume-pane-mika").textContent).not.toMatch(
+ /starts fresh/i,
+ );
+ });
+
+ it("marks a pane whose coding CLI is gone from this machine", () => {
+ const offer: ResumeOffer = {
+ ...OFFER,
+ terminals: [
+ OFFER.terminals[0],
+ { ...OFFER.terminals[1], available: false },
+ ],
+ };
+ render(
+ <ResumeCard offer={offer} busy={false} onResume={vi.fn()} onDismiss={vi.fn()} />,
+ );
+ expect(screen.getByTestId("resume-pane-nova").textContent).toMatch(
+ /not installed here/i,
+ );
+ });
+
+ it("resumes and dismisses through its two buttons", () => {
+ const onResume = vi.fn();
+ const onDismiss = vi.fn();
+ render(
+ <ResumeCard
+ offer={OFFER}
+ busy={false}
+ onResume={onResume}
+ onDismiss={onDismiss}
+ />,
+ );
+ fireEvent.click(screen.getByTestId("resume-all"));
+ expect(onResume).toHaveBeenCalledTimes(1);
+ fireEvent.click(screen.getByTestId("resume-dismiss"));
+ expect(onDismiss).toHaveBeenCalledTimes(1);
+ });
+
+ it("cannot be resumed once its folder is gone", () => {
+ const gone: ResumeOffer = { ...OFFER, available: false, folder_exists: false };
+ render(
+ <ResumeCard offer={gone} busy={false} onResume={vi.fn()} onDismiss={vi.fn()} />,
+ );
+ expect(button("resume-all").disabled).toBe(true);
+ expect(screen.getByText(/moved or deleted/i)).toBeTruthy();
+ // ...but "start fresh" still works, or the card could never be cleared away.
+ expect(button("resume-dismiss").disabled).toBe(false);
+ });
+
+ it("locks both buttons while a resume is in flight", () => {
+ render(
+ <ResumeCard offer={OFFER} busy onResume={vi.fn()} onDismiss={vi.fn()} />,
+ );
+ expect(button("resume-all").disabled).toBe(true);
+ expect(button("resume-dismiss").disabled).toBe(true);
+ });
+});
+
+describe("resumeSummary", () => {
+ it("distinguishes all, some and none", () => {
+ expect(resumeSummary({ ...OFFER, resumable_count: 2 })).toMatch(
+ /each continuing/i,
+ );
+ expect(resumeSummary(OFFER)).toMatch(/1 continue/i);
+ expect(resumeSummary({ ...OFFER, resumable_count: 0 })).toMatch(
+ /none of their conversations/i,
+ );
+ });
+
+ it("leads with the reason nothing can be reopened", () => {
+ expect(resumeSummary({ ...OFFER, folder_exists: false })).toMatch(
+ /no longer on this machine/i,
+ );
+ expect(resumeSummary({ ...OFFER, available: false })).toMatch(
+ /not installed/i,
+ );
+ });
+});
+
+describe("savedAgo", () => {
+ it("stays coarse enough to be useful", () => {
+ const now = 1_753_473_600_000;
+ expect(savedAgo(1_753_473_600, now)).toBe("just now");
+ expect(savedAgo(1_753_473_600 - 60 * 5, now)).toBe("5 minutes ago");
+ expect(savedAgo(1_753_473_600 - 3600, now)).toBe("1 hour ago");
+ expect(savedAgo(1_753_473_600 - 3600 * 30, now)).toBe("1 day ago");
+ });
+
+ it("says nothing rather than something wrong", () => {
+ expect(savedAgo(0)).toBe("");
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/ResumeCard.tsx b/jarvis/ui/web/frontend/src/components/agentic/ResumeCard.tsx
new file mode 100644
index 0000000000..40b6b1264d
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/ResumeCard.tsx
@@ -0,0 +1,155 @@
+/**
+ * "Resume all sessions" — the offer to reopen the workspace that was last open.
+ *
+ * Shown at the top of the wizard whenever a previous workspace can be brought
+ * back: after the browser was closed, after the app restarted, after a reboot.
+ *
+ * ## Why a card and not a dialog
+ *
+ * A dialog would sit in front of the wizard on every single visit, including
+ * the many where the user came here to open something else entirely. That is
+ * how people learn to dismiss a thing without reading it — and this one has
+ * something worth reading. A card is just as visible, stays out of the way, and
+ * costs nothing to ignore.
+ *
+ * ## Why every pane is listed individually
+ *
+ * Because "resumed" is not one answer. A pane can come back with its whole
+ * conversation, or with nothing but its call-sign — and the two look identical
+ * on screen until you ask the agent a follow-up question and get a blank stare.
+ * So each pane says which of the two it will be BEFORE the click, and a pane
+ * whose coding CLI is no longer installed says that too, instead of failing
+ * quietly a second after the workspace opens.
+ */
+import { AlertCircle, RotateCcw, Terminal } from "lucide-react";
+import { cn } from "@/lib/utils";
+import type { ResumeOffer } from "@/lib/agenticIdeApi";
+
+interface ResumeCardProps {
+ offer: ResumeOffer;
+ busy: boolean;
+ onResume: () => void;
+ onDismiss: () => void;
+}
+
+/**
+ * "2 hours ago" for a POSIX timestamp.
+ *
+ * Deliberately coarse. The exact minute a workspace was saved is not a decision
+ * input; "yesterday" versus "just now" is.
+ */
+export function savedAgo(seconds: number, now: number = Date.now()): string {
+ if (!Number.isFinite(seconds) || seconds <= 0) return "";
+ const minutes = Math.floor((now - seconds * 1000) / 60_000);
+ if (minutes < 1) return "just now";
+ if (minutes < 60) return `${minutes} minute${minutes === 1 ? "" : "s"} ago`;
+ const hours = Math.floor(minutes / 60);
+ if (hours < 24) return `${hours} hour${hours === 1 ? "" : "s"} ago`;
+ const days = Math.floor(hours / 24);
+ return `${days} day${days === 1 ? "" : "s"} ago`;
+}
+
+/** One line of plain language for what the button will actually do. */
+export function resumeSummary(offer: ResumeOffer): string {
+ const total = offer.terminals.length;
+ const panes = `${total} terminal${total === 1 ? "" : "s"}`;
+ if (!offer.folder_exists) return "That folder is no longer on this machine.";
+ if (!offer.available) {
+ return "None of these terminals can run here — their coding CLIs are not installed.";
+ }
+ const kept = offer.resumable_count;
+ if (kept === 0) {
+ return `${panes} come back with their names and places; none of their conversations could be kept.`;
+ }
+ if (kept === total) {
+ return `${panes}, each continuing the conversation it was having.`;
+ }
+ return `${panes} — ${kept} continue their conversation, the rest start fresh.`;
+}
+
+export function ResumeCard({ offer, busy, onResume, onDismiss }: ResumeCardProps) {
+ const when = savedAgo(offer.saved_at);
+ return (
+ <section
+ data-testid="resume-card"
+ aria-labelledby="resume-card-title"
+ className="rounded-xl border border-primary/30 bg-primary/5 p-5"
+ >
+ <div className="flex flex-wrap items-start gap-3">
+ <span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/15">
+ <RotateCcw className="h-4 w-4 text-primary" />
+ </span>
+ <div className="min-w-0 flex-1">
+ <h3 id="resume-card-title" className="font-display text-base font-semibold">
+ Resume all sessions
+ </h3>
+ <p className="text-sm text-muted-foreground">
+ <span className="font-medium text-foreground">{offer.folder_name}</span>
+ {when && <span> · last open {when}</span>}
+ </p>
+ <code className="mt-0.5 block truncate font-mono text-[11px] text-muted-foreground">
+ {offer.folder}
+ </code>
+ </div>
+ </div>
+
+ <ul className="mt-4 flex flex-wrap gap-2">
+ {offer.terminals.map((pane) => (
+ <li
+ key={pane.key}
+ data-testid={`resume-pane-${pane.key}`}
+ className={cn(
+ "flex items-center gap-2 rounded-lg border px-2.5 py-1.5 text-xs",
+ pane.available
+ ? "border-border bg-card/60"
+ : "border-amber-500/40 bg-amber-500/10",
+ )}
+ >
+ <Terminal className="h-3.5 w-3.5 shrink-0 text-primary" />
+ <span className="font-medium text-foreground">{pane.name}</span>
+ <span className="text-muted-foreground">{pane.display_name}</span>
+ {!pane.available ? (
+ <span className="text-amber-200">not installed here</span>
+ ) : (
+ !pane.resumable && (
+ <span className="text-muted-foreground">· starts fresh</span>
+ )
+ )}
+ </li>
+ ))}
+ </ul>
+
+ <p className="mt-3 text-xs text-muted-foreground">{resumeSummary(offer)}</p>
+
+ {!offer.folder_exists && (
+ <p className="mt-2 flex items-start gap-2 text-xs text-amber-200">
+ <AlertCircle className="mt-0.5 h-3.5 w-3.5 shrink-0" />
+ The folder was moved or deleted, so there is nothing left to reopen.
+ </p>
+ )}
+
+ <div className="mt-4 flex flex-wrap items-center justify-end gap-2">
+ <button
+ type="button"
+ data-testid="resume-dismiss"
+ className="btn-ghost"
+ disabled={busy}
+ onClick={onDismiss}
+ title="Forget this workspace and start from the wizard"
+ >
+ Start fresh
+ </button>
+ <button
+ type="button"
+ data-testid="resume-all"
+ className="btn-primary disabled:cursor-not-allowed disabled:opacity-40"
+ disabled={busy || !offer.available}
+ onClick={onResume}
+ >
+ <RotateCcw className="h-4 w-4" />
+ Resume all sessions
+ </button>
+ </div>
+ </section>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
index a8746f14c6..471e9af5bf 100644
--- a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
+++ b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
@@ -112,6 +112,46 @@ export interface IdeState {
max_terminals: number;
}
+/** One pane of the workspace being offered back after a close or a restart. */
+export interface ResumeTerminalOffer {
+ key: string;
+ name: string;
+ agent: string;
+ display_name: string;
+ column: number;
+ slot: number;
+ /** Can this pane open at all? False when its coding CLI is gone from this machine. */
+ available: boolean;
+ /**
+ * Does its CONVERSATION come back, or only its call-sign?
+ *
+ * The distinction is the whole point of showing this before the click: a pane
+ * that reopens empty looks exactly like one that continued, right up until it
+ * is asked a follow-up question.
+ */
+ resumable: boolean;
+ prompts_sent: number;
+}
+
+export interface ResumeOffer {
+ available: boolean;
+ folder: string;
+ folder_name: string;
+ folder_exists: boolean;
+ saved_at: number;
+ session_id: string;
+ resumable_count: number;
+ terminals: ResumeTerminalOffer[];
+}
+
+export interface ResumeResult {
+ session: SessionState;
+ /** Panes that continued their conversation. */
+ resumable_count: number;
+ /** Panes that came back with the right name and an empty history. */
+ started_fresh: number;
+}
+
export interface TerminalPlan {
agent: string;
name?: string;
@@ -203,6 +243,29 @@ export async function endIdeSession(): Promise<void> {
if (!res.ok) throw new Error(await detail(res));
}
+/** What reopening the last workspace would bring back, checked against this machine. */
+export function fetchResumeOffer(): Promise<ResumeOffer> {
+ return getJson<ResumeOffer>("/api/agentic-ide/resume");
+}
+
+/**
+ * Reopen the last workspace — same panes, same places, same coding CLIs.
+ *
+ * Nothing is started here: the panes connect the way they always do, and that
+ * connection is what continues each conversation.
+ */
+export async function resumeWorkspace(): Promise<ResumeResult> {
+ const res = await fetch("/api/agentic-ide/resume", { method: "POST" });
+ if (!res.ok) throw new Error(await detail(res));
+ return (await res.json()) as ResumeResult;
+}
+
+/** Throw the restore point away, so the IDE opens to a clean wizard. */
+export async function forgetResumeOffer(): Promise<void> {
+ const res = await fetch("/api/agentic-ide/resume", { method: "DELETE" });
+ if (!res.ok) throw new Error(await detail(res));
+}
+
/**
* Open one more terminal in the running workspace.
*
diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx
index f778ea2c67..3ef7a6bc77 100644
--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.test.tsx
@@ -54,6 +54,9 @@ vi.mock("@/lib/agenticIdeApi", () => ({
endIdeSession: vi.fn(),
setFocusMode: vi.fn(),
promptTerminal: vi.fn(),
+ fetchResumeOffer: vi.fn(),
+ resumeWorkspace: vi.fn(),
+ forgetResumeOffer: vi.fn(),
}));
import { AgenticIdeView } from "./AgenticIdeView";
@@ -83,6 +86,51 @@ const AGENTS: api.AgentsResponse = {
const EMPTY_STATE: api.IdeState = { active: false, session: null, max_terminals: 12 };
+const NO_OFFER: api.ResumeOffer = {
+ available: false,
+ folder: "",
+ folder_name: "",
+ folder_exists: false,
+ saved_at: 0,
+ session_id: "",
+ resumable_count: 0,
+ terminals: [],
+};
+
+const PREVIOUS_WORKSPACE: api.ResumeOffer = {
+ available: true,
+ folder: "/work/project",
+ folder_name: "project",
+ folder_exists: true,
+ saved_at: 1_753_473_600,
+ session_id: "ide_old",
+ resumable_count: 1,
+ terminals: [
+ {
+ key: "mika",
+ name: "Mika",
+ agent: "claude",
+ display_name: "Claude Code",
+ column: 0,
+ slot: 0,
+ available: true,
+ resumable: true,
+ prompts_sent: 2,
+ },
+ {
+ key: "nova",
+ name: "Nova",
+ agent: "claude",
+ display_name: "Claude Code",
+ column: 1,
+ slot: 0,
+ available: true,
+ resumable: false,
+ prompts_sent: 0,
+ },
+ ],
+};
+
function sessionWith(names: string[], focus = false): api.SessionState {
return {
id: "ide_test",
@@ -144,6 +192,8 @@ beforeEach(() => {
entries: [],
truncated: false,
});
+ // Nothing to resume by default; the resume tests override this.
+ vi.mocked(api.fetchResumeOffer).mockResolvedValue(NO_OFFER);
});
afterEach(() => {
@@ -429,3 +479,67 @@ describe("Agentic IDE running workspace", () => {
expect(screen.getByTestId("pane-Mika")).toBeTruthy();
});
});
+
+describe("AgenticIdeView — resuming the last workspace", () => {
+ it("offers the previous workspace above the wizard", async () => {
+ vi.mocked(api.fetchResumeOffer).mockResolvedValue(PREVIOUS_WORKSPACE);
+ render(<AgenticIdeView />);
+
+ await screen.findByTestId("resume-card");
+ expect(screen.getByTestId("resume-pane-mika")).toBeTruthy();
+ // The wizard is still right there — the offer never blocks it.
+ expect(screen.getByText("Folder")).toBeTruthy();
+ });
+
+ it("says nothing when there is nothing to resume", async () => {
+ render(<AgenticIdeView />);
+ await screen.findByText("Folder");
+ expect(screen.queryByTestId("resume-card")).toBeNull();
+ });
+
+ it("does not offer a resume while a workspace is open", async () => {
+ vi.mocked(api.fetchIdeState).mockResolvedValue({
+ active: true,
+ session: sessionWith(["Mika"]),
+ max_terminals: 12,
+ });
+ vi.mocked(api.fetchResumeOffer).mockResolvedValue(PREVIOUS_WORKSPACE);
+ render(<AgenticIdeView />);
+
+ await screen.findByTestId("pane-Mika");
+ expect(screen.queryByTestId("resume-card")).toBeNull();
+ });
+
+ it("reopens the workspace and reports what really came back", async () => {
+ vi.mocked(api.fetchResumeOffer).mockResolvedValue(PREVIOUS_WORKSPACE);
+ vi.mocked(api.resumeWorkspace).mockResolvedValue({
+ session: sessionWith(["Mika", "Nova"]),
+ resumable_count: 1,
+ started_fresh: 1,
+ });
+ render(<AgenticIdeView />);
+
+ fireEvent.click(await screen.findByTestId("resume-all"));
+
+ await screen.findByTestId("pane-Mika");
+ expect(screen.queryByTestId("resume-card")).toBeNull();
+ // The honest report: one pane came back empty and the user is told so.
+ await waitFor(() =>
+ expect(pushToast).toHaveBeenCalledWith(
+ "success",
+ expect.stringMatching(/1 continued, 1 started fresh/),
+ ),
+ );
+ });
+
+ it("forgets the workspace when the user starts fresh", async () => {
+ vi.mocked(api.fetchResumeOffer).mockResolvedValue(PREVIOUS_WORKSPACE);
+ vi.mocked(api.forgetResumeOffer).mockResolvedValue(undefined);
+ render(<AgenticIdeView />);
+
+ fireEvent.click(await screen.findByTestId("resume-dismiss"));
+
+ await waitFor(() => expect(api.forgetResumeOffer).toHaveBeenCalledTimes(1));
+ expect(screen.queryByTestId("resume-card")).toBeNull();
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
index 15508d03b2..916a0571fe 100644
--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
@@ -37,16 +37,24 @@ import { useEventStore } from "@/store/events";
import { cn } from "@/lib/utils";
import { useT } from "@/i18n";
import { AgenticGrid } from "@/components/agentic/AgenticGrid";
-import { bandCapacityFor, paneColumns } from "@/components/agentic/layout";
+import {
+ paneColumns,
+ workspaceBandCapacityFor,
+} from "@/components/agentic/layout";
import { FolderPicker } from "@/components/agentic/FolderPicker";
+import { ResumeCard } from "@/components/agentic/ResumeCard";
import {
endIdeSession,
fetchIdeAgents,
fetchIdeState,
+ fetchResumeOffer,
+ forgetResumeOffer,
+ resumeWorkspace,
setFocusMode,
startIdeSession,
type AgentStatus,
type AgentsResponse,
+ type ResumeOffer,
type SessionState,
} from "@/lib/agenticIdeApi";
@@ -61,9 +69,6 @@ interface PlannedTerminal {
// selector instead of widening this row with a card for every possible value.
const COUNT_CHOICES = [1, 2, 3, 4, 6, 8] as const;
-/** The grid's own horizontal padding (`p-3`), which the preview must discount. */
-const GRID_PADDING_PX = 24;
-
/**
* Terminal plan for ``count`` panes, preserving whatever the user already chose
* for the panes that still exist.
@@ -105,6 +110,10 @@ export function AgenticIdeView() {
const [count, setCount] = useState(2);
const [customCountSelected, setCustomCountSelected] = useState(false);
const [planned, setPlanned] = useState<PlannedTerminal[]>([]);
+ // The workspace that was open when the window last closed, if it can come
+ // back. Null both when there is nothing to offer and after the user has
+ // answered the offer either way.
+ const [offer, setOffer] = useState<ResumeOffer | null>(null);
const refresh = useCallback(async () => {
try {
@@ -112,6 +121,19 @@ export function AgenticIdeView() {
setMeta(agents);
setSession(state.session);
setFocus(Boolean(state.session?.focus_mode));
+ // Only worth asking about when there is no workspace on screen. With one
+ // open, the panes reconnect and continue by themselves — the offer is for
+ // the case where the workspace itself did not survive.
+ if (state.session === null) {
+ try {
+ const previous = await fetchResumeOffer();
+ setOffer(previous.terminals.length > 0 ? previous : null);
+ } catch {
+ /* no offer is a perfectly good answer — the wizard still works */
+ }
+ } else {
+ setOffer(null);
+ }
} catch {
/* backend still warming or headless — keep whatever we had */
} finally {
@@ -185,7 +207,7 @@ export function AgenticIdeView() {
// The grid pads itself by 12 px on each side; without that the preview would
// promise one column more than fits at the boundary.
const previewPerBand = useMemo(
- () => bandCapacityFor(Math.max(0, shellWidth - GRID_PADDING_PX)),
+ () => workspaceBandCapacityFor(shellWidth),
[shellWidth],
);
@@ -298,6 +320,9 @@ export function AgenticIdeView() {
setSession(null);
setFocus(false);
setStep(0);
+ // Closing on purpose withdraws the offer, so the wizard comes back clean
+ // rather than immediately proposing the workspace just shut down.
+ setOffer(null);
} catch (e) {
pushToast("error", (e as Error).message);
} finally {
@@ -305,6 +330,41 @@ export function AgenticIdeView() {
}
};
+ const resumeAll = async () => {
+ setBusy(true);
+ try {
+ const result = await resumeWorkspace();
+ setSession(result.session);
+ setFocus(result.session.focus_mode);
+ setOffer(null);
+ // Report what actually came back, not what was hoped for. A pane that
+ // reopened empty looks exactly like one that continued until it is asked
+ // a follow-up question, so the count has to be said out loud.
+ const panes = result.session.terminals.length;
+ pushToast(
+ "success",
+ result.started_fresh === 0
+ ? `Resumed ${panes} terminal${panes === 1 ? "" : "s"} — every conversation continued.`
+ : `Resumed ${panes} terminal${panes === 1 ? "" : "s"} — ${result.resumable_count} continued, ${result.started_fresh} started fresh.`,
+ );
+ } catch (e) {
+ pushToast("error", (e as Error).message);
+ } finally {
+ setBusy(false);
+ }
+ };
+
+ const dismissOffer = async () => {
+ // Cleared on screen first: the user said no, and that should not wait for a
+ // round-trip. A failed delete only means the offer returns next visit.
+ setOffer(null);
+ try {
+ await forgetResumeOffer();
+ } catch (e) {
+ pushToast("error", (e as Error).message);
+ }
+ };
+
const toggleFocus = async (enabled: boolean) => {
// Remember a deliberate opt-out, or the auto-enable effect above would turn
// the mode straight back on and the switch would look broken.
@@ -360,6 +420,20 @@ export function AgenticIdeView() {
<div className="flex-1 overflow-y-auto scrollbar-jarvis">
<div className="mx-auto flex w-full max-w-3xl flex-col gap-6 p-6">
+ {/*
+ Above the wizard, not in front of it. Someone who came here to open
+ a different folder can walk straight past; someone who lost a window
+ full of running agents sees the way back first.
+ */}
+ {offer && (
+ <ResumeCard
+ offer={offer}
+ busy={busy}
+ onResume={() => void resumeAll()}
+ onDismiss={() => void dismissOffer()}
+ />
+ )}
+
<StepRail step={step} />
{loading && (