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(jarvisbar): prevent wake reveal backing-window flash
Ruben Lütke26da93409981
diff --git a/jarvis/ui/jarvisbar/overlay.py b/jarvis/ui/jarvisbar/overlay.pyindex f44d1263bd..387602daee 100644--- a/jarvis/ui/jarvisbar/overlay.py+++ b/jarvis/ui/jarvisbar/overlay.py@@ -151,6 +151,20 @@ def _primary_work_area() -> tuple[int, int, int, int] | None:return None+def _create_hidden_tk_root(tk: Any) -> Any:+ """Create a Tk root without mapping its platform-default backing window.++ ``tk.Tk()`` starts with a default geometry (roughly 400x300 physical pixels+ on a 150% Windows desktop). Configuring geometry and a color key afterwards+ can leave that original DWM surface eligible for a flash during a later+ layered-window style mutation. Withdraw synchronously so only the fully+ configured Jarvis Bar can ever be mapped.+ """+ root = tk.Tk()+ root.withdraw()+ return root++class JarvisBarOverlay:def __init__(self,@@ -226,6 +240,17 @@ class JarvisBarOverlay:returnself._enqueue_ui(self._do_hide)+ def reassert_z_order(self) -> None:+ """Re-pin an already-visible bar without treating it as a reveal.++ Wake/state updates call ``show`` repeatedly while a persistent bar is+ already mapped. Those updates must not mutate the native layered-window+ styles. The one deliberate post-boot repair uses this explicit method.+ """+ if self._root is None:+ return+ self._enqueue_ui(self._do_reassert_z_order)+def set_level(self, level: float) -> None:# Direct atomic write (no enqueue) — matches OrbOverlay.set_level.lv = 0.0 if level < 0.0 else 1.0 if level > 1.0 else float(level)@@ -330,7 +355,10 @@ class JarvisBarOverlay:self._tk_thread_id = threading.get_ident()self._renderer = renderer.JarvisBarRenderer(accent=self._accent)- root = tk.Tk()+ # Some window managers map Tk's default-size root eagerly. Hide it+ # before assigning ``self._root`` or applying any styles so that stale+ # backing surface can never flash at the top-left on a later wake.+ root = _create_hidden_tk_root(tk)self._root = rootroot.title("JarvisBar")# Give the bar the Jarvis mascot icon on every OS. Tk otherwise inherits@@ -397,9 +425,6 @@ class JarvisBarOverlay:except Exception: # noqa: BLE001 — drop is optional; never block bar boot.log.debug("bar drop target registration skipped", exc_info=True)- if self._should_start_withdrawn():- root.withdraw() # only-when-active variant / boot gate starts hidden-try:from jarvis.audio import level_tap@@ -409,10 +434,13 @@ class JarvisBarOverlay:self._running = Trueself._t0 = time.perf_counter()- self._started.set()- self._schedule_ui_queue()+ # Paint a complete first frame while the root is still withdrawn.self._schedule_frame()+ self._schedule_ui_queue()self._schedule_frame_watchdog() # independent anti-freeze revival loop+ if not self._should_start_withdrawn():+ self._do_show()+ self._started.set()root.mainloop()def stop(self) -> None:@@ -469,10 +497,27 @@ class JarvisBarOverlay:def _do_show(self) -> None:if self._root is None:return+ # A persistent bar is already mapped when wake/state events arrive.+ # Re-running deiconify/topmost/transparentcolor is not a harmless no-op+ # on Windows: it mutates a layered HWND and can resurrect Tk's original+ # default-size opaque backing surface at the top-left. The renderer reads+ # ``self._mode`` directly, so a mapped window needs no native operation.+ try:+ if bool(self._root.winfo_ismapped()):+ return+ except Exception: # noqa: BLE001+ # Unusual Tk shims may not expose the query. Prefer an attempted+ # reveal over leaving a genuinely hidden bar unavailable.+ log.debug("jarvisbar mapped-state query failed", exc_info=True)try:self._root.deiconify()except Exception: # noqa: BLE001log.debug("jarvisbar deiconify failed", exc_info=True)+ self._do_reassert_z_order()++ def _do_reassert_z_order(self) -> None:+ if self._root is None:+ return# Re-assert topmost + lift after every reveal. A withdrawn→deiconified# ``overrideredirect`` window comes back on Windows WITHOUT its topmost# z-order (it is remapped as an ordinary window), so later-mapped windowsdiff --git a/tests/unit/ui/jarvisbar/test_show_lifts_topmost.py b/tests/unit/ui/jarvisbar/test_show_lifts_topmost.pyindex 41308c272b..0c5eb8f9da 100644--- a/tests/unit/ui/jarvisbar/test_show_lifts_topmost.py+++ b/tests/unit/ui/jarvisbar/test_show_lifts_topmost.py@@ -1,10 +1,10 @@-"""The reveal path must LIFT + re-pin topmost, not just deiconify.+"""Native reveal and z-order repairs must be explicit and style-safe.Forensic (2026-06-27): a withdrawn→deiconified ``overrideredirect`` window canlose its topmost z-order on Windows, so later desktop windows map above it untilthe next wake re-shows it. The persistent bar now maps immediately at boot, and-the voice-ready maintenance pass re-shows its current mode only to re-pin-topmost. ``_do_show`` re-asserts ``-topmost`` and lifts, matching the mascot orb.+the voice-ready maintenance pass explicitly re-pins topmost. ``_do_show``+re-asserts ``-topmost`` and lifts only when it maps a withdrawn window.These tests pin that contract without a real Tk window.Forensic (2026-06-30): re-asserting ``-topmost`` is itself a Win32 style@@ -12,8 +12,10 @@ mutation on this layered (color-key + alpha) window, and Windows can silentlydrop the layered attributes on such a mutation (BUG-030) — the bar then brieflyrenders its true opaque black backing instead of the keyed-out magenta ("blackborder 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.+re-applies ``-transparentcolor``/``-alpha`` right after the topmost re-assert.+Repeated wake updates on an already-mapped persistent bar skip all of those+native style mutations, preventing the old default-size Tk backing surface from+flashing at the top-left of the screen."""from __future__ import annotations@@ -23,12 +25,17 @@ from jarvis.ui.jarvisbar.overlay import COLOR_KEY_HEX, JarvisBarOverlayclass _FakeRoot:"""Records the order of the visibility calls ``_do_show`` makes."""- def __init__(self) -> None:+ def __init__(self, *, mapped: bool = False) -> None:self.calls: list[str] = []self.attrs: dict[str, object] = {}+ self.mapped = mapped++ def winfo_ismapped(self) -> int:+ return int(self.mapped)def deiconify(self) -> None:self.calls.append("deiconify")+ self.mapped = Truedef lift(self) -> None:self.calls.append("lift")@@ -38,9 +45,9 @@ class _FakeRoot:self.attrs[name] = value-def _bar_with_fake_root() -> tuple[JarvisBarOverlay, _FakeRoot]:+def _bar_with_fake_root(*, mapped: bool = False) -> tuple[JarvisBarOverlay, _FakeRoot]:bar = JarvisBarOverlay(persistent=True)- root = _FakeRoot()+ root = _FakeRoot(mapped=mapped)bar._root = root # noqa: SLF001 — inject a fake Tk root (no real window)return bar, root@@ -58,6 +65,25 @@ def test_do_show_deiconifies_then_lifts_and_repins_topmost() -> None:assert root.calls.index("deiconify") < root.calls.index("lift")+def test_do_show_mapped_window_skips_all_native_style_mutations() -> None:+ bar, root = _bar_with_fake_root(mapped=True)++ bar._do_show() # noqa: SLF001++ assert root.calls == []+++def test_explicit_z_order_reassert_repins_an_already_mapped_window() -> None:+ bar, root = _bar_with_fake_root(mapped=True)++ bar._do_reassert_z_order() # noqa: SLF001++ assert "deiconify" not in root.calls+ assert "lift" in root.calls+ assert root.attrs.get("-topmost") is True+ assert root.attrs.get("-transparentcolor") == COLOR_KEY_HEX++def test_do_show_reapplies_transparentcolor_and_alpha_after_topmost() -> None:"""BUG-030 guard: the topmost re-assert must not leave the layeredcolor-key/alpha attributes un-reapplied — else a Windows-side drop ofdiff --git a/tests/unit/ui/jarvisbar/test_start_hidden.py b/tests/unit/ui/jarvisbar/test_start_hidden.pyindex e1dfa3e9db..97bba975f6 100644--- a/tests/unit/ui/jarvisbar/test_start_hidden.py+++ b/tests/unit/ui/jarvisbar/test_start_hidden.py@@ -8,7 +8,23 @@ from __future__ import annotationsimport inspect-from jarvis.ui.jarvisbar.overlay import JarvisBarOverlay+from jarvis.ui.jarvisbar.overlay import JarvisBarOverlay, _create_hidden_tk_root+++class _FakeRoot:+ def __init__(self) -> None:+ self.calls: list[str] = []++ def withdraw(self) -> None:+ self.calls.append("withdraw")+++class _FakeTk:+ def __init__(self, root: _FakeRoot) -> None:+ self.root = root++ def Tk(self) -> _FakeRoot: # noqa: N802 - mirrors tkinter's public name+ return self.rootdef test_persistent_bar_does_not_start_withdrawn() -> None:@@ -23,3 +39,10 @@ def test_non_persistent_bar_starts_withdrawn() -> None:def test_start_hidden_override_is_not_part_of_the_surface_api() -> None:assert "start_hidden" not in inspect.signature(JarvisBarOverlay).parameters+++def test_new_tk_root_is_withdrawn_before_configuration() -> None:+ root = _FakeRoot()++ assert _create_hidden_tk_root(_FakeTk(root)) is root+ assert root.calls == ["withdraw"]diff --git a/tests/unit/ui/test_orb_bus_bridge.py b/tests/unit/ui/test_orb_bus_bridge.pyindex 93a420e9a7..722ad9c7cd 100644--- a/tests/unit/ui/test_orb_bus_bridge.py+++ b/tests/unit/ui/test_orb_bus_bridge.py@@ -96,6 +96,11 @@ class _FakeOrb:self.mute_callback = callback+class _FakeBarWithExplicitReassert(_FakeOrb):+ def reassert_z_order(self) -> None:+ self.calls.append(("reassert_z_order", None))++async def test_orb_is_shown_again_for_thinking_after_external_hide() -> None:orb = _FakeOrb()bridge = OrbBusBridge(bus=_FakeBus(), orb=orb, idle_animations_enabled=False) # type: ignore[arg-type]@@ -605,6 +610,19 @@ async def test_persistent_bar_reasserts_current_mode_once_when_voice_ready() ->assert orb.calls.count(("show", "listen")) == 1+async def test_persistent_bar_uses_explicit_z_order_reassert_when_available() -> None:+ orb = _FakeBarWithExplicitReassert()+ bridge = OrbBusBridge( # type: ignore[arg-type]+ bus=_FakeBus(), orb=orb, idle_animations_enabled=False, hide_on_idle=False+ )++ await bridge._on_voice_boot_status(VoiceBootStatus(ready=True)) # noqa: SLF001+ await bridge.reassert_persistent_bar_when_voice_ready(timeout_s=1.0)++ assert orb.calls.count(("reassert_z_order", None)) == 1+ assert not any(call[0] == "show" for call in orb.calls)++async def test_voice_boot_status_not_ready_does_not_reassert_bar() -> None:orb = _FakeOrb()bridge = OrbBusBridge( # type: ignore[arg-type]diff --git a/ui/orb/bus_bridge.py b/ui/orb/bus_bridge.pyindex 3fced3706d..5219d1d788 100644--- a/ui/orb/bus_bridge.py+++ b/ui/orb/bus_bridge.py@@ -598,7 +598,7 @@ class OrbBusBridge:self._reassert_persistent_bar(reason)def _reassert_persistent_bar(self, reason: str) -> None:- """Re-show the persistent bar's current mode exactly once."""+ """Re-pin the persistent bar's z-order exactly once."""if self._boot_reassert_done:returnself._boot_reassert_done = True@@ -606,8 +606,15 @@ class OrbBusBridge:# Non-persistent bar / mascot: stays hidden until a voice session.returntry:- mode = str(getattr(self._orb, "_mode", "idle") or "idle")- self._orb.show(mode)+ reassert = getattr(self._orb, "reassert_z_order", None)+ if callable(reassert):+ reassert()+ else:+ # Compatibility floor for alternate and test surfaces. Only the+ # Jarvis Bar owns the layered native window and implements the+ # explicit style-safe z-order operation.+ mode = str(getattr(self._orb, "_mode", "idle") or "idle")+ self._orb.show(mode)log.info("Persistent overlay z-order reasserted after boot (%s).", reason)