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.

feat(open_app): maximize a freshly launched app so it fills its monitor

Ruben Lütkeb30dd30375d3
diff --git a/jarvis/platform/window_state.py b/jarvis/platform/window_state.py
index 0122ef78be..2bf94beded 100644
--- a/jarvis/platform/window_state.py
+++ b/jarvis/platform/window_state.py
@@ -825,6 +825,7 @@ def raise_after_launch(
*,
timeout_s: float = _RAISE_POLL_TIMEOUT_S,
poll_s: float = _RAISE_POLL_INTERVAL_S,
+ maximize: bool = False,
) -> tuple[bool, str]:
"""Poll until a window matching ``app_name`` appears, then actively bring it
to the foreground. Returns ``(raised, title_or_reason)``. Best-effort, never
@@ -839,6 +840,14 @@ def raise_after_launch(
path; macOS/Linux reuse :func:`focus_window` (by title). Synchronous and
blocking by design — an async caller wraps it in ``asyncio.to_thread`` (as
the speech/CU paths already do for :func:`focus_window`).
+
+ When ``maximize`` is set, a successfully raised window is also filled to its
+ own monitor via :func:`maximize_window` (user request 2026-07-23: a freshly
+ launched app — e.g. Chrome — must not sit tiny in the middle of a big
+ desktop). Applied to the EXACT window just found (not the foreground), so it
+ never depends on a readable maximized-state and never touches a sibling
+ window. A fixed-size dialog, Wayland, or a headless session is left as-is by
+ that call, and its result never changes the returned raise status.
"""
token = _app_token(app_name)
if len(token) < _MIN_TOKEN_LEN:
@@ -848,7 +857,12 @@ def raise_after_launch(
while True:
win = _match_window(app_name, list_windows())
if win is not None:
- return raise_window(win)
+ raised, msg = raise_window(win)
+ if raised and maximize:
+ max_ok, max_msg = maximize_window(win)
+ if max_ok:
+ log.info("raise_after_launch maximized '%s': %s", token, max_msg)
+ return raised, msg
if time.monotonic() >= deadline:
return False, (
f"no window matching '{token}' appeared within {timeout_s:.0f}s"
diff --git a/jarvis/plugins/tool/open_app.py b/jarvis/plugins/tool/open_app.py
index 533fd403b6..2e987fcea4 100644
--- a/jarvis/plugins/tool/open_app.py
+++ b/jarvis/plugins/tool/open_app.py
@@ -408,6 +408,13 @@ class OpenAppTool:
# existing browser window; the app-name match would not apply).
raised = False
if not is_url and not is_path:
+ # Also MAXIMIZE the freshly launched window so it fills its
+ # monitor instead of sitting tiny in the middle of a big desktop
+ # (user request 2026-07-23: Chrome/apps opened small + off-centre
+ # looked broken). Best-effort inside raise_after_launch: a
+ # fixed-size dialog, Wayland, or a headless session is left as-is,
+ # and it never changes the raise result. Skipped for URLs/paths
+ # (those reuse an existing browser window we must not resize).
# Hard overall cap: the poll (3s) plus a slow AX raise must
# never approach the CU dispatcher's 15s action budget — the
# launch already succeeded, the raise only softens the
@@ -415,7 +422,8 @@ class OpenAppTool:
try:
async with asyncio.timeout(6.0):
raised, _ = await asyncio.to_thread(
- window_state.raise_after_launch, app_name
+ window_state.raise_after_launch, app_name,
+ maximize=True,
)
except TimeoutError:
raised = False
diff --git a/tests/unit/platform/test_window_state.py b/tests/unit/platform/test_window_state.py
index bc2fa214df..08ee6f5dad 100644
--- a/tests/unit/platform/test_window_state.py
+++ b/tests/unit/platform/test_window_state.py
@@ -487,6 +487,64 @@ def test_raise_after_launch_never_raises(monkeypatch):
assert ok is False
+def test_raise_after_launch_maximizes_the_exact_window_when_requested(monkeypatch):
+ # maximize=True → the freshly raised window is filled to its monitor, on the
+ # EXACT WindowInfo just found (user request 2026-07-23: a launched app must
+ # not sit tiny in a big desktop).
+ monkeypatch.setattr(ws, "detect_platform", lambda: "win32")
+ win = WindowInfo("New Tab - Google Chrome", handle=4242)
+ monkeypatch.setattr(ws, "list_windows", lambda: [win])
+ monkeypatch.setattr(ws, "_force_foreground_windows", lambda h: True)
+ maximized: list[WindowInfo] = []
+ monkeypatch.setattr(
+ ws, "maximize_window", lambda w: (maximized.append(w), (True, "maximized"))[1]
+ )
+
+ ok, _title = ws.raise_after_launch(
+ "chrome", timeout_s=1.0, poll_s=0.001, maximize=True
+ )
+ assert ok is True
+ assert maximized == [win], "maximize must target the exact window just raised"
+
+
+def test_raise_after_launch_does_not_maximize_by_default(monkeypatch):
+ # Default (no maximize) must NOT touch the window size — protects every
+ # existing caller and the already-running focus path.
+ monkeypatch.setattr(ws, "detect_platform", lambda: "win32")
+ monkeypatch.setattr(
+ ws, "list_windows", lambda: [WindowInfo("Spotify Premium", handle=7)]
+ )
+ monkeypatch.setattr(ws, "_force_foreground_windows", lambda h: True)
+ monkeypatch.setattr(
+ ws,
+ "maximize_window",
+ lambda w: (_ for _ in ()).throw(AssertionError("maximized without opt-in")),
+ )
+
+ ok, _title = ws.raise_after_launch("spotify", timeout_s=1.0, poll_s=0.001)
+ assert ok is True
+
+
+def test_raise_after_launch_skips_maximize_when_raise_fails(monkeypatch):
+ # A failed raise must never maximize — otherwise a stale/sibling foreground
+ # window would be blown up instead of the intended app.
+ monkeypatch.setattr(ws, "detect_platform", lambda: "win32")
+ monkeypatch.setattr(
+ ws, "list_windows", lambda: [WindowInfo("New Tab - Google Chrome", handle=9)]
+ )
+ monkeypatch.setattr(ws, "_force_foreground_windows", lambda h: False) # raise fails
+ monkeypatch.setattr(
+ ws,
+ "maximize_window",
+ lambda w: (_ for _ in ()).throw(AssertionError("maximized after a failed raise")),
+ )
+
+ ok, _title = ws.raise_after_launch(
+ "chrome", timeout_s=0.05, poll_s=0.001, maximize=True
+ )
+ assert ok is False
+
+
# --- native macOS maximize -------------------------------------------------
diff --git a/tests/unit/plugins/tool/test_open_app_reuse.py b/tests/unit/plugins/tool/test_open_app_reuse.py
index adda211ce1..bbf0c105e2 100644
--- a/tests/unit/plugins/tool/test_open_app_reuse.py
+++ b/tests/unit/plugins/tool/test_open_app_reuse.py
@@ -127,6 +127,37 @@ async def test_fresh_launch_raises_window_to_foreground(monkeypatch):
assert "vorn" in (res.output or "").lower() # honest readback
+async def test_fresh_launch_requests_maximize(monkeypatch):
+ # A freshly launched app is maximized so it fills its monitor instead of
+ # sitting tiny in the middle of a big desktop (user request 2026-07-23).
+ _stub_launch(monkeypatch)
+ monkeypatch.setattr(oa.window_state, "is_app_running", lambda n: None)
+ seen: list = []
+ monkeypatch.setattr(
+ oa.window_state, "raise_after_launch",
+ lambda n, **k: (seen.append(k), (True, "New Tab - Google Chrome"))[1],
+ )
+ res = await OpenAppTool().execute({"app_name": "chrome"}, _ctx())
+ assert res.success is True
+ assert seen and seen[0].get("maximize") is True, (
+ "the fresh-launch path must ask raise_after_launch to maximize"
+ )
+
+
+async def test_url_launch_does_not_maximize(monkeypatch):
+ # A URL reuses an existing browser window — it must never be resized.
+ _stub_launch(monkeypatch)
+ monkeypatch.setattr(oa.window_state, "is_app_running", lambda n: None)
+ seen: list = []
+ monkeypatch.setattr(
+ oa.window_state, "raise_after_launch",
+ lambda n, **k: seen.append(k) or (True, n),
+ )
+ res = await OpenAppTool().execute({"app_name": "https://example.com"}, _ctx())
+ assert res.success is True
+ assert seen == [] # raise+maximize both skipped for URLs
+
+
async def test_raise_miss_keeps_success(monkeypatch):
# The launch already succeeded; a foreground-raise miss must NOT flip the
# result to failure — it only softens the readback back to plain "Gestartet". # i18n-allow: quotes the tool's real (currently German) readback text