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(browser): restore manual tabs on explicit handback
rubenluetke10-beep2f2ed28ca3ec
diff --git a/docs/browser-verification-review.md b/docs/browser-verification-review.mdindex 4395f15945..6b2c940fc7 100644--- a/docs/browser-verification-review.md+++ b/docs/browser-verification-review.md@@ -83,3 +83,12 @@ visible browser, complete any required verification, and confirm that the sameprofile retains its session after browser/app restart and explicit agenthandoff. Fakes prove routing, state and lifecycle contracts, not provideracceptance. No hidden browser was used as a substitute for those checks.+++## Session restoration after manual control++Explicit handback requests Chrome's previous session when automation reopens the+owned profile, so open tabs can return without page inspection during sign-in.+The native contract observes fixture HTTP traffic while the browser is disconnected,+then checks tab recovery after explicit handback. Unit checks alone do not qualify+the native transition or real provider authentication.diff --git a/jarvis/society/browser/live_runner.py b/jarvis/society/browser/live_runner.pyindex f7d409fe02..6a3de1ecda 100644--- a/jarvis/society/browser/live_runner.py+++ b/jarvis/society/browser/live_runner.py@@ -172,7 +172,11 @@ class Worker:viewport={"width": 1280, "height": 800},accept_downloads=True,service_workers="block",- args=["--remote-debugging-port=0", "--remote-debugging-address=127.0.0.1"],+ args=[+ "--remote-debugging-port=0", "--remote-debugging-address=127.0.0.1",+ # Explicit handback resumes the tabs the person just used.+ *(["--restore-last-session"] if self.login_mode else []),+ ],)private_hosts = {str(pattern).split("://")[-1].split("/")[0]diff --git a/tests/contract/test_browser_live.py b/tests/contract/test_browser_live.pyindex 0a7e652927..caad474888 100644--- a/tests/contract/test_browser_live.py+++ b/tests/contract/test_browser_live.py@@ -3,6 +3,7 @@from __future__ import annotationsimport asyncio+import htmlimport osimport threadingfrom http.server import BaseHTTPRequestHandler, ThreadingHTTPServer@@ -66,8 +67,10 @@ def test_actual_browser_click_emits_pointer_telemetry(tmp_path):class PageHandler(BaseHTTPRequestHandler):profile_requests = []+ page_requests = []def do_GET(self):+ self.page_requests.append(self.path)if self.path.startswith(("/login", "/account")):signed_in = "fixture_session=verified" in self.headers.get("Cookie", "")self.profile_requests.append((self.path, signed_in))@@ -80,6 +83,7 @@ class PageHandler(BaseHTTPRequestHandler):)signed_in = Trueself.end_headers()+ self.wfile.write(b"<!doctype html><title>Account fixture</title>")self.wfile.write(b"<h1>Signed in</h1>" if signed_in else b"<h1>Sign in required</h1>")returnif self.path == "/download":@@ -109,14 +113,17 @@ class PageHandler(BaseHTTPRequestHandler):def do_POST(self):body = self.rfile.read(int(self.headers.get("Content-Length", "0")))self.send_response(200)- self.send_header("Content-Type", "text/plain")+ self.send_header("Content-Type", "text/html")self.end_headers()- self.wfile.write(b"Upload received: " + body)+ self.wfile.write(b"<!doctype html><title>Upload fixture</title><pre>Upload received: "+ + html.escape(body.decode("utf-8", errors="replace")).encode("utf-8")+ + b"</pre>")@pytest.fixturedef site():PageHandler.profile_requests = []+ PageHandler.page_requests = []server = ThreadingHTTPServer(("127.0.0.1", 0), PageHandler)thread = threading.Thread(target=server.serve_forever, daemon=True)thread.start()@@ -140,6 +147,8 @@ async def _control(live, session, owner, op, args):"""Send the observed browser generation just as the visible viewer does."""if op not in {"takeover", "cancel"}:args = {"generation": session.state.get("generation", session.generation), **args}+ elif op == "takeover" and args.get("enabled") is False:+ args = {"login": False, **args} # The test performs explicit owner handback.return await live.control(session, owner, op, args)@@ -226,19 +235,20 @@ async def test_native_chrome_toolbar_keyboard_and_agent_handoff(live, site):await _control(live, session, "viewer", "key", {"key": "Enter"})try:async with asyncio.timeout(15):- while True:- event = await queue.get()- if event["kind"] == "state" and event["url"].rstrip("/") == site:- break+ # A plain Chrome sign-in deliberately exposes no DOM or URL.+ # HTTP arrival proves native toolbar input reached the fixture.+ while "/" not in PageHandler.page_requests:+ await asyncio.sleep(0.05)except TimeoutError:pytest.fail(f"Native browser did not select the navigated tab: {session.state}")- assert len(event["tabs"]) == 2await _control(live, session, "viewer", "takeover", {"enabled": False})- async with asyncio.timeout(5):+ async with asyncio.timeout(15):while True:event = await queue.get()- if event["kind"] == "state" and not event["manual"]:+ if (event["kind"] == "state" and not event["manual"]+ and event["url"].rstrip("/") == site):break+ assert len(event["tabs"]) >= 2assert event["url"].rstrip("/") == sitefinally:await live.close()@@ -656,6 +666,9 @@ async def test_login_profile_survives_restart_and_stays_with_its_agent(live, sitsession, _ = await live.subscribe(agent)await _control(live, session, "viewer", "takeover", {"enabled": True})await _control(live, session, "viewer", "navigate", {"url": site + path})+ async with asyncio.timeout(15):+ while not any(request_path == path for request_path, _ in PageHandler.profile_requests):+ await asyncio.sleep(0.05)await _control(live, session, "viewer", "takeover", {"enabled": False})return sessiondiff --git a/tests/unit/society/test_browser_login_worker.py b/tests/unit/society/test_browser_login_worker.pyindex a69ada841c..239adf954a 100644--- a/tests/unit/society/test_browser_login_worker.py+++ b/tests/unit/society/test_browser_login_worker.py@@ -297,10 +297,12 @@ async def test_stopping_monitors_awaits_inflight_capture_and_cursor_work(runtime@pytest.mark.parametrize("pinned", [None, "stable-chrome.exe", "invalid"])[email protected]("handback", [False, True])async def test_startup_reuses_durable_chrome_pin_and_never_falls_back_if_invalid(- runtime, monkeypatch, pinned+ runtime, monkeypatch, pinned, handback):worker = runtime.worker+ worker.login_mode = handbackpw = PlaywrightStartup()monkeypatch.setitem(sys.modules,@@ -338,7 +340,8 @@ async def test_startup_reuses_durable_chrome_pin_and_never_falls_back_if_invalidresult = await worker.start(worker.start_args)assert pw.launches[0][0] == str(profile)assert pw.launches[0][1]["executable_path"] == (pinned or "testing-chrome.exe")- assert not result["login_mode"] and not result["login_available"]+ assert ("--restore-last-session" in pw.launches[0][1]["args"]) is handback+ assert result["login_mode"] is handback and not result["login_available"]async def test_person_opening_browser_starts_plain_chrome_before_any_automation(