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): add per-pane prompt history

Ruben Lütkeb6c2c4ae5c6f
diff --git a/jarvis/agentic_ide/prompt_history.py b/jarvis/agentic_ide/prompt_history.py
new file mode 100644
index 0000000000..058637ab0d
--- /dev/null
+++ b/jarvis/agentic_ide/prompt_history.py
@@ -0,0 +1,122 @@
+"""Durable readback of every prompt handed to an Agentic-IDE pane.
+
+The workspace snapshot intentionally stays metadata-only because it is read on
+the IDE's first screen and may describe hundreds of panes. Full prompts live in
+separate append-only JSONL files instead: writing one prompt does not rewrite a
+large history, and opening the history is the only operation that reads it.
+
+Files are keyed by an opaque pane-lifetime id, never by a user-provided call-sign
+or folder path. Renaming a pane therefore keeps its history, while closing it
+and later reusing the same visible name cannot inherit somebody else's prompts.
+"""
+
+from __future__ import annotations
+
+import hashlib
+import json
+import threading
+from dataclasses import asdict, dataclass
+from pathlib import Path
+from typing import Any
+
+from loguru import logger
+
+_WRITE_LOCK = threading.Lock()
+
+
+@dataclass(frozen=True, slots=True)
+class PromptHistoryEntry:
+ """One exact prompt and the delivery result recorded beside it."""
+
+ id: str
+ sequence: int
+ text: str
+ at: float
+ submitted: bool | None
+
+ @staticmethod
+ def from_dict(value: Any) -> PromptHistoryEntry | None:
+ """Parse one row defensively; a damaged row never hides valid ones."""
+ if not isinstance(value, dict):
+ return None
+ entry_id = value.get("id")
+ text = value.get("text")
+ if not isinstance(entry_id, str) or not entry_id or not isinstance(text, str):
+ return None
+ try:
+ sequence = int(value.get("sequence") or 0)
+ at = float(value.get("at") or 0.0)
+ except (TypeError, ValueError):
+ return None
+ submitted = value.get("submitted")
+ if submitted not in (True, False, None):
+ submitted = None
+ return PromptHistoryEntry(
+ id=entry_id,
+ sequence=max(0, sequence),
+ text=text,
+ at=max(0.0, at),
+ submitted=submitted,
+ )
+
+
+def _store_dir() -> Path:
+ from jarvis.core.paths import user_data_dir
+
+ return user_data_dir() / "agentic_ide" / "prompt_history"
+
+
+def _path(history_id: str) -> Path:
+ """Map an opaque id to a fixed safe filename even after a hand-edited restore."""
+ digest = hashlib.sha256(history_id.encode("utf-8", errors="replace")).hexdigest()
+ return _store_dir() / f"{digest}.jsonl"
+
+
+def append(history_id: str, entry: PromptHistoryEntry) -> None:
+ """Append one complete row; callers decide whether a write failure is fatal."""
+ target = _path(history_id)
+ line = json.dumps(asdict(entry), ensure_ascii=False, separators=(",", ":"))
+ with _WRITE_LOCK:
+ target.parent.mkdir(parents=True, exist_ok=True)
+ with target.open("a", encoding="utf-8", newline="\n") as handle:
+ handle.write(line)
+ handle.write("\n")
+
+
+def load(history_id: str) -> list[PromptHistoryEntry]:
+ """Return valid rows oldest-first, skipping a crash-truncated final line."""
+ target = _path(history_id)
+ if not target.is_file():
+ return []
+ entries: list[PromptHistoryEntry] = []
+ damaged = 0
+ try:
+ with _WRITE_LOCK, target.open("r", encoding="utf-8") as handle:
+ for line in handle:
+ try:
+ parsed = PromptHistoryEntry.from_dict(json.loads(line))
+ except (json.JSONDecodeError, UnicodeDecodeError):
+ parsed = None
+ if parsed is None:
+ damaged += 1
+ else:
+ entries.append(parsed)
+ except OSError as exc:
+ logger.warning("Agentic IDE: could not read prompt history {}: {}", target, exc)
+ return []
+ if damaged:
+ logger.warning(
+ "Agentic IDE: ignored {} damaged prompt-history row(s) in {}",
+ damaged,
+ target,
+ )
+ return entries
+
+
+def merged(
+ stored: list[PromptHistoryEntry], current: list[PromptHistoryEntry]
+) -> list[PromptHistoryEntry]:
+ """Combine disk and live-memory records once, preserving chronological order."""
+ by_id = {entry.id: entry for entry in stored}
+ by_id.update((entry.id, entry) for entry in current)
+ return sorted(by_id.values(), key=lambda entry: (entry.at, entry.sequence, entry.id))
diff --git a/jarvis/agentic_ide/resume_store.py b/jarvis/agentic_ide/resume_store.py
index e28d23446f..0cddba3908 100644
--- a/jarvis/agentic_ide/resume_store.py
+++ b/jarvis/agentic_ide/resume_store.py
@@ -61,6 +61,9 @@ class SnapshotTerminal:
key: str
name: str
agent: str
+ # Opaque identity of the pane's on-demand prompt-history stream. Additive:
+ # older snapshots leave it empty and receive a fresh id when restored.
+ history_id: str = ""
column: int = 0
slot: int = 0
resume: ResumeHandle | None = None
@@ -82,6 +85,7 @@ class SnapshotTerminal:
"key": self.key,
"name": self.name,
"agent": self.agent,
+ "history_id": self.history_id,
"column": self.column,
"slot": self.slot,
"resume": self.resume.to_dict() if self.resume else None,
@@ -102,6 +106,7 @@ class SnapshotTerminal:
key=str(data.get("key") or "").strip() or name.lower(),
name=name,
agent=agent,
+ history_id=str(data.get("history_id") or "").strip(),
column=_as_int(data.get("column")),
slot=_as_int(data.get("slot")),
resume=ResumeHandle.from_dict(data.get("resume")),
diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.py
index a0a331d52a..ab95384621 100644
--- a/jarvis/agentic_ide/session.py
+++ b/jarvis/agentic_ide/session.py
@@ -78,7 +78,7 @@ from loguru import logger
from jarvis.workspace import agents as workspace_agents
-from . import recap_engine, resume_store
+from . import prompt_history, recap_engine, resume_store
from .agent_sessions import (
ResumeHandle,
can_resume,
@@ -781,6 +781,11 @@ class Terminal:
# pane to the anchor's OWN column and leaves every other column alone.
#
# The second axis is load-bearing. With only a row number, "split down"
+ # Stable for THIS pane's lifetime and deliberately unrelated to its visible
+ # call-sign. A closed T1 and a new T1 are different panes; a renamed T1 is
+ # still the same pane. Prompt-history files use this id to preserve exactly
+ # that boundary across app restarts.
+ history_id: str = field(default_factory=lambda: uuid4().hex)
# could only mean "open a new row", and a row is window-wide by definition —
# so splitting one pane squashed every other pane to half height. A full
# split TREE (arbitrary nesting, draggable separators) is still deliberately
@@ -820,6 +825,12 @@ class Terminal:
# terminal stream, and that is the whole point. A pane proves a prompt
# arrived by echoing it, which requires a chain of things to have gone
# right at one particular moment: the pane on screen, its output un-parked,
+ # The current process's records are kept as a fallback if the local history
+ # file cannot be written. The full durable history is loaded only when its
+ # UI is opened, never in the workspace-state hot path.
+ prompt_records: list[prompt_history.PromptHistoryEntry] = field(
+ default_factory=list, repr=False, compare=False
+ )
# its socket up, the emulator painted. Every link in that chain has failed
# in production at least once, and each failure looks identical from the
# user's chair — Jarvis says it sent the brief and the pane shows nothing,
@@ -1055,6 +1066,7 @@ class Terminal:
prompts_sent=self.prompts_sent,
account=self.account,
continuation_needed=self.resume_continuation_needed,
+ history_id=self.history_id,
)
@@ -1815,6 +1827,7 @@ class Registry:
#
# **The bug this fixes.** `continuation_pending` used to be raised in
# `attach`, which is the moment a pane's process is spawned — and cold
+ history_id=entry.history_id or uuid4().hex,
# starts are deliberately staggered (see COLD_START_LIMIT), so in a
# workspace of a dozen panes most of them are still `pending` seconds
# after the grid appears. Anybody pressing "Continue" in that window got
@@ -3397,6 +3410,25 @@ class Registry:
)
return None
return left_the_box
+ history_entry = prompt_history.PromptHistoryEntry(
+ id=uuid4().hex,
+ sequence=term.prompts_sent,
+ text=payload,
+ at=term.last_prompt_at,
+ submitted=submitted,
+ )
+ # Memory first: even a read-only or temporarily unavailable data folder
+ # must not make a prompt disappear from the history while the pane is
+ # still open. Disk is the persistence layer, not the only copy.
+ term.prompt_records.append(history_entry)
+ try:
+ await asyncio.to_thread(prompt_history.append, term.history_id, history_entry)
+ except OSError as exc:
+ logger.warning(
+ "Agentic IDE: could not persist the prompt history for {}: {}",
+ term.name,
+ exc,
+ )
async def _await_arrival(self, term: Terminal, payload: str) -> bool:
"""Wait until the pane visibly holds ``payload``, or give up.
diff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.py
index 99ce157d25..ebc64088fb 100644
--- a/jarvis/ui/web/agentic_ide_routes.py
+++ b/jarvis/ui/web/agentic_ide_routes.py
@@ -67,6 +67,7 @@ from jarvis.agentic_ide import (
notifications,
recap_engine,
recents,
+ prompt_history,
resume_store,
)
from jarvis.agentic_ide.agent_sessions import has_conversation
@@ -918,6 +919,34 @@ class RecapEdit(BaseModel):
max_length=recap_engine.MAX_EDIT_DETAIL * 2,
)
+class PromptHistoryItem(BaseModel):
+ """One exact prompt in a pane's delivery history."""
+
+ id: str = Field(description="Opaque stable id for this history entry.")
+ sequence: int = Field(description="Delivery number within this pane.")
+ text: str = Field(description="Exact prompt text, unabridged.")
+ chars: int = Field(description="Length of ``text``.")
+ at: float = Field(description="When it was delivered (epoch seconds).")
+ submitted: bool | None = Field(
+ description=(
+ "True when the agent accepted it, false when it remained in the input "
+ "box, null when delivery could not be confirmed."
+ )
+ )
+
+
+class PromptHistoryResponse(BaseModel):
+ """All prompt text still belonging to one pane, newest first."""
+
+ name: str
+ total: int = Field(description="How many prompts this pane is known to have received.")
+ available: int = Field(description="How many exact prompt records are available here.")
+ complete: bool = Field(
+ description="False only when this pane predates durable prompt-history recording."
+ )
+ items: list[PromptHistoryItem] = Field(default_factory=list)
+
+
# --------------------------------------------------------------------------- #
# REST #
@@ -2062,6 +2091,43 @@ async def terminal_attach(
which is what makes dropping a screenshot work against an agent that
cannot open one.
* ``deliver=false`` stores and analyses without typing anything into the
+ "/terminals/{name}/prompts",
+ response_model=PromptHistoryResponse,
+ summary="Every prompt sent to one terminal",
+)
+async def get_prompt_history(
+ name: str, workspace_id: str | None = None
+) -> PromptHistoryResponse:
+ """Read every exact prompt handed to this pane, newest first.
+
+ Prompt bodies live outside the workspace snapshot and are loaded only for
+ this request. That keeps the IDE's state poll and first-screen restore small
+ even when a workspace has many panes with long coding briefs.
+ """
+ term, _session = _pane_for_recap(name, workspace_id)
+ stored = await asyncio.to_thread(prompt_history.load, term.history_id)
+ entries = prompt_history.merged(stored, term.prompt_records)
+ total = max(term.prompts_sent, len(entries))
+ return PromptHistoryResponse(
+ name=term.name,
+ total=total,
+ available=len(entries),
+ complete=len(entries) >= term.prompts_sent,
+ items=[
+ PromptHistoryItem(
+ id=entry.id,
+ sequence=entry.sequence,
+ text=entry.text,
+ chars=len(entry.text),
+ at=entry.at,
+ submitted=entry.submitted,
+ )
+ for entry in reversed(entries)
+ ],
+ )
+
+
pane, for a caller that is assembling a prompt rather than handing the
agent a path right now. The files are on disk and referenced either way,
so nothing is lost if the user then walks away.
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
index eff6c7477f..198393f5ec 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
@@ -1687,6 +1687,7 @@ export function AgenticGrid({
// with it. Marking a pane on right-click was too easy to
// trigger by accident, and letting the event through would
// open the app-wide Cut/Copy/Paste menu over an overlay that
+ promptCount={term.prompts_sent}
// has no text to copy. Left-click marks; right-click is inert.
onContextMenu={(event) => {
event.preventDefault();
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
index c5b8453d1a..2fe187f07c 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
@@ -104,6 +104,7 @@ import {
import { PromptReceipt } from "./PromptReceipt";
/**
+import { PromptHistoryButton } from "./PromptHistoryButton";
* How old a delivery may be and still raise its receipt on a fresh connection.
*
* Only applies to the receipt recovered from the HANDSHAKE — a prompt arriving
@@ -215,6 +216,8 @@ interface AgenticTerminalProps {
/** True while this pane fills the whole grid. */
maximized?: boolean;
onToggleMaximize?: () => void;
+ /** Number shown beside the pane header's prompt-history icon. */
+ promptCount?: number;
/**
* Open another terminal beside or below this one.
*
@@ -298,6 +301,7 @@ export function AgenticTerminal({
}: AgenticTerminalProps) {
const containerRef = useRef<HTMLDivElement | null>(null);
// The padded box around the xterm host — the pane's visible inset, kept off
+ promptCount = 0,
// the host itself because FitAddon reads the host's border-box. The pane's
// scrollbar overlays this box and measures hover against it.
const scrollRegionRef = useRef<HTMLDivElement | null>(null);
@@ -1130,6 +1134,7 @@ export function AgenticTerminal({
{/*
Keep the visual inset OUTSIDE xterm's measured host. FitAddon reads the
host's border-box but does not subtract padding on that host, so putting
+ workspaceId={workspaceId}
the inset there made it report one row more than the pane could show.
The last terminal line was consequently clipped after a vertical resize.
@@ -1141,6 +1146,7 @@ export function AgenticTerminal({
className="relative min-h-0 flex-1 overflow-hidden px-1.5 pb-0.5 pt-0.5"
>
<div
+ promptCount={promptCount}
ref={containerRef}
data-testid={`agentic-terminal-host-${name}`}
// Read by ./index.css, which anchors the contents to the bottom for
@@ -1256,6 +1262,7 @@ function PaneHeader({
displayName: string;
recap?: string;
recapDetail?: string;
+ workspaceId,
recapMeta?: PaneRecapMeta;
recapActions?: PaneRecapActions;
accountLabel?: string | null;
@@ -1263,6 +1270,7 @@ function PaneHeader({
focused: boolean;
maximized: boolean;
onToggleMaximize?: () => void;
+ promptCount,
onSplit?: (direction: SplitDirection, agent?: string) => void;
agents?: SplitAgentChoice[];
onClose?: () => void;
@@ -1277,6 +1285,7 @@ function PaneHeader({
const light = appearance === "light";
// Which split button opened the CLI picker, if any.
const [picking, setPicking] = useState<SplitDirection | null>(null);
+ workspaceId?: string;
// With one installed CLI there is nothing to pick, so the button splits
// straight away — a menu with a single entry is a click tax, not a choice.
@@ -1284,6 +1293,7 @@ function PaneHeader({
const offersChoice = choices.filter((a) => a.installed).length > 1;
const startSplit = (direction: SplitDirection) => {
+ promptCount: number;
if (offersChoice)
setPicking((current) => (current === direction ? null : direction));
else onSplit?.(direction);
@@ -1538,6 +1548,12 @@ function SplitAgentMenu({
<span className="shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground">
{agent.kind === "shell" ? "no shell here" : "not installed"}
</span>
+ <PromptHistoryButton
+ terminal={name}
+ workspaceId={workspaceId}
+ count={promptCount}
+ light={light}
+ />
)}
</button>
))}
diff --git a/jarvis/ui/web/frontend/src/components/agentic/PromptHistoryButton.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/PromptHistoryButton.test.tsx
new file mode 100644
index 0000000000..eac4a7b078
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/PromptHistoryButton.test.tsx
@@ -0,0 +1,130 @@
+import { fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+import { PromptHistoryButton } from "./PromptHistoryButton";
+
+vi.mock("@/lib/agenticIdeApi", () => ({
+ fetchPromptHistory: vi.fn(),
+}));
+vi.mock("@/lib/clipboard", () => ({
+ robustCopy: vi.fn(),
+}));
+
+const { fetchPromptHistory } = await import("@/lib/agenticIdeApi");
+const { robustCopy } = await import("@/lib/clipboard");
+const fetchMock = fetchPromptHistory as unknown as ReturnType<typeof vi.fn>;
+const copyMock = robustCopy as unknown as ReturnType<typeof vi.fn>;
+
+const olderText = "## First task\nReview the terminal transport.";
+const newerText = "## Second task\nAdd regression coverage and report the result.";
+
+beforeEach(() => {
+ fetchMock.mockReset();
+ copyMock.mockReset();
+ copyMock.mockResolvedValue(true);
+ fetchMock.mockResolvedValue({
+ name: "Nova",
+ total: 2,
+ available: 2,
+ complete: true,
+ items: [
+ {
+ id: "newer",
+ sequence: 2,
+ text: newerText,
+ chars: newerText.length,
+ at: 1_800_000_100,
+ submitted: true,
+ },
+ {
+ id: "older",
+ sequence: 1,
+ text: olderText,
+ chars: olderText.length,
+ at: 1_800_000_000,
+ submitted: false,
+ },
+ ],
+ });
+});
+
+describe("PromptHistoryButton", () => {
+ it("puts a small, counted history control in the pane header", () => {
+ render(
+ <PromptHistoryButton
+ terminal="Nova"
+ workspaceId="ide_alpha"
+ count={7}
+ light={false}
+ />,
+ );
+
+ const button = screen.getByTestId("pane-prompt-history-Nova");
+ expect(button.textContent).toBe("7");
+ expect(button.getAttribute("aria-label")).toContain("Nova");
+ });
+
+ it("opens with every prompt listed and the newest prompt in full", async () => {
+ render(
+ <PromptHistoryButton
+ terminal="Nova"
+ workspaceId="ide_alpha"
+ count={2}
+ light={false}
+ />,
+ );
+
+ fireEvent.click(screen.getByTestId("pane-prompt-history-Nova"));
+
+ await waitFor(() => expect(screen.getByTestId("prompt-history-dialog")).toBeTruthy());
+ await waitFor(() => {
+ expect(screen.getByTestId("prompt-history-detail").textContent).toContain(
+ "Add regression coverage",
+ );
+ });
+ expect(fetchMock).toHaveBeenCalledWith("Nova", "ide_alpha");
+ expect(screen.getByTestId("prompt-history-row-older")).toBeTruthy();
+ });
+
+ it("copies the exact prompt selected from the history", async () => {
+ render(
+ <PromptHistoryButton
+ terminal="Nova"
+ workspaceId="ide_alpha"
+ count={2}
+ light={false}
+ />,
+ );
+ fireEvent.click(screen.getByTestId("pane-prompt-history-Nova"));
+ await waitFor(() => expect(screen.getByTestId("prompt-history-row-older")).toBeTruthy());
+
+ fireEvent.click(screen.getByTestId("prompt-history-row-older"));
+ fireEvent.click(screen.getByTestId("prompt-history-copy"));
+
+ await waitFor(() => expect(copyMock).toHaveBeenCalledWith(olderText));
+ expect(screen.getByTestId("prompt-history-copy").textContent).toContain("Copied");
+ });
+
+ it("explains the empty history instead of presenting a blank panel", async () => {
+ fetchMock.mockResolvedValue({
+ name: "Nova",
+ total: 0,
+ available: 0,
+ complete: true,
+ items: [],
+ });
+ render(
+ <PromptHistoryButton
+ terminal="Nova"
+ workspaceId="ide_alpha"
+ count={0}
+ light
+ />,
+ );
+
+ fireEvent.click(screen.getByTestId("pane-prompt-history-Nova"));
+
+ await waitFor(() => expect(screen.getByText("No prompts yet")).toBeTruthy());
+ expect(screen.getByText(/voice, chat, or the prompt bar/i)).toBeTruthy();
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/PromptHistoryButton.tsx b/jarvis/ui/web/frontend/src/components/agentic/PromptHistoryButton.tsx
new file mode 100644
index 0000000000..06cba951c9
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/PromptHistoryButton.tsx
@@ -0,0 +1,365 @@
+/** A pane-header button and on-demand browser for every prompt sent to that pane. */
+import { useEffect, useMemo, useState } from "react";
+import * as Dialog from "@radix-ui/react-dialog";
+import {
+ AlertCircle,
+ Check,
+ Copy,
+ History,
+ RefreshCw,
+ X,
+} from "lucide-react";
+
+import { useT } from "@/i18n";
+import {
+ fetchPromptHistory,
+ type PromptHistoryItem,
+ type PromptHistoryResponse,
+} from "@/lib/agenticIdeApi";
+import { robustCopy } from "@/lib/clipboard";
+import { cn } from "@/lib/utils";
+
+type CopyState = "idle" | "copied" | "failed";
+
+function fill(template: string, ...values: Array<string | number>): string {
+ // Annotated because the accumulator is a string while the values are not:
+ // without it the reduce is inferred over the ELEMENT type and the build fails
+ // on `text.replace` not existing for a number.
+ return values.reduce<string>(
+ (text, value, index) => text.replace(`{${index}}`, String(value)),
+ template,
+ );
+}
+
+function whenLabel(at: number): string {
+ return new Intl.DateTimeFormat(undefined, {
+ dateStyle: "medium",
+ timeStyle: "short",
+ }).format(new Date(at * 1000));
+}
+
+function firstLine(text: string): string {
+ return text.split(/\r?\n/, 1)[0]?.replace(/^#+\s*/, "").trim() || text.trim();
+}
+
+export function PromptHistoryButton({
+ terminal,
+ workspaceId,
+ count,
+ light,
+}: {
+ terminal: string;
+ workspaceId?: string;
+ count: number;
+ light: boolean;
+}): JSX.Element {
+ const t = useT();
+ const [open, setOpen] = useState(false);
+ const [loading, setLoading] = useState(false);
+ const [error, setError] = useState("");
+ const [history, setHistory] = useState<PromptHistoryResponse | null>(null);
+ const [selectedId, setSelectedId] = useState<string | null>(null);
+ const [copyState, setCopyState] = useState<CopyState>("idle");
+ const [reloadToken, setReloadToken] = useState(0);
+
+ useEffect(() => {
+ if (!open) return;
+ let current = true;
+ setLoading(true);
+ setError("");
+ fetchPromptHistory(terminal, workspaceId)
+ .then((result) => {
+ if (!current) return;
+ setHistory(result);
+ setSelectedId((selected) =>
+ selected && result.items.some((item) => item.id === selected)
+ ? selected
+ : (result.items[0]?.id ?? null),
+ );
+ })
+ .catch((reason: unknown) => {
+ if (!current) return;
+ setError(reason instanceof Error ? reason.message : String(reason));
+ })
+ .finally(() => {
+ if (current) setLoading(false);
+ });
+ // Renames and workspace switches can reuse this component while an older
+ // request is still in flight. Ignore that stale answer instead of briefly
+ // showing another pane's prompts.
+ return () => {
+ current = false;
+ };
+ }, [open, reloadToken, terminal, workspaceId]);
+
+ useEffect(() => {
+ if (copyState === "idle") return;
+ const timer = window.setTimeout(() => setCopyState("idle"), 2_000);
+ return () => window.clearTimeout(timer);
+ }, [copyState]);
+
+ const selected = useMemo(
+ () => history?.items.find((item) => item.id === selectedId) ?? null,
+ [history, selectedId],
+ );
+
+ const copySelected = async () => {
+ if (!selected) return;
+ setCopyState((await robustCopy(selected.text)) ? "copied" : "failed");
+ };
+
+ const triggerLabel = fill(t("agentic_grid.history.open"), terminal);
+
+ return (
+ <Dialog.Root
+ open={open}
+ onOpenChange={(next) => {
+ setOpen(next);
+ if (!next) setCopyState("idle");
+ }}
+ >
+ <Dialog.Trigger asChild>
+ <button
+ type="button"
+ aria-label={triggerLabel}
+ title={triggerLabel}
+ data-testid={`pane-prompt-history-${terminal}`}
+ onMouseDown={(event) => event.stopPropagation()}
+ className={cn(
+ "flex h-6 min-w-6 shrink-0 items-center justify-center gap-1 rounded-md px-1.5",
+ "text-[10px] font-medium tabular-nums transition-colors active:translate-y-px",
+ light
+ ? "text-[#6b6b73] hover:bg-black/10 hover:text-[#2b2b33]"
+ : "text-[#9a9aa5] hover:bg-white/10 hover:text-[#e8e8ec]",
+ )}
+ >
+ <History className="h-3.5 w-3.5" aria-hidden="true" />
+ {count > 0 && <span>{count}</span>}
+ </button>
+ </Dialog.Trigger>
+
+ <Dialog.Portal>
+ <Dialog.Overlay className="fixed inset-0 z-[80] bg-[#090909]/75 backdrop-blur-sm data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-reduce:animate-none" />
+ <Dialog.Content
+ data-testid="prompt-history-dialog"
+ className={cn(
+ "fixed left-1/2 top-1/2 z-[90] flex max-h-[82dvh] w-[min(940px,calc(100vw-2rem))]",
+ "-translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-border",
+ "bg-card shadow-[0_28px_90px_-24px_rgba(0,0,0,0.75)] outline-none",
+ "data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 motion-reduce:animate-none",
+ )}
+ >
+ <header className="flex items-start justify-between gap-4 border-b border-border px-5 py-4">
+ <div className="min-w-0">
+ <div className="mb-1 flex items-center gap-2">
+ <History className="h-4 w-4 text-primary" aria-hidden="true" />
+ <Dialog.Title className="font-display text-base font-semibold tracking-tight text-foreground">
+ {t("agentic_grid.history.title")}
+ </Dialog.Title>
+ </div>
+ <Dialog.Description className="text-xs leading-relaxed text-muted-foreground">
+ {fill(t("agentic_grid.history.description"), terminal)}
+ </Dialog.Description>
+ </div>
+ <Dialog.Close asChild>
+ <button
+ type="button"
+ aria-label={t("agentic_grid.history.close")}
+ className="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground active:translate-y-px"
+ >
+ <X className="h-4 w-4" aria-hidden="true" />
+ </button>
+ </Dialog.Close>
+ </header>
+
+ {loading ? (
+ <HistorySkeleton />
+ ) : error ? (
+ <div className="flex min-h-64 flex-col items-center justify-center px-6 text-center">
+ <AlertCircle className="mb-3 h-6 w-6 text-destructive" aria-hidden="true" />
+ <p className="text-sm font-medium text-foreground">
+ {t("agentic_grid.history.load_failed")}
+ </p>
+ <p className="mt-1 max-w-md text-xs text-muted-foreground" role="alert">
+ {error}
+ </p>
+ <button
+ type="button"
+ onClick={() => setReloadToken((token) => token + 1)}
+ 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 active:translate-y-px"
+ >
+ <RefreshCw className="h-3.5 w-3.5" aria-hidden="true" />
+ {t("agentic_grid.history.retry")}
+ </button>
+ </div>
+ ) : !history || history.items.length === 0 ? (
+ <div className="flex min-h-64 flex-col items-center justify-center px-6 text-center">
+ <div className="mb-4 flex h-12 w-12 items-center justify-center rounded-2xl border border-border bg-muted/30">
+ <History className="h-5 w-5 text-muted-foreground" aria-hidden="true" />
+ </div>
+ <p className="text-sm font-medium text-foreground">
+ {t("agentic_grid.history.empty_title")}
+ </p>
+ <p className="mt-1 max-w-sm text-xs leading-relaxed text-muted-foreground">
+ {t("agentic_grid.history.empty_detail")}
+ </p>
+ </div>
+ ) : (
+ <div className="grid min-h-0 flex-1 grid-cols-1 md:grid-cols-[minmax(15rem,0.8fr)_minmax(0,1.4fr)]">
+ <aside className="min-h-0 border-b border-border md:border-b-0 md:border-r">
+ <div className="flex items-center justify-between border-b border-border/60 px-4 py-2.5">
+ <span className="text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground">
+ {fill(
+ t(
+ history.available === 1
+ ? "agentic_grid.history.count_one"
+ : "agentic_grid.history.count_many",
+ ),
+ history.available,
+ )}
+ </span>
+ {!history.complete && (
+ <span className="text-[10px] text-amber-500">
+ {t("agentic_grid.history.partial")}
+ </span>
+ )}
+ </div>
+ <div className="max-h-52 overflow-y-auto md:max-h-none md:h-[min(60dvh,34rem)]">
+ {history.items.map((item) => (
+ <HistoryRow
+ key={item.id}
+ item={item}
+ selected={item.id === selectedId}
+ onSelect={() => {
+ setSelectedId(item.id);
+ setCopyState("idle");
+ }}
+ />
+ ))}
+ </div>
+ </aside>
+
+ {selected && (
+ <section className="flex min-h-0 flex-col" data-testid="prompt-history-detail">
+ <div className="flex items-center justify-between gap-3 border-b border-border/60 px-4 py-2.5">
+ <div className="min-w-0">
+ <div className="truncate text-xs font-medium text-foreground">
+ {fill(t("agentic_grid.history.prompt_number"), selected.sequence)}
+ </div>
+ <div className="mt-0.5 text-[10px] text-muted-foreground">
+ {whenLabel(selected.at)} · {fill(t("agentic_grid.history.characters"), selected.chars)}
+ </div>
+ </div>
+ <button
+ type="button"
+ onClick={() => void copySelected()}
+ data-testid="prompt-history-copy"
+ className={cn(
+ "inline-flex h-8 shrink-0 items-center gap-1.5 rounded-lg border px-2.5 text-xs font-medium",
+ "transition-colors active:translate-y-px",
+ copyState === "failed"
+ ? "border-destructive/40 text-destructive"
+ : copyState === "copied"
+ ? "border-emerald-500/30 text-emerald-500"
+ : "border-border text-foreground hover:border-primary/40 hover:bg-primary/10",
+ )}
+ >
+ {copyState === "copied" ? (
+ <Check className="h-3.5 w-3.5" aria-hidden="true" />
+ ) : (
+ <Copy className="h-3.5 w-3.5" aria-hidden="true" />
+ )}
+ {t(
+ copyState === "copied"
+ ? "agentic_grid.history.copied"
+ : copyState === "failed"
+ ? "agentic_grid.history.copy_failed"
+ : "agentic_grid.history.copy",
+ )}
+ </button>
+ </div>
+ <pre className="min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words bg-background/35 p-4 font-mono text-[11px] leading-relaxed text-foreground/90">
+ {selected.text}
+ </pre>
+ </section>
+ )}
+ </div>
+ )}
+ </Dialog.Content>
+ </Dialog.Portal>
+ </Dialog.Root>
+ );
+}
+
+function HistoryRow({
+ item,
+ selected,
+ onSelect,
+}: {
+ item: PromptHistoryItem;
+ selected: boolean;
+ onSelect: () => void;
+}): JSX.Element {
+ const t = useT();
+ const statusKey =
+ item.submitted === true
+ ? "agentic_grid.history.sent"
+ : item.submitted === false
+ ? "agentic_grid.history.waiting"
+ : "agentic_grid.history.unconfirmed";
+ return (
+ <button
+ type="button"
+ onClick={onSelect}
+ data-testid={`prompt-history-row-${item.id}`}
+ className={cn(
+ "group flex w-full items-start gap-3 border-b border-border/50 px-4 py-3 text-left transition-colors",
+ selected ? "bg-primary/10" : "hover:bg-muted/40",
+ )}
+ >
+ <span
+ className={cn(
+ "mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full",
+ item.submitted === true
+ ? "bg-emerald-500"
+ : item.submitted === false
+ ? "bg-amber-500"
+ : "bg-muted-foreground",
+ )}
+ aria-hidden="true"
+ />
+ <span className="min-w-0 flex-1">
+ <span className="block truncate text-xs font-medium text-foreground">
+ {firstLine(item.text)}
+ </span>
+ <span className="mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground">
+ <span>{whenLabel(item.at)}</span>
+ <span>{t(statusKey)}</span>
+ </span>
+ </span>
+ </button>
+ );
+}
+
+function HistorySkeleton(): JSX.Element {
+ return (
+ <div className="grid min-h-64 grid-cols-1 md:grid-cols-[minmax(15rem,0.8fr)_minmax(0,1.4fr)]">
+ <div className="border-b border-border p-4 md:border-b-0 md:border-r">
+ {[0, 1, 2, 3].map((row) => (
+ <div key={row} className="border-b border-border/50 py-3">
+ <div className="h-3 w-4/5 animate-pulse rounded bg-muted" />
+ <div className="mt-2 h-2 w-1/2 animate-pulse rounded bg-muted/70" />
+ </div>
+ ))}
+ </div>
+ <div className="p-4">
+ <div className="h-3 w-1/3 animate-pulse rounded bg-muted" />
+ <div className="mt-6 space-y-3">
+ {["w-full", "w-11/12", "w-4/5", "w-5/6", "w-2/3"].map((width, row) => (
+ <div key={row} className={cn("h-2.5 animate-pulse rounded bg-muted/70", width)} />
+ ))}
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 1ea0e14ff0..cd05dbc66c 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -3520,6 +3520,27 @@
"above": "Über {0}",
"below": "Unter {0}"
},
+ "history": {
+ "open": "Prompt-Verlauf für {0} öffnen",
+ "title": "Prompt-Verlauf",
+ "description": "Jeder Prompt, den {name} an {0} gesendet hat — exakt so gespeichert, wie der Agent ihn erhalten hat.",
+ "close": "Prompt-Verlauf schließen",
+ "load_failed": "Der Prompt-Verlauf konnte nicht geladen werden.",
+ "retry": "Erneut versuchen",
+ "empty_title": "Noch keine Prompts",
+ "empty_detail": "Prompts, die per Sprache, Chat oder Prompt-Leiste an dieses Fenster gesendet werden, erscheinen hier.",
+ "count_one": "1 Prompt",
+ "count_many": "{0} Prompts",
+ "partial": "Frühere Prompts nicht verfügbar",
+ "prompt_number": "Prompt #{0}",
+ "characters": "{0} Zeichen",
+ "copy": "Prompt kopieren",
+ "copied": "Kopiert",
+ "copy_failed": "Kopieren fehlgeschlagen",
+ "sent": "An Agent gesendet",
+ "waiting": "Wartet auf Enter",
+ "unconfirmed": "Zustellung unbestätigt"
+ },
"selection": {
"start": "Terminals auswählen",
"finish": "Auswahl beenden",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 5eff9d5f83..332786e946 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -3521,6 +3521,27 @@
"above": "Above {0}",
"below": "Below {0}"
},
+ "history": {
+ "open": "View prompt history for {0}",
+ "title": "Prompt history",
+ "description": "Every prompt {name} sent to {0}, preserved exactly as the agent received it.",
+ "close": "Close prompt history",
+ "load_failed": "The prompt history could not be loaded.",
+ "retry": "Try again",
+ "empty_title": "No prompts yet",
+ "empty_detail": "Prompts sent to this pane by voice, chat, or the prompt bar will appear here.",
+ "count_one": "1 prompt",
+ "count_many": "{0} prompts",
+ "partial": "Earlier prompts unavailable",
+ "prompt_number": "Prompt #{0}",
+ "characters": "{0} characters",
+ "copy": "Copy prompt",
+ "copied": "Copied",
+ "copy_failed": "Copy failed",
+ "sent": "Sent to agent",
+ "waiting": "Waiting for Enter",
+ "unconfirmed": "Delivery unconfirmed"
+ },
"selection": {
"start": "Select terminals",
"finish": "Done selecting",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index f613776df3..26ec434c54 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -3520,6 +3520,27 @@
"above": "Encima de {0}",
"below": "Debajo de {0}"
},
+ "history": {
+ "open": "Ver el historial de prompts de {0}",
+ "title": "Historial de prompts",
+ "description": "Todos los prompts que {name} envió a {0}, conservados exactamente como los recibió el agente.",
+ "close": "Cerrar el historial de prompts",
+ "load_failed": "No se pudo cargar el historial de prompts.",
+ "retry": "Intentar de nuevo",
+ "empty_title": "Aún no hay prompts",
+ "empty_detail": "Los prompts enviados a este panel por voz, chat o la barra de prompts aparecerán aquí.",
+ "count_one": "1 prompt",
+ "count_many": "{0} prompts",
+ "partial": "Los prompts anteriores no están disponibles",
+ "prompt_number": "Prompt n.º {0}",
+ "characters": "{0} caracteres",
+ "copy": "Copiar prompt",
+ "copied": "Copiado",
+ "copy_failed": "Error al copiar",
+ "sent": "Enviado al agente",
+ "waiting": "Esperando Enter",
+ "unconfirmed": "Entrega sin confirmar"
+ },
"selection": {
"start": "Seleccionar terminales",
"finish": "Terminar selección",
diff --git a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
index 29ef58a303..a69c0a85b6 100644
--- a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
+++ b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
@@ -471,6 +471,41 @@ export function fetchLastPrompt(
);
}
+/** One exact prompt in a pane's durable delivery history. */
+export interface PromptHistoryItem {
+ id: string;
+ sequence: number;
+ text: string;
+ chars: number;
+ /** Epoch seconds. */
+ at: number;
+ submitted: boolean | null;
+}
+
+export interface PromptHistoryResponse {
+ name: string;
+ /** Known delivery count, including prompts from before history recording existed. */
+ total: number;
+ /** Exact prompt records available to inspect and copy. */
+ available: number;
+ complete: boolean;
+ /** Newest first. */
+ items: PromptHistoryItem[];
+}
+
+/** Read every exact prompt handed to this pane without loading it into workspace state. */
+export function fetchPromptHistory(
+ name: string,
+ workspaceId?: string,
+): Promise<PromptHistoryResponse> {
+ const query = workspaceId
+ ? `?workspace_id=${encodeURIComponent(workspaceId)}`
+ : "";
+ return getJson<PromptHistoryResponse>(
+ `/api/agentic-ide/terminals/${encodeURIComponent(name)}/prompts${query}`,
+ );
+}
+
function recapUrl(name: string, workspaceId?: string, suffix = ""): string {
const query = workspaceId
? `?workspace_id=${encodeURIComponent(workspaceId)}`
diff --git a/tests/unit/agentic_ide/test_prompt_history_route.py b/tests/unit/agentic_ide/test_prompt_history_route.py
new file mode 100644
index 0000000000..32337108b1
--- /dev/null
+++ b/tests/unit/agentic_ide/test_prompt_history_route.py
@@ -0,0 +1,145 @@
+"""The pane-level prompt history is complete, durable, and exact."""
+
+from __future__ import annotations
+
+from pathlib import Path
+
+import pytest
+from fastapi import FastAPI
+from fastapi.testclient import TestClient
+
+from jarvis.agentic_ide import prompt_history
+from jarvis.agentic_ide import session as session_mod
+from jarvis.agentic_ide.session import Registry
+from tests.fakes.fake_pty_manager import FakePtyManager
+
+
+def registry(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> Registry:
+ monkeypatch.setattr(session_mod, "agent_argv", lambda name: (f"/usr/bin/{name}",))
+ monkeypatch.setattr(prompt_history, "_store_dir", lambda: tmp_path / "prompt-history")
+ reg = Registry(pty_manager=FakePtyManager())
+ monkeypatch.setattr(session_mod, "get_registry", lambda: reg)
+ from jarvis.ui.web import agentic_ide_routes
+
+ monkeypatch.setattr(agentic_ide_routes, "get_registry", lambda: reg)
+ return reg
+
+
+def client(registry: Registry) -> TestClient:
+ from jarvis.ui.web.agentic_ide_routes import router
+
+ app = FastAPI()
+ app.include_router(router)
+ return TestClient(app)
+
+
+async def _noop(_text: str) -> None:
+ return None
+
+
+async def _noop_exit(_code: int) -> None:
+ return None
+
+
+async def _live_pane(
+ registry: Registry, folder: Path, monkeypatch: pytest.MonkeyPatch
+) -> str:
+ await registry.start(str(folder), [{"agent": "claude"}])
+ assert registry.session is not None
+ term = registry.session.terminals[0]
+ await registry.attach(term.name, 100, 30, _noop, _noop_exit)
+
+ async def accepted(*_args: object) -> bool:
+ return True
+
+ monkeypatch.setattr(registry, "_write_and_confirm", accepted)
+ return term.name
+
+
+async def test_history_returns_every_full_prompt_newest_first(
+ client: TestClient,
+ registry: Registry,
+ tmp_path: Path,
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ name = await _live_pane(registry, tmp_path, monkeypatch)
+ first = ("## First task\n" + ("Inspect the parser carefully. " * 120)).strip()
+ second = "## Second task\nWrite the regression tests."
+ await registry.send_prompt(name, first)
+ await registry.send_prompt(name, second)
+
+ response = client.get(f"/api/agentic-ide/terminals/{name}/prompts")
+
+ assert response.status_code == 200
+ body = response.json()
+ assert body["total"] == 2
+ assert body["available"] == 2
+ assert body["complete"] is True
+ assert [item["text"] for item in body["items"]] == [second, first]
+ assert body["items"][1]["chars"] == len(first)
+ assert [item["sequence"] for item in body["items"]] == [2, 1]
+
+
+async def test_history_survives_after_the_live_memory_copy_is_gone(
+ client: TestClient,
+ registry: Registry,
+ tmp_path: Path,
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ name = await _live_pane(registry, tmp_path, monkeypatch)
+ await registry.send_prompt(name, "Review the release checklist")
+ assert registry.session is not None
+ registry.session.terminals[0].prompt_records.clear()
+
+ body = client.get(f"/api/agentic-ide/terminals/{name}/prompts").json()
+
+ assert body["items"][0]["text"] == "Review the release checklist"
+ assert body["complete"] is True
+
+
+async def test_a_pane_with_no_prompts_has_an_honest_empty_history(
+ client: TestClient,
+ registry: Registry,
+ tmp_path: Path,
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ name = await _live_pane(registry, tmp_path, monkeypatch)
+
+ body = client.get(f"/api/agentic-ide/terminals/{name}/prompts").json()
+
+ assert body == {
+ "name": name,
+ "total": 0,
+ "available": 0,
+ "complete": True,
+ "items": [],
+ }
+
+
+def test_history_id_round_trips_through_the_metadata_snapshot(
+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ from jarvis.agentic_ide import resume_store
+
+ monkeypatch.setattr(resume_store, "_store_path", lambda: tmp_path / "session.json")
+ pane = resume_store.SnapshotTerminal(
+ key="t1", name="T1", agent="claude", history_id="pane-lifetime-id"
+ )
+ snapshot = resume_store.Snapshot(
+ saved_at=1.0,
+ workspaces=[
+ resume_store.SnapshotWorkspace(
+ session_id="ide_test",
+ folder=str(tmp_path),
+ terminals=[pane],
+ )
+ ],
+ )
+
+ resume_store.save(snapshot)
+ loaded = resume_store.load()
+
+ assert loaded is not None
+ assert loaded.workspaces[0].terminals[0].history_id == "pane-lifetime-id"