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(macos): JarvisBar/mascot host survives Tk 9 — init Tk before pyobjc NSApplication (BUG-067)
Joana Lütke3bbf49bc0f4f
diff --git a/docs/BUGS.md b/docs/BUGS.mdindex 83410aed25..0b5782d9f6 100644--- a/docs/BUGS.md+++ b/docs/BUGS.md@@ -5300,3 +5300,39 @@ it. Any runtime code that shells out to pip must treat "No module namedpip" as a repairable state (ensurepip / uv fallback), not a terminalerror, or every in-app install silently bricks for the growing uv-managedinstall base.++---++## BUG-074: JarvisBar/mascot host died instantly on macOS — pyobjc NSApplication before Tk 9 init (HIGH, FIXED 2026-07-17)++> Shipped in the 2026-07-17 public-repo (Mac session) commits as "BUG-067";+> renumbered on integration — the local register had already assigned BUG-067+> to an unrelated Computer-Use bug.++**Symptom.** On the freshly installed Intel Mac the bar never appeared;+`jarvis_desktop.log` repeated "JarvisBar host not ready within 3.0s" /+"JarvisBar host process is gone". Running the host by hand showed a native+abort (SIGABRT) inside `libtcl9tk9.0`: `-[NSApplication macOSVersion]:+unrecognized selector`.++**Root cause.** The host hid its Dock icon via pyobjc+(`NSApplication.sharedApplication().setActivationPolicy_(1)`) BEFORE creating+the Tk root. Tk 9's aqua backend calls selectors that only exist on Tk's own+`TKApplication` subclass of NSApplication; when pyobjc has already+instantiated a plain `NSApplication` as `NSApp`, `Tk()` aborts natively.+Tk 8.6 tolerated this order — but uv's python-build-standalone CPython (the+interpreter the installer provisions on Intel Macs / Python-3.14 systems)+bundles **Tk 9.0**, so every fresh macOS install hit it. Reproduced+minimally: `AppKit.NSApplication.sharedApplication()` then `tkinter.Tk()`+crashes; `Tk()` first, AppKit second works.++**Fix (2026-07-17).** `_hide_dock_icon()` now creates a withdrawn bootstrap+`tkinter.Tk()` root FIRST (kept alive for the host's lifetime) so Tk owns+`NSApp`, then applies the accessory activation policy. darwin-only code+path; Linux/Windows byte-identical. Verified live: the host reaches+`{"event": "ready"}` and the Tk mainloop keeps running.++**Class rule.** In any process that will run Aqua-Tk, Tk must be the first+framework to touch `NSApplication`. Never call a pyobjc/AppKit API before+the first `Tk()` in Tk-hosting subprocesses — and treat "works with Tk 8.6"+as unproven for Tk 9.diff --git a/jarvis/ui/jarvisbar/host.py b/jarvis/ui/jarvisbar/host.pyindex dd84319b49..6f1999b8af 100644--- a/jarvis/ui/jarvisbar/host.py+++ b/jarvis/ui/jarvisbar/host.py@@ -207,12 +207,37 @@ class _EchoBar:return _echo+# Keeps the bootstrap Tk interpreter alive for the host's lifetime — Tk aqua+# teardown is fragile, and NSApp must stay Tk's own TKApplication.+_TK_BOOTSTRAP_ROOT: Any = None++def _hide_dock_icon() -> None:"""Best-effort: run as a Dock-less accessory app (macOS only).Without this the bar host would add a second python rocket to the Dock.pyobjc may be absent — purely cosmetic, never blocks the bar.++ ORDER IS LOAD-BEARING (BUG-074): Tk MUST initialize before any pyobjc+ ``NSApplication.sharedApplication()`` call in this process. Tk 9's aqua+ backend calls selectors that only exist on Tk's own ``TKApplication``+ subclass; if a plain ``NSApplication`` already owns ``NSApp`` (because+ pyobjc created it first), ``Tk()`` aborts natively with+ ``-[NSApplication macOSVersion]: unrecognized selector`` — the bar host+ dies before it can signal ready. uv's python-build-standalone CPython+ bundles Tk 9, so this is the default fresh-install constellation on+ macOS. A withdrawn bootstrap root created here makes Tk the one that+ instantiates ``NSApp``; the later overlay root joins the same process+ safely."""+ global _TK_BOOTSTRAP_ROOT+ try:+ import tkinter # noqa: PLC0415++ _TK_BOOTSTRAP_ROOT = tkinter.Tk()+ _TK_BOOTSTRAP_ROOT.withdraw()+ except Exception: # noqa: BLE001 — headless/no-Tk hosts degrade downstream+ log.debug("Tk bootstrap root failed (no display?)", exc_info=True)try:from AppKit import NSApplication # type: ignore[import-not-found]