Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(modes): a Modes section - pick a character, or talk one into existence
rubenluetke10-beepdf243bdf997c
diff --git a/jarvis/ui/web/frontend/src/components/layout/MainView.tsx b/jarvis/ui/web/frontend/src/components/layout/MainView.tsxindex 86e00e790d..8134f2f69e 100644--- a/jarvis/ui/web/frontend/src/components/layout/MainView.tsx+++ b/jarvis/ui/web/frontend/src/components/layout/MainView.tsx@@ -78,6 +78,9 @@ const JarvisAgentsView = lazyView(() =>const WikiView = lazyView(() =>import("@/views/WikiView").then((m) => ({ default: m.WikiView })),);+const ModesView = lazyView(() =>+ import("@/views/ModesView").then((m) => ({ default: m.ModesView })),+);const ApiKeysView = lazyView(() =>import("@/views/ApiKeysView").then((m) => ({ default: m.ApiKeysView })),);@@ -433,6 +436,10 @@ function SwitchOnActiveSection({ active }: { active: string }) {// AROUND it looks like (see App.tsx).case "visualization":return <VisualizationView />;+ // The assistant's character: which mode is active, and the workshop for+ // building another one by talking to it.+ case "modes":+ return <ModesView />;// Deliberately nothing: the coding workspace is rendered by the STICKY// branch in `MainView` above, which keeps it mounted across section// changes. This switch is not rendered at all while one of those ids isdiff --git a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsxindex acd763583a..e470e318dd 100644--- a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx+++ b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx@@ -7,6 +7,7 @@ import {Settings,UserCircle2,ListTodo,+ Drama,FolderOpen,Gauge,Notebook,@@ -156,6 +157,14 @@ const NAV_GROUPS: NavItem[][] = [fallbackLabel: "Voice",},{ id: "outputs", labelKey: "nav.outputs", icon: FolderOpen },+ // The assistant's character. Sits with the configuration group because it+ // changes how the assistant behaves everywhere, not what any one page holds.+ {+ id: "modes",+ labelKey: "nav.modes",+ icon: Drama,+ fallbackLabel: "Modes",+ },// Appearance. Sits with the configuration group rather than with the// content views: it changes how the app looks, not what it holds.{diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex db807b3c1c..ae9af71624 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -101,6 +101,7 @@"feedback": "Feedback","agent_instructions": "{name}.md","wallpaper": "Hintergrund",+ "modes": "Modi","agentic_ide": "Agentic IDE","agentic_ide_beta": "Beta","voice": "{name} Stimme",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex 9b6483624a..485b6b21bc 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -101,6 +101,7 @@"feedback": "Feedback","agent_instructions": "{name}.md","wallpaper": "Wallpaper",+ "modes": "Modes","agentic_ide": "Agentic IDE","agentic_ide_beta": "Beta","voice": "{name} Voice",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex a64f49a35b..ab1041e202 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -101,6 +101,7 @@"feedback": "Comentarios","agent_instructions": "{name}.md","wallpaper": "Fondo de pantalla",+ "modes": "Modos","agentic_ide": "IDE agéntico","agentic_ide_beta": "Beta","voice": "Voz de {name}",diff --git a/jarvis/ui/web/frontend/src/lib/modesApi.ts b/jarvis/ui/web/frontend/src/lib/modesApi.tsnew file mode 100644index 0000000000..c1b153db13--- /dev/null+++ b/jarvis/ui/web/frontend/src/lib/modesApi.ts@@ -0,0 +1,104 @@+/**+ * Client for /api/modes — the assistant's shelf of characters.+ *+ * A mode changes how Jarvis behaves in voice AND in chat from the next turn on,+ * with no restart, because both brains read the persona through one function on+ * the backend. Nothing here needs to know that; it matters only in that a+ * switch is a single call and the UI never has to tell the user to restart.+ */++/** Layer 4 of the five-layer enum pattern — mirrors `modes.VERBOSITIES`. */+export type Verbosity = "brief" | "normal" | "rich";+/** Mirrors `modes.PROACTIVITIES`. */+export type Proactivity = "reactive" | "normal" | "forward";++export interface AssistantMode {+ slug: string;+ name: string;+ emoji: string;+ description: string;+ /** How the assistant behaves — appended to the base persona, never replacing it. */+ character: string;+ built_in: boolean;+ voice: string;+ verbosity: Verbosity;+ proactivity: Proactivity;+}++export interface ModesState {+ modes: AssistantMode[];+ active: string;+ /**+ * A mode a SCREEN switched on (today: the Agentic IDE), which outranks the+ * user's own choice while it lasts. Surfaced so the UI can say why the active+ * card is not the one the user picked — an unexplained mode is exactly what+ * this feature was built to replace.+ */+ section_override: string;+ verbosities: Verbosity[];+ proactivities: Proactivity[];+}++async function readJson<T>(res: Response): Promise<T> {+ if (!res.ok) {+ // FastAPI puts the human-readable reason in `detail`; surfacing it beats a+ // bare status code, because every failure here has a specific cause the+ // user can act on ("that is a built-in mode", "that looks like a path").+ let detail = `${res.status} ${res.statusText}`;+ try {+ const body = (await res.json()) as { detail?: string };+ if (body?.detail) detail = body.detail;+ } catch {+ /* a non-JSON error body leaves the status line as the message */+ }+ throw new Error(detail);+ }+ return (await res.json()) as T;+}++export async function fetchModes(): Promise<ModesState> {+ return readJson<ModesState>(await fetch("/api/modes"));+}++export async function activateMode(slug: string): Promise<ModesState> {+ return readJson<ModesState>(+ await fetch("/api/modes/active", {+ method: "PUT",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ slug }),+ }),+ );+}++export interface ModeDraft {+ slug?: string;+ name: string;+ character: string;+ emoji?: string;+ description?: string;+ voice?: string;+ verbosity?: Verbosity;+ proactivity?: Proactivity;+}++export async function saveMode(draft: ModeDraft): Promise<ModesState> {+ return readJson<ModesState>(+ await fetch("/api/modes", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify(draft),+ }),+ );+}++export async function deleteMode(slug: string): Promise<ModesState> {+ return readJson<ModesState>(+ await fetch(`/api/modes/${encodeURIComponent(slug)}`, { method: "DELETE" }),+ );+}++export async function restoreBuiltin(slug: string): Promise<ModesState> {+ return readJson<ModesState>(+ await fetch(`/api/modes/${encodeURIComponent(slug)}/restore`, { method: "POST" }),+ );+}diff --git a/jarvis/ui/web/frontend/src/store/events.ts b/jarvis/ui/web/frontend/src/store/events.tsindex 5cdfeaed75..936d3c5672 100644--- a/jarvis/ui/web/frontend/src/store/events.ts+++ b/jarvis/ui/web/frontend/src/store/events.ts@@ -87,7 +87,9 @@ export type SectionId =// The OLD terminal grid. "agentic-ide" now opens the rebuilt chat surface,// so the grid needs an id of its own — it still holds live panes and must// stay reachable while the new surface grows into full parity.- | "agentic-ide-classic";+ | "agentic-ide-classic"+ // The assistant's character: pick a mode, or build one by talking to it.+ | "modes";export const SECTION_IDS = ["chats",@@ -128,6 +130,7 @@ export const SECTION_IDS = ["agentic-ide","chat-workspace","agentic-ide-classic",+ "modes",] as const satisfies readonly SectionId[];export function isSectionId(value: unknown): value is SectionId {@@ -194,6 +197,7 @@ export const SECTION_LABELS: Record<SectionId, string> = {"agentic-ide": "Agentic IDE","chat-workspace": "Chat","agentic-ide-classic": "Terminal grid",+ modes: "Modes",};export interface EventItem {diff --git a/jarvis/ui/web/frontend/src/views/ModesView.tsx b/jarvis/ui/web/frontend/src/views/ModesView.tsxnew file mode 100644index 0000000000..62b478d97c--- /dev/null+++ b/jarvis/ui/web/frontend/src/views/ModesView.tsx@@ -0,0 +1,408 @@+/**+ * Modes — pick the character the assistant answers in, or build a new one.+ *+ * Two halves, in the order the decision actually gets made: the shelf you+ * choose from, and the workshop where you make another one. Switching applies+ * from the next turn in voice AND in chat, with no restart, because both brains+ * read the persona through one function on the backend.+ *+ * The workshop offers two ways in, because describing a personality out loud+ * and typing one are genuinely different tasks. "Talk it through" opens a real+ * voice conversation: the assistant interviews you and writes the mode itself+ * with its `save_mode` tool. The written path hands the same job to the chat.+ * Either way the mode lands in the same place and shows up on this screen.+ *+ * Colours come from theme tokens only, so the view is correct in light and dark+ * without a second palette to keep in step.+ */+import { useCallback, useEffect, useMemo, useState } from "react";+import { Loader2, Mic, MicOff, Plus, RotateCcw, Sparkles, Trash2, Check } from "lucide-react";++import { ViewHeader } from "@/views/ChatsView";+import { useEventStore } from "@/store/events";+import { useVoiceCall } from "@/components/agentic/useVoiceCall";+import { sendChatMessage } from "@/lib/chat";+import { cn } from "@/lib/utils";+import {+ activateMode,+ deleteMode,+ fetchModes,+ restoreBuiltin,+ saveMode,+ type AssistantMode,+ type ModesState,+ type Proactivity,+ type Verbosity,+} from "@/lib/modesApi";++/**+ * What the assistant is told when the user asks for an interview.+ *+ * Deliberately an instruction to ASK rather than to produce: handed "build me a+ * friendly mode", a model writes one immediately and the user gets whatever it+ * guessed. The point of the interview is that the questions surface the things+ * people do not think to say — whether they want to be disagreed with, what the+ * assistant should never do, how it should open a conversation.+ */+const INTERVIEW_BRIEF =+ "I want to create a new assistant mode — a character for you to answer in. " ++ "Interview me first: ask me one question at a time about how you should " ++ "behave. How should you greet me? Should you have opinions and disagree with " ++ "me? How long should your answers be? Should you ask about my day, or stay " ++ "on the task? What should you never do? When you have enough, read the mode " ++ "back to me in a sentence and save it with the save_mode tool.";++const VERBOSITY_LABELS: Record<Verbosity, string> = {+ brief: "Short answers",+ normal: "Normal length",+ rich: "Explains the reasoning",+};++const PROACTIVITY_LABELS: Record<Proactivity, string> = {+ reactive: "Answers only what was asked",+ normal: "Balanced",+ forward: "Thinks a step ahead",+};++const EMPTY_DRAFT = {+ name: "",+ emoji: "",+ description: "",+ character: "",+ verbosity: "normal" as Verbosity,+ proactivity: "normal" as Proactivity,+};++export function ModesView() {+ const pushToast = useEventStore((s) => s.pushToast);+ const setActiveSection = useEventStore((s) => s.setActiveSection);+ const { active: voiceLive, busy: voiceBusy, connecting, toggleCall } = useVoiceCall();++ const [state, setState] = useState<ModesState | null>(null);+ const [loading, setLoading] = useState(true);+ const [switching, setSwitching] = useState("");+ const [draft, setDraft] = useState(EMPTY_DRAFT);+ const [saving, setSaving] = useState(false);+ const [written, setWritten] = useState("");++ const refresh = useCallback(async () => {+ try {+ setState(await fetchModes());+ } catch {+ // Backend still warming, or headless. Keep whatever we had: blanking the+ // shelf on a hiccup would claim the user has no modes, which is a claim+ // about their setup rather than about this one failed read.+ } finally {+ setLoading(false);+ }+ }, []);++ useEffect(() => {+ void refresh();+ }, [refresh]);++ /*+ * While a voice interview is running, watch for the mode it creates.+ *+ * The assistant saves through its own tool, not through this screen, so there+ * is no response here to react to. Polling is confined to exactly that window+ * — a call in progress — rather than running for the whole session, which is+ * how a background refresh quietly becomes a per-second request forever.+ */+ useEffect(() => {+ if (!voiceLive) return;+ const timer = setInterval(() => void refresh(), 4000);+ return () => clearInterval(timer);+ }, [voiceLive, refresh]);++ const modes = useMemo(() => state?.modes ?? [], [state]);+ const override = state?.section_override ?? "";++ const choose = async (slug: string) => {+ setSwitching(slug);+ try {+ setState(await activateMode(slug));+ } catch (e) {+ pushToast("error", (e as Error).message);+ } finally {+ setSwitching("");+ }+ };++ const remove = async (mode: AssistantMode) => {+ try {+ setState(mode.built_in ? await restoreBuiltin(mode.slug) : await deleteMode(mode.slug));+ pushToast("success", mode.built_in ? `${mode.name} restored.` : `${mode.name} deleted.`);+ } catch (e) {+ pushToast("error", (e as Error).message);+ }+ };++ const create = async () => {+ if (!draft.name.trim() || !draft.character.trim()) {+ pushToast("warning", "A mode needs a name and a description of how it behaves.");+ return;+ }+ setSaving(true);+ try {+ setState(await saveMode(draft));+ pushToast("success", `${draft.name} saved.`);+ setDraft(EMPTY_DRAFT);+ } catch (e) {+ pushToast("error", (e as Error).message);+ } finally {+ setSaving(false);+ }+ };++ const startInterview = async () => {+ // Ending a call needs no brief — only the opening of one does.+ if (!voiceLive) pushToast("info", "Say what kind of assistant you want. I'll ask the rest.");+ await toggleCall();+ };++ const describeInWriting = async () => {+ const text = written.trim();+ if (!text) return;+ const sent = await sendChatMessage(`${INTERVIEW_BRIEF}\n\nTo start: ${text}`);+ if (!sent) {+ pushToast("error", "The chat connection is not up yet.");+ return;+ }+ setWritten("");+ // The conversation happens in Chats, so go where the answer will appear+ // rather than leaving the user watching a screen that will not change.+ setActiveSection("chats");+ };++ return (+ <div className="flex h-full flex-col overflow-y-auto">+ <ViewHeader+ icon={<Sparkles className="h-4 w-4 text-muted-foreground" />}+ title="Modes"+ subtitle="How the assistant behaves. Applies to voice and chat from the next turn."+ />++ {loading ? (+ <div className="flex flex-1 items-center justify-center">+ <Loader2 className="h-5 w-5 animate-spin text-muted-foreground" />+ </div>+ ) : (+ <div className="flex flex-col gap-8 px-6 py-6">+ {override && (+ <p className="rounded-lg border border-border bg-secondary/40 px-4 py-3 text-sm text-muted-foreground">+ The <span className="font-medium text-foreground">{override}</span> mode is in force+ while that section is open. Your own choice comes back when you leave it.+ </p>+ )}++ <section className="flex flex-col gap-3">+ <h3 className="font-display text-sm font-semibold tracking-tight">Your modes</h3>+ <div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">+ {modes.map((mode) => {+ const isActive = mode.slug === state?.active;+ return (+ <button+ key={mode.slug}+ type="button"+ onClick={() => void choose(mode.slug)}+ disabled={switching !== ""}+ aria-pressed={isActive}+ data-testid={`mode-card-${mode.slug}`}+ className={cn(+ "group relative flex flex-col gap-2 rounded-xl border p-4 text-left transition-colors",+ isActive+ ? "border-primary bg-primary/10"+ : "border-border bg-secondary/30 hover:bg-secondary/60",+ )}+ >+ <div className="flex items-center gap-2">+ <span className="text-lg leading-none">{mode.emoji || "•"}</span>+ <span className="font-medium">{mode.name}</span>+ {isActive && <Check className="ml-auto h-4 w-4 text-primary" />}+ {switching === mode.slug && (+ <Loader2 className="ml-auto h-4 w-4 animate-spin text-muted-foreground" />+ )}+ </div>+ <p className="text-sm text-muted-foreground">{mode.description}</p>+ <div className="mt-1 flex items-center gap-2 text-xs text-muted-foreground">+ <span>{VERBOSITY_LABELS[mode.verbosity]}</span>+ <span aria-hidden>·</span>+ <span>{PROACTIVITY_LABELS[mode.proactivity]}</span>+ </div>+ {/*+ Built-ins offer "restore", user modes offer "delete" — the+ same button position, because to the user both mean "undo+ what I did to this card".+ */}+ <span+ role="button"+ tabIndex={0}+ aria-label={mode.built_in ? `Restore ${mode.name}` : `Delete ${mode.name}`}+ onClick={(e) => {+ e.stopPropagation();+ void remove(mode);+ }}+ onKeyDown={(e) => {+ if (e.key !== "Enter" && e.key !== " ") return;+ e.stopPropagation();+ e.preventDefault();+ void remove(mode);+ }}+ className="absolute right-3 top-3 hidden rounded p-1 text-muted-foreground hover:bg-destructive/20 hover:text-destructive group-hover:block"+ >+ {mode.built_in ? (+ <RotateCcw className="h-3.5 w-3.5" />+ ) : (+ <Trash2 className="h-3.5 w-3.5" />+ )}+ </span>+ </button>+ );+ })}+ </div>+ </section>++ <section className="flex flex-col gap-4">+ <div>+ <h3 className="font-display text-sm font-semibold tracking-tight">Build a mode</h3>+ <p className="mt-1 text-sm text-muted-foreground">+ Describe the assistant you want and let it write the mode, or fill it in yourself.+ </p>+ </div>++ <div className="grid gap-4 lg:grid-cols-2">+ <div className="flex flex-col gap-3 rounded-xl border border-border bg-secondary/30 p-4">+ <button+ type="button"+ onClick={() => void startInterview()}+ disabled={voiceBusy || connecting}+ data-testid="mode-interview-button"+ className={cn(+ "flex items-center justify-center gap-2 rounded-lg px-4 py-3 font-medium transition-colors",+ voiceLive+ ? "bg-destructive/15 text-destructive hover:bg-destructive/25"+ : "bg-primary text-primary-foreground hover:opacity-90",+ (voiceBusy || connecting) && "opacity-60",+ )}+ >+ {connecting ? (+ <Loader2 className="h-4 w-4 animate-spin" />+ ) : voiceLive ? (+ <MicOff className="h-4 w-4" />+ ) : (+ <Mic className="h-4 w-4" />+ )}+ {voiceLive ? "End the conversation" : "Talk it through"}+ </button>+ <p className="text-sm text-muted-foreground">+ {voiceLive+ ? "Listening. Describe the assistant you want — it will ask the rest and save the mode when you agree."+ : "Opens a voice conversation. It interviews you, then writes the mode itself."}+ </p>++ <div className="mt-2 flex flex-col gap-2 border-t border-border pt-3">+ <label className="text-xs font-medium text-muted-foreground" htmlFor="mode-written">+ Rather type it?+ </label>+ <textarea+ id="mode-written"+ value={written}+ onChange={(e) => setWritten(e.target.value)}+ rows={3}+ placeholder="A version of you that is blunt and never softens bad news…"+ className="resize-none rounded-lg border border-border bg-background px-3 py-2 text-sm outline-none focus:border-primary"+ />+ <button+ type="button"+ onClick={() => void describeInWriting()}+ disabled={!written.trim()}+ className="self-start rounded-lg border border-border px-3 py-1.5 text-sm hover:bg-secondary/60 disabled:opacity-50"+ >+ Ask in chat+ </button>+ </div>+ </div>++ <div className="flex flex-col gap-3 rounded-xl border border-border bg-secondary/30 p-4">+ <div className="flex gap-2">+ <input+ aria-label="Emoji"+ value={draft.emoji}+ onChange={(e) => setDraft({ ...draft, emoji: e.target.value })}+ placeholder="🦉"+ className="w-16 rounded-lg border border-border bg-background px-3 py-2 text-center text-sm outline-none focus:border-primary"+ />+ <input+ aria-label="Mode name"+ value={draft.name}+ onChange={(e) => setDraft({ ...draft, name: e.target.value })}+ placeholder="Night Owl"+ className="flex-1 rounded-lg border border-border bg-background px-3 py-2 text-sm outline-none focus:border-primary"+ />+ </div>+ <input+ aria-label="One-line description"+ value={draft.description}+ onChange={(e) => setDraft({ ...draft, description: e.target.value })}+ placeholder="Quiet and short. Refuses to start new work late."+ className="rounded-lg border border-border bg-background px-3 py-2 text-sm outline-none focus:border-primary"+ />+ <textarea+ aria-label="How it behaves"+ value={draft.character}+ onChange={(e) => setDraft({ ...draft, character: e.target.value })}+ rows={5}+ placeholder="Speak quietly. It is late and I am winding down…"+ className="resize-none rounded-lg border border-border bg-background px-3 py-2 text-sm outline-none focus:border-primary"+ />+ <div className="flex flex-wrap gap-2">+ <select+ aria-label="Answer length"+ value={draft.verbosity}+ onChange={(e) => setDraft({ ...draft, verbosity: e.target.value as Verbosity })}+ className="rounded-lg border border-border bg-background px-3 py-2 text-sm outline-none focus:border-primary"+ >+ {(state?.verbosities ?? []).map((v) => (+ <option key={v} value={v}>+ {VERBOSITY_LABELS[v]}+ </option>+ ))}+ </select>+ <select+ aria-label="How much it volunteers"+ value={draft.proactivity}+ onChange={(e) =>+ setDraft({ ...draft, proactivity: e.target.value as Proactivity })+ }+ className="rounded-lg border border-border bg-background px-3 py-2 text-sm outline-none focus:border-primary"+ >+ {(state?.proactivities ?? []).map((p) => (+ <option key={p} value={p}>+ {PROACTIVITY_LABELS[p]}+ </option>+ ))}+ </select>+ </div>+ <button+ type="button"+ onClick={() => void create()}+ disabled={saving}+ data-testid="mode-save-button"+ className="flex items-center justify-center gap-2 self-start rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:opacity-90 disabled:opacity-60"+ >+ {saving ? (+ <Loader2 className="h-4 w-4 animate-spin" />+ ) : (+ <Plus className="h-4 w-4" />+ )}+ Save mode+ </button>+ </div>+ </div>+ </section>+ </div>+ )}+ </div>+ );+}