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): give the JarvisBar the Jarvis mascot icon on every OS

rubenluetke10-beep61c3d7eaf61c
diff --git a/docs/BUGS.md b/docs/BUGS.md
index c40d4b5474..7820fca980 100644
--- a/docs/BUGS.md
+++ b/docs/BUGS.md
@@ -1188,6 +1188,51 @@ leftovers survive this fix and are *not* the app's identity: the stale pinned
unpin/re-pin to clear) and the mic-privacy flyout (`NVIDIA Broadcast / Python`),
which lists the raw *process* name and cannot be renamed without a signed host.
+### Follow-up 2026-07-09: the Python logo came back — via the JarvisBar (drift regression)
+
+A user on a **fresh test machine** saw the blue/yellow Python logo again. The
+main pywebview window was healthy (verified live: its class icon is the mascot),
+and so was the OLD orb (`ui/orb/overlay.py`, which still carried
+`_apply_jarvis_icon_to_tk_root`). The culprit was the **JarvisBar**
+(`jarvis/ui/jarvisbar/overlay.py`) — the newer Tk surface that is now the
+**DEFAULT** `orb_style` (`jarvis_bar`). It created its `tk.Tk()` root with **no
+icon work at all**, so it inherited the process icon (`pythonw.exe` → Python
+logo). Enumerating the live process confirmed it: two top-level windows under one
+PID — `WindowsForms10` "Personal Jarvis" wearing the mascot, `TkTopLevel`
+"JarvisBar" wearing Python. The frameless bar is normally `WS_EX_TOOLWINDOW`
+(off the taskbar), but that trick is best-effort on Win11; any leak surfaces the
+Python logo, exactly as root cause #1 predicted.
+
+**Root cause: drift.** The icon fix lived only in the orb; the JarvisBar was
+added later and never got it — the two Tk surfaces had diverged. **Fix:** one
+canonical, cross-platform helper `jarvis.ui.icon_utils.apply_tk_window_icon(root)`
+that BOTH the JarvisBar and the orb now call (the orb is now a thin wrapper), so
+they cannot drift again:
+
+- **Windows** — `ensure_windows_app_identity()` + `iconbitmap(default=.ico)` +
+ the Win32 `WM_SETICON`/`SetClassLongPtrW` class-icon override. `iconphoto` is
+ deliberately NOT used on Windows: Tk re-asserts a `PhotoImage`-derived class
+ icon on later map/update cycles and raced/overwrote the `SetClassLongPtrW`
+ handle, leaving the live window a **blank/greyed** class icon (observed on the
+ running app before the path was split). The `.ico` + Win32 path is the proven
+ one.
+- **Linux / macOS** — `root.iconphoto(True, PhotoImage(jarvis.png))`, which sets
+ `_NET_WM_ICON` (what the dock/taskbar reads); the PNG is stashed on the root so
+ Python does not GC it. This is the Linux face of the same "shows python3, not
+ Jarvis" symptom.
+
+**Verified end-to-end on the live app:** restarted the running desktop app
+(editable install picks up the edit) and re-extracted the actual "JarvisBar"
+window's class icon via `GetClassLongPtrW + DrawIconEx + GetDIBits` → the mascot,
+not Python (and not blank). Guard: `tests/unit/ui/test_tk_icon_applied.py`
+(importable helper + source-wiring assertions that fail if either Tk surface
+stops calling it + a real-window Windows check).
+
+**Lesson — the anti-drift rule generalizes:** every NEW window-spawning surface
+(Tk toplevel, Qt window, subprocess) must route through the ONE
+`apply_tk_window_icon` / `ensure_windows_app_identity` call site. A second copy of
+the icon dance is a latent Python-logo regression waiting for the next surface.
+
---
## Bug-008 Episode 2: Transcription view empty (HangupReason drift, regressed after restore) — 2026-05-05
diff --git a/jarvis/ui/icon_utils.py b/jarvis/ui/icon_utils.py
index 36b09aede5..60d3060628 100644
--- a/jarvis/ui/icon_utils.py
+++ b/jarvis/ui/icon_utils.py
@@ -298,6 +298,85 @@ def set_window_icon_by_hwnd(hwnd: int, ico_path: Path) -> bool:
return _apply_icon_to_hwnd(hwnd, ico_path)
+def apply_tk_window_icon(root: Any) -> None:
+ """Give a Tkinter root/Toplevel the Jarvis mascot icon on **every** OS.
+
+ Tkinter registers its window class *without* a class-icon slot, so a
+ ``python -m …`` launch leaves every Tk window inheriting the interpreter's
+ process icon: on Windows the taskbar/titlebar falls back to
+ ``pythonw.exe`` → the blue/yellow Python logo, on Linux to the generic
+ ``python3`` interpreter icon. Both are the same "shows Python, not Jarvis"
+ symptom (BUG #UI-Pin-2026-05-05). Any Tk surface — the JarvisBar, the orb,
+ any future Tk dialog — must call this once, right after creating its root,
+ or it will visibly regress to the Python logo.
+
+ Two OS-specific paths, because the toolkits read different surfaces:
+
+ **Windows** — the taskbar renders the window *class* icon, and the
+ highest-fidelity source is the multi-resolution ``jarvis.ico``:
+
+ 1. ``ensure_windows_app_identity`` — group this process under the Jarvis
+ taskbar button (idempotent across processes).
+ 2. ``iconbitmap(default=.ico)`` — Tk-level icon for all toplevels.
+ 3. ``WM_SETICON`` + ``SetClassLongPtrW`` — the Win32 class-icon override,
+ the only surface the taskbar actually reads.
+
+ ``iconphoto`` (the PNG path) is deliberately NOT used on Windows: Tk
+ re-asserts a ``PhotoImage``-derived class icon on later map/update cycles,
+ which races and overwrites our ``SetClassLongPtrW`` — the live window ended
+ up with a blank/greyed class icon. The ``.ico`` + Win32 path is the proven
+ one (BUG #UI-Pin-2026-05-05).
+
+ **Linux / macOS** — Tk exposes no class-icon slot to Win32, but its portable
+ ``root.iconphoto`` sets ``_NET_WM_ICON``, which is exactly what the
+ dock/taskbar reads. It needs a PNG (most Linux desktops and Tk cannot decode
+ a Windows ``.ico``). The ``PhotoImage`` is stashed on the root because Tk
+ keeps no reference — without it Python garbage-collects the image and the
+ icon silently reverts to the generic ``python3`` interpreter icon.
+
+ Every step is wrapped: the bar/orb are cosmetic and must never crash — or
+ block their Tk mainloop — on an icon hiccup. Must run on the Tk thread that
+ owns ``root`` (``winfo_id`` / ``PhotoImage`` are thread-affine).
+ """
+ if sys.platform == "win32":
+ ensure_windows_app_identity()
+ ico_path = project_icon_path()
+ if not ico_path.is_file():
+ return
+ try:
+ root.iconbitmap(default=str(ico_path))
+ except Exception as exc: # noqa: BLE001
+ logger.debug("Tk iconbitmap could not be applied: {}", exc)
+ try:
+ hwnd = int(root.winfo_id())
+ except Exception as exc: # noqa: BLE001
+ logger.debug("Tk winfo_id() unavailable; class icon not set: {}", exc)
+ return
+ set_window_icon_by_hwnd(hwnd, ico_path)
+ return
+
+ # Linux / macOS — portable Tk icon via the PNG (_NET_WM_ICON).
+ try:
+ from jarvis.assets import bundled_app_icon_png
+
+ png = bundled_app_icon_png()
+ except Exception as exc: # noqa: BLE001
+ logger.debug("bundled PNG icon lookup failed: {}", exc)
+ png = None
+ if png is None or not png.is_file():
+ return
+ try:
+ import tkinter as tk
+
+ photo = tk.PhotoImage(file=str(png), master=root)
+ root.iconphoto(True, photo)
+ # Tk holds no reference to the image; pin it to the root so it is not
+ # garbage-collected out from under the window icon.
+ root._jarvis_icon_photo = photo # noqa: SLF001
+ except Exception as exc: # noqa: BLE001
+ logger.debug("Tk iconphoto could not be applied: {}", exc)
+
+
def set_window_icon_by_title(
title: str, ico_path: Path, *, quiet: bool = False
) -> bool:
diff --git a/jarvis/ui/jarvisbar/overlay.py b/jarvis/ui/jarvisbar/overlay.py
index 127f464360..d99306eeee 100644
--- a/jarvis/ui/jarvisbar/overlay.py
+++ b/jarvis/ui/jarvisbar/overlay.py
@@ -274,6 +274,17 @@ class JarvisBarOverlay:
root = tk.Tk()
self._root = root
root.title("JarvisBar")
+ # Give the bar the Jarvis mascot icon on every OS. Tk otherwise inherits
+ # the interpreter's process icon (pythonw.exe → Python logo on Windows,
+ # python3 on Linux); if this frameless window ever surfaces on the
+ # taskbar/dock it would advertise itself as plain Python
+ # (BUG #UI-Pin-2026-05-05). Best-effort — never blocks the bar.
+ try:
+ from jarvis.ui.icon_utils import apply_tk_window_icon
+
+ apply_tk_window_icon(root)
+ except Exception: # noqa: BLE001 — the bar is cosmetic; never crash on it
+ log.debug("jarvisbar icon setup skipped", exc_info=True)
root.overrideredirect(True)
root.wm_attributes("-topmost", True)
try:
diff --git a/tests/unit/ui/test_tk_icon_applied.py b/tests/unit/ui/test_tk_icon_applied.py
new file mode 100644
index 0000000000..6fb101a954
--- /dev/null
+++ b/tests/unit/ui/test_tk_icon_applied.py
@@ -0,0 +1,84 @@
+"""Regression guard: every Tk surface wears the Jarvis mascot, not the Python logo.
+
+BUG #UI-Pin-2026-05-05 recurred because the icon fix lived only in the old orb
+(``ui/orb/overlay.py``) while the JarvisBar (``jarvis/ui/jarvisbar/overlay.py``,
+now the DEFAULT ``orb_style``) created its ``tk.Tk()`` root without any icon
+work — so it inherited the process icon (``pythonw.exe`` → Python logo on
+Windows, ``python3`` on Linux). The fix routes BOTH through one canonical
+helper, :func:`jarvis.ui.icon_utils.apply_tk_window_icon`. These tests fail if a
+Tk surface ever forgets to call it (the exact drift that caused the bug), and —
+on a real display — prove the applied class icon is the bundled mascot.
+"""
+from __future__ import annotations
+
+import inspect
+import sys
+
+import pytest
+
+
+def test_apply_tk_window_icon_is_importable() -> None:
+ from jarvis.ui.icon_utils import apply_tk_window_icon
+
+ assert callable(apply_tk_window_icon)
+
+
+def test_jarvisbar_wires_the_icon_helper() -> None:
+ """The JarvisBar must call the canonical Tk-icon helper on its root."""
+ import jarvis.ui.jarvisbar.overlay as bar
+
+ src = inspect.getsource(bar)
+ assert "apply_tk_window_icon" in src, (
+ "JarvisBar no longer applies the Jarvis icon to its Tk root — it will "
+ "regress to the Python logo (BUG #UI-Pin-2026-05-05)."
+ )
+
+
+def test_orb_wires_the_icon_helper() -> None:
+ """The legacy orb must delegate to the same canonical helper (no drift)."""
+ import ui.orb.overlay as orb
+
+ src = inspect.getsource(orb)
+ assert "apply_tk_window_icon" in src, (
+ "The orb no longer routes through the shared Tk-icon helper; the two "
+ "Tk surfaces have drifted apart again."
+ )
+
+
[email protected](sys.platform != "win32", reason="Windows class-icon surface")
+def test_apply_sets_a_class_icon_on_a_real_tk_root() -> None:
+ """On a real Windows display, the applied class icon is the bundled mascot."""
+ import ctypes
+
+ tk = pytest.importorskip("tkinter")
+ try:
+ root = tk.Tk()
+ except tk.TclError:
+ pytest.skip("no display available for Tk")
+
+ try:
+ root.withdraw()
+ from jarvis.ui.icon_utils import apply_tk_window_icon, project_icon_path
+
+ if not project_icon_path().is_file():
+ pytest.skip("bundled icon missing in this checkout")
+
+ apply_tk_window_icon(root)
+ root.update()
+
+ user32 = ctypes.windll.user32
+ get_class_long = getattr(user32, "GetClassLongPtrW", user32.GetClassLongW)
+ _GCLP_HICON = -14
+ _WM_GETICON = 0x007F
+ _ICON_BIG = 1
+ hwnd = int(root.winfo_id())
+ class_icon = get_class_long(hwnd, _GCLP_HICON)
+ wm_icon = user32.SendMessageW(hwnd, _WM_GETICON, _ICON_BIG, 0)
+
+ # Both the class icon (what the taskbar reads) and the window icon
+ # (WM_SETICON, titlebar/Alt-Tab) are now the bundled mascot .ico — the
+ # window no longer falls back to the pythonw.exe process icon.
+ assert class_icon != 0
+ assert wm_icon != 0
+ finally:
+ root.destroy()
diff --git a/ui/orb/overlay.py b/ui/orb/overlay.py
index 0a9526096e..99ae5f338c 100644
--- a/ui/orb/overlay.py
+++ b/ui/orb/overlay.py
@@ -203,60 +203,21 @@ def _resolve_mascot_path(path_str: str | None) -> Path | None:
def _apply_jarvis_icon_to_tk_root(root: tk.Tk) -> None:
"""Set the Jarvis taskbar/titlebar icon on this Tk root.
- Tkinter on Windows registers a window class without a class icon slot, so
- Windows falls back to the process icon (``pythonw.exe`` → Python logo).
- We override on three levels:
- 1. ``SetCurrentProcessExplicitAppUserModelID`` — gives this process a
- stable taskbar grouping identity (idempotent across processes).
- 2. ``Tk.iconbitmap(default=...)`` — Tk's own way to set an icon for all
- windows in this interpreter.
- 3. ``WM_SETICON`` + ``SetClassLongPtrW`` — the only reliable override
- for the taskbar icon, because the taskbar reads the *class* icon.
-
- Each step is best-effort; any failure is silent (the orb is cosmetic).
+ Thin wrapper over the canonical, cross-platform
+ :func:`jarvis.ui.icon_utils.apply_tk_window_icon` so the orb and the
+ JarvisBar share ONE implementation — the two used to drift apart, which is
+ how the JarvisBar regressed to the Python logo (BUG #UI-Pin-2026-05-05).
+ Best-effort; any failure is silent (the orb is cosmetic).
"""
- if sys.platform != "win32":
- return
try:
- from jarvis.ui.icon_utils import (
- ensure_windows_app_identity,
- project_icon_path,
- set_window_icon_by_hwnd,
- )
- except Exception: # noqa: BLE001
- return
-
- ensure_windows_app_identity()
+ from jarvis.ui.icon_utils import apply_tk_window_icon
- ico_path = project_icon_path()
- if not ico_path.is_file():
- return
-
- # Step 2: Tk-level. ``default=`` applies to all current and future
- # windows of this interpreter (including hidden toplevels Tk creates
- # internally), preventing the brief Python-logo flash on first show.
- try:
- root.iconbitmap(default=str(ico_path))
- except Exception: # noqa: BLE001
- import logging
-
- logging.getLogger("jarvis.orb").debug(
- "Tk iconbitmap setup failed; continuing without it.",
- exc_info=True,
- )
-
- # Step 3: Win32-level. winfo_id() returns the HWND of the Tk root.
- try:
- hwnd = int(root.winfo_id())
- except Exception: # noqa: BLE001
- return
- try:
- set_window_icon_by_hwnd(hwnd, ico_path)
+ apply_tk_window_icon(root)
except Exception: # noqa: BLE001
import logging
logging.getLogger("jarvis.orb").debug(
- "Win32 Tk icon setup failed; continuing without it.",
+ "Tk icon setup failed; continuing without it.",
exc_info=True,
)