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.

fix(ui): universal taskbar icon via per-window Relaunch properties

rubenluetke10-beep5aacce522ea7
diff --git a/docs/BUGS.md b/docs/BUGS.md
index c7cc028175..12d6e9e414 100644
--- a/docs/BUGS.md
+++ b/docs/BUGS.md
@@ -1288,6 +1288,61 @@ jarvis.ui.web.launcher` now re-execs to `PersonalJarvis.exe`, which OWNS the
"Personal Jarvis" window, and the live taskbar button is the Gigi ghost (captured
screenshot), not the Python logo.
+### Follow-up 2026-07-09 (part 3): v1.0.5 reinstall STILL showed Python — the per-window Relaunch properties are the actual universal fix
+
+**Part 2 shipped in v1.0.5 and the maintainer's reinstall still showed the Python
+logo.** Root cause of the recurrence: the reinstall rebuilt the venv against the
+**MS Store Python** — exactly the environment where the branded-exe re-exec
+degrades to a no-op (the Store base exe cannot be copied/branded), which part 2
+explicitly accepted as a cosmetic loss. That acceptance was wrong: it left every
+Store-Python install (and any install where the base dir is not writable) showing
+the Python logo forever. "Works on the maintainer's setup, breaks on the next
+machine" — the exact §3 defect class.
+
+**The mechanism part 2 missed** (and the reason its "the button follows the exe
+icon and NOTHING else" conclusion was incomplete): the taskbar button follows the
+window-owning exe's icon **only when the window carries no explicit identity of
+its own**. Windows exposes a per-window property store —
+`SHGetPropertyStoreForWindow` — with `System.AppUserModel.RelaunchIconResource` /
+`RelaunchDisplayNameResource` / `RelaunchCommand` / `ID`, documented precisely
+for apps hosted by a shared interpreter exe. Stamping
+`RelaunchIconResource = "<jarvis.ico>,0"` flips the LIVE button to the mascot
+instantly — no restart, no exe copy, no admin, works on MS-Store Python.
+
+**Fix:** `jarvis/ui/icon_utils.py::set_window_relaunch_properties(hwnd)` —
+stamps AUMID + icon + display name + relaunch command on the window's property
+store (session-cached per HWND, COM-initialized for the poll thread,
+best-effort). Called from `_apply_icon_to_hwnd`, the one chokepoint every icon
+path already funnels through (the desktop icon-setter poll by title/PID, Tk
+surfaces via `apply_tk_window_icon`), so every present and future window gets it
+for free. The part-2 branded-exe re-exec stays (correct exe identity on
+python.org installs); the relaunch properties are the layer that makes the
+button correct EVERYWHERE. Guard: `tests/unit/ui/test_relaunch_properties.py`
+(wiring + a real-window stamp/read-back test).
+
+**Verified on the Store-Python box that reproduced the report:** cold boot via
+bare `pythonw -m jarvis.ui.web.launcher` → taskbar button is the Gigi ghost;
+`SHGetPropertyStoreForWindow` read-back on the live window confirms AUMID +
+icon + name.
+
+**Collateral regression, same report:** after the v1.0.5 reinstall, Windows
+search no longer found "Personal Jarvis" — the Start-Menu shortcut
+(`%APPDATA%\...\Start Menu\Programs\Personal Jarvis.lnk`) was missing. The
+uninstall/reinstall removed it and the session kept running without it (boot-time
+re-ensure only runs at import). Two watchdog-instrumented reboots could NOT
+reproduce an active deleter in the app — every fresh boot recreates the shortcut
+correctly. Hardening anyway: the desktop icon-setter now re-ensures the shortcut
+once the window is up (`_start_icon_setter_thread`), so a shortcut deleted
+mid-session heals within the same session instead of at the next boot. (Windows
+search indexing may still lag a few minutes after recreation.)
+
+**Lesson:** "the taskbar follows the exe icon" was verified by *changing* the
+exe icon and watching the button follow — a true positive that masked the
+cheaper, more general mechanism sitting one API away. When a shell surface
+misbehaves, enumerate the *documented identity layers* for that surface first
+(window property store > shortcut > exe resource), and test the highest-level
+one before shipping workarounds at a lower level.
+
---
## Bug-008 Episode 2: Transcription view empty (HangupReason drift, regressed after restore) — 2026-05-05
diff --git a/jarvis/ui/desktop_app.py b/jarvis/ui/desktop_app.py
index a7c6d14999..81fba05723 100644
--- a/jarvis/ui/desktop_app.py
+++ b/jarvis/ui/desktop_app.py
@@ -3154,6 +3154,24 @@ class DesktopApp:
logger.debug(
"Taskbar icon set; re-arming against WebView2 override."
)
+ # Late shortcut self-heal: the import-time ensure runs
+ # before anything else — if the Start-Menu shortcut got
+ # deleted after that (an uninstall/reinstall race, a
+ # cleanup tool), Windows search loses "Personal Jarvis"
+ # for the whole session. Re-ensure once now that the
+ # window is up; idempotent + best-effort off the boot
+ # path (regression: search found no app, 2026-07-09).
+ try:
+ from jarvis.ui.icon_utils import (
+ ensure_start_menu_shortcut,
+ )
+
+ ensure_start_menu_shortcut()
+ except Exception: # noqa: BLE001 — never kill the poll
+ logger.debug(
+ "late Start-Menu shortcut re-ensure failed",
+ exc_info=True,
+ )
elif time.monotonic() - first_set_at > 8.0:
return
time.sleep(0.3)
diff --git a/jarvis/ui/icon_utils.py b/jarvis/ui/icon_utils.py
index f4e052b668..f1aba4b1a7 100644
--- a/jarvis/ui/icon_utils.py
+++ b/jarvis/ui/icon_utils.py
@@ -656,6 +656,90 @@ def ensure_windows_app_identity(app_id: str = APP_USER_MODEL_ID) -> bool:
return False
+# System.AppUserModel.* property keys (fmtid + pid) for the per-WINDOW property
+# store. ``RelaunchIconResource`` is THE documented mechanism for an app hosted
+# by a shared interpreter exe (pythonw) to give its taskbar button its own icon.
+_APPUSERMODEL_FMTID = "{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}"
+_PID_RELAUNCH_COMMAND = 2
+_PID_RELAUNCH_ICON = 3
+_PID_RELAUNCH_NAME = 4
+_PID_AUMID = 5
+
+# HWNDs already stamped with relaunch properties this session — the icon-setter
+# thread re-polls every 300 ms and the COM property-store dance is not free.
+_RELAUNCH_STAMPED: set[int] = set()
+
+
+def set_window_relaunch_properties(
+ hwnd: int,
+ *,
+ ico_path: Path | None = None,
+ aumid: str = APP_USER_MODEL_ID,
+ display_name: str = APP_DISPLAY_NAME,
+) -> bool:
+ """Stamp per-window AppUserModel Relaunch* properties → taskbar shows OUR icon.
+
+ THE universal taskbar-icon fix, and the one that finally covers every install
+ (verified live on an MS-Store-Python machine, where exe branding is
+ impossible): without explicit window properties, the Windows taskbar renders
+ a button with the icon of the window-owning EXECUTABLE — for a source run
+ that is ``pythonw.exe`` → the Python logo, no matter what ``WM_SETICON`` /
+ class icon / AUMID / Start-Menu shortcut say (all verified ineffective on the
+ button). ``SHGetPropertyStoreForWindow`` +
+ ``System.AppUserModel.RelaunchIconResource`` exists precisely for
+ interpreter-hosted apps: it tells the shell, per window, which icon (and
+ name/relaunch command, used when the button is pinned) the button carries.
+ Takes effect immediately on a live window — no restart, no exe copy.
+
+ Idempotent per HWND (session-cached), Windows-only, best-effort: any COM /
+ pywin32 hiccup returns ``False`` and the window keeps whatever the other
+ layers achieved. Returns ``True`` when the properties were committed.
+ """
+ if sys.platform != "win32" or not hwnd:
+ return False
+ if hwnd in _RELAUNCH_STAMPED:
+ return True
+ try:
+ import pywintypes
+ from win32com.propsys import propsys
+
+ try:
+ # The icon-setter poll runs on a plain daemon thread with no COM
+ # apartment; initialize one (idempotent, "already init" is fine).
+ import pythoncom
+
+ pythoncom.CoInitialize()
+ except Exception: # noqa: BLE001 — already initialized / free-threaded
+ pass
+
+ ico = ico_path or project_icon_path()
+ fmtid = pywintypes.IID(_APPUSERMODEL_FMTID)
+ store = propsys.SHGetPropertyStoreForWindow(
+ hwnd, propsys.IID_IPropertyStore
+ )
+ store.SetValue((fmtid, _PID_AUMID), propsys.PROPVARIANTType(aumid))
+ if ico.is_file():
+ store.SetValue(
+ (fmtid, _PID_RELAUNCH_ICON), propsys.PROPVARIANTType(f"{ico},0")
+ )
+ store.SetValue(
+ (fmtid, _PID_RELAUNCH_NAME), propsys.PROPVARIANTType(display_name)
+ )
+ pythonw = _pythonw_executable()
+ if pythonw is not None:
+ store.SetValue(
+ (fmtid, _PID_RELAUNCH_COMMAND),
+ propsys.PROPVARIANTType(f'"{pythonw}" -m {_LAUNCHER_MODULE}'),
+ )
+ store.Commit()
+ _RELAUNCH_STAMPED.add(hwnd)
+ logger.debug("Relaunch properties stamped on hwnd={}", hwnd)
+ return True
+ except Exception as exc: # noqa: BLE001 — cosmetic layer, never load-bearing
+ logger.debug("relaunch properties could not be stamped: {}", exc)
+ return False
+
+
def _apply_icon_to_hwnd(hwnd: int, ico_path: Path) -> bool:
"""Set window + class icon on a known HWND. Returns True on success."""
if sys.platform != "win32":
@@ -666,6 +750,12 @@ def _apply_icon_to_hwnd(hwnd: int, ico_path: Path) -> bool:
logger.warning("Icon file missing: {}", ico_path)
return False
+ # Per-window relaunch properties FIRST — the only layer the taskbar button
+ # honours on every install (incl. MS-Store Python, where the branded-exe
+ # re-exec cannot run). The class/WM_SETICON work below still covers the
+ # titlebar + Alt-Tab surfaces.
+ set_window_relaunch_properties(hwnd, ico_path=ico_path)
+
try:
import ctypes
from ctypes import wintypes
diff --git a/tests/unit/ui/test_relaunch_properties.py b/tests/unit/ui/test_relaunch_properties.py
new file mode 100644
index 0000000000..503a917597
--- /dev/null
+++ b/tests/unit/ui/test_relaunch_properties.py
@@ -0,0 +1,88 @@
+"""Regression guard: per-window Relaunch* properties brand the taskbar button.
+
+THE universal taskbar-icon fix (2026-07-09, part 3). The Windows taskbar renders
+a button with the icon of the window-owning EXECUTABLE unless the window carries
+explicit ``System.AppUserModel.RelaunchIconResource`` properties — for a source
+run under ``pythonw.exe`` that exe icon is the Python logo, and on MS-Store
+Python the owning exe cannot even be copied/branded (read-only 0-byte alias), so
+the branded-exe re-exec is impossible there. ``SHGetPropertyStoreForWindow`` +
+the Relaunch* keys exist precisely for interpreter-hosted apps and take effect
+on a LIVE window (verified on an MS-Store-Python machine). These tests pin the
+wiring so no refactor silently drops the one layer that works everywhere.
+"""
+from __future__ import annotations
+
+import inspect
+import sys
+
+import pytest
+
+from jarvis.ui import icon_utils
+
+
+def test_relaunch_properties_api_is_importable() -> None:
+ assert callable(icon_utils.set_window_relaunch_properties)
+
+
+def test_apply_icon_chokepoint_stamps_relaunch_properties() -> None:
+ """Every icon path funnels through ``_apply_icon_to_hwnd`` — it must stamp
+ the relaunch properties, or MS-Store-Python installs regress to the Python
+ logo (the branded-exe re-exec cannot run there)."""
+ src = inspect.getsource(icon_utils._apply_icon_to_hwnd)
+ assert "set_window_relaunch_properties" in src
+
+
+def test_desktop_icon_setter_reensures_the_start_menu_shortcut() -> None:
+ """The icon-setter poll must re-ensure the Start-Menu shortcut once the
+ window is up — without it, a shortcut deleted mid-session leaves Windows
+ search unable to find "Personal Jarvis" (regression 2026-07-09)."""
+ import jarvis.ui.desktop_app as desktop_app
+
+ src = inspect.getsource(desktop_app.DesktopApp._start_icon_setter_thread)
+ assert "ensure_start_menu_shortcut" in src
+
+
+def test_non_windows_is_a_noop() -> None:
+ if sys.platform == "win32":
+ pytest.skip("Windows behaviour covered by the real-window test")
+ assert icon_utils.set_window_relaunch_properties(12345) is False
+
+
[email protected](sys.platform != "win32", reason="Windows-only shell surface")
+def test_relaunch_properties_stick_on_a_real_window() -> None:
+ """Stamp a real Tk window and read the properties back from the shell."""
+ tk = pytest.importorskip("tkinter")
+ pywintypes = pytest.importorskip("pywintypes")
+ propsys_mod = pytest.importorskip("win32com.propsys")
+ propsys = propsys_mod.propsys
+
+ try:
+ root = tk.Tk()
+ except tk.TclError:
+ pytest.skip("no display available for Tk")
+ try:
+ root.withdraw()
+ root.update_idletasks()
+ hwnd = int(root.winfo_id())
+
+ assert icon_utils.set_window_relaunch_properties(hwnd) is True
+ # Second call: session-cached fast path.
+ assert icon_utils.set_window_relaunch_properties(hwnd) is True
+
+ fmtid = pywintypes.IID(icon_utils._APPUSERMODEL_FMTID)
+ store = propsys.SHGetPropertyStoreForWindow(
+ hwnd, propsys.IID_IPropertyStore
+ )
+ aumid = store.GetValue((fmtid, icon_utils._PID_AUMID)).GetValue()
+ icon = store.GetValue((fmtid, icon_utils._PID_RELAUNCH_ICON)).GetValue()
+ name = store.GetValue((fmtid, icon_utils._PID_RELAUNCH_NAME)).GetValue()
+
+ assert aumid == icon_utils.APP_USER_MODEL_ID
+ assert name == icon_utils.APP_DISPLAY_NAME
+ assert str(icon).lower().endswith(".ico,0")
+ finally:
+ try:
+ icon_utils._RELAUNCH_STAMPED.discard(hwnd)
+ except Exception: # noqa: BLE001 — cache hygiene only
+ pass
+ root.destroy()