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(autostart): notice when the shortcut's icon points at another checkout
rubenluetke10-beep2e0daa774825
diff --git a/jarvis/autostart/windows.py b/jarvis/autostart/windows.pyindex b482a7e6c2..c05f97895b 100644--- a/jarvis/autostart/windows.py+++ b/jarvis/autostart/windows.py@@ -301,7 +301,14 @@ def build_create_script(link: Path, spec: LaunchSpec, *, icon: str | None = Nonedef build_read_script(link: Path) -> str:- """Pure: PowerShell that prints TargetPath/Arguments/WorkingDirectory.+ """Pure: PowerShell printing TargetPath/Arguments/WorkingDirectory/Icon.++ IconLocation is read for the same reason ``icon_utils`` reads it on the+ Start-Menu shortcut: it is the field that goes stale on its own. A shortcut+ written from one checkout keeps pointing its icon at that checkout even+ after target, arguments and working directory have all moved to another —+ and since Windows renders the taskbar button from this shortcut, the app+ shows an icon from a directory nobody uses any more.Base64-encoded for the same reason as the task query — see:func:`_ps_emit_field`.@@ -314,6 +321,7 @@ def build_read_script(link: Path) -> str:f"{_ps_emit_field(_READBACK_SENTINEL, '$sc.TargetPath')}"f"{_ps_emit_field(_READBACK_SENTINEL, '$sc.Arguments')}"f"{_ps_emit_field(_READBACK_SENTINEL, '$sc.WorkingDirectory')}"+ f"{_ps_emit_field(_READBACK_SENTINEL, '$sc.IconLocation')}")@@ -339,6 +347,20 @@ def _resolve_app_icon() -> str | None:return None+def _icon_matches(actual: str, expected: str | None) -> bool:+ """Does a shortcut's ``IconLocation`` still name this installation's icon?++ ``IconLocation`` is ``"<path>,<index>"``. An empty path means "inherit the+ target's icon", which for ``pythonw.exe`` is the Python logo — never a+ match. When the icon cannot be resolved at all there is nothing to write, so+ whatever is there is left alone rather than churning the shortcut.+ """+ if expected is None:+ return True+ path = (actual or "").rsplit(",", 1)[0].strip().strip('"')+ return bool(path) and _norm(path) == _norm(expected)++def _tag_shortcut_aumid(link: Path) -> bool:"""Best-effort: write the app AUMID into ``link``'s property store.@@ -677,21 +699,22 @@ class WindowsAutostart:log.debug("shortcut read failed: %s", exc)return Falsefields = _sentinel_fields(result.stdout, _READBACK_SENTINEL)- if len(fields) < 3:+ if len(fields) < 4:# A truncated read-back is "unknown", not "matches". Padding the# missing fields with "" made a half-failed COM read compare equal# to any spec with no args — reporting a stale shortcut as current# and suppressing the refresh that would have fixed it.log.debug(- "shortcut read-back returned %d of 3 fields — treating as drift",+ "shortcut read-back returned %d of 4 fields — treating as drift",len(fields),)return False- target, args, workdir = fields[:3]+ target, args, workdir, icon = fields[:4]return (_norm(target) == _norm(spec.program)and args.strip() == " ".join(spec.args).strip()and _norm(workdir) == _norm(spec.working_dir)+ and _icon_matches(icon, _resolve_app_icon()))def _remove_legacy(self) -> None:diff --git a/tests/unit/autostart/test_windows_scripts.py b/tests/unit/autostart/test_windows_scripts.pyindex 535c274b67..37f903d0ea 100644--- a/tests/unit/autostart/test_windows_scripts.py+++ b/tests/unit/autostart/test_windows_scripts.py@@ -8,8 +8,14 @@ from __future__ import annotationsfrom pathlib import Path+import pytest+from jarvis.autostart.protocol import LaunchSpec-from jarvis.autostart.windows import build_create_script, build_read_script+from jarvis.autostart.windows import (+ _icon_matches,+ build_create_script,+ build_read_script,+)def _spec(minimized: bool = True) -> LaunchSpec:@@ -37,12 +43,39 @@ def test_non_minimized_maps_to_windowstyle_1() -> None:assert "$sc.WindowStyle = 1" in build_create_script(Path("x.lnk"), _spec(minimized=False))-def test_read_script_emits_three_sentinel_lines() -> None:+def test_read_script_emits_four_sentinel_lines() -> None:script = build_read_script(Path(r"C:\startup\Personal Jarvis.lnk"))- assert script.count("Write-Output") == 3+ assert script.count("Write-Output") == 4assert "$sc.TargetPath" in scriptassert "$sc.Arguments" in scriptassert "$sc.WorkingDirectory" in script+ assert "$sc.IconLocation" in script+++def test_read_script_reads_the_icon_back() -> None:+ """The icon is the field that goes stale on its own.++ A shortcut written from one checkout keeps pointing its icon there long+ after target, arguments and working directory have moved elsewhere. Windows+ draws the taskbar button from this shortcut, so without reading the icon+ back the app shows artwork from a directory nobody uses any more, forever.+ """+ assert "$sc.IconLocation" in build_read_script(Path(r"C:\s\a.lnk"))+++ ("actual", "expected", "matches"),+ [+ (r"C:\app\jarvis.ico,0", r"C:\app\jarvis.ico", True),+ (r"c:\APP\jarvis.ico,0", r"C:\app\jarvis.ico", True), # Windows is case-blind+ (r"C:\old-worktree\jarvis.ico,0", r"C:\app\jarvis.ico", False),+ (",0", r"C:\app\jarvis.ico", False), # empty == inherit pythonw's logo+ ("", r"C:\app\jarvis.ico", False),+ (r"C:\anything\jarvis.ico,0", None, True), # unresolvable → leave it alone+ ],+)+def test_icon_matches(actual: str, expected: str | None, matches: bool) -> None:+ assert _icon_matches(actual, expected) is matchesdef test_create_script_embeds_icon_when_given() -> None: