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(browser): move the shared browser between agents instead of failing

rubenluetke10-beep4458e6d1aa1e
diff --git a/jarvis/society/browser/live.py b/jarvis/society/browser/live.py
index 05da78c430..01f430e15b 100644
--- a/jarvis/society/browser/live.py
+++ b/jarvis/society/browser/live.py
@@ -37,6 +37,15 @@ _PAUSED = (
)
+class BrowserProfileBusy(RuntimeError):
+ """Another agent holds the same browser profile; names it for the viewer."""
+
+ def __init__(self, holder_id: str, holder_name: str, *, running: bool) -> None:
+ self.holder_id, self.holder_name, self.running = holder_id, holder_name, running
+ doing = "running a task" if running else "under manual control"
+ super().__init__(f"This browser profile is in use: {holder_name} is {doing}.")
+
+
class LiveUpdates:
"""Latest pixels plus coalesced control events; a frame cannot drop approval."""
@@ -426,18 +435,31 @@ class LiveSessions:
)
changed = other_id == agent.agent_id and previous.access_key != binding.access_key
if changed or (same_profile and other_id != agent.agent_id):
- if (
- other.run_lock.locked()
- or other.control_owner
- or other.subscribers
+ holder = getattr(getattr(other, "profile_agent", None), "name", "") or other_id
+ if other.run_lock.locked():
+ raise BrowserProfileBusy(other_id, holder, running=True)
+ # One Chrome profile opens in one browser at a time. A person
+ # opening it for another agent moves it there, even from a
+ # sign-in they left open; an agent task never takes it from
+ # someone's hands, but merely watching never blocks a task.
+ if not window_view and (
+ other.control_owner
or other.state.get("manual", False)
+ or other.state.get("login_mode", False)
):
- raise RuntimeError(
- "This profile is in use. Stop its task or return manual control first."
- )
+ raise BrowserProfileBusy(other_id, holder, running=False)
# The active panel follows the newly assigned owner. It must
# never keep accepting input into the old account.
- other.publish({"kind": "disconnected"})
+ other.publish(
+ {"kind": "disconnected"}
+ if changed
+ else {
+ "kind": "disconnected",
+ "reason": "moved",
+ "agent_id": agent.agent_id,
+ "agent_name": getattr(agent, "name", "") or agent.agent_id,
+ }
+ )
await other.close()
self.sessions.pop(other_id, None)
old = self.sessions.get(agent.agent_id)
diff --git a/jarvis/ui/web/frontend/src/components/society/card/AgentBrowserPreview.test.tsx b/jarvis/ui/web/frontend/src/components/society/card/AgentBrowserPreview.test.tsx
index 9f52e489e6..855c6397b9 100644
--- a/jarvis/ui/web/frontend/src/components/society/card/AgentBrowserPreview.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/card/AgentBrowserPreview.test.tsx
@@ -13,6 +13,10 @@ vi.mock("@/i18n", () => ({
"society.browser_live.live": "Live",
"society.browser_live.off_hint": "Starts when {0} needs it",
"society.browser_live.open": "Open browser",
+ "society.browser_live.open_here": "Open here",
+ "society.browser_live.moved": "The shared browser is open for {0} now.",
+ "society.browser_live.busy_task": "{0} is using the shared browser for a task until {0} is done.",
+ "society.browser_live.stop_holder": "Stop {0}'s task",
"society.browser_profiles.chrome_offline": "Chrome disconnected",
"society.browser_profiles.profile_unavailable": "Profile disconnected — choose a profile",
"society.browser_profiles.title": "Browser profiles",
@@ -36,7 +40,8 @@ const { control, state, view, browser } = vi.hoisted(() => ({
view: vi.fn(),
browser: { open: true, mode: "own", connected: true, profileName: "" },
state: { connected: true, ready: true, fullWindow: false, extendedInput: false, previewPaused: false, loginMode: false, loginReady: false, loginAvailable: false, manual: false, running: false,
- url: "https://example.com", target: "one", tabs: [{ id: "one", url: "https://example.com" }], error: "" },
+ url: "https://example.com", target: "one", tabs: [{ id: "one", url: "https://example.com" }], error: "",
+ busy: undefined as undefined | { holderId: string; holderName: string; running: boolean }, movedTo: "" },
}));
vi.mock("./useBrowserView", () => ({
useBrowserView: (agentId: string, enabled: boolean) => {
@@ -64,6 +69,8 @@ afterEach(() => {
browser.mode = "own"; browser.connected = true; browser.profileName = "";
state.url = "https://example.com";
state.loginMode = false; state.loginReady = false; state.loginAvailable = false;
+ state.busy = undefined; state.movedTo = "";
+ vi.unstubAllGlobals();
});
describe("live agent browser", () => {
test("reload and restart remain visible in the compact full-window login view", () => {
@@ -161,6 +168,33 @@ describe("live agent browser", () => {
fireEvent.click(screen.getByTestId("agent-browser-open"));
expect(view).toHaveBeenLastCalledWith("scout", true);
});
+ test("a shared browser held by another agent's task names it and can stop that task", () => {
+ const fetch = vi.fn(async () => new Response("{}"));
+ vi.stubGlobal("fetch", fetch);
+ state.ready = false; state.error = "";
+ state.busy = { holderId: "juno", holderName: "Juno", running: true };
+ mount();
+ expect(screen.getByRole("status").textContent).toContain("Juno is using the shared browser for a task until Juno is done.");
+ expect(screen.queryByRole("button", { name: "Repair browser" })).toBeNull();
+ fireEvent.click(screen.getByRole("button", { name: "Stop Juno's task" }));
+ expect(fetch).toHaveBeenCalledWith("/api/society/agents/juno/browser/cancel", expect.objectContaining({ method: "POST" }));
+ });
+ test("a shared browser moved to another agent stops this view until opened here again", () => {
+ browser.open = false;
+ state.movedTo = "Wren";
+ mount();
+ expect(view).toHaveBeenLastCalledWith("scout", false);
+ expect(screen.getByTestId("agent-browser-preview").textContent).toContain("The shared browser is open for Wren now.");
+ state.movedTo = "";
+ fireEvent.click(screen.getByRole("button", { name: "Open here" }));
+ expect(view).toHaveBeenLastCalledWith("scout", true);
+ });
+ test("a session error never offers a runtime repair that cannot fix it", () => {
+ state.error = "Browser stream: TimeoutError";
+ mount();
+ expect(screen.getByText("Browser stream: TimeoutError")).toBeTruthy();
+ expect(screen.queryByRole("button", { name: "Repair browser" })).toBeNull();
+ });
test("a browser the agent already runs is shown straight away", () => {
mount();
expect(view).toHaveBeenLastCalledWith("scout", true);
diff --git a/jarvis/ui/web/frontend/src/components/society/card/AgentBrowserPreview.tsx b/jarvis/ui/web/frontend/src/components/society/card/AgentBrowserPreview.tsx
index 6cf299281d..0d6fc71056 100644
--- a/jarvis/ui/web/frontend/src/components/society/card/AgentBrowserPreview.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/card/AgentBrowserPreview.tsx
@@ -30,7 +30,9 @@ export function AgentBrowserPreview({ agent }: { agent: SocietyAgent }) {
// agent already runs, or after the person asks for it.
const running = useAgentBrowserOpen(agent.agentId);
const [wanted, setWanted] = useState(false);
- useEffect(() => { setWanted(false); }, [agent.agentId]);
+ // All agents share one browser profile by default, and it opens in one place.
+ const [movedTo, setMovedTo] = useState("");
+ useEffect(() => { setWanted(false); setMovedTo(""); }, [agent.agentId]);
useEffect(() => { if (running.data?.open) setWanted(true); }, [running.data?.open]);
const profileUnavailable = running.data?.mode === "unavailable";
const live = !profileUnavailable && (wanted || running.data?.open === true);
@@ -38,6 +40,17 @@ export function AgentBrowserPreview({ agent }: { agent: SocietyAgent }) {
const managedRuntime = !isChrome && !profileUnavailable;
const chromeDisconnected = isChrome && !running.data?.connected;
const { canvas, state, control, approve } = useBrowserView(agent.agentId, live);
+ useEffect(() => {
+ if (!state.movedTo) return;
+ setMovedTo(state.movedTo);
+ setWanted(false);
+ }, [state.movedTo]);
+ const open = () => { setMovedTo(""); setWanted(true); };
+ const stopHolder = () => {
+ if (!state.busy?.holderId) return;
+ void fetch("/api/society/agents/" + encodeURIComponent(state.busy.holderId) + "/browser/cancel",
+ { method: "POST", headers: { "X-Jarvis-Stop-Chat": "1" } });
+ };
const rejectedGoogle = managedRuntime && live && googleSignInRejected(state.url);
const install = useBrowserInstallStatus();
const [expanded, setExpanded] = useState(false);
@@ -65,8 +78,12 @@ export function AgentBrowserPreview({ agent }: { agent: SocietyAgent }) {
? t(state.loginReady ? "society.browser_profiles.inline_login_active" : "society.browser_profiles.inline_login_not_ready")
: state.previewPaused
? t("society.browser_profiles.sign_in_chrome")
+ : !live && movedTo
+ ? t("society.browser_live.moved_status").replace("{0}", movedTo)
: !live
? t("society.browser_live.off")
+ : state.busy
+ ? t("society.browser_live.waiting_for").replace("{0}", state.busy.holderName)
: state.connected && state.ready
? t(state.manual ? "society.browser_live.manual" : "society.browser_live.live")
: t(managedRuntime && install.data && !install.data.installed ? "society.card.browser_setting_up" : "society.card.browser_connecting");
@@ -165,14 +182,23 @@ export function AgentBrowserPreview({ agent }: { agent: SocietyAgent }) {
<AgentCursor pointer={state.ready && state.connected && !state.manual ? state.pointer : undefined} />
)}
{!live && <div className="absolute inset-0 flex flex-col items-center justify-center gap-2 bg-muted p-3 text-center text-xs text-muted-foreground">
- <p>{profileUnavailable ? t("society.browser_profiles.profile_unavailable") : chromeDisconnected ? t("society.browser_profiles.disconnected") : t("society.browser_live.off_hint").replace("{0}", displayName)}</p>
+ <p>{profileUnavailable ? t("society.browser_profiles.profile_unavailable") : chromeDisconnected ? t("society.browser_profiles.disconnected")
+ : movedTo ? t("society.browser_live.moved").replace("{0}", movedTo) : t("society.browser_live.off_hint").replace("{0}", displayName)}</p>
{!profileUnavailable && <button type="button" data-testid="agent-browser-open"
className="rounded-md border border-border bg-background px-3 py-1 text-xs font-medium text-foreground hover:bg-secondary"
- disabled={chromeDisconnected} onClick={() => setWanted(true)}>
- {t("society.browser_live.open")}
+ disabled={chromeDisconnected} onClick={open}>
+ {t(movedTo ? "society.browser_live.open_here" : "society.browser_live.open")}
+ </button>}
+ </div>}
+ {live && !state.ready && !state.previewPaused && state.busy && <div role="status" className="absolute inset-0 flex flex-col items-center justify-center gap-2 bg-muted p-3 text-center text-xs text-muted-foreground">
+ <p>{t("society.browser_live.busy_task").replace(/\{0\}/g, state.busy.holderName)}</p>
+ {state.busy.running && state.busy.holderId && <button type="button"
+ className="rounded-md border border-border bg-background px-3 py-1 text-xs font-medium text-foreground hover:bg-secondary"
+ onClick={stopHolder}>
+ {t("society.browser_live.stop_holder").replace("{0}", state.busy.holderName)}
</button>}
</div>}
- {live && !state.ready && !state.previewPaused && <div className="absolute inset-0 grid place-items-center bg-muted p-3 text-center text-xs text-muted-foreground">
+ {live && !state.ready && !state.previewPaused && !state.busy && <div className="absolute inset-0 grid place-items-center bg-muted p-3 text-center text-xs text-muted-foreground">
{chromeDisconnected ? t("society.browser_profiles.disconnected") : (managedRuntime && install.data?.detail) || status}
{managedRuntime && install.data?.running && <span>{install.data.percent}%</span>}
</div>}
@@ -232,7 +258,8 @@ export function AgentBrowserPreview({ agent }: { agent: SocietyAgent }) {
</div>}
{(state.error || (managedRuntime && install.data?.error)) && <div className="mt-2 text-xs text-destructive" role="status">
{profileUnavailable ? t("society.browser_profiles.profile_unavailable") : chromeDisconnected ? t("society.browser_profiles.disconnected") : state.error || install.data?.error}
- {managedRuntime && <button className={buttonClass} onClick={() => void fetch("/api/society/browser/repair", { method: "POST" })}>{t("society.browser_live.repair")}</button>}
+ {/* Repair reinstalls the browser runtime; it cannot fix a session or profile error. */}
+ {managedRuntime && install.data?.error && <button className={buttonClass} onClick={() => void fetch("/api/society/browser/repair", { method: "POST" })}>{t("society.browser_live.repair")}</button>}
</div>}
</div>
);
diff --git a/jarvis/ui/web/frontend/src/components/society/card/useBrowserView.ts b/jarvis/ui/web/frontend/src/components/society/card/useBrowserView.ts
index 7c2bb679a8..3ab2b54197 100644
--- a/jarvis/ui/web/frontend/src/components/society/card/useBrowserView.ts
+++ b/jarvis/ui/web/frontend/src/components/society/card/useBrowserView.ts
@@ -23,6 +23,10 @@ export interface BrowserViewState {
pointer?: BrowserPointerState;
approval?: { id: string; action: string };
dialog?: { type: string; message: string };
+ /** Another agent holds this shared browser profile; the view retries until it is free. */
+ busy?: { holderId: string; holderName: string; running: boolean };
+ /** The shared profile was opened for another agent; this view stops reconnecting. */
+ movedTo?: string;
}
const empty: BrowserViewState = {
connected: false, ready: false, fullWindow: false, extendedInput: false, previewPaused: false, loginAvailable: false, loginMode: false, loginReady: false, manual: false, running: false, controlPending: false,
@@ -68,6 +72,7 @@ export function useBrowserView(agentId: string, enabled = true) {
let decodeBusy = false;
let lastLiveEvent = Date.now();
let renderedFrames = 0;
+ let moved = false;
let latestFrame: { data: string; sequence: number; timestamp: number; generation: string; geometry_id?: string; extended_input?: boolean } | null = null;
manual.current = false;
previewPaused.current = false;
@@ -141,6 +146,7 @@ export function useBrowserView(agentId: string, enabled = true) {
try {
const event = JSON.parse(message.data);
if (event.kind === "frame") {
+ setState((s) => s.busy ? { ...s, busy: undefined } : s);
if (previewPaused.current || (loginMode.current && !loginReady.current)) return;
if (typeof event.data !== "string" || typeof event.sequence !== "number") return;
if (!Number.isFinite(event.timestamp)) return;
@@ -172,10 +178,20 @@ export function useBrowserView(agentId: string, enabled = true) {
&& event.width > 0 && event.height > 0) {
setState((s) => ({ ...s, pointer: event }));
}
+ } else if (event.kind === "error" && event.code === "profile_busy") {
+ lastLiveEvent = Date.now();
+ setState((s) => ({ ...s, ready: false, error: "", busy: {
+ holderId: String(event.holder_id ?? ""), holderName: String(event.holder_name ?? ""),
+ running: event.running === true } }));
+ } else if (event.kind === "disconnected" && event.reason === "moved") {
+ // Reconnecting would take the profile straight back from the other agent.
+ moved = true;
+ setState((s) => ({ ...s, movedTo: String(event.agent_name || event.agent_id || "") }));
} else if (event.kind === "error") {
setState((s) => ({ ...s, ready: false, error: event.error }));
} else if (event.kind === "state") {
lastLiveEvent = Date.now();
+ setState((s) => s.busy ? { ...s, busy: undefined } : s);
loginCapability.current = event.login_available === true;
loginMode.current = event.login_mode === true;
loginReady.current = event.login_ready === true;
@@ -267,6 +283,7 @@ export function useBrowserView(agentId: string, enabled = true) {
loginReady.current = false;
inputs.current = [];
setState((s) => ({ ...s, connected: false, ready: false, manual: false, extendedInput: false, loginAvailable: false, loginReady: false, controlPending: false, pointer: undefined }));
+ if (moved) return;
cancelConnect = requestConnect(() => void connect(), jitteredDelay(attempt++));
};
ws.onerror = () => ws.close();
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/de.json b/jarvis/ui/web/frontend/src/i18n/locales/society/de.json
index 8c509bca9d..e490b616b4 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/society/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/de.json
@@ -675,6 +675,12 @@
"repair": "Browser reparieren",
"off": "Browser aus",
"off_hint": "Der Browser startet erst, wenn {0} ihn braucht.",
+ "moved": "Der gemeinsame Browser ist jetzt für {0} geöffnet. Er kann immer nur für einen Agent offen sein.",
+ "moved_status": "Für {0} geöffnet",
+ "open_here": "Hier öffnen",
+ "waiting_for": "Wartet auf {0}",
+ "busy_task": "{0} nutzt den gemeinsamen Browser gerade für eine Aufgabe. Er öffnet sich hier, sobald {0} fertig ist.",
+ "stop_holder": "Aufgabe von {0} stoppen",
"open": "Browser öffnen"
},
"mars": {
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/en.json b/jarvis/ui/web/frontend/src/i18n/locales/society/en.json
index 17d4f35b52..78b2721588 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/society/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/en.json
@@ -675,6 +675,12 @@
"repair": "Repair browser",
"off": "Browser off",
"off_hint": "The browser starts only when {0} needs it.",
+ "moved": "The shared browser is open for {0} now. It can only be open for one agent at a time.",
+ "moved_status": "Open for {0}",
+ "open_here": "Open here",
+ "waiting_for": "Waiting for {0}",
+ "busy_task": "{0} is using the shared browser for a task. It opens here as soon as {0} is done.",
+ "stop_holder": "Stop {0}'s task",
"open": "Open browser"
},
"mars": {
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/es.json b/jarvis/ui/web/frontend/src/i18n/locales/society/es.json
index 4367ec73f3..506065684b 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/society/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/es.json
@@ -675,6 +675,12 @@
"repair": "Reparar navegador",
"off": "Navegador apagado",
"off_hint": "El navegador solo se inicia cuando {0} lo necesita.",
+ "moved": "El navegador compartido está abierto ahora para {0}. Solo puede estar abierto para un agente a la vez.",
+ "moved_status": "Abierto para {0}",
+ "open_here": "Abrir aquí",
+ "waiting_for": "Esperando a {0}",
+ "busy_task": "{0} está usando el navegador compartido para una tarea. Se abrirá aquí en cuanto {0} termine.",
+ "stop_holder": "Detener la tarea de {0}",
"open": "Abrir navegador"
},
"mars": {
diff --git a/jarvis/ui/web/society_browser_routes.py b/jarvis/ui/web/society_browser_routes.py
index d4823224ec..b8436d22ea 100644
--- a/jarvis/ui/web/society_browser_routes.py
+++ b/jarvis/ui/web/society_browser_routes.py
@@ -312,14 +312,23 @@ async def agent_browser_live(websocket: WebSocket, agent_id: str) -> None:
log.debug("Browser view disconnected for %s", agent_id, exc_info=True)
with contextlib.suppress(Exception):
if session is None:
- await send(
- {
- "kind": "error",
- "error": str(exc)[:300]
- if isinstance(exc, (RuntimeError, ValueError))
- else "Browser startup failed. Retry or repair the installation.",
- }
- )
+ payload = {
+ "kind": "error",
+ "error": str(exc)[:300]
+ if isinstance(exc, (RuntimeError, ValueError))
+ else "Browser startup failed. Retry or repair the installation.",
+ }
+ from jarvis.society.browser.live import BrowserProfileBusy
+
+ if isinstance(exc, BrowserProfileBusy):
+ # The panel names who holds the shared browser and waits.
+ payload.update(
+ code="profile_busy",
+ holder_id=exc.holder_id,
+ holder_name=exc.holder_name[:120],
+ running=exc.running,
+ )
+ await send(payload)
await websocket.close(code=1011)
finally:
for task in (receive, pending):
diff --git a/tests/contract/test_browser_contract.py b/tests/contract/test_browser_contract.py
index 14e8744e37..8b47b2b29b 100644
--- a/tests/contract/test_browser_contract.py
+++ b/tests/contract/test_browser_contract.py
@@ -652,6 +652,45 @@ async def test_viewer_disconnect_cancels_pending_takeover(monkeypatch, burst):
assert released.is_set()
+async def test_busy_shared_profile_names_its_holder_to_the_viewer(monkeypatch):
+ from jarvis.society.browser.live import BrowserProfileBusy
+ from jarvis.ui.web import society_browser_routes as routes
+
+ sent: list[dict] = []
+
+ class Live:
+ async def subscribe(self, agent):
+ raise BrowserProfileBusy("juno", "Juno", running=True)
+
+ class Socket:
+ scope = {}
+
+ async def accept(self):
+ pass # Test socket has no transport to accept.
+
+ async def close(self, **kwargs):
+ pass # Test socket has no transport to close.
+
+ async def send_json(self, value):
+ sent.append(value)
+
+ async def resolve(_):
+ return SimpleNamespace(agent_id="wren")
+
+ async def runtime(_):
+ return SimpleNamespace(
+ roster=SimpleNamespace(resolve=resolve), browser=SimpleNamespace(live=Live())
+ )
+
+ monkeypatch.setattr(routes, "_runtime", runtime)
+ monkeypatch.setattr(routes, "credentials_valid", lambda _: True)
+ await routes.agent_browser_live(Socket(), "wren")
+ error = next(m for m in sent if m["kind"] == "error")
+ assert error["code"] == "profile_busy"
+ assert (error["holder_id"], error["holder_name"], error["running"]) == ("juno", "Juno", True)
+ assert "Juno is running a task" in error["error"]
+
+
async def test_hover_motion_coalesces_and_never_delays_or_drops_clicks(monkeypatch):
import asyncio
diff --git a/tests/unit/society/test_browser_profile_live.py b/tests/unit/society/test_browser_profile_live.py
index ba8c3946a4..c36c43f2f0 100644
--- a/tests/unit/society/test_browser_profile_live.py
+++ b/tests/unit/society/test_browser_profile_live.py
@@ -149,6 +149,51 @@ async def test_another_agent_cannot_reclaim_manual_profile_after_viewer_loss(tmp
await live.close()
+async def test_opening_another_agent_moves_a_left_open_sign_in_there(tmp_path, monkeypatch):
+ live = manager(tmp_path, monkeypatch)
+ pid = live.profiles.create("Shared", "managed", [])["id"]
+ live.profiles.share(pid, "all", [], {"lead", "scout"})
+ lead = await live.ensure(SimpleNamespace(**vars(agent("lead")), name="Juno"))
+ lead.state.update(manual=True, login_mode=True)
+ lead.control_owner = "person"
+ lead.subscribers.add(LiveUpdates())
+ wren = SimpleNamespace(**vars(agent("scout")), name="Wren")
+ scout = await live.ensure(wren, window_view=True)
+ assert lead.closed and not scout.closed and "lead" not in live.sessions
+ assert ("event", {"kind": "disconnected", "reason": "moved", "agent_id": "scout",
+ "agent_name": "Wren"}) in lead.commands
+ await live.close()
+
+
+async def test_watching_one_agent_never_blocks_another_agents_task(tmp_path, monkeypatch):
+ live = manager(tmp_path, monkeypatch)
+ pid = live.profiles.create("Shared", "managed", [])["id"]
+ live.profiles.share(pid, "all", [], {"lead", "scout"})
+ lead = await live.ensure(agent("lead"))
+ lead.subscribers.add(LiveUpdates())
+ scout = await live.ensure(agent("scout"))
+ assert lead.closed and not scout.closed
+ await live.close()
+
+
+async def test_a_running_task_keeps_the_profile_and_names_its_agent(tmp_path, monkeypatch):
+ from jarvis.society.browser.live import BrowserProfileBusy
+
+ live = manager(tmp_path, monkeypatch)
+ pid = live.profiles.create("Shared", "managed", [])["id"]
+ live.profiles.share(pid, "all", [], {"lead", "scout"})
+ lead = await live.ensure(SimpleNamespace(**vars(agent("lead")), name="Juno"))
+ await lead.run_lock.acquire()
+ try:
+ with pytest.raises(BrowserProfileBusy, match="Juno is running a task") as busy:
+ await live.ensure(agent("scout"), window_view=True)
+ assert (busy.value.holder_id, busy.value.running) == ("lead", True)
+ assert not lead.closed
+ finally:
+ lead.run_lock.release()
+ await live.close()
+
+
async def test_lost_viewer_keeps_chrome_login_paused_until_explicit_reclaim(tmp_path):
live = LiveSessions(tmp_path)
session = ProfileSession("lead")