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(overlay): stop a stalled bar from being replaced by a black box

Ruben Lütke3379c13b6275
diff --git a/docs/BUGS.md b/docs/BUGS.md
index d53dd544e2..033e1ba053 100644
--- a/docs/BUGS.md
+++ b/docs/BUGS.md
@@ -6523,14 +6523,10 @@ periodic ordering operation does not activate the helper application. Keep
compositor workarounds behind a platform backend instead of changing a
rendering path already proven on another OS.
-**Triage note (2026-07-28).** A later Windows screenshot showed the same black
-rectangle, but a live measurement proved the Windows color key was keying out
-correctly (zero black pixels on screen) — the black padding was produced by the
-screen-capture path, not by the compositor. Because a real defect and a capture
-artifact are indistinguishable in a screenshot, and the two have unrelated
-fixes, confirm the box on the physical display before changing transparency
-code. Per-OS mechanics, the color-of-the-box decision table, and the measured
-Windows evidence:
+**Sequel on Windows (2026-07-28).** The same black rectangle was then reported
+on Windows, where the colour key measurably works. It has a different cause —
+Windows' ghost window over a stalled bar — and its own entry: BUG-118. Per-OS
+mechanics and the colour-of-the-box decision table:
[`docs/overlay-transparency.md`](overlay-transparency.md).
---
@@ -8185,3 +8181,62 @@ with two variables changed the accepted retry proves nothing.
Related: BUG-019 (stale-cache recovery in the same except block), AP-21
(capability probes), AP-22 (the single-provider brick this produced live:
gemini 400 + openai 429 left zero reachable tool-tier families).
+
+---
+
+## BUG-118: black rectangle around the JarvisBar on Windows — a stalled paint loop gets an unlayered ghost window (MEDIUM, FIXED 2026-07-28)
+
+**Symptom (maintainer field report).** An opaque black box around the bar's
+pill, surviving a restart. Read as a rendering regression of the macOS defect
+BUG-093, but on Windows, where the colour-key path was believed proven.
+
+**Root cause.** The bar's magenta colour key is a property of the WINDOW, not
+of the pixels: `-transparentcolor` sets `LWA_COLORKEY` on the layered window
+Jarvis owns. When a top-level window stops pumping messages for ~5 s, Windows
+hides it and substitutes a stand-in window of class `Ghost`, painted by the DWM
+at the identical rectangle. That stand-in carries **no `WS_EX_LAYERED`**, so
+the key is never applied to it and the whole window rect lands on screen as
+opaque black. Measured with both windows alive at once: `TkTopLevel` (app pid,
+`LAYERED=True`, `key=0x00ff00ff`) and `Ghost` (dwm pid, `LAYERED=False`),
+`IsHungAppWindow=True` on both, `black=3141` on screen over the rect.
+
+Reaching this needs no crash. The bar paints from an in-process Tk loop, so it
+stops pumping whenever ANOTHER thread holds the GIL through a long CPU-bound
+stretch. The live trigger was the backend thread sitting `active+gil` in
+`load_config()` → `JarvisConfig(**data)`, reached from
+`resolve_provider_endpoint()` in `claude_api._ensure_client` on every brain
+call — the pydantic half of the freeze whose TOML half `325af16d` cached. So a
+STALL presented itself as a RENDERING defect, which is why it was first
+mis-triaged (as a screen-capture artifact, on the strength of an isolated probe
+whose window was never stalled).
+
+**Fix.** `disable_windows_app_ghosting()` in `jarvis/core/process_utils.py`,
+called from both colour-key surfaces: the bar (`jarvis/ui/jarvisbar/overlay.py`)
+and the mascot (`ui/orb/overlay.py`). `DisableProcessWindowsGhosting` is
+process-wide and irreversible, which is the right trade — a frameless
+click-through overlay gains nothing from a ghost (no title bar to grey out, no
+close button to offer), while the app keeps its own Restart control, the tray
+icon, and Task Manager as ways out of a hang. Windows-only; a no-op returning
+False on macOS/Linux, which substitute nothing.
+
+**Proof.** A color-keyed frameless Tk window showing a real renderer frame,
+with its UI thread deliberately blocked past the threshold, measured from a
+second thread: control `before black=0 / during black=1982` of 2870; with the
+fix `before black=0 / during black=0`.
+
+**Guards.** `tests/unit/core/test_process_utils_ghosting.py` — no-op off
+Windows without touching ctypes, disables on Windows, idempotent second call
+never re-enters user32, a failing API degrades to False instead of taking the
+overlay boot down, and the helper stays exported.
+
+**Still open (separate defect).** The stall itself. Ghosting-off stops it
+LOOKING like a rendering bug; the bar still freezes while the GIL is held. The
+in-process bar is Windows/Linux-only coupling — macOS already runs it in a
+companion process (BUG-093), which is immune by construction.
+
+**Class rule.** A compositor-level transparency trick protects only the window
+you own, and only while that window is the one on screen. Before concluding
+that a transparency path works, check it in the state the report describes —
+an unstalled probe cannot falsify a stall-triggered defect. When a UI defect's
+rectangle matches a window exactly and its colour is one the renderer never
+emits, suspect a substituted window before suspecting the renderer.
diff --git a/docs/overlay-transparency.md b/docs/overlay-transparency.md
index 5793f42ca1..6fd7ba0bab 100644
--- a/docs/overlay-transparency.md
+++ b/docs/overlay-transparency.md
@@ -41,10 +41,11 @@ diagnosis: the color of the visible box tells you which layer broke.
* **Magenta padding** → the frame is correct, but the *window* is not keying it
out. `-transparentcolor` was rejected, or the layered attributes were lost
(window recreated, moved across monitors, re-shown after `withdraw`).
-* **Black padding** → the padding is not magenta any more. Either an RGBA path
- ran where a color-key path was expected (magenta with `alpha=0` resolves to
- `(0,0,0)` when flattened without a backdrop), or something composited the
- window's alpha channel against an empty black buffer.
+* **Black padding** → nothing is keying the padding out, because what is on
+ screen is no longer the window Jarvis owns. On Windows this is almost always
+ the **ghost window** (§4). Otherwise: an RGBA path ran where a color-key path
+ was expected (magenta with `alpha=0` resolves to `(0,0,0)` when flattened
+ without a backdrop).
* **Opaque grey/appearance-colored padding** → macOS Tk backing (BUG-075).
---
@@ -87,7 +88,7 @@ removes the Tk dependency but replaces it with a PySide6 one.
---
-## 3. Windows: measured, and the color key is working
+## 3. Windows: the color key works — while the window is being pumped
Measured on a live Windows 11 install, 4K display, with the bar running
(2026-07-28):
@@ -111,38 +112,65 @@ A colorkey + alpha 0.6 : black=0 (backdrop visible through the padding)
B colorkey only : black=0 goldish=406 (pill visible)
```
-**Zero black pixels in either case.** The color key keys out correctly on
-Windows, including in combination with window alpha.
+**Zero black pixels in either case** — *while the window is being pumped*. That
+qualifier is the whole story, and missing it once cost a wrong diagnosis: the
+color key is not a property of the pixels, it is a property of **the window**,
+and it protects the padding only for as long as that window is the thing on
+screen.
---
-## 4. The capture trap — why a screenshot can lie
+## 4. The ghost window — why the padding turns black on Windows (BUG-118)
-The reported screenshot's padding measures **pure `(0,0,0)`**, while the pill
-itself carries the exact renderer constants (`PILL_BORDER (215,182,105)`,
-`PILL_BG (14,13,12)`). So the *frame* reached the screen intact and only the
-padding is wrong — and it is wrong in the one color the renderer never emits.
+When a top-level window stops pumping messages for roughly five seconds,
+Windows hides it and puts a stand-in window of class `Ghost` at the same
+rectangle, painted by the DWM rather than by the app. **The ghost is an
+ordinary window: it carries no `WS_EX_LAYERED`,** so the magenta colour key is
+never applied to it and the entire window rectangle lands on screen as an
+opaque black box around the pill.
-Capture APIs disagree wildly about layered windows, which is reproducible:
+Measured on the live app, both windows present at once:
-* `PIL.ImageGrab.grab()` over the bar's rectangle returned the desktop **without
- the bar at all** — that BitBlt path skips layered windows.
-* `BitBlt` with and without `CAPTUREBLT` both showed the padding correctly
- transparent.
-* Capture stacks built on DWM thumbnails / `Windows.Graphics.Capture` (Snipping
- Tool, Game Bar, ShareX, meeting-share pipelines) hand back **BGRA**. A
- color-keyed layered window's dropped pixels arrive as `alpha = 0` with RGB
- zeroed; flattening that to BGRX without a backdrop yields exactly
- `(0,0,0)` — a black rectangle of precisely the window size.
+```
+hwnd=4004742 class='TkTopLevel' pid=88416(app) HUNG=True LAYERED=True key=0x00ff00ff
+hwnd=8196144 class='Ghost' pid=1340(dwm) HUNG=True LAYERED=False no key
+ identical rect 1873,2031 93x39 screen over it: black=3141
+```
-Hence the rule for triaging any future report:
+Reproduced from first principles — a color-keyed frameless Tk window showing a
+real renderer frame, whose UI thread is then deliberately blocked:
-> **A black box in a screenshot is not evidence of a black box on screen.**
-> Confirm on the physical display, or with a capture path known to composite
-> layered windows, before touching the transparency code.
+```
+control (no fix): before stall black=0 during stall black=1982 / 2870
+with the fix: before stall black=0 during stall black=0
+```
-Conversely, a black box that persists *on the physical display* is a real
-defect — and on macOS that is the expected failure mode, per §2.
+**This does not require the app to be broken.** The bar paints from a Tk loop,
+and that loop stops pumping whenever *another* thread holds the GIL through a
+long CPU-bound stretch. The trigger in the field was exactly that: the backend
+thread sat `active+gil` inside `load_config()` → `JarvisConfig(**data)` on the
+event loop, reached from `resolve_provider_endpoint()` in `_ensure_client` on
+every brain call (same family as the freeze fixed in `325af16d`, which cached
+the TOML parse but not the pydantic construction above it).
+
+So the user-visible symptom of a **stall** is a **rendering defect**, which is
+why this reads as "the bar has a black border" rather than "the app is busy".
+
+**Fix.** `disable_windows_app_ghosting()` (`jarvis/core/process_utils.py`),
+called from both color-key surfaces — the bar (`jarvis/ui/jarvisbar/overlay.py`)
+and the mascot (`ui/orb/overlay.py`). `DisableProcessWindowsGhosting` is
+process-wide and cannot be undone, which is the right trade: a frameless
+click-through overlay gains nothing from a ghost (no title bar to grey out, no
+close button to offer), and the app keeps its Restart control, the tray icon,
+and Task Manager as ways out of a hang. Windows-only, a logged no-op elsewhere.
+Guards: `tests/unit/core/test_process_utils_ghosting.py`.
+
+**Note on captures.** Screenshot APIs also disagree about layered windows —
+`PIL.ImageGrab.grab()` over the bar's rectangle returned the desktop *without
+the bar at all*, while `BitBlt` with `CAPTUREBLT` composited it correctly. So a
+capture can hide the bar, and it is worth knowing which path you are measuring
+with; but it was **not** the cause here, and a black box on the physical
+display is always real.
---
@@ -163,6 +191,12 @@ defect — and on macOS that is the expected failure mode, per §2.
4. **The Tk macOS branch in `overlay.py` is now unreachable for the bar** (the
host selects Qt on Darwin) but still present, so a future reader may fix the
wrong branch.
+5. **The bar shares a process — and a GIL — with the backend.** On Windows and
+ Linux the bar paints in-process, so any long CPU-bound stretch elsewhere
+ freezes its paint loop. Ghosting is now off, so that no longer *looks* like
+ a rendering bug, but the bar still stops animating. macOS does not have this
+ coupling: there the bar lives in its own companion process. Moving the
+ Windows/Linux bar out of process would remove the class entirely.
---
diff --git a/jarvis/core/process_utils.py b/jarvis/core/process_utils.py
index 6f4ea8f88a..1b071b6e6e 100644
--- a/jarvis/core/process_utils.py
+++ b/jarvis/core/process_utils.py
@@ -1,4 +1,9 @@
-"""Cross-platform helpers for spawning subprocesses without flashing console windows.
+"""Cross-platform helpers for the Windows quirks a ``pythonw`` desktop app hits.
+
+Two unrelated ones live here: spawning subprocesses without flashing console
+windows (``NO_WINDOW_CREATIONFLAGS``, below) and stopping Windows from replacing
+an unresponsive window with an opaque ghost (``disable_windows_app_ghosting``).
+Both are no-ops off Windows.
Background:
The desktop app runs under ``pythonw.exe`` (no attached console). When a
@@ -70,4 +75,55 @@ def resolve_executable(name: str) -> str:
return name
-__all__ = ["NO_WINDOW_CREATIONFLAGS", "resolve_executable"]
+_ghosting_disabled = False
+
+
+def disable_windows_app_ghosting() -> bool:
+ """Stop Windows swapping an unresponsive window for an opaque ghost.
+
+ When a top-level window stops pumping messages for roughly five seconds,
+ Windows hides it and puts a stand-in window of class ``Ghost`` at the exact
+ same rectangle, painted by the DWM rather than by the app. That stand-in is
+ an ordinary window: it does **not** inherit ``WS_EX_LAYERED``, so the Jarvis
+ Bar's magenta colour key is never applied to it, and the full window
+ rectangle lands on screen as an opaque BLACK box around the pill.
+
+ Reaching this does not require the app to be broken. The bar paints from a
+ Tk loop, and that loop stops pumping whenever *another* thread holds the GIL
+ through a long CPU-bound stretch — a slow config load on the backend thread
+ is enough. The user sees a black rectangle around their bar and nothing else
+ wrong, which reads as a rendering bug rather than as a stall.
+
+ ``DisableProcessWindowsGhosting`` is process-wide and cannot be undone. That
+ is the right trade for this app: a frameless click-through overlay gains
+ nothing from a ghost — there is no title bar to grey out and no close button
+ to offer — while the desktop window keeps its own Restart control, the tray
+ icon, and Task Manager as ways out of a hang.
+
+ Idempotent and never raises. Returns ``True`` when ghosting is off for this
+ process, ``False`` on a platform that has no such behaviour (macOS, Linux)
+ or when the call could not be made.
+ """
+ global _ghosting_disabled
+ if _ghosting_disabled:
+ return True
+ if sys.platform != "win32":
+ # No equivalent exists: macOS shows a spinning cursor and Linux WMs
+ # offer their own "not responding" prompt, neither of which repaints
+ # the window's own pixels.
+ return False
+ try:
+ import ctypes # noqa: PLC0415 — Windows-only, keep it off the import floor
+
+ ctypes.windll.user32.DisableProcessWindowsGhosting()
+ except Exception: # noqa: BLE001 — cosmetic hardening; never block a UI boot
+ return False
+ _ghosting_disabled = True
+ return True
+
+
+__all__ = [
+ "NO_WINDOW_CREATIONFLAGS",
+ "disable_windows_app_ghosting",
+ "resolve_executable",
+]
diff --git a/jarvis/ui/jarvisbar/overlay.py b/jarvis/ui/jarvisbar/overlay.py
index f087dbdc1f..0508eb3d2f 100644
--- a/jarvis/ui/jarvisbar/overlay.py
+++ b/jarvis/ui/jarvisbar/overlay.py
@@ -739,6 +739,16 @@ class JarvisBarOverlay:
except tk.TclError:
log.warning("transparentcolor unsupported — bar will show its key colour")
root.configure(bg=COLOR_KEY_HEX)
+ # The colour key only ever applies to the window WE own. Once this
+ # Tk loop stops pumping — which any long GIL-holding stretch on
+ # another thread is enough to cause — Windows hides that window and
+ # paints an unlayered ``Ghost`` stand-in over the same rectangle,
+ # so the keyed-out padding arrives on screen as an opaque BLACK box
+ # around the pill. Turn the stand-in off rather than let a stall
+ # present itself as a rendering defect.
+ from jarvis.core.process_utils import disable_windows_app_ghosting
+
+ disable_windows_app_ghosting()
# Window-level alpha ON TOP of the color key: the magenta stays fully
# keyed out (verified — no bleed) while the pill itself goes
# semi-transparent, so the desktop shows through it (glass look).
@@ -1281,7 +1291,11 @@ class JarvisBarOverlay:
hovered=self._hovered,
muted=self._muted,
drop_state=drop_visual,
- drop_elapsed=now - self._drop_visual_t0,
+ # Same getattr guard as the level stamp above, and for the
+ # same reason: a ``__new__``-built test/hot-reload instance
+ # skips __init__, and a missing stamp must read as "no drop
+ # in flight" rather than blow the frame away.
+ drop_elapsed=now - getattr(self, "_drop_visual_t0", 0.0),
)
if getattr(self, "_mac_transparent", False):
# macOS: no color key — carry real per-pixel alpha instead.
@@ -1541,9 +1555,12 @@ class JarvisBarOverlay:
retire a verdict once its animation has run out — doing it here means
the bar also falls back out of the fast-path veto and can settle again.
"""
- state = self._drop_visual
+ # getattr, like the level stamp in the frame loop: a ``__new__``-built
+ # test/hot-reload instance skips __init__, and an unset drop state must
+ # read as "nothing in flight" rather than kill the whole frame.
+ state = getattr(self, "_drop_visual", renderer.DROP_STATE_NONE)
if state in (renderer.DROP_STATE_OK, renderer.DROP_STATE_REJECTED):
- elapsed = time.perf_counter() - self._drop_visual_t0
+ elapsed = time.perf_counter() - getattr(self, "_drop_visual_t0", 0.0)
if elapsed >= renderer.DROP_CONFIRM_TOTAL_S:
self._drop_visual = renderer.DROP_STATE_NONE
return renderer.DROP_STATE_NONE
diff --git a/tests/unit/core/test_process_utils_ghosting.py b/tests/unit/core/test_process_utils_ghosting.py
new file mode 100644
index 0000000000..642d7e3637
--- /dev/null
+++ b/tests/unit/core/test_process_utils_ghosting.py
@@ -0,0 +1,87 @@
+"""Guards for ``disable_windows_app_ghosting`` (BUG-118).
+
+The bar's magenta colour key belongs to the window Jarvis owns. When that
+window stops pumping messages, Windows substitutes an UNLAYERED ghost window at
+the same rectangle, the key is never applied to it, and the padding around the
+pill reaches the screen as an opaque black box. The helper turns the
+substitution off; these tests pin its contract, which has to hold on the two
+OSes that have no such behaviour just as much as on Windows.
+"""
+from __future__ import annotations
+
+import sys
+
+import pytest
+
+from jarvis.core import process_utils
+
+
[email protected](autouse=True)
+def _reset_flag():
+ """Each test starts from 'not yet disabled' — the flag is process-global."""
+ original = process_utils._ghosting_disabled
+ process_utils._ghosting_disabled = False
+ yield
+ process_utils._ghosting_disabled = original
+
+
+def test_is_a_quiet_no_op_off_windows(monkeypatch):
+ """macOS/Linux have no ghost window — report False, never raise, never
+ touch ctypes."""
+ monkeypatch.setattr(sys, "platform", "darwin")
+ assert process_utils.disable_windows_app_ghosting() is False
+ monkeypatch.setattr(sys, "platform", "linux")
+ assert process_utils.disable_windows_app_ghosting() is False
+ # A no-op must not claim the process is protected.
+ assert process_utils._ghosting_disabled is False
+
+
[email protected](sys.platform != "win32", reason="Windows-only API")
+def test_disables_ghosting_on_windows():
+ assert process_utils.disable_windows_app_ghosting() is True
+ assert process_utils._ghosting_disabled is True
+
+
[email protected](sys.platform != "win32", reason="Windows-only API")
+def test_second_call_is_free():
+ """Idempotent: both overlay surfaces call it, and the API cannot be undone,
+ so a repeat must short-circuit rather than re-enter user32."""
+ assert process_utils.disable_windows_app_ghosting() is True
+ calls = []
+
+ class _Boom:
+ def __getattr__(self, name): # any ctypes access is a failure here
+ calls.append(name)
+ raise AssertionError("second call must not reach ctypes")
+
+ import ctypes
+
+ original = ctypes.windll
+ try:
+ ctypes.windll = _Boom()
+ assert process_utils.disable_windows_app_ghosting() is True
+ finally:
+ ctypes.windll = original
+ assert calls == []
+
+
+def test_a_failing_api_never_propagates(monkeypatch):
+ """Cosmetic hardening: a Windows build without the export (or a locked-down
+ host) must degrade to False, not take the overlay's boot down with it."""
+ monkeypatch.setattr(sys, "platform", "win32")
+
+ class _Windll:
+ @property
+ def user32(self):
+ raise OSError("user32 unavailable")
+
+ import ctypes
+
+ monkeypatch.setattr(ctypes, "windll", _Windll(), raising=False)
+ assert process_utils.disable_windows_app_ghosting() is False
+ assert process_utils._ghosting_disabled is False
+
+
+def test_exported_from_the_module():
+ """Both overlay surfaces import it by name; keep it in __all__."""
+ assert "disable_windows_app_ghosting" in process_utils.__all__
diff --git a/ui/orb/overlay.py b/ui/orb/overlay.py
index 9e0b7d8dea..3323df8b5b 100644
--- a/ui/orb/overlay.py
+++ b/ui/orb/overlay.py
@@ -1492,6 +1492,23 @@ class OrbOverlay:
else:
self._root.wm_attributes("-transparentcolor", COLOR_KEY_HEX)
self._root.configure(bg=COLOR_KEY_HEX)
+ # The colour key belongs to THIS window only. Once this Tk loop
+ # stops pumping — any long GIL-holding stretch on another thread
+ # does it — Windows paints an unlayered ``Ghost`` stand-in over the
+ # same rectangle, and the keyed-out padding arrives as an opaque
+ # black box around the mascot. Same defect as the bar's.
+ try:
+ from jarvis.core.process_utils import disable_windows_app_ghosting
+
+ disable_windows_app_ghosting()
+ except Exception: # noqa: BLE001 — cosmetic; the orb must still boot
+ import logging
+
+ logging.getLogger("jarvis.orb").debug(
+ "window-ghosting suppression unavailable — a stalled orb may "
+ "show an opaque box",
+ exc_info=True,
+ )
# Apply the Jarvis icon BEFORE hiding from the task switcher: Windows
# caches the taskbar entry on first show, so even a brief flash with
# the default pythonw icon sticks. Belt-and-suspenders: stable AppID