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-06-30 18:12)

Ruben Lütke6393dbb2a715
diff --git a/jarvis/ui/web/frontend/src/components/OpenWithDialog.test.tsx b/jarvis/ui/web/frontend/src/components/OpenWithDialog.test.tsx
index 66a10da563..9e0cdb0f4f 100644
--- a/jarvis/ui/web/frontend/src/components/OpenWithDialog.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/OpenWithDialog.test.tsx
@@ -51,4 +51,15 @@ describe("OpenWithDialog", () => {
screen.getByText("No apps detected to open this file."),
).toBeDefined();
});
+
+ it("shows a detecting state (not the empty hint) while still loading", () => {
+ render(
+ <OpenWithDialog openers={[]} loading onPick={() => {}} onClose={() => {}} />,
+ );
+ // The misleading "no apps" message must NOT flash while detection runs.
+ expect(
+ screen.queryByText("No apps detected to open this file."),
+ ).toBeNull();
+ expect(screen.getByText("Detecting apps…")).toBeDefined();
+ });
});
diff --git a/jarvis/ui/web/frontend/src/components/OpenWithDialog.tsx b/jarvis/ui/web/frontend/src/components/OpenWithDialog.tsx
index 6bc83138b5..9d16626740 100644
--- a/jarvis/ui/web/frontend/src/components/OpenWithDialog.tsx
+++ b/jarvis/ui/web/frontend/src/components/OpenWithDialog.tsx
@@ -7,7 +7,7 @@
* event store; its only outputs are the `onPick` / `onClose` callbacks.
*/
import { useEffect, useState } from "react";
-import { AppWindow, FileText, Globe, X } from "lucide-react";
+import { AppWindow, FileText, Globe, Loader2, X } from "lucide-react";
import { cn } from "@/lib/utils";
import { useT } from "@/i18n";
@@ -16,6 +16,9 @@ import type { OpenerInfo } from "@/hooks/useOutputs";
export interface OpenWithDialogProps {
/** The apps that can open the artifact (from `useOpeners`). */
openers: OpenerInfo[];
+ /** True while the opener list is still being detected. Shows a spinner
+ * instead of the misleading "no apps detected" hint during that window. */
+ loading?: boolean;
/** Called with the chosen opener id and whether to remember it as default. */
onPick: (opener: string, remember: boolean) => void;
/** Called when the user dismisses the dialog (X, Escape, click-outside). */
@@ -37,7 +40,12 @@ function OpenerIcon({ id }: { id: string }) {
return <AppWindow className={cls} />;
}
-export function OpenWithDialog({ openers, onPick, onClose }: OpenWithDialogProps) {
+export function OpenWithDialog({
+ openers,
+ loading = false,
+ onPick,
+ onClose,
+}: OpenWithDialogProps) {
const t = useT();
const [remember, setRemember] = useState(false);
@@ -76,8 +84,15 @@ export function OpenWithDialog({ openers, onPick, onClose }: OpenWithDialogProps
</div>
{openers.length === 0 ? (
- <div className="py-4 text-center text-xs text-muted-foreground">
- {t("outputs_view.open_with_empty")}
+ <div className="flex items-center justify-center gap-2 py-4 text-center text-xs text-muted-foreground">
+ {loading ? (
+ <>
+ <Loader2 className="h-3.5 w-3.5 animate-spin" />
+ {t("outputs_view.open_with_loading")}
+ </>
+ ) : (
+ t("outputs_view.open_with_empty")
+ )}
</div>
) : (
<ul className="flex flex-col gap-1">
diff --git a/jarvis/ui/web/frontend/src/components/sessions/SessionDetail.tsx b/jarvis/ui/web/frontend/src/components/sessions/SessionDetail.tsx
index ecbc77e183..733b2b5402 100644
--- a/jarvis/ui/web/frontend/src/components/sessions/SessionDetail.tsx
+++ b/jarvis/ui/web/frontend/src/components/sessions/SessionDetail.tsx
@@ -317,6 +317,7 @@ export function SessionDetail({ detail, loading, error }: Props) {
{editorFormat && (
<OpenWithDialog
openers={openers.data ?? []}
+ loading={openers.isLoading}
onPick={pickOpener}
onClose={() => setEditorFormat(null)}
/>
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 462efd6ba6..d710883767 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -1205,6 +1205,7 @@
"open_with_remember": "Als Standard merken",
"open_with_change": "Öffnen-mit ändern",
"open_with_empty": "Keine Apps gefunden, um diese Datei zu öffnen.",
+ "open_with_loading": "Apps werden gesucht …",
"opener_default": "System-Standard-App",
"opener_browser": "Browser",
"reveal_in_folder": "Im Ordner anzeigen"
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 940c028b6f..5aad882dc1 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -1206,6 +1206,7 @@
"open_with_remember": "Remember as default",
"open_with_change": "Change how this opens",
"open_with_empty": "No apps detected to open this file.",
+ "open_with_loading": "Detecting apps…",
"opener_default": "System default app",
"opener_browser": "Browser",
"reveal_in_folder": "Reveal in folder"
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index d6f22abc10..ce446e2e99 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -1205,6 +1205,7 @@
"open_with_remember": "Recordar como predeterminado",
"open_with_change": "Cambiar cómo se abre",
"open_with_empty": "No se detectaron apps para abrir este archivo.",
+ "open_with_loading": "Detectando apps…",
"opener_default": "App predeterminada del sistema",
"opener_browser": "Navegador",
"reveal_in_folder": "Mostrar en la carpeta"
diff --git a/jarvis/ui/web/outputs_routes.py b/jarvis/ui/web/outputs_routes.py
index c0d4b9f342..d2bbc6e837 100644
--- a/jarvis/ui/web/outputs_routes.py
+++ b/jarvis/ui/web/outputs_routes.py
@@ -888,14 +888,41 @@ def _resolve_opener(opener_id: str) -> tuple[str, str] | None:
return None
+# Detecting the installed editors resolves each candidate, and a not-installed
+# one walks the whole Start Menu tree (``_resolve_via_start_menu``) — far too
+# slow to repeat on every chooser open. Recomputing it per request made the
+# dialog flash "no apps detected" for a second until the scan finished. The
+# installed-app set is stable for a session, so memoize with a short TTL; a
+# freshly installed editor still appears within the window or after a restart.
+_OPENERS_TTL_S = 300.0
+_openers_cache: tuple[float, list[dict[str, str]]] | None = None
+
+
+def _reset_openers_cache() -> None:
+ """Drop the memoized opener list. For tests and warm-up; safe to call anytime."""
+ global _openers_cache
+ _openers_cache = None
+
+
def _available_openers() -> list[dict[str, str]]:
- """The openers actually launchable on this host, for the chooser dialog."""
+ """The openers actually launchable on this host, for the chooser dialog.
+
+ Memoized per process (``_OPENERS_TTL_S``) because resolving each editor
+ candidate can walk the Start Menu tree, which is too slow to redo on every
+ dialog open.
+ """
+ global _openers_cache
+ now = time.monotonic()
+ cached = _openers_cache
+ if cached is not None and now - cached[0] < _OPENERS_TTL_S:
+ return cached[1]
out: list[dict[str, str]] = [{"id": "default", "label": "System default app"}]
if _resolve_browser_target() is not None:
out.append({"id": "browser", "label": "Browser"})
for oid, label in _OPENER_EDITORS:
if _resolve_installed(oid) is not None:
out.append({"id": oid, "label": label})
+ _openers_cache = (now, out)
return out
diff --git a/tests/unit/ui/web/test_outputs_routes.py b/tests/unit/ui/web/test_outputs_routes.py
index ab61cf0b3a..fad9160059 100644
--- a/tests/unit/ui/web/test_outputs_routes.py
+++ b/tests/unit/ui/web/test_outputs_routes.py
@@ -37,6 +37,18 @@ from jarvis.ui.web.outputs_routes import (
router as outputs_router,
)
+
[email protected](autouse=True)
+def _reset_openers_cache_between_tests():
+ """The opener list is memoized per process; clear it around every test so
+ the editor-detection cases don't see each other's cached result."""
+ from jarvis.ui.web import outputs_routes
+
+ outputs_routes._reset_openers_cache()
+ yield
+ outputs_routes._reset_openers_cache()
+
+
# --- Stubs -------------------------------------------------------------------
@@ -1035,6 +1047,30 @@ def test_openers_detects_installed_editor_only(app):
assert "cursor" not in ids # raw fallback → not installed → hidden
+def test_openers_result_is_memoized(app):
+ """Resolving the editor candidates walks the Start Menu per not-installed
+ editor — too slow to redo on every open. The list is cached per process, so
+ a second request must serve the cache without re-resolving (the fix for the
+ 'open' button taking too long and flashing 'no apps detected')."""
+ from unittest.mock import MagicMock
+
+ app.state.native_file_actions = True
+ resolver = MagicMock(side_effect=_fake_resolver_only("code"))
+ with patch(
+ "jarvis.plugins.tool.app_resolver.resolve_app_launch_target", resolver
+ ), patch(
+ "jarvis.ui.web.outputs_routes._resolve_browser_target", return_value=None
+ ):
+ client = TestClient(app)
+ first = client.get("/api/outputs/openers")
+ calls_after_first = resolver.call_count
+ second = client.get("/api/outputs/openers")
+
+ assert first.json() == second.json()
+ assert calls_after_first > 0 # first call did the real resolution
+ assert resolver.call_count == calls_after_first # second came from the cache
+
+
def test_open_with_404_when_native_disabled(app):
root = Path(app.state.outputs_root)
slug = "mission_019ed2dfd0fab"