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.

chore: auto-save WIP via Claude stop-hook safety net (2026-07-01 19:39)

Ruben Lütke70cf4b2aa918
diff --git a/jarvis/ui/web/frontend/index.html b/jarvis/ui/web/frontend/index.html
index 574ed9e0c6..f8f7968c87 100644
--- a/jarvis/ui/web/frontend/index.html
+++ b/jarvis/ui/web/frontend/index.html
@@ -5,7 +5,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/png" sizes="256x256" href="/jarvis-gigi-256.png" />
<link rel="icon" type="image/x-icon" href="/jarvis-gigi.ico" />
- <title>Jarvis</title>
+ <!-- Neutral, trademark-free fallback title. The inline boot script below
+ overwrites it with the user's own assistant name (from the localStorage
+ cache) the instant the window opens, so a trademarked placeholder is
+ never shown. -->
+ <title>Assistant</title>
<style>
/* Boot splash — painted from index.html the instant the window opens, so
there is NO black screen while the (large) JS bundle loads + React
@@ -41,10 +45,37 @@
<div id="root">
<div id="jarvis-boot-splash">
<div class="ring"></div>
- <div class="name">Personal Jarvis</div>
+ <!-- Painted synchronously by the inline script below from the cached
+ assistant name (the user's chosen wake word, e.g. "Nico"). Left
+ empty in static HTML so the very first run — before any name is
+ cached — shows only the spinner, never a hardcoded / trademarked
+ name. -->
+ <div class="name"></div>
<div class="sub">Starting…</div>
</div>
</div>
+ <script>
+ // Paint the user's own assistant name (derived from their wake word) into
+ // the boot splash + window title the instant the window opens. The name is
+ // read SYNCHRONOUSLY from localStorage — no network, no await — so this
+ // adds effectively zero startup latency. The cache is written by the app
+ // after each name resolve (see src/lib/assistantNameCache.ts; keep this
+ // storage key in lockstep). On the very first run the cache is empty and
+ // the splash keeps just its spinner. A trademarked placeholder such as
+ // "Jarvis" is never painted here.
+ (function () {
+ try {
+ var name = (localStorage.getItem("jarvis.assistantName") || "").trim();
+ if (name) {
+ var el = document.querySelector("#jarvis-boot-splash .name");
+ if (el) el.textContent = name;
+ document.title = name;
+ }
+ } catch (e) {
+ /* storage blocked (private mode) — keep the neutral fallback */
+ }
+ })();
+ </script>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
diff --git a/jarvis/ui/web/frontend/src/__tests__/i18nNameInterpolation.test.tsx b/jarvis/ui/web/frontend/src/__tests__/i18nNameInterpolation.test.tsx
index e262844040..dc350aa268 100644
--- a/jarvis/ui/web/frontend/src/__tests__/i18nNameInterpolation.test.tsx
+++ b/jarvis/ui/web/frontend/src/__tests__/i18nNameInterpolation.test.tsx
@@ -33,7 +33,7 @@ function RestartHintProbe() {
describe("useT name substitution", () => {
beforeEach(() => {
- useEventStore.setState({ assistantName: "Jarvis" });
+ useEventStore.setState({ assistantName: "Assistant" });
});
afterEach(() => cleanup());
@@ -46,14 +46,16 @@ describe("useT name substitution", () => {
expect(text).not.toContain("Jarvis");
});
- it("renders the default 'Jarvis' when the store is unseeded (test backward-compat)", () => {
+ it("renders the neutral default when the store is unseeded — never a trademarked name", () => {
render(<RestartHintProbe />);
- expect(screen.getByTestId("hint").textContent).toBe("Restart Jarvis");
+ const text = screen.getByTestId("hint").textContent ?? "";
+ expect(text).toBe("Restart Assistant");
+ expect(text).not.toContain("Jarvis");
});
it("follows a live rename through t()", () => {
render(<RestartHintProbe />);
- expect(screen.getByTestId("hint").textContent).toBe("Restart Jarvis");
+ expect(screen.getByTestId("hint").textContent).toBe("Restart Assistant");
act(() => {
useEventStore.setState({ assistantName: "Athena" });
diff --git a/jarvis/ui/web/frontend/src/hooks/useAssistantNameSeed.test.tsx b/jarvis/ui/web/frontend/src/hooks/useAssistantNameSeed.test.tsx
index 1058ac652d..e594de635d 100644
--- a/jarvis/ui/web/frontend/src/hooks/useAssistantNameSeed.test.tsx
+++ b/jarvis/ui/web/frontend/src/hooks/useAssistantNameSeed.test.tsx
@@ -18,13 +18,15 @@ function Harness() {
describe("useAssistantNameSeed mount seed", () => {
beforeEach(() => {
- useEventStore.setState({ assistantName: "Jarvis" });
+ localStorage.clear();
+ useEventStore.setState({ assistantName: "Assistant" });
});
afterEach(() => {
cleanup();
vi.restoreAllMocks();
vi.unstubAllGlobals();
+ localStorage.clear();
});
it("seeds assistantName from GET /api/settings/assistant-name { resolved }", async () => {
@@ -75,7 +77,7 @@ describe("useAssistantNameSeed mount seed", () => {
render(<Harness />);
await Promise.resolve();
- expect(useEventStore.getState().assistantName).toBe("Jarvis");
+ expect(useEventStore.getState().assistantName).toBe("Assistant");
});
it("ignores an empty resolved value (does not blank the wordmark)", async () => {
@@ -91,6 +93,21 @@ describe("useAssistantNameSeed mount seed", () => {
await Promise.resolve();
await Promise.resolve();
- expect(useEventStore.getState().assistantName).toBe("Jarvis");
+ expect(useEventStore.getState().assistantName).toBe("Assistant");
+ });
+
+ it("caches the resolved name in localStorage for an instant next-boot paint", async () => {
+ vi.stubGlobal(
+ "fetch",
+ vi.fn(async () => ({
+ ok: true,
+ json: async () => ({ resolved: "Nico" }),
+ })) as unknown as typeof fetch,
+ );
+
+ render(<Harness />);
+
+ await waitFor(() => expect(useEventStore.getState().assistantName).toBe("Nico"));
+ expect(localStorage.getItem("jarvis.assistantName")).toBe("Nico");
});
});
diff --git a/jarvis/ui/web/frontend/src/hooks/useAssistantNameSeed.ts b/jarvis/ui/web/frontend/src/hooks/useAssistantNameSeed.ts
index 719afd2fc0..655304fd10 100644
--- a/jarvis/ui/web/frontend/src/hooks/useAssistantNameSeed.ts
+++ b/jarvis/ui/web/frontend/src/hooks/useAssistantNameSeed.ts
@@ -1,5 +1,6 @@
import { useEffect } from "react";
import { useEventStore } from "@/store/events";
+import { writeCachedAssistantName } from "@/lib/assistantNameCache";
/**
* Seed the resolved assistant name into the global store on mount.
@@ -29,7 +30,12 @@ export function useAssistantNameSeed(): void {
if (cancelled || !data) return;
const resolved =
typeof data.resolved === "string" ? data.resolved.trim() : "";
- if (resolved) setAssistantName(resolved);
+ if (resolved) {
+ setAssistantName(resolved);
+ // Mirror into localStorage so the next boot can paint this name
+ // instantly (store seed + index.html splash) with no fetch wait.
+ writeCachedAssistantName(resolved);
+ }
})
.catch(() => {
// Network/timeout/headless — keep the store value; a later rename
diff --git a/jarvis/ui/web/frontend/src/lib/assistantNameCache.test.ts b/jarvis/ui/web/frontend/src/lib/assistantNameCache.test.ts
new file mode 100644
index 0000000000..c423ad76f5
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/assistantNameCache.test.ts
@@ -0,0 +1,51 @@
+/**
+ * The assistant name shown at boot must never be a trademarked placeholder
+ * (e.g. "Jarvis" / Marvel), because it is briefly visible before the real,
+ * user-chosen name resolves. These tests lock (a) the round-trip cache so the
+ * user's own name paints instantly on the next boot, and (b) the trademark-free
+ * neutral fallback used on the first run.
+ */
+import { afterEach, beforeEach, describe, expect, it } from "vitest";
+
+import {
+ ASSISTANT_NAME_CACHE_KEY,
+ NEUTRAL_ASSISTANT_NAME,
+ readCachedAssistantName,
+ writeCachedAssistantName,
+} from "@/lib/assistantNameCache";
+
+describe("assistantNameCache", () => {
+ beforeEach(() => localStorage.clear());
+ afterEach(() => localStorage.clear());
+
+ it("returns the neutral fallback when nothing is cached", () => {
+ expect(readCachedAssistantName()).toBe(NEUTRAL_ASSISTANT_NAME);
+ });
+
+ it("round-trips the resolved name for an instant next-boot paint", () => {
+ writeCachedAssistantName("Nico");
+ expect(readCachedAssistantName()).toBe("Nico");
+ expect(localStorage.getItem(ASSISTANT_NAME_CACHE_KEY)).toBe("Nico");
+ });
+
+ it("trims whitespace and ignores blank writes (never blanks the wordmark)", () => {
+ writeCachedAssistantName(" Athena ");
+ expect(readCachedAssistantName()).toBe("Athena");
+
+ writeCachedAssistantName(" ");
+ // Blank write is a no-op — the previous value survives.
+ expect(readCachedAssistantName()).toBe("Athena");
+ });
+
+ it("honours a caller-supplied fallback", () => {
+ expect(readCachedAssistantName("")).toBe("");
+ });
+
+ // Trademark guard: the neutral fallback must be a generic word, never a
+ // product or character name. This is the regression fence for the boot-time
+ // "Jarvis" flash that prompted this cache.
+ it("never falls back to a trademarked name", () => {
+ expect(NEUTRAL_ASSISTANT_NAME).not.toMatch(/jarvis/i);
+ expect(readCachedAssistantName()).not.toMatch(/jarvis/i);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/lib/assistantNameCache.ts b/jarvis/ui/web/frontend/src/lib/assistantNameCache.ts
new file mode 100644
index 0000000000..f61783a17f
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/assistantNameCache.ts
@@ -0,0 +1,66 @@
+/**
+ * Local, synchronous cache for the resolved assistant display name.
+ *
+ * The assistant's name is derived from the user's configured wake word (e.g.
+ * "Nico" / "Athena"). It lives authoritatively on the backend and is fetched by
+ * `useAssistantNameSeed` after mount. That fetch is asynchronous, so during the
+ * first paint the store would otherwise fall back to a hardcoded placeholder —
+ * which MUST NEVER be a trademarked name such as "Jarvis" (Marvel), because the
+ * placeholder is briefly visible before the real name resolves. A single frame
+ * of a trademarked character name is a real legal exposure for redistributors,
+ * so the placeholder is always trademark-free.
+ *
+ * To make the user's own name appear instantly at boot with ZERO added latency,
+ * we mirror the last resolved name into `localStorage` — a synchronous,
+ * in-process read with no network round-trip. The store seeds from this cache,
+ * and `index.html` paints the boot splash from it via a tiny inline script. On
+ * the very first run the cache is empty and the neutral fallback is used until
+ * the fetch resolves.
+ *
+ * The storage key is duplicated verbatim in `index.html`'s inline boot script —
+ * keep the two in lockstep.
+ */
+
+/** localStorage key holding the last resolved assistant name. */
+export const ASSISTANT_NAME_CACHE_KEY = "jarvis.assistantName";
+
+/**
+ * Neutral, trademark-free fallback used only until a real name is known (first
+ * run, or a blocked/empty cache). Matches the backend's neutral default in
+ * `jarvis.brain.assistant_name.resolve_assistant_name`. It is intentionally a
+ * generic word, never a product or character name — and never empty, because
+ * `interpolateName` leaves the `{name}` token intact for an empty value, which
+ * would surface a literal "{name}" in the UI.
+ */
+export const NEUTRAL_ASSISTANT_NAME = "Assistant";
+
+/**
+ * Synchronously read the cached assistant name. Returns `fallback` when no name
+ * has been cached yet or storage is unavailable (private mode / headless).
+ */
+export function readCachedAssistantName(
+ fallback: string = NEUTRAL_ASSISTANT_NAME,
+): string {
+ try {
+ const cached = window.localStorage.getItem(ASSISTANT_NAME_CACHE_KEY);
+ const trimmed = cached ? cached.trim() : "";
+ return trimmed || fallback;
+ } catch {
+ return fallback;
+ }
+}
+
+/**
+ * Persist the resolved name so the next boot can paint it instantly. Empty or
+ * whitespace-only names are ignored (they would blank the wordmark). A blocked
+ * storage (private mode) is a silent no-op — the async fetch still seeds the
+ * store on that run.
+ */
+export function writeCachedAssistantName(name: string): void {
+ try {
+ const trimmed = (name || "").trim();
+ if (trimmed) window.localStorage.setItem(ASSISTANT_NAME_CACHE_KEY, trimmed);
+ } catch {
+ // Storage disabled — non-fatal; the fetch path still seeds the store.
+ }
+}
diff --git a/jarvis/ui/web/frontend/src/store/events.ts b/jarvis/ui/web/frontend/src/store/events.ts
index 600f2c46a8..d63005bbb8 100644
--- a/jarvis/ui/web/frontend/src/store/events.ts
+++ b/jarvis/ui/web/frontend/src/store/events.ts
@@ -1,5 +1,6 @@
import { create } from "zustand";
import type { MessageRole } from "@/types/messages";
+import { readCachedAssistantName } from "@/lib/assistantNameCache";
import {
finalizeThinkingSteps,
reduceThinkingSteps,
@@ -214,9 +215,12 @@ interface EventStore {
// phrase with its prefix stripped, else the neutral "Assistant" default —
// [persona].name was removed 2026-06-20). Seeded once at app start by
// useAssistantNameSeed and refreshed on a wake-word save, so the
- // header wordmark + every assistant byline follow the configured identity
- // instead of a hardcoded "Jarvis". Defaults to "Jarvis" only for the sub-tick
- // before the local seed fetch resolves (zero-regression first paint).
+ // header wordmark + every assistant byline follow the configured identity.
+ // The initial value is read SYNCHRONOUSLY from the localStorage cache (the
+ // last resolved name) so the user's own name paints instantly at boot with no
+ // added latency; it falls back to the neutral "Assistant" — NEVER a
+ // trademarked placeholder like "Jarvis" — only on the very first run before
+ // any name has been cached. See src/lib/assistantNameCache.ts.
assistantName: string;
// Chat mic-dictation (transcribe-only). ``dictating`` is true while the mic
// session runs; ``dictationText`` is the live interim tail (overwritten by
@@ -301,7 +305,7 @@ export const useEventStore = create<EventStore>((set, get) => ({
thinkingTraces: {},
brainProvider: "unknown",
brainModel: "",
- assistantName: "Jarvis",
+ assistantName: readCachedAssistantName(),
dictating: false,
dictationText: "",
dictationCommitSeq: 0,