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(desktop): repair taskbar pins left on an old install (#861)

Ruben Lütke75fdc048d6e1
diff --git a/dodaios/ui/icon_utils.py b/dodaios/ui/icon_utils.py
index 9c8f94a494..9b571fcbf6 100644
--- a/dodaios/ui/icon_utils.py
+++ b/dodaios/ui/icon_utils.py
@@ -1084,6 +1084,86 @@ def ensure_desktop_shortcut(
return False
+def _default_taskbar_pins_dir() -> Path | None:
+ appdata = os.environ.get("APPDATA")
+ if not appdata:
+ return None
+ return (
+ Path(appdata)
+ / "Microsoft"
+ / "Internet Explorer"
+ / "Quick Launch"
+ / "User Pinned"
+ / "TaskBar"
+ )
+
+
+def _read_shortcut_aumid(lnk: Path) -> str | None:
+ try:
+ import pywintypes
+ from win32com.propsys import propsys, pscon
+
+ store = propsys.SHGetPropertyStoreFromParsingName(
+ str(lnk), None, 0, pywintypes.IID(_IID_IPROPERTYSTORE) # GPS_DEFAULT
+ )
+ value = store.GetValue(pscon.PKEY_AppUserModel_ID).GetValue()
+ return value if isinstance(value, str) else None
+ except Exception as exc: # noqa: BLE001
+ logger.debug("could not read AUMID of {}: {}", lnk, exc)
+ return None
+
+
+def repair_taskbar_pins(
+ *,
+ aumid: str = APP_USER_MODEL_ID,
+ display_name: str = WINDOWS_APP_DISPLAY_NAME,
+ icon_path: Path | None = None,
+ pins_dir: Path | None = None,
+) -> int:
+ """Re-aim taskbar pins of this app that point at an old install.
+
+ A pinned taskbar button is its own ``.lnk`` in the "User Pinned" folder,
+ written when the user pinned the app. Nothing ever updated it, so after a
+ rename or move (``jarvis`` -> ``dodaios``) the pin kept the old icon path and
+ launcher module. The shell then draws a blank page for the button and a click
+ starts nothing.
+
+ Only pins that carry this app's AUMID are touched, and each is rewritten in
+ place under its own file name so the pin itself survives. Never creates a
+ pin. Returns how many pins were rewritten.
+ """
+ if sys.platform != "win32":
+ return 0
+ if _installer_owns_shell_registration("taskbar pin"):
+ return 0
+ pins = pins_dir or _default_taskbar_pins_dir()
+ if pins is None or not pins.is_dir():
+ return 0
+ if not _interpreter_may_own_the_launcher_shortcut():
+ return 0
+ target = _shortcut_launch_target()
+ if target is None:
+ return 0
+ ico = icon_path or project_icon_path()
+ repaired = 0
+ for lnk in sorted(pins.glob("*.lnk")):
+ if _read_shortcut_aumid(lnk) != aumid:
+ continue
+ if _shortcut_matches_install(
+ lnk,
+ expected_target=target,
+ expected_icon=ico,
+ expected_arguments=_launcher_arguments(),
+ ):
+ continue
+ if _write_branded_shortcut(
+ lnk, target=target, ico=ico, aumid=aumid, display_name=display_name
+ ):
+ logger.info("taskbar pin re-aimed at this install: {}", lnk)
+ repaired += 1
+ return repaired
+
+
def _notify_shell_of_shortcut(lnk: Path) -> None:
"""Tell the shell the Start-Menu entry changed, so app search can pick it up.
@@ -1153,6 +1233,7 @@ def ensure_windows_app_identity(
# appears, so Explorer resolves them on first button creation.
if write_shortcut:
ensure_start_menu_shortcut(aumid=app_id, icon_path=ico_arg)
+ repair_taskbar_pins(aumid=app_id, icon_path=ico_arg)
register_windows_app_user_model_id(app_id, icon_path=ico_arg)
try:
import ctypes
diff --git a/tests/unit/ui/test_taskbar_pin_repair.py b/tests/unit/ui/test_taskbar_pin_repair.py
new file mode 100644
index 0000000000..aec6fb41f9
--- /dev/null
+++ b/tests/unit/ui/test_taskbar_pin_repair.py
@@ -0,0 +1,80 @@
+"""A taskbar pin made before a rename must follow the app to its new install.
+
+Report 2026-10-26: the pinned taskbar button showed a blank page. The pin's
+``.lnk`` still named ``jarvis\\assets\\icons\\jarvis.ico`` and
+``-m jarvis.ui.web.launcher``, both gone after the rename to ``dodaios``.
+Start-Menu and Desktop shortcuts were repaired on every start; the pin was not.
+
+These tests write real shortcuts, but only into ``tmp_path``.
+"""
+from __future__ import annotations
+
+import sys
+from pathlib import Path
+
+import pytest
+
+from dodaios.ui import icon_utils
+
+pytestmark = pytest.mark.skipif(
+ sys.platform != "win32", reason="taskbar pins are Windows-only"
+)
+
+_AUMID = "PersonalJarvis.Test.TaskbarPin"
+
+
+def _stale_pin(lnk: Path, aumid: str) -> None:
+ lnk.parent.mkdir(parents=True, exist_ok=True)
+ assert icon_utils._write_branded_shortcut(
+ lnk,
+ target=Path(sys.executable),
+ ico=lnk.parent / "gone" / "jarvis.ico",
+ aumid=aumid,
+ display_name="Old name",
+ )
+
+
+def _read(lnk: Path) -> tuple[str, str, str]:
+ from win32com.client import Dispatch
+
+ sc = Dispatch("WScript.Shell").CreateShortcut(str(lnk))
+ return sc.TargetPath, sc.Arguments, sc.IconLocation
+
+
+def pins(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
+ monkeypatch.setattr(icon_utils, "_installer_owns_shell_registration", lambda _w: False)
+ monkeypatch.setattr(icon_utils, "_interpreter_may_own_the_launcher_shortcut", lambda: True)
+ monkeypatch.setattr(icon_utils, "_shortcut_launch_target", lambda: Path(sys.executable))
+ return tmp_path / "TaskBar"
+
+
+def test_stale_pin_of_this_app_is_rewritten_in_place(pins: Path) -> None:
+ lnk = pins / "Personal Jarvis.lnk"
+ _stale_pin(lnk, _AUMID)
+ ico = icon_utils.project_icon_path()
+
+ assert icon_utils.repair_taskbar_pins(aumid=_AUMID, icon_path=ico, pins_dir=pins) == 1
+
+ target, args, icon = _read(lnk)
+ assert icon_utils._same_file_path(target, Path(sys.executable))
+ assert args == icon_utils._launcher_arguments()
+ assert icon_utils._same_file_path(icon.rsplit(",", 1)[0], ico)
+ assert icon_utils._read_shortcut_aumid(lnk) == _AUMID
+ # Second run finds nothing to do.
+ assert icon_utils.repair_taskbar_pins(aumid=_AUMID, icon_path=ico, pins_dir=pins) == 0
+
+
+def test_pins_of_other_apps_are_left_alone(pins: Path) -> None:
+ lnk = pins / "Other.lnk"
+ _stale_pin(lnk, "Someone.Else")
+ before = _read(lnk)
+
+ assert icon_utils.repair_taskbar_pins(
+ aumid=_AUMID, icon_path=icon_utils.project_icon_path(), pins_dir=pins
+ ) == 0
+ assert _read(lnk) == before
+
+
+def test_missing_pins_folder_is_a_no_op(tmp_path: Path, pins: Path) -> None:
+ assert icon_utils.repair_taskbar_pins(aumid=_AUMID, pins_dir=tmp_path / "nope") == 0