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
chore: auto-save WIP via Claude stop-hook safety net (2026-07-07 19:34)
Ruben Lütkeb4aeaeef43eb
diff --git a/jarvis/ui/web/frontend/src/components/wiki/ObsidianSetupDialog.tsx b/jarvis/ui/web/frontend/src/components/wiki/ObsidianSetupDialog.tsxindex ee01b03b82..f320af567e 100644--- a/jarvis/ui/web/frontend/src/components/wiki/ObsidianSetupDialog.tsx+++ b/jarvis/ui/web/frontend/src/components/wiki/ObsidianSetupDialog.tsx@@ -24,6 +24,12 @@ import { Button } from "@/components/ui/button";import { cn } from "@/lib/utils";import { useT } from "@/i18n";import type { ObsidianStatus } from "@/types/setup";+import {+ fetchObsidianVaults,+ registerObsidianVault,+ type ObsidianVaultInfo,+ type RegisterMode,+} from "@/lib/obsidian";export interface ObsidianSetupDialogProps {/** Whether the dialog is visible. */@@ -55,8 +61,12 @@ interface RegisterResponse {vault_uuid?: string | null;backup_path?: string | null;error?: string | null;+ active_vault_root?: string | null;+ restart_required?: boolean;}+const RESTART_URL = "/api/settings/restart-app";+/*** Extract the final segment of the vault path so the* ``obsidian://open?vault=`` URL scheme can target it by name.@@ -183,12 +193,44 @@ export function ObsidianSetupDialog({const [registerHint, setRegisterHint] = useState<string | null>(null);const [registerError, setRegisterError] = useState<string | null>(null);+ // Step 2 — vault choice (spec A6): "separate" (default, today's behavior)+ // vs. "existing" (repoint into a vault the user already has in Obsidian).+ const [registerMode, setRegisterMode] = useState<RegisterMode>("separate");+ const [vaults, setVaults] = useState<ObsidianVaultInfo[]>([]);+ const [selectedVaultPath, setSelectedVaultPath] = useState<string | null>(null);++ // Result of a successful register, surfaced on step 3 regardless of mode.+ const [activeVaultRoot, setActiveVaultRoot] = useState<string | null>(null);+ const [restartRequired, setRestartRequired] = useState(false);+ const [restarting, setRestarting] = useState(false);+// Stable fetch reference.const fetchRef = useRef<typeof fetch>(fetchImpl ?? window.fetch.bind(window));useEffect(() => {fetchRef.current = fetchImpl ?? window.fetch.bind(window);}, [fetchImpl]);+ // Fetch the existing-vault picker list once when the dialog opens. Best+ // effort — a failed fetch just leaves "use my existing vault" disabled,+ // it never blocks the default "separate" path.+ useEffect(() => {+ if (!open) return;+ let cancelled = false;+ (async () => {+ try {+ const list = await fetchObsidianVaults(fetchRef.current);+ if (cancelled) return;+ setVaults(list);+ setSelectedVaultPath((prev) => prev ?? list[0]?.path ?? null);+ } catch {+ // Keep the picker disabled — this list is a nice-to-have.+ }+ })();+ return () => {+ cancelled = true;+ };+ }, [open]);+// Escape closes the dialog.useEffect(() => {if (!open) return;@@ -255,6 +297,8 @@ export function ObsidianSetupDialog({body.status === "added" ||body.status === "already_registered") {+ setActiveVaultRoot(body?.active_vault_root ?? null);+ setRestartRequired(Boolean(body?.restart_required));advance(3);} else {// Defensive: 200 with an unexpected body — surface as error.@@ -297,6 +341,61 @@ export function ObsidianSetupDialog({}}, [advance, t]);+ // "Use my existing vault" (mode="existing") — unlike `handleRegister`+ // above, the backend always answers HTTP 200 with a flat body for this+ // mode (see `registerObsidianVault`'s docstring), so no status-code+ // branching is needed here.+ const handleRegisterExisting = useCallback(async () => {+ if (!selectedVaultPath) return;+ setRegisterHint(null);+ setRegisterError(null);+ setRegistering(true);+ try {+ const body = await registerObsidianVault(+ "existing",+ selectedVaultPath,+ fetchRef.current,+ );+ if (body.status === "added" || body.status === "already_registered") {+ setActiveVaultRoot(body.active_vault_root ?? null);+ setRestartRequired(Boolean(body.restart_required));+ advance(3);+ } else {+ setRegisterError(+ `${t("obsidian_setup_dialog.register_failed")}: ${+ body.error ?? t("obsidian_setup_dialog.unknown_status")+ }`,+ );+ }+ } catch (exc) {+ const msg = exc instanceof Error ? exc.message : String(exc);+ setRegisterError(`${t("obsidian_setup_dialog.register_failed")}: ${msg}`);+ } finally {+ setRegistering(false);+ }+ }, [advance, selectedVaultPath, t]);++ const handleConfirmRegister = useCallback(() => {+ if (registerMode === "existing") {+ void handleRegisterExisting();+ } else {+ void handleRegister();+ }+ }, [registerMode, handleRegisterExisting, handleRegister]);++ const handleRestartNow = useCallback(async () => {+ setRestarting(true);+ try {+ await fetchRef.current(RESTART_URL, { method: "POST" });+ // On success the app tears itself down and relaunches — leave+ // `restarting` true so the button stays disabled until that happens.+ } catch {+ // Re-enable so the user can retry; the vault choice is already+ // persisted either way.+ setRestarting(false);+ }+ }, []);+const vaultName = useMemo(() => deriveVaultName(vaultPath), [vaultPath]);const handleLaunchObsidian = useCallback(() => {diff --git a/jarvis/ui/web/frontend/src/lib/obsidian.ts b/jarvis/ui/web/frontend/src/lib/obsidian.tsindex a59469c038..a634920ef3 100644--- a/jarvis/ui/web/frontend/src/lib/obsidian.ts+++ b/jarvis/ui/web/frontend/src/lib/obsidian.ts@@ -1,5 +1,7 @@/**- * Helpers for the Obsidian URL scheme.+ * Helpers for talking to the Obsidian integration: the `obsidian://` URL+ * scheme plus the setup-wizard API (`GET /api/setup/obsidian/vaults`,+ * `POST /api/setup/obsidian/register`).** The `obsidian://open?vault=<vault>&file=<path>` URL handler is installed* by Obsidian on the user's machine and opens the named file inside the@@ -15,6 +17,78 @@/** Vault name in Obsidian — matches the on-disk folder `wiki/obsidian-vault/`. */export const VAULT_NAME = "obsidian-vault";+/** One entry in the "use my existing vault" picker (spec A6). */+export interface ObsidianVaultInfo {+ path: string;+ name: string;+}++/**+ * List the user's already-registered Obsidian vaults, for the vault-choice+ * picker in `ObsidianSetupDialog`. Degrades to an empty list on any+ * non-OK response or `ok: false` body — the "use my existing vault" option+ * simply stays disabled rather than the dialog surfacing an error, since+ * this list is a nice-to-have, not load-bearing for the default setup path.+ *+ * Accepts an optional `fetchImpl` (mirrors the dialog's own `fetchImpl`+ * prop) so callers can inject a stable fetch reference for tests instead+ * of always hitting `window.fetch`.+ */+export async function fetchObsidianVaults(+ fetchImpl: typeof fetch = fetch,+): Promise<ObsidianVaultInfo[]> {+ const res = await fetchImpl("/api/setup/obsidian/vaults");+ if (!res.ok) return [];+ const body = (await res.json()) as {+ ok: boolean;+ vaults?: ObsidianVaultInfo[];+ };+ return body.ok ? (body.vaults ?? []) : [];+}++/** `"separate"` (default) creates a Jarvis-owned vault; `"existing"` repoints+ * Jarvis's vault root into a `Jarvis` subfolder of a vault the user already+ * has registered in Obsidian. */+export type RegisterMode = "separate" | "existing";++/** Flat result shape returned by `POST /api/setup/obsidian/register`. */+export interface ObsidianRegisterResult {+ status: string;+ active_vault_root?: string;+ restart_required?: boolean;+ error?: string;+}++/**+ * Register (or repoint) the Jarvis wiki vault.+ *+ * Unlike `mode="separate"`, which still answers HTTP 409/500 with a+ * FastAPI `{"detail": {...}}` error envelope for its failure branches (see+ * `ObsidianSetupDialog`'s own `handleRegister`, which parses those by+ * status code), `mode="existing"` always answers HTTP 200 with a flat+ * body — an unknown/missing `existingVaultPath` comes back inline as+ * `status: "config_missing"` rather than as an HTTP error (see+ * `jarvis/ui/web/setup_routes.py::obsidian_register`). This helper parses+ * the body unconditionally and is therefore only safe to use for+ * `mode="existing"`; the `separate` flow keeps its existing status-code-aware+ * handling in the dialog.+ */+export async function registerObsidianVault(+ mode: RegisterMode,+ existingVaultPath?: string | null,+ fetchImpl: typeof fetch = fetch,+): Promise<ObsidianRegisterResult> {+ const res = await fetchImpl("/api/setup/obsidian/register", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ mode,+ existing_vault_path: existingVaultPath ?? null,+ }),+ });+ return (await res.json()) as ObsidianRegisterResult;+}+/*** Build an `obsidian://open` URL for a vault-relative file path.*