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.

chore: auto-save WIP via Claude stop-hook safety net (2026-06-30 20:32)

Ruben Lütke6db3fc7a28fd
diff --git a/jarvis/ui/jarvisbar/overlay.py b/jarvis/ui/jarvisbar/overlay.py
index 00524095e8..f0c0510752 100644
--- a/jarvis/ui/jarvisbar/overlay.py
+++ b/jarvis/ui/jarvisbar/overlay.py
@@ -15,9 +15,11 @@ Threading mirrors the orb: a daemon thread runs the Tk mainloop; all Tk
mutations from the bus-subscriber thread go through ``_enqueue_ui`` → a queue
drained on the Tk thread. ``set_level`` is the sole exception (atomic write).
-No ``SetWindowLong`` is ever called, so this surface is not exposed to the
-BUG-030 LWA color-key destruction risk. ``-transparentcolor`` is set once at
-window creation and never mutated.
+No ``SetWindowLong`` is ever called directly, but ``-topmost`` IS re-asserted
+on every reveal (``_do_show``), and Windows can silently drop the layered
+color-key/alpha on that kind of style mutation (BUG-030). ``_do_show``
+re-applies ``-transparentcolor``/``-alpha`` right after, so a dropped
+attribute self-heals on the next reveal instead of leaving a black flash.
"""
from __future__ import annotations
@@ -399,6 +401,20 @@ class JarvisBarOverlay:
self._root.lift()
except Exception: # noqa: BLE001
log.debug("jarvisbar lift/topmost re-assert failed", exc_info=True)
+ # BUG-030 guard: re-asserting ``-topmost`` is itself a Win32 style
+ # mutation on this layered (color-key + alpha) window, and Windows can
+ # silently drop the layered attributes on such a mutation — the bar
+ # then briefly renders its true opaque black backing surface instead of
+ # the keyed-out magenta until the next repaint ("black border flashes
+ # around the bar, then disappears" forensic, 2026-06-30). Re-apply both
+ # exactly as set at creation so a dropped attribute self-heals on the
+ # very next reveal instead of needing an app restart. Guarded
+ # separately so a failure here can never undo the topmost re-assert.
+ try:
+ self._root.wm_attributes("-transparentcolor", COLOR_KEY_HEX)
+ self._root.wm_attributes("-alpha", self._opacity)
+ except Exception: # noqa: BLE001
+ log.debug("jarvisbar transparentcolor/alpha re-assert failed", exc_info=True)
def _do_hide(self) -> None:
if self._root is None:
diff --git a/tests/unit/ui/jarvisbar/test_show_lifts_topmost.py b/tests/unit/ui/jarvisbar/test_show_lifts_topmost.py
index df005eeec1..25c2c83c2f 100644
--- a/tests/unit/ui/jarvisbar/test_show_lifts_topmost.py
+++ b/tests/unit/ui/jarvisbar/test_show_lifts_topmost.py
@@ -8,10 +8,18 @@ Windows, so the later boot windows mapped on top of the bar and it stayed hidden
until the first wake-word re-showed it ("bar does not appear when ready, only
after the wake-word"). ``_do_show`` now re-asserts ``-topmost`` and lifts, matching
the mascot orb. These tests pin that contract without a real Tk window.
+
+Forensic (2026-06-30): re-asserting ``-topmost`` is itself a Win32 style
+mutation on this layered (color-key + alpha) window, and Windows can silently
+drop the layered attributes on such a mutation (BUG-030) — the bar then briefly
+renders its true opaque black backing instead of the keyed-out magenta ("black
+border flashes around the bar, then disappears"). ``_do_show`` now also
+re-applies ``-transparentcolor``/``-alpha`` right after the topmost re-assert,
+so a dropped attribute self-heals on the very next reveal.
"""
from __future__ import annotations
-from jarvis.ui.jarvisbar.overlay import JarvisBarOverlay
+from jarvis.ui.jarvisbar.overlay import COLOR_KEY_HEX, JarvisBarOverlay
class _FakeRoot:
@@ -52,6 +60,38 @@ def test_do_show_deiconifies_then_lifts_and_repins_topmost() -> None:
assert root.calls.index("deiconify") < root.calls.index("lift")
+def test_do_show_reapplies_transparentcolor_and_alpha_after_topmost() -> None:
+ """BUG-030 guard: the topmost re-assert must not leave the layered
+ color-key/alpha attributes un-reapplied — else a Windows-side drop of
+ those attributes on the style mutation shows as a black flash."""
+ bar, root = _bar_with_fake_root()
+
+ bar._do_show() # noqa: SLF001
+
+ assert root.attrs.get("-transparentcolor") == COLOR_KEY_HEX
+ assert root.attrs.get("-alpha") == bar._opacity # noqa: SLF001
+ # Re-applied AFTER the topmost mutation, not before — the whole point is
+ # to heal whatever the topmost re-assert may have just dropped.
+ assert root.calls.index("wm_attributes:-topmost=True") < root.calls.index(
+ f"wm_attributes:-transparentcolor={COLOR_KEY_HEX}"
+ )
+
+
+def test_do_show_transparentcolor_reassert_failure_does_not_raise() -> None:
+ bar, root = _bar_with_fake_root()
+
+ def _boom(name: str, value: object) -> None:
+ if name == "-transparentcolor":
+ raise RuntimeError("transparentcolor exploded")
+ root.calls.append(f"wm_attributes:{name}={value}")
+ root.attrs[name] = value
+
+ root.wm_attributes = _boom # type: ignore[method-assign]
+
+ # Must not raise even when the color-key re-assert fails.
+ bar._do_show() # noqa: SLF001
+
+
def test_do_show_lift_failure_does_not_swallow_deiconify() -> None:
bar, root = _bar_with_fake_root()