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
docs(errors): say why six quiet exception handlers are right to stay quiet
rubenluetke10-beep304ebed2837b
diff --git a/jarvis/agentic_ide/library.py b/jarvis/agentic_ide/library.pyindex 6ec0902c59..e3aaeb0f50 100644--- a/jarvis/agentic_ide/library.py+++ b/jarvis/agentic_ide/library.py@@ -167,6 +167,8 @@ def _read_json(path: Path) -> Any:try:raw = path.read_text(encoding="utf-8")except FileNotFoundError:+ # Silent on purpose: no library file yet is the normal first-run state,+ # not a failure. Every other read error below is logged.return Noneexcept OSError as exc:logger.warning("Chat library: cannot read {}: {}", path.name, exc)@@ -223,6 +225,9 @@ def project_id_for(path: str | Path) -> str:try:resolved = Path(path).expanduser().resolve()except (OSError, ValueError):+ # Silent on purpose: an unresolvable path (gone, too long, a bad drive+ # letter) still deserves a stable id, and the unresolved spelling is a+ # perfectly good one. Nothing is lost, so there is nothing to report.resolved = Path(str(path))key = os.path.normcase(str(resolved))# Not a security boundary: this is a short, stable name for a local folderdiff --git a/jarvis/realtime/webrtc_transport.py b/jarvis/realtime/webrtc_transport.pyindex 973c19fb53..e8ee1f1c9b 100644--- a/jarvis/realtime/webrtc_transport.py+++ b/jarvis/realtime/webrtc_transport.py@@ -250,10 +250,14 @@ def _build_sender_track(base: Any) -> Any:self.queue.put_nowait(payload)return 0except asyncio.QueueFull:+ # Not swallowed: a full queue is the trigger for the elastic+ # cap below, and the bytes it sheds ARE reported, as this+ # method's return value. The caller logs them once per call.while True:try:self._residue += self.queue.get_nowait()except asyncio.QueueEmpty:+ # Drained — the loop's exit condition, not a failure.breakself._residue += payloadshed = len(self._residue) - _ELASTIC_BACKLOG_MAX_BYTESdiff --git a/jarvis/ui/theme.py b/jarvis/ui/theme.pyindex 63f19a9086..ad342b66d2 100644--- a/jarvis/ui/theme.py+++ b/jarvis/ui/theme.py@@ -79,6 +79,8 @@ def _detect_windows() -> Theme | None:try:import winreg # type: ignore[import-not-found]except ImportError:+ # Silent on purpose: no winreg means this is not Windows, which is the+ # expected answer on macOS and Linux, not a fault worth logging.return Nonetry:with winreg.OpenKey(diff --git a/jarvis/ui/web/chat_library_routes.py b/jarvis/ui/web/chat_library_routes.pyindex a71b87d846..d966d257aa 100644--- a/jarvis/ui/web/chat_library_routes.py+++ b/jarvis/ui/web/chat_library_routes.py@@ -144,6 +144,9 @@ def _folder_exists(path: str) -> bool:try:return Path(path).is_dir()except OSError:+ # Silent on purpose: this IS the answer, not a swallowed failure — the+ # caller asked whether the folder is reachable and gets "no". It runs+ # per project on every listing, so logging would be pure noise.return Falsediff --git a/jarvis/ui/web/frontend/src/components/chat/ChatLibrarySidebar.tsx b/jarvis/ui/web/frontend/src/components/chat/ChatLibrarySidebar.tsxnew file mode 100644index 0000000000..8c87ae39c8--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/chat/ChatLibrarySidebar.tsx@@ -0,0 +1,529 @@+/**+ * Projects, and the chats inside them.+ *+ * The column follows one rule the old workspace bar could not: **a project's+ * chats are fetched when the project is opened, never before.** Somebody with+ * forty repositories and a thousand conversations gets a sidebar that arrives+ * at once, and pays for exactly the list they clicked on. Each project keeps+ * whatever it has already loaded, so collapsing and reopening is free — but a+ * project that was never opened has never cost a request.+ *+ * Rows carry the coding agent's own mark rather than a generic icon, because+ * "which agent was this" is the question people actually scan the list for.+ */+import { useCallback, useEffect, useMemo, useRef, useState } from "react";+import {+ Archive,+ ChevronRight,+ FolderOpen,+ Loader2,+ MoreHorizontal,+ Pencil,+ Plus,+ Search,+ Trash2,+ TriangleAlert,+} from "lucide-react";++import { AgentMark } from "@/components/agentic/AgentMark";+import { cn } from "@/lib/utils";+import {+ type ChatProject,+ type ChatRow,+ deleteChat,+ deleteProject,+ fetchChats,+ fetchProjects,+ patchChat,+ patchProject,+ projectColor,+} from "@/lib/chatLibraryApi";++/** What one project's chat list is doing right now. */+type ChatsState =+ | { status: "idle" }+ | { status: "loading" }+ | { status: "ready"; chats: ChatRow[] }+ | { status: "error"; message: string };++export interface ChatLibrarySidebarProps {+ /** The chat currently on screen, so its row can say so. */+ activeChatId?: string | null;+ /** Open a chat. The shell owns what "open" means. */+ onOpenChat?: (project: ChatProject, chat: ChatRow) => void;+ /** Start a new chat in a project — the shell asks the questions. */+ onNewChat?: (project: ChatProject) => void;+ /** Add a folder as a project. */+ onAddProject?: () => void;+}++/**+ * How long ago, in a form that fits a sidebar row.+ *+ * Deliberately coarse and locale-free: this sits under a title that already+ * competes for the row's width, and a full timestamp there reads as noise. The+ * exact time is on the chat itself.+ */+function shortAge(seconds: number): string {+ if (!seconds) return "";+ const delta = Math.max(0, Date.now() / 1000 - seconds);+ if (delta < 60) return "now";+ if (delta < 3600) return `${Math.floor(delta / 60)}m`;+ if (delta < 86400) return `${Math.floor(delta / 3600)}h`;+ if (delta < 604800) return `${Math.floor(delta / 86400)}d`;+ return `${Math.floor(delta / 604800)}w`;+}++export function ChatLibrarySidebar({+ activeChatId = null,+ onOpenChat,+ onNewChat,+ onAddProject,+}: ChatLibrarySidebarProps) {+ const [projects, setProjects] = useState<ChatProject[]>([]);+ const [loading, setLoading] = useState(true);+ const [loadError, setLoadError] = useState<string | null>(null);+ const [expanded, setExpanded] = useState<Set<string>>(() => new Set());+ const [chats, setChats] = useState<Record<string, ChatsState>>({});+ const [filter, setFilter] = useState("");+ const [menuFor, setMenuFor] = useState<string | null>(null);+ /*+ * A late response from a project the user has already collapsed (or a whole+ * sidebar that unmounted) must not write into state. Without this the+ * "loading" spinner of a reopened project is replaced by the PREVIOUS+ * request's list, which is the same class of bug as a stale terminal viewer+ * painting over a fresh pane.+ */+ const alive = useRef(true);+ useEffect(() => {+ alive.current = true;+ return () => {+ alive.current = false;+ };+ }, []);++ const reloadProjects = useCallback(async () => {+ try {+ const next = await fetchProjects();+ if (!alive.current) return;+ setProjects(next);+ setLoadError(null);+ } catch (error) {+ if (!alive.current) return;+ setLoadError(error instanceof Error ? error.message : "Could not load projects");+ } finally {+ if (alive.current) setLoading(false);+ }+ }, []);++ useEffect(() => {+ void reloadProjects();+ }, [reloadProjects]);++ const loadChats = useCallback(async (projectId: string) => {+ setChats((current) => ({ ...current, [projectId]: { status: "loading" } }));+ try {+ const rows = await fetchChats(projectId);+ if (!alive.current) return;+ setChats((current) => ({+ ...current,+ [projectId]: { status: "ready", chats: rows },+ }));+ } catch (error) {+ if (!alive.current) return;+ setChats((current) => ({+ ...current,+ [projectId]: {+ status: "error",+ message: error instanceof Error ? error.message : "Could not load chats",+ },+ }));+ }+ }, []);++ const toggleProject = useCallback(+ (project: ChatProject) => {+ setExpanded((current) => {+ const next = new Set(current);+ if (next.has(project.id)) {+ next.delete(project.id);+ return next;+ }+ next.add(project.id);+ // Fetch only the first time. A project that is reopened shows what it+ // already had, instantly, and refreshes only when something changes it.+ if (!chats[project.id]) void loadChats(project.id);+ return next;+ });+ },+ [chats, loadChats],+ );++ const renameChat = useCallback(+ async (projectId: string, chat: ChatRow) => {+ const next = window.prompt("Rename this chat", chat.title || "");+ if (next === null) return;+ await patchChat(projectId, chat.id, { title: next });+ void loadChats(projectId);+ },+ [loadChats],+ );++ const archiveChat = useCallback(+ async (projectId: string, chat: ChatRow) => {+ await patchChat(projectId, chat.id, { archived: true });+ void loadChats(projectId);+ void reloadProjects();+ },+ [loadChats, reloadProjects],+ );++ const removeChat = useCallback(+ async (projectId: string, chat: ChatRow) => {+ const label = chat.title || "this chat";+ if (!window.confirm(`Delete ${label}? The agent's own history is kept.`)) return;+ await deleteChat(projectId, chat.id);+ void loadChats(projectId);+ void reloadProjects();+ },+ [loadChats, reloadProjects],+ );++ const renameProject = useCallback(+ async (project: ChatProject) => {+ const next = window.prompt("Rename this project", project.name);+ if (next === null) return;+ await patchProject(project.id, { name: next });+ void reloadProjects();+ },+ [reloadProjects],+ );++ const removeProject = useCallback(+ async (project: ChatProject) => {+ if (+ !window.confirm(+ `Remove ${project.name} and its ${project.chats} chat(s)? The folder itself is untouched.`,+ )+ ) {+ return;+ }+ await deleteProject(project.id);+ void reloadProjects();+ },+ [reloadProjects],+ );++ /*+ * The filter matches on what the user can SEE — a project's name and the+ * titles of the chats already loaded under it. It deliberately does not go+ * to the server for the chats of collapsed projects: typing a letter must+ * not fire forty requests, which is the exact cost this column exists to+ * avoid.+ */+ const visible = useMemo(() => {+ const needle = filter.trim().toLowerCase();+ if (!needle) return projects;+ return projects.filter((project) => {+ if (project.name.toLowerCase().includes(needle)) return true;+ const state = chats[project.id];+ if (state?.status !== "ready") return false;+ return state.chats.some((chat) => chat.title.toLowerCase().includes(needle));+ });+ }, [chats, filter, projects]);++ return (+ <div+ data-testid="chat-library-sidebar"+ className="flex h-full min-h-0 w-full flex-col border-r border-border bg-card/30"+ >+ <div className="flex items-center gap-2 border-b border-border px-3 py-2.5">+ <div className="relative flex min-w-0 flex-1 items-center">+ <Search className="pointer-events-none absolute left-2 h-3.5 w-3.5 text-muted-foreground" />+ <input+ value={filter}+ onChange={(event) => setFilter(event.target.value)}+ placeholder="Search projects and chats"+ aria-label="Search projects and chats"+ className="h-8 w-full rounded-md border border-border bg-background/60 pl-7 pr-2 text-xs outline-none placeholder:text-muted-foreground/70 focus-visible:ring-1 focus-visible:ring-ring"+ />+ </div>+ <button+ type="button"+ onClick={onAddProject}+ title="Add a project folder"+ aria-label="Add a project folder"+ className="flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground"+ >+ <Plus className="h-4 w-4" aria-hidden />+ </button>+ </div>++ <div className="min-h-0 flex-1 overflow-y-auto scrollbar-jarvis p-1.5">+ {loading ? (+ <div className="flex items-center gap-2 px-2 py-6 text-xs text-muted-foreground">+ <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />+ Loading projects…+ </div>+ ) : loadError ? (+ <div className="px-2 py-6 text-xs text-destructive">{loadError}</div>+ ) : visible.length === 0 ? (+ <div className="px-2 py-6 text-xs text-muted-foreground">+ {filter+ ? "Nothing matches that."+ : "No projects yet. Add a folder to start your first chat."}+ </div>+ ) : (+ visible.map((project) => {+ const open = expanded.has(project.id);+ const state = chats[project.id] ?? { status: "idle" as const };+ return (+ <div key={project.id} className="mb-0.5">+ <div+ className={cn(+ "group flex items-center gap-1.5 rounded-md px-1.5 py-1.5",+ "transition-colors hover:bg-accent/40",+ )}+ >+ <button+ type="button"+ data-testid={`project-row-${project.id}`}+ onClick={() => toggleProject(project)}+ aria-expanded={open}+ className="flex min-w-0 flex-1 items-center gap-2 text-left"+ >+ <ChevronRight+ className={cn(+ "h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform",+ open && "rotate-90",+ )}+ aria-hidden+ />+ <span+ className="h-2 w-2 shrink-0 rounded-full"+ style={{ background: projectColor(project) }}+ aria-hidden+ />+ <span className="min-w-0 flex-1 truncate text-xs font-medium">+ {project.name}+ </span>+ {!project.exists && (+ <TriangleAlert+ className="h-3.5 w-3.5 shrink-0 text-amber-400"+ aria-label="Folder not reachable right now"+ />+ )}+ <span className="shrink-0 text-[10px] tabular-nums text-muted-foreground">+ {project.chats}+ </span>+ </button>+ <button+ type="button"+ onClick={() => onNewChat?.(project)}+ title={`New chat in ${project.name}`}+ aria-label={`New chat in ${project.name}`}+ className="flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground opacity-0 transition-opacity hover:bg-accent/60 hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100"+ >+ <Plus className="h-3.5 w-3.5" aria-hidden />+ </button>+ <div className="relative shrink-0">+ <button+ type="button"+ onClick={() =>+ setMenuFor((current) => (current === project.id ? null : project.id))+ }+ title={`More for ${project.name}`}+ aria-label={`More for ${project.name}`}+ className="flex h-6 w-6 items-center justify-center rounded text-muted-foreground opacity-0 transition-opacity hover:bg-accent/60 hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100"+ >+ <MoreHorizontal className="h-3.5 w-3.5" aria-hidden />+ </button>+ {menuFor === project.id && (+ <div+ className="absolute right-0 top-7 z-20 w-40 rounded-md border border-border bg-popover py-1 shadow-lg"+ onMouseLeave={() => setMenuFor(null)}+ >+ <MenuItem+ icon={Pencil}+ label="Rename"+ onClick={() => {+ setMenuFor(null);+ void renameProject(project);+ }}+ />+ <MenuItem+ icon={Archive}+ label={project.pinned ? "Unpin" : "Pin to top"}+ onClick={() => {+ setMenuFor(null);+ void patchProject(project.id, { pinned: !project.pinned }).then(+ reloadProjects,+ );+ }}+ />+ <MenuItem+ icon={Trash2}+ label="Remove project"+ destructive+ onClick={() => {+ setMenuFor(null);+ void removeProject(project);+ }}+ />+ </div>+ )}+ </div>+ </div>++ {open && (+ <div className="ml-4 border-l border-border/60 pl-1.5">+ {state.status === "loading" && (+ <div className="flex items-center gap-2 px-2 py-2 text-[11px] text-muted-foreground">+ <Loader2 className="h-3 w-3 animate-spin" aria-hidden />+ Loading chats…+ </div>+ )}+ {state.status === "error" && (+ <div className="px-2 py-2 text-[11px] text-destructive">+ {state.message}+ </div>+ )}+ {state.status === "ready" && state.chats.length === 0 && (+ <button+ type="button"+ onClick={() => onNewChat?.(project)}+ className="w-full rounded px-2 py-2 text-left text-[11px] text-muted-foreground hover:bg-accent/40 hover:text-foreground"+ >+ No chats yet — start one+ </button>+ )}+ {state.status === "ready" &&+ state.chats.map((chat) => (+ <div+ key={chat.id}+ className={cn(+ "group/chat flex items-center gap-1 rounded-md px-1 py-1",+ "transition-colors hover:bg-accent/40",+ activeChatId === chat.id && "bg-accent/60",+ )}+ >+ <button+ type="button"+ data-testid={`chat-row-${chat.id}`}+ onClick={() => onOpenChat?.(project, chat)}+ className="flex min-w-0 flex-1 items-center gap-2 text-left"+ >+ <AgentMark agent={chat.agent} label={chat.agent} size="sm" />+ <span className="min-w-0 flex-1">+ <span className="block truncate text-[11px] font-medium">+ {chat.title || "New chat"}+ </span>+ {chat.preview && (+ <span className="block truncate text-[10px] text-muted-foreground">+ {chat.preview}+ </span>+ )}+ </span>+ {chat.terminal && (+ <span+ className="h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-400"+ title="Running"+ aria-label="Running"+ />+ )}+ <span className="shrink-0 text-[10px] tabular-nums text-muted-foreground">+ {shortAge(chat.updated_at)}+ </span>+ </button>+ <div className="flex shrink-0 items-center opacity-0 transition-opacity focus-within:opacity-100 group-hover/chat:opacity-100">+ <IconButton+ icon={Pencil}+ label={`Rename ${chat.title || "chat"}`}+ onClick={() => void renameChat(project.id, chat)}+ />+ <IconButton+ icon={Archive}+ label={`Archive ${chat.title || "chat"}`}+ onClick={() => void archiveChat(project.id, chat)}+ />+ <IconButton+ icon={Trash2}+ label={`Delete ${chat.title || "chat"}`}+ destructive+ onClick={() => void removeChat(project.id, chat)}+ />+ </div>+ </div>+ ))}+ </div>+ )}+ </div>+ );+ })+ )}+ </div>++ <button+ type="button"+ onClick={onAddProject}+ className="flex items-center gap-2 border-t border-border px-3 py-2.5 text-xs text-muted-foreground transition-colors hover:bg-accent/40 hover:text-foreground"+ >+ <FolderOpen className="h-3.5 w-3.5" aria-hidden />+ Add a project folder+ </button>+ </div>+ );+}++function IconButton({+ icon: Icon,+ label,+ onClick,+ destructive,+}: {+ icon: typeof Pencil;+ label: string;+ onClick: () => void;+ destructive?: boolean;+}) {+ return (+ <button+ type="button"+ onClick={onClick}+ title={label}+ aria-label={label}+ className={cn(+ "flex h-5 w-5 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent/60",+ destructive ? "hover:text-destructive" : "hover:text-foreground",+ )}+ >+ <Icon className="h-3 w-3" aria-hidden />+ </button>+ );+}++function MenuItem({+ icon: Icon,+ label,+ onClick,+ destructive,+}: {+ icon: typeof Pencil;+ label: string;+ onClick: () => void;+ destructive?: boolean;+}) {+ return (+ <button+ type="button"+ onClick={onClick}+ className={cn(+ "flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-xs transition-colors hover:bg-accent/60",+ destructive ? "text-destructive" : "text-foreground",+ )}+ >+ <Icon className="h-3.5 w-3.5" aria-hidden />+ {label}+ </button>+ );+}diff --git a/jarvis/ui/web/frontend/src/components/layout/MainView.tsx b/jarvis/ui/web/frontend/src/components/layout/MainView.tsxindex d0e7ef48aa..9f949879b8 100644--- a/jarvis/ui/web/frontend/src/components/layout/MainView.tsx+++ b/jarvis/ui/web/frontend/src/components/layout/MainView.tsx@@ -89,6 +89,13 @@ const ExtensionsView = lazyView(() =>const AgenticIdeView = lazyPropView<AgenticIdeViewProps>(() =>import("@/views/AgenticIdeView").then((m) => ({ default: m.AgenticIdeView })),);+// The rebuilt chat surface. Lazy like every other section and NOT sticky: it+// holds no live terminal of its own yet, so there is nothing to tear down by+// unmounting it — that changes when the conversation view lands, and the+// sticky treatment moves with it.+const ChatWorkspaceView = lazyView(() =>+ import("@/views/ChatWorkspaceView").then((m) => ({ default: m.ChatWorkspaceView })),+);const TasksView = lazyView(() =>import("@/views/TasksView").then((m) => ({ default: m.TasksView })),);@@ -306,6 +313,8 @@ export function MainView() {function SwitchOnActiveSection({ active }: { active: string }) {switch (active) {+ case "chat-workspace":+ return <ChatWorkspaceView />;case "chats":return <ChatsView />;case "agents":diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex 4e3950d8b1..1242b7e1e7 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -62,6 +62,7 @@"update_network_error": "Netzwerkfehler"},"nav": {+ "chat_workspace": "Chat","chats": "Chats","agents": "{name}-Agents","extensions": "Skills, Plugins & MCPs",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex 21cc119bf8..f7c9f8227f 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -62,6 +62,7 @@"update_network_error": "network error"},"nav": {+ "chat_workspace": "Chat","chats": "Chats","agents": "{name}-Agents","extensions": "Skills, Plugins & MCPs",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex 5f8e638044..3b325797b8 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -62,6 +62,7 @@"update_network_error": "error de red"},"nav": {+ "chat_workspace": "Chat","chats": "Chats","agents": "{name}-Agents","extensions": "Skills, Plugins & MCPs",diff --git a/jarvis/ui/web/frontend/src/lib/chatLibraryApi.ts b/jarvis/ui/web/frontend/src/lib/chatLibraryApi.tsnew file mode 100644index 0000000000..2011c071c6--- /dev/null+++ b/jarvis/ui/web/frontend/src/lib/chatLibraryApi.ts@@ -0,0 +1,187 @@+/**+ * Client for the project/chat library — `/api/chat-library`.+ *+ * The shape of this module IS the lazy-loading rule: `fetchProjects` returns+ * rows with a chat COUNT, and `fetchChats` is a separate call taking one+ * project. There is deliberately no "give me everything" function, because the+ * moment one exists somebody calls it on mount and a user with forty repos+ * waits for a thousand conversations they did not ask for.+ *+ * Nothing here returns message content. Opening a conversation is a different+ * call against the coding CLI's own transcript; these rows are titles, marks+ * and timestamps.+ */++export interface ChatProject {+ id: string;+ path: string;+ name: string;+ color: string | null;+ pinned: boolean;+ archived: boolean;+ created_at: number;+ last_opened_at: number;+ /** Is the folder reachable right now? False = unplugged drive, dead share. */+ exists: boolean;+ /** How many live chats it holds. The count travels; the chats do not. */+ chats: number;+}++export interface ChatRow {+ id: string;+ project_id: string;+ title: string;+ agent: string;+ model: string | null;+ account: string | null;+ /** The live pane this chat is attached to, or null when nothing is running. */+ terminal: string | null;+ /** Can the CLI reopen this conversation? False = only a fresh start is honest. */+ resumable: boolean;+ created_at: number;+ updated_at: number;+ archived: boolean;+ preview: string;+ prompts_sent: number;+}++const BASE = "/api/chat-library";++export class ChatLibraryError extends Error {+ constructor(+ message: string,+ readonly status: number,+ ) {+ super(message);+ this.name = "ChatLibraryError";+ }+}++/**+ * One request, with the server's own explanation when it refuses.+ *+ * FastAPI answers a rejection with `{"detail": "..."}`, and that sentence is+ * almost always more useful than "Request failed" — a caller showing it to the+ * user is telling them what actually happened. A body that is not JSON (a proxy+ * error page, a restarting backend) falls back to the status text rather than+ * throwing a parse error on top of the original failure.+ */+async function request<T>(path: string, init?: RequestInit): Promise<T> {+ const response = await fetch(`${BASE}${path}`, {+ headers: init?.body ? { "Content-Type": "application/json" } : undefined,+ ...init,+ });+ if (!response.ok) {+ let detail = response.statusText;+ try {+ const body = await response.json();+ if (body && typeof body.detail === "string") detail = body.detail;+ } catch {+ /* not JSON — the status text is the best we have */+ }+ throw new ChatLibraryError(detail, response.status);+ }+ if (response.status === 204) return undefined as T;+ return (await response.json()) as T;+}++export async function fetchProjects(+ options: { includeArchived?: boolean } = {},+): Promise<ChatProject[]> {+ const query = options.includeArchived ? "?include_archived=true" : "";+ const body = await request<{ projects: ChatProject[] }>(`/projects${query}`);+ return body.projects;+}++/** Register (or re-open) a folder as a project. Idempotent by folder. */+export async function openProject(path: string, name?: string): Promise<ChatProject> {+ return request<ChatProject>("/projects", {+ method: "POST",+ body: JSON.stringify({ path, name }),+ });+}++export async function patchProject(+ projectId: string,+ changes: Partial<Pick<ChatProject, "name" | "color" | "pinned" | "archived">>,+): Promise<ChatProject> {+ return request<ChatProject>(`/projects/${encodeURIComponent(projectId)}`, {+ method: "PATCH",+ body: JSON.stringify(changes),+ });+}++export async function deleteProject(projectId: string): Promise<boolean> {+ const body = await request<{ removed: boolean }>(+ `/projects/${encodeURIComponent(projectId)}`,+ { method: "DELETE" },+ );+ return body.removed;+}++/** One project's chats. Called when a project is opened, never on mount. */+export async function fetchChats(+ projectId: string,+ options: { includeArchived?: boolean } = {},+): Promise<ChatRow[]> {+ const query = options.includeArchived ? "?include_archived=true" : "";+ const body = await request<{ chats: ChatRow[] }>(+ `/projects/${encodeURIComponent(projectId)}/chats${query}`,+ );+ return body.chats;+}++export async function createChat(+ projectId: string,+ options: { agent: string; model?: string | null; account?: string | null; title?: string },+): Promise<ChatRow> {+ return request<ChatRow>(`/projects/${encodeURIComponent(projectId)}/chats`, {+ method: "POST",+ body: JSON.stringify(options),+ });+}++export async function patchChat(+ projectId: string,+ chatId: string,+ changes: Partial<Pick<ChatRow, "title" | "archived" | "model" | "account">>,+): Promise<ChatRow> {+ return request<ChatRow>(+ `/projects/${encodeURIComponent(projectId)}/chats/${encodeURIComponent(chatId)}`,+ { method: "PATCH", body: JSON.stringify(changes) },+ );+}++export async function deleteChat(projectId: string, chatId: string): Promise<boolean> {+ const body = await request<{ removed: boolean }>(+ `/projects/${encodeURIComponent(projectId)}/chats/${encodeURIComponent(chatId)}`,+ { method: "DELETE" },+ );+ return body.removed;+}++/**+ * A stable accent colour for a project that has not been given one.+ *+ * Derived from the id so the same project is the same colour on every machine+ * and after every restart, and so a user never has to pick one to get a+ * readable sidebar. The palette is fixed rather than a free hue rotation:+ * arbitrary HSL produces colours that vanish against one of the two themes.+ */+const PROJECT_COLORS = [+ "#e7c46e",+ "#7dd3fc",+ "#a5b4fc",+ "#86efac",+ "#fca5a5",+ "#f0abfc",+ "#fdba74",+ "#5eead4",+] as const;++export function projectColor(project: Pick<ChatProject, "id" | "color">): string {+ if (project.color) return project.color;+ let sum = 0;+ for (const char of project.id) sum = (sum + char.charCodeAt(0)) % 4096;+ return PROJECT_COLORS[sum % PROJECT_COLORS.length];+}diff --git a/jarvis/ui/web/frontend/src/store/events.ts b/jarvis/ui/web/frontend/src/store/events.tsindex 522f111eb9..d9839eff01 100644--- a/jarvis/ui/web/frontend/src/store/events.ts+++ b/jarvis/ui/web/frontend/src/store/events.ts@@ -70,7 +70,10 @@ export type SectionId =| "voice-shortcuts"| "voice-language"| "voice-api-keys"- | "agentic-ide";+ | "agentic-ide"+ // The rebuilt chat surface — projects, their chats, one conversation on+ // screen. Lives alongside "agentic-ide" until its parity checklist is empty.+ | "chat-workspace";export const SECTION_IDS = ["chats",@@ -107,6 +110,7 @@ export const SECTION_IDS = ["voice-language","voice-api-keys","agentic-ide",+ "chat-workspace",] as const satisfies readonly SectionId[];export function isSectionId(value: unknown): value is SectionId {@@ -152,6 +156,7 @@ export const SECTION_LABELS: Record<SectionId, string> = {"voice-language": "Dictation Language","voice-api-keys": "Voice Input Keys","agentic-ide": "Agentic IDE",+ "chat-workspace": "Chat",};export interface EventItem {diff --git a/jarvis/ui/web/frontend/src/views/ChatWorkspaceView.tsx b/jarvis/ui/web/frontend/src/views/ChatWorkspaceView.tsxnew file mode 100644index 0000000000..76939c3760--- /dev/null+++ b/jarvis/ui/web/frontend/src/views/ChatWorkspaceView.tsx@@ -0,0 +1,219 @@+/**+ * The chat surface — projects on the left, one conversation on screen.+ *+ * This is the shell of the rebuilt section. It owns three things and delegates+ * everything else: which project/chat is open, how a project gets added, and+ * how a new chat is started. The list is `ChatLibrarySidebar`; the conversation+ * itself arrives in the next wave, reading the coding CLI's own transcript+ * rather than scraping a terminal.+ *+ * The header is deliberately the only chrome. The old surface stacked a+ * workspace bar, an agent column, a pane toolbar and a status strip around the+ * content, and the result was that the thing you came for — the conversation —+ * had the least room on screen.+ */+import { useCallback, useState } from "react";+import { FolderOpen, MessagesSquare, X } from "lucide-react";++import { AgentMark } from "@/components/agentic/AgentMark";+import { ChatLibrarySidebar } from "@/components/chat/ChatLibrarySidebar";+import { FolderPicker } from "@/components/agentic/FolderPicker";+import { PaneResizer } from "@/components/layout/PaneResizer";+import { useResizablePane } from "@/hooks/useResizablePane";+import { useEventStore } from "@/store/events";+import {+ type ChatProject,+ type ChatRow,+ createChat,+ openProject,+ projectColor,+} from "@/lib/chatLibraryApi";++/** What is on screen in the main column. */+interface OpenChat {+ project: ChatProject;+ chat: ChatRow;+}++export function ChatWorkspaceView() {+ const pushToast = useEventStore((s) => s.pushToast);+ const [open, setOpen] = useState<OpenChat | null>(null);+ const [picking, setPicking] = useState(false);+ const [pickedPath, setPickedPath] = useState<string | null>(null);+ /*+ * Bumped whenever something changes the library from OUT here — adding a+ * project, starting a chat. The sidebar remounts on the new key and reloads,+ * which is a great deal simpler than threading a refresh handle up through+ * it, and cheap because the reload is two small requests.+ */+ const [libraryKey, setLibraryKey] = useState(0);++ // The list column is drag-resizable and remembers its width, like every other+ // seam in the app.+ const list = useResizablePane({+ storageKey: "jarvis.chat.listWidth.v1",+ defaultSize: 288,+ min: 220,+ max: 480,+ });++ const addProject = useCallback(async () => {+ if (!pickedPath) return;+ try {+ await openProject(pickedPath);+ setPicking(false);+ setPickedPath(null);+ setLibraryKey((n) => n + 1);+ } catch (error) {+ pushToast(+ "error",+ error instanceof Error ? error.message : "Could not add that folder",+ );+ }+ }, [pickedPath, pushToast]);++ const startChat = useCallback(+ async (project: ChatProject) => {+ try {+ // The agent is asked for in the next wave's new-chat dialog. Until it+ // exists a chat is created unassigned rather than silently pinned to+ // one CLI — an empty agent shows a neutral mark, a wrong one would lie.+ const chat = await createChat(project.id, { agent: "" });+ setLibraryKey((n) => n + 1);+ setOpen({ project, chat });+ } catch (error) {+ pushToast(+ "error",+ error instanceof Error ? error.message : "Could not start that chat",+ );+ }+ },+ [pushToast],+ );++ return (+ <div className="flex h-full min-h-0 w-full" data-testid="chat-workspace">+ <div style={{ width: list.size }} className="h-full min-h-0 shrink-0">+ <ChatLibrarySidebar+ key={libraryKey}+ activeChatId={open?.chat.id ?? null}+ onOpenChat={(project, chat) => setOpen({ project, chat })}+ onNewChat={(project) => void startChat(project)}+ onAddProject={() => setPicking(true)}+ />+ </div>++ <PaneResizer+ orientation="vertical"+ onPointerDown={list.startResize}+ onDoubleClick={list.reset}+ onNudge={list.nudge}+ active={list.isResizing}+ title="Drag to resize the chat list — double-click to reset"+ />++ <div className="flex min-h-0 min-w-0 flex-1 flex-col">+ {open ? (+ <>+ <header className="flex shrink-0 items-center gap-3 border-b border-border px-4 py-3">+ <AgentMark agent={open.chat.agent} label={open.chat.agent || "?"} />+ <div className="min-w-0 flex-1">+ <div className="truncate text-sm font-semibold">+ {open.chat.title || "New chat"}+ </div>+ <div className="flex items-center gap-1.5 truncate text-xs text-muted-foreground">+ <span+ className="h-2 w-2 shrink-0 rounded-full"+ style={{ background: projectColor(open.project) }}+ aria-hidden+ />+ {open.project.name}+ </div>+ </div>+ <button+ type="button"+ onClick={() => setOpen(null)}+ title="Close this chat"+ aria-label="Close this chat"+ className="flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground"+ >+ <X className="h-4 w-4" aria-hidden />+ </button>+ </header>+ <div className="flex min-h-0 flex-1 items-center justify-center px-8 text-center">+ <div className="max-w-md">+ <MessagesSquare+ className="mx-auto mb-3 h-8 w-8 text-muted-foreground/60"+ aria-hidden+ />+ <p className="text-sm text-muted-foreground">+ Nothing has been said in this chat yet.+ </p>+ <p className="mt-1 text-xs text-muted-foreground/70">+ The conversation view and the composer land in the next wave — this+ chat already exists and will keep whatever is said in it.+ </p>+ </div>+ </div>+ </>+ ) : (+ <div className="flex min-h-0 flex-1 items-center justify-center px-8 text-center">+ <div className="max-w-md">+ <FolderOpen+ className="mx-auto mb-3 h-8 w-8 text-muted-foreground/60"+ aria-hidden+ />+ <p className="text-sm text-muted-foreground">+ Pick a chat on the left, or add a project folder to start one.+ </p>+ </div>+ </div>+ )}+ </div>++ {picking && (+ <div className="fixed inset-0 z-50 flex items-center justify-center bg-background/80 p-6">+ <div className="flex max-h-[80vh] w-full max-w-2xl flex-col overflow-hidden rounded-lg border border-border bg-card shadow-xl">+ <header className="flex items-center justify-between border-b border-border px-4 py-3">+ <h2 className="text-sm font-semibold">Add a project folder</h2>+ <button+ type="button"+ onClick={() => {+ setPicking(false);+ setPickedPath(null);+ }}+ aria-label="Cancel"+ className="flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent/60 hover:text-foreground"+ >+ <X className="h-4 w-4" aria-hidden />+ </button>+ </header>+ <div className="min-h-0 flex-1 overflow-auto p-3">+ <FolderPicker selected={pickedPath} onSelect={setPickedPath} />+ </div>+ <footer className="flex items-center justify-end gap-2 border-t border-border px-4 py-3">+ <button+ type="button"+ onClick={() => {+ setPicking(false);+ setPickedPath(null);+ }}+ className="rounded-md px-3 py-1.5 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground"+ >+ Cancel+ </button>+ <button+ type="button"+ disabled={!pickedPath}+ onClick={() => void addProject()}+ className="rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-40"+ >+ Add project+ </button>+ </footer>+ </div>+ </div>+ )}+ </div>+ );+}