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
fix(desktop): the embedded browser keeps its profile across restarts
Harald7cc9567d442b
diff --git a/jarvis/ui/desktop_app.py b/jarvis/ui/desktop_app.pyindex 4cb24700f3..e59afc3ac1 100644--- a/jarvis/ui/desktop_app.py+++ b/jarvis/ui/desktop_app.py@@ -996,6 +996,58 @@ async def _await_cancellable_chat_turn(runtime_refs.clear_active_chat_turn(task)+# ---------------------------------------------------------------------------+# WebView profile — where the embedded browser keeps its site data+# ---------------------------------------------------------------------------++#: The embedded browser's profile directory, relative to the data directory.+WEBVIEW_PROFILE_DIRNAME = "webview"+++def webview_storage_dir(+ *,+ data_dir: Path | None = None,+ fallback_dir: Path | None = None,+) -> Path | None:+ """The directory the embedded browser persists its site data in, or None.++ pywebview starts in ``private_mode`` by default: the WebView2 profile lives+ in a fresh ``%TEMP%\tmpXXXX`` folder that nobody deletes, and everything the+ frontend keeps in ``localStorage`` — the chosen wallpaper, the deck/classic+ surface, pane sizes, favourites, the theme cache the boot script paints the+ first frame from — dies with the process (forensic 2026-08-18: light chrome+ on the dark bundled artwork after every restart, because the light pick was+ gone while the theme itself survived on the backend). The profile therefore+ lives in a fixed directory next to the other per-checkout state, and the+ same call persists it on every backend pywebview has (Edge, WebKitGTK, Qt,+ Cocoa) — see ``docs/os-parity.md``.++ Per checkout on purpose (``DATA_DIR``, like the single-instance lock): two+ checkouts running side by side must not fight over one browser profile. A+ read-only checkout falls back to the per-user data directory, exactly like+ the credential store does; if neither can be created the caller keeps+ pywebview's private mode — a wallpaper that does not survive a restart is+ not worth failing the boot over.+ """+ candidates: list[Path] = [+ (data_dir if data_dir is not None else DATA_DIR) / WEBVIEW_PROFILE_DIRNAME+ ]+ if fallback_dir is not None:+ candidates.append(fallback_dir / WEBVIEW_PROFILE_DIRNAME)+ else:+ from jarvis.core.paths import user_data_dir++ candidates.append(user_data_dir() / WEBVIEW_PROFILE_DIRNAME)+ for candidate in candidates:+ try:+ candidate.mkdir(parents=True, exist_ok=True)+ if os.access(candidate, os.W_OK):+ return candidate+ except OSError:+ continue+ return None++# ---------------------------------------------------------------------------# Single-Instance-Lock# ---------------------------------------------------------------------------@@ -4849,12 +4901,28 @@ class DesktopApp:# crash the app or tear down the backend thread that is already serving# the UI: degrade to the browser-UI fallback. No-op on Windows/macOS# where the native backend starts normally.+ # The browser profile is persistent (see webview_storage_dir): the+ # frontend's localStorage — wallpaper, surface, pane sizes, theme cache+ # — must survive a restart, and pywebview's default private mode throws+ # it away with the process. Only when no directory can be written does+ # the shell fall back to that private mode, and says so.+ storage_dir = webview_storage_dir()+ if storage_dir is None:+ from loguru import logger as _profile_logger++ _profile_logger.warning(+ "No writable directory for the WebView profile — the browser "+ "runs in private mode and the interface forgets its wallpaper "+ "and layout on every restart."+ )try:webview.start(func=self._inject_token,args=(self._window,),gui=gui,debug=debug,+ private_mode=storage_dir is None,+ storage_path=str(storage_dir) if storage_dir is not None else None,)except webview.WebViewException as exc:# Not swallowed: the exception is handed to the degrade path, whichdiff --git a/tests/unit/ui/test_desktop_webview_profile.py b/tests/unit/ui/test_desktop_webview_profile.pynew file mode 100644index 0000000000..53440d2b22--- /dev/null+++ b/tests/unit/ui/test_desktop_webview_profile.py@@ -0,0 +1,76 @@+"""The desktop shell keeps the embedded browser's profile across restarts.++pywebview defaults to ``private_mode=True`` — a fresh WebView2 profile in+``%TEMP%`` per launch — and everything the frontend stores in ``localStorage``+(the wallpaper pick, the deck/classic surface, pane sizes, favourites, the+theme cache the boot script paints the first frame from) died with the+process. Forensic 2026-08-18: after every restart the interface wore light+chrome over the dark bundled artwork, because the light pick was gone while+the theme survived on the backend.++These tests pin the directory the shell hands pywebview: per checkout, with+the same fallbacks the credential store uses, and an honest ``None`` (→ private+mode, logged) only when nothing can be written.+"""++from __future__ import annotations++from pathlib import Path++from jarvis.ui.desktop_app import WEBVIEW_PROFILE_DIRNAME, webview_storage_dir+++def test_profile_lives_under_the_data_dir(tmp_path: Path) -> None:+ got = webview_storage_dir(data_dir=tmp_path, fallback_dir=tmp_path / "unused")++ assert got == tmp_path / WEBVIEW_PROFILE_DIRNAME+ assert got.is_dir()+ # The fallback is not touched while the primary works.+ assert not (tmp_path / "unused").exists()+++def test_profile_is_created_when_missing(tmp_path: Path) -> None:+ data_dir = tmp_path / "data"+ assert not data_dir.exists()++ got = webview_storage_dir(data_dir=data_dir, fallback_dir=tmp_path / "user")++ assert got == data_dir / WEBVIEW_PROFILE_DIRNAME+ assert got.is_dir()+++def test_profile_falls_back_to_the_user_dir_when_the_checkout_is_read_only(+ tmp_path: Path,+) -> None:+ # A FILE where the data dir should be: mkdir(parents=True) fails with an+ # OSError, which is what a read-only site-packages checkout looks like.+ blocked = tmp_path / "blocked"+ blocked.write_text("", encoding="utf-8")+ user_dir = tmp_path / "user"++ got = webview_storage_dir(data_dir=blocked, fallback_dir=user_dir)++ assert got == user_dir / WEBVIEW_PROFILE_DIRNAME+ assert got.is_dir()+++def test_no_writable_dir_means_none_not_a_crash(tmp_path: Path) -> None:+ blocked_a = tmp_path / "a"+ blocked_b = tmp_path / "b"+ blocked_a.write_text("", encoding="utf-8")+ blocked_b.write_text("", encoding="utf-8")++ assert webview_storage_dir(data_dir=blocked_a, fallback_dir=blocked_b) is None+++def test_default_lives_next_to_the_other_per_checkout_state() -> None:+ from jarvis.core.config import DATA_DIR+ from jarvis.core.paths import user_data_dir++ got = webview_storage_dir()++ # Either the checkout's own data dir or the per-user fallback — never a+ # temp folder, which is exactly what private mode used.+ assert got is not None+ assert got.name == WEBVIEW_PROFILE_DIRNAME+ assert got.parent in {DATA_DIR, user_data_dir()}