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(macos): restore native controls and minimized detached windows (#452)

Ruben Lütke4378a940629a
diff --git a/.github/workflows/macos-desktop.yml b/.github/workflows/macos-desktop.yml
index 89bcb83e2e..553dd0e8d0 100644
--- a/.github/workflows/macos-desktop.yml
+++ b/.github/workflows/macos-desktop.yml
@@ -277,6 +277,7 @@ jobs:
tests/unit/ui/test_desktop_macos_permission_gate.py \
tests/unit/ui/test_window_command.py \
tests/unit/ui/test_desktop_detached_windows.py \
+ tests/unit/ui/test_appshot_editor_warm.py \
tests/unit/ui/test_desktop_background.py \
tests/unit/ui/test_window_fullscreen.py \
tests/unit/setup/test_macos_app_bundle.py \
diff --git a/docs/os-parity.md b/docs/os-parity.md
index ddcd0bc989..914bfb08b6 100644
--- a/docs/os-parity.md
+++ b/docs/os-parity.md
@@ -178,14 +178,25 @@ Cocoa restore operation only deminiaturizes. Existing close/background and
detached-window lifecycle handling remains attached to the native window events.
Windows and Linux retain their existing frameless web captions.
+The 2026-10-07 follow-up covers the prewarmed Appshot/recording editor too:
+its hidden creation path now retains the same native title bar as a cold open.
+Reopening an existing detached window or warm editor on macOS calls the Cocoa
+show and restore APIs; the Windows title-based foreground helper is a no-op on
+macOS and previously left minimized detached views in the Dock. Native red
+close still destroys and deregisters the detached window, so a later open
+creates a new one. The editor's in-page Done/Close action still keeps it warm.
+
Regression coverage checks all three platform configurations, reopened and
-detached window creation, the chrome API, and the existing close/background
+all registered detached window creation paths, warm-editor creation and
+restoration, the chrome API, and the existing close/background
lifecycle. The macOS desktop lane runs these tests on Intel, Apple Silicon,
and standalone Python alongside its dependency and application-bundle checks.
These automated checks do not replace a physical Mac acceptance pass: verify
red close, yellow minimize/Dock restore, green fullscreen/exit and Option-green
zoom in light and dark appearance, including a detached view and a reopened
-main window. This Windows development host cannot qualify those native clicks.
+main window. Include both a cold and a prewarmed Appshot/recording editor, and
+reopen a minimized editor from its card. This Windows development host cannot
+qualify those native clicks.
## Reopening the desktop with detached windows (2026-10-07, T2)
diff --git a/dodaios/ui/desktop_app.py b/dodaios/ui/desktop_app.py
index 26c218ae80..fe88876af0 100644
--- a/dodaios/ui/desktop_app.py
+++ b/dodaios/ui/desktop_app.py
@@ -5559,7 +5559,23 @@ class DesktopApp:
logger.opt(exception=exc).warning("Detached '{}' could not navigate", view)
return {"ok": False, "reason": f"{type(exc).__name__}: {exc}"}
- _bring_window_to_front_by_title(self._detached_title(view))
+ if sys.platform == "darwin":
+ try:
+ # The title-based foreground helper is Windows-only. Cocoa
+ # needs both show and deminiaturize to reopen a Dock window.
+ existing.show()
+ existing.restore()
+ except Exception as exc: # noqa: BLE001
+ from loguru import logger
+
+ logger.opt(exception=exc).warning("Detached '{}' could not be shown", view)
+ return {
+ "ok": False,
+ "reason": f"{type(exc).__name__}: {exc}",
+ "fallback_url": fallback,
+ }
+ else:
+ _bring_window_to_front_by_title(self._detached_title(view))
return {"ok": True, "already_open": True, "view": view}
if self._window is None and not self._detached_windows:
# No live window means no running GUI loop to attach to —
@@ -5643,6 +5659,10 @@ class DesktopApp:
# The page has not finished loading yet: load it on this shot.
window.load_url(f"{self._url()}{fallback}")
window.show()
+ if sys.platform == "darwin":
+ # show() orders the window forward; restore() brings it out
+ # of the Dock after the native yellow button minimized it.
+ window.restore()
except Exception as exc: # noqa: BLE001
from loguru import logger
@@ -5676,7 +5696,8 @@ class DesktopApp:
height=height,
min_size=_EDITOR_MIN_SIZE,
resizable=True,
- frameless=True,
+ # The warm path needs the same Cocoa controls as a cold open.
+ frameless=sys.platform != "darwin",
easy_drag=False,
confirm_close=False,
hidden=True,
diff --git a/tests/unit/ui/test_appshot_editor_warm.py b/tests/unit/ui/test_appshot_editor_warm.py
index 207af3b76a..ca38301751 100644
--- a/tests/unit/ui/test_appshot_editor_warm.py
+++ b/tests/unit/ui/test_appshot_editor_warm.py
@@ -43,6 +43,9 @@ class _Window:
def show(self) -> None:
self.calls.append("show")
+ def restore(self) -> None:
+ self.calls.append("restore")
+
def resize(self, width: int, height: int) -> None:
self.calls.append(f"resize {width}x{height}")
self.width = width
@@ -66,7 +69,11 @@ def _app(monkeypatch: pytest.MonkeyPatch) -> DesktopApp:
return app
-def test_prewarm_creates_the_editor_hidden_once(monkeypatch: pytest.MonkeyPatch) -> None:
[email protected]("platform", ["darwin", "win32", "linux"])
+def test_prewarm_creates_the_editor_hidden_once(
+ monkeypatch: pytest.MonkeyPatch, platform: str,
+) -> None:
+ monkeypatch.setattr(sys, "platform", platform)
created: list[dict] = []
def create_window(title, url, **kwargs):
@@ -84,6 +91,8 @@ def test_prewarm_creates_the_editor_hidden_once(monkeypatch: pytest.MonkeyPatch)
assert second == {"ok": True, "already_open": True}
assert len(created) == 1
assert created[0]["hidden"] is True
+ assert created[0]["frameless"] is (platform != "darwin")
+ assert created[0]["resizable"] is True
assert created[0]["url"].endswith("/?view=appshot-editor&solo=1")
@@ -103,10 +112,44 @@ def test_a_page_still_loading_is_navigated_then_shown(monkeypatch: pytest.Monkey
# Windows paints a WebView that was created hidden only after a size change.
if sys.platform == "win32":
assert window.calls[3:] == ["resize 900x601", "resize 900x600"]
+ elif sys.platform == "darwin":
+ assert window.calls[3:] == ["restore"]
else:
assert window.calls[3:] == []
+def test_reopening_the_editor_on_macos_restores_it_from_the_dock(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ monkeypatch.setattr(sys, "platform", "darwin")
+ app = _app(monkeypatch)
+ window = _Window()
+ app._detached_windows["appshot-editor"] = window
+
+ result = app.open_detached_window("appshot-editor", query="appshot=a1b2c3d4")
+
+ assert result["ok"] is True
+ assert window.calls == ["js", "show", "restore"]
+ assert app._detached_windows["appshot-editor"] is window
+
+
+def test_macos_editor_restore_failure_is_reported(monkeypatch: pytest.MonkeyPatch) -> None:
+ monkeypatch.setattr(sys, "platform", "darwin")
+ app = _app(monkeypatch)
+ window = _Window()
+
+ def failed_restore() -> None:
+ raise RuntimeError("window unavailable")
+
+ window.restore = failed_restore
+ app._detached_windows["appshot-editor"] = window
+
+ result = app.open_detached_window("appshot-editor", query="appshot=a1b2c3d4")
+
+ assert result["ok"] is False
+ assert app._detached_windows["appshot-editor"] is window
+
+
def test_a_script_result_that_is_not_true_still_loads_the_shot(
monkeypatch: pytest.MonkeyPatch,
) -> None:
diff --git a/tests/unit/ui/test_desktop_detached_windows.py b/tests/unit/ui/test_desktop_detached_windows.py
index 43134d93cf..cf8543c129 100644
--- a/tests/unit/ui/test_desktop_detached_windows.py
+++ b/tests/unit/ui/test_desktop_detached_windows.py
@@ -39,6 +39,7 @@ class _FakeWindow:
self.url = url
self.destroyed = False
self.shown = 0
+ self.restored = False
self.evaluated: list[str] = []
self.events = SimpleNamespace(
loaded=_List(), closed=_List(), closing=_List(), shown=_List(),
@@ -50,6 +51,9 @@ class _FakeWindow:
def destroy(self) -> None:
self.destroyed = True
+ def restore(self) -> None:
+ self.restored = True
+
def evaluate_js(self, js: str) -> None:
self.evaluated.append(js)
@@ -118,7 +122,8 @@ def _app(monkeypatch: pytest.MonkeyPatch | None = None) -> DesktopApp:
@pytest.mark.parametrize("platform", ["darwin", "win32", "linux"])
-def test_open_detached_creates_titled_solo_window(monkeypatch, platform) -> None:
[email protected]("view", sorted(DETACHABLE_VIEWS))
+def test_open_detached_creates_titled_solo_window(monkeypatch, platform, view) -> None:
import sys
app = _app(monkeypatch)
@@ -126,26 +131,29 @@ def test_open_detached_creates_titled_solo_window(monkeypatch, platform) -> None
created: list[_FakeWindow] = []
monkeypatch.setitem(sys.modules, "webview", _fake_webview(created))
- result = app.open_detached_window("agentic-ide")
+ result = app.open_detached_window(view)
- assert result == {"ok": True, "already_open": False, "view": "agentic-ide"}
+ # A tab of a section family opens its owner's shared window.
+ owner = section_window(view)
+ assert result == {"ok": True, "already_open": False, "view": owner}
assert len(created) == 1
window = created[0]
assert window.frameless is (platform != "darwin")
assert window.resizable is True
# Distinct title: FindWindowW-exact focus and the icon setter key on it.
- assert window.title == f"{WINDOW_TITLE} — Agentic IDE"
+ assert window.title == app._detached_title(owner)
assert window.title != WINDOW_TITLE
- assert "?view=agentic-ide&solo=1" in window.url
- assert app._detached_windows == {"agentic-ide": window}
+ assert f"?view={view}&solo=1" in window.url
+ assert app._detached_windows == {owner: window}
assert len(window.events.loaded) == 1 # injection hook
assert len(window.events.closed) == 1 # deregistration hook
- assert app.published == [("agentic-ide", True)]
+ assert app.published == [(owner, True)]
def test_open_detached_is_idempotent_and_focuses(monkeypatch) -> None:
import sys
+ monkeypatch.setattr(sys, "platform", "win32")
app = _app(monkeypatch)
created: list[_FakeWindow] = []
monkeypatch.setitem(sys.modules, "webview", _fake_webview(created))
@@ -171,6 +179,58 @@ def test_open_detached_rejects_unknown_view(monkeypatch) -> None:
}
+def test_reopening_a_macos_detached_window_restores_and_shows_it(monkeypatch) -> None:
+ monkeypatch.setattr("dodaios.ui.desktop_app.sys.platform", "darwin")
+ app = _app(monkeypatch)
+ window = _FakeWindow()
+ app._detached_windows["chats"] = window
+
+ result = app.open_detached_window("chats")
+
+ assert result == {"ok": True, "already_open": True, "view": "chats"}
+ assert window.shown and window.restored
+ assert app._detached_windows == {"chats": window}
+
+
+def test_macos_detached_restore_failure_is_reported(monkeypatch) -> None:
+ monkeypatch.setattr("dodaios.ui.desktop_app.sys.platform", "darwin")
+ app = _app(monkeypatch)
+ window = _FakeWindow()
+
+ def failed_restore() -> None:
+ raise RuntimeError("window unavailable")
+
+ window.restore = failed_restore
+ app._detached_windows["chats"] = window
+
+ result = app.open_detached_window("chats")
+
+ assert result["ok"] is False
+ assert result["fallback_url"] == "/?view=chats&solo=1"
+ assert app._detached_windows == {"chats": window}
+
+
+def test_native_close_of_warm_macos_editor_allows_a_fresh_open(monkeypatch) -> None:
+ import sys
+
+ monkeypatch.setattr(sys, "platform", "darwin")
+ app = _app(monkeypatch)
+ created: list[_FakeWindow] = []
+ monkeypatch.setitem(sys.modules, "webview", _fake_webview(created))
+
+ assert app.prewarm_appshot_editor()["ok"] is True
+ closed = created[0]
+ for handler in closed.events.closed:
+ handler()
+
+ assert app.detached_views_snapshot() == []
+ assert app.published == [("appshot-editor", False)]
+ assert app._user_requested_quit is False
+ assert app.prewarm_appshot_editor()["already_open"] is False
+ assert app._detached_windows["appshot-editor"] is created[1]
+ assert created[1].frameless is False
+
+
@pytest.mark.parametrize("owner,tabs", WINDOW_GROUPS.items())
def test_tabs_share_one_window_and_keep_the_requested_initial_page(
monkeypatch, owner, tabs,
diff --git a/tests/unit/ui/test_desktop_show_window.py b/tests/unit/ui/test_desktop_show_window.py
index 20cb549f21..9e606506f6 100644
--- a/tests/unit/ui/test_desktop_show_window.py
+++ b/tests/unit/ui/test_desktop_show_window.py
@@ -391,20 +391,24 @@ def test_the_appshot_editor_window_opens_in_compact_proportions() -> None:
assert detached_window_size("appshot-editor", (800, 500)) == (800, 500)
[email protected]("platform", ["darwin", "win32", "linux"])
def test_an_open_editor_window_is_pointed_at_the_new_appshot(
- monkeypatch: pytest.MonkeyPatch,
+ monkeypatch: pytest.MonkeyPatch, platform: str,
) -> None:
"""The appshot card opens the editor through ``open_detached_window`` with
a query; an editor already open is re-pointed, never duplicated."""
+ monkeypatch.setattr("dodaios.ui.desktop_app.sys.platform", platform)
app = DesktopApp.__new__(DesktopApp)
loaded: list[str] = []
scripts: list[str] = []
shown: list[bool] = []
+ restored: list[bool] = []
existing = SimpleNamespace(
load_url=loaded.append,
# The warm page answers: it switched to the new appshot in place.
evaluate_js=lambda js: scripts.append(js) or True,
show=lambda: shown.append(True),
+ restore=lambda: restored.append(True),
)
app._detached_windows = {"appshot-editor": existing} # noqa: SLF001
app._url = lambda: "http://127.0.0.1:47821" # type: ignore[method-assign] # noqa: SLF001
@@ -419,4 +423,5 @@ def test_an_open_editor_window_is_pointed_at_the_new_appshot(
assert loaded == [], "a warm editor is re-pointed, not reloaded"
assert scripts and '"a1b2c3d4"' in scripts[0]
assert shown == [True]
+ assert restored == ([True] if platform == "darwin" else [])
assert len(raised) == 1