diff --git a/.claude/skills/debug-standalone-agent-browser/SKILL.md b/.claude/skills/debug-standalone-agent-browser/SKILL.md index c03e02f6b..b29e30eb6 100644 --- a/.claude/skills/debug-standalone-agent-browser/SKILL.md +++ b/.claude/skills/debug-standalone-agent-browser/SKILL.md @@ -103,7 +103,7 @@ agent-browser --session eval '(()=>{var ta=document.querySelecto The screencast canvas forwards real pointer events to the nested page, and the nested page viewport is **1:1 with the canvas intrinsic size**, so mapping is just an offset: 1. Get the outer canvas box: `agent-browser --session eval '(()=>{var c=document.querySelector("canvas");var r=c.getBoundingClientRect();return JSON.stringify({x:r.x,y:r.y,iw:c.width,ih:c.height})})()'` -2. Find the link's center in the **nested** session DOM (the real page): `agent-browser --session dormouse.1.default eval '(()=>{var a=[...document.querySelectorAll("a")].find(x=>/github\.com/i.test(x.href));var r=a.getBoundingClientRect();return JSON.stringify({cx:r.x+r.width/2,cy:r.y+r.height/2})})()'` +2. Find the link's center in the **nested** session DOM (the real page): `agent-browser --session dormouse_1_default eval '(()=>{var a=[...document.querySelectorAll("a")].find(x=>/github\.com/i.test(x.href));var r=a.getBoundingClientRect();return JSON.stringify({cx:r.x+r.width/2,cy:r.y+r.height/2})})()'` 3. Outer click point = `canvas.x + nested.cx`, `canvas.y + nested.cy`. Click with move → down → up, and **dwell ~0.1–0.2s between down and up** — a too-fast click on an *idle* (quiet) daemon does not register: ```sh @@ -111,7 +111,7 @@ agent-browser --session mouse move agent-browser --session mouse down ; sleep 0.12 ; agent-browser --session mouse up ``` -Confirm the click landed against the **real** daemon, not just the panel: `agent-browser --session dormouse.1.default tab list`. +Confirm the click landed against the **real** daemon, not just the panel: `agent-browser --session dormouse_1_default tab list`. ## Timing Pattern diff --git a/docs/specs/dor-browser.md b/docs/specs/dor-browser.md index d23489189..6babd8ce4 100644 --- a/docs/specs/dor-browser.md +++ b/docs/specs/dor-browser.md @@ -148,11 +148,11 @@ Source of truth: `browserLaunchEnv` in `lib/src/host/browser-launch-env.ts`, `cr ### Managed identity -- **Must match `--key ` against `[A-Za-z0-9._-]+`**, since it becomes part of a session name and so a filesystem path; the default is `--key default`. Identity-flag exclusivity: `docs/specs/dor-cli.md` → "Browser Surface Addressing". +- **Must match `--key ` against `[A-Za-z0-9_-]+`**, since it becomes part of a session name, which agent-browser holds to those characters (rationale); the default is `--key default`. Identity-flag exclusivity: `docs/specs/dor-cli.md` → "Browser Surface Addressing". - **Must resolve a key to the Surface of that provider holding it in the answering Wall**, whose stored binding — session, cwd, executable — the command runs with, so a Surface keeps its session however keys were named when it was made. -- **Must mint a key no Surface holds as `dormouse..`**, scoped by the id of the Workspace that will hold the browser, so a strip reorder renames nothing; **Must scrub every character outside `[A-Za-z0-9._-]` from scope and key**, the id's `:` included, since the name becomes a filesystem path (`workspace:3` → `dormouse.workspace-3.`). **Must give a bare Wall (a VS Code webview, Pocket), which has no Workspace id, a scope of its own for its life**, so two webviews' `--key default` are two browsers (rationale). A key's concurrent first commands share one reservation of the caller's cwd and executable (`BrowserBindingReservations`). **Never mint a session a Surface anywhere in the Window holds, or the provider's reservation of another key**: take the first free `.2`, `.3`, … suffix (rationale). -- **Must let only the answering Workspace name a key**, so `dor` resolves it host-side (`docs/specs/dor-cli.md` → "Browser Surface Addressing") and names `dormouse.1.` itself only with no control endpoint at all, outside Dormouse, where `dor` is a pure passthrough. **Never fall back CLI-side when the host refuses a managed invocation**, a passthrough verb included: that would name the wrong Workspace's browser, so the refusal fails the command before the binary runs (`docs/specs/dor-cli.md` → "Handle Model"). -- **Must name GUI-spawned sessions `dormouse.1.gui-`, minted host-wide**, which no `--key` names; `--surface ` reaches them. **Must answer only for a Surface its provider renders**: an `iframe` Surface has no session to drive. +- **Must mint a key no Surface holds as `dormouse__`**, scoped by the id of the Workspace that will hold the browser, so a strip reorder renames nothing; **Must scrub every character outside `[A-Za-z0-9_-]` from scope and key**, the id's `:` included (`workspace:3` → `dormouse_workspace-3_`). **Must give a bare Wall (a VS Code webview, Pocket), which has no Workspace id, a scope of its own for its life**, so two webviews' `--key default` are two browsers (rationale). A key's concurrent first commands share one reservation of the caller's cwd and executable (`BrowserBindingReservations`). **Never mint a session a Surface anywhere in the Window holds, or the provider's reservation of another key**: take the first free `_2`, `_3`, … suffix (rationale). +- **Must let only the answering Workspace name a key**, so `dor` resolves it host-side (`docs/specs/dor-cli.md` → "Browser Surface Addressing") and names `dormouse_1_` itself only with no control endpoint at all, outside Dormouse, where `dor` is a pure passthrough. **Never fall back CLI-side when the host refuses a managed invocation**, a passthrough verb included: that would name the wrong Workspace's browser, so the refusal fails the command before the binary runs (`docs/specs/dor-cli.md` → "Handle Model"). +- **Must name GUI-spawned sessions `dormouse_1_gui-`, minted host-wide**, which no `--key` names; `--surface ` reaches them. **Must answer only for a Surface its provider renders**: an `iframe` Surface has no session to drive. - **Must map one browser to one Surface window-wide**, found by its host-reported native identity (agent-browser: the session; Playwright: installation, project scope and session, which a raw `--session` shares across one project's subdirectories). A command for a browser that has a Surface hands its stream over, refreshes `binaryPath` and reuses the pane — not an invariant: a Surface killed or render-swapped mid-command lets the trailing request mint a fresh pane; a killed `--surface` fails it (rationale). Source of truth: `sessionForKey` in `dor-lib-common/src/browser-providers.ts`, `runBrowserCli` in `dor/src/commands/browser-cli.ts`, `BrowserBindingReservations` in `lib/src/components/wall/browser-binding-reservations.ts`, `ensureBrowserSurface` in `lib/src/components/wall/use-dor-control.ts`. diff --git a/docs/specs/dor-browser.rationale.md b/docs/specs/dor-browser.rationale.md index fc9af3a79..88f8745ef 100644 --- a/docs/specs/dor-browser.rationale.md +++ b/docs/specs/dor-browser.rationale.md @@ -44,9 +44,11 @@ Viewport preparation with agent-browser 0.27.0 (Windows, 2026-10-21): dropping ` **Why one-session-one-surface is not an invariant.** `dor` forwards the user's command before it asks the host for a surface, so a surface killed or render-swapped inside that window is gone by the time the trailing request arrives — and the session behind it is still live and needs somewhere to render. -**Why a bare Wall mints its own key scope.** Every VS Code webview is a bare Wall, and each named `--key default` `dormouse.1.default`: two webviews' default browsers were one browser behind two Surfaces, and killing either closed it under the other. Playwright had avoided it with random session names and a reservation; one deterministic scheme with a scope unique per bare Wall covers both, and needs no migration because a key finds its Surface's stored session first (review of the browser stack, 2026-09). +**Why session names use `_`, not `.`.** Session names were `dormouse..` until agent-browser 0.41.1 (2026-11-01) began refusing any `--session` outside letters, digits, `-` and `_` before starting a browser (upstream `validate session names before use`, #2272): every pane then failed to open and fell back to an iframe. Every earlier release accepts `_`. -**Why a key numbers past sessions held elsewhere.** A key's session is `dormouse..`, and the key lookup searches only the answering Wall. A pane bound to that session which left for another Workspace keeps it, so the same command here bound a second pane to the same browser, and closing either closed the other's (review of #777, 2026-09). Playwright keys had minted a fresh UUID each, so this was new there; agent-browser keys always worked this way. +**Why a bare Wall mints its own key scope.** Every VS Code webview is a bare Wall, and each named `--key default` `dormouse_1_default`: two webviews' default browsers were one browser behind two Surfaces, and killing either closed it under the other. Playwright had avoided it with random session names and a reservation; one deterministic scheme with a scope unique per bare Wall covers both, and needs no migration because a key finds its Surface's stored session first (review of the browser stack, 2026-09). + +**Why a key numbers past sessions held elsewhere.** A key's session is `dormouse__`, and the key lookup searches only the answering Wall. A pane bound to that session which left for another Workspace keeps it, so the same command here bound a second pane to the same browser, and closing either closed the other's (review of #777, 2026-09). Playwright keys had minted a fresh UUID each, so this was new there; agent-browser keys always worked this way. **Why a bind for a session another Workspace shows is answered there (2026-11).** A raw `--session` names no key, so nothing above steered it, and the bind looked only in the caller's Wall: a session whose pane sat in another Workspace got a second pane in the caller's, and closing either closed the other's. The bind now hands the request to the Wall that shows the session, by the same Window-wide session list a key's reservation reads. diff --git a/docs/specs/glossary.md b/docs/specs/glossary.md index a14601d6e..9958944f2 100644 --- a/docs/specs/glossary.md +++ b/docs/specs/glossary.md @@ -258,7 +258,7 @@ Use glossary names instead. A left-column term retains meaning only where noted. | **reconnect** | Retired: live-PTY case → **resume**; cold start → **restore**. | | **restore** | Keeps its cold-start rehydrate meaning. Never for Door→Pane (**reattach**), a closed Surface's rebuild (**reopen**), or alert-manager seeding (**seed**). | | **attach** | Retired at the DOM layer (`attachTerminal`) → **mount**; user-level **reattach** (Door→Pane) keeps the `re-` prefix. | -| **session** | The durable identity of a **terminal Surface**. Never for the Activity projection (`ActivityState`, not `SessionUiState`), nor for a browser provider's lowercase `session` string (`dormouse..`) — not a Dormouse durable unit. | +| **session** | The durable identity of a **terminal Surface**. Never for the Activity projection (`ActivityState`, not `SessionUiState`), nor for a browser provider's lowercase `session` string (`dormouse__`) — not a Dormouse durable unit. | | **terminal** | Keeps its meaning for the `xterm.Terminal` instance; prose meaning "the whole thing" is **Session**. | | **surface** | Not retired. **Session** names only the terminal kind; **Surface** covers both. | | **panel / pane / leaf** | Prefer **pane** for the layout slot; **leaf** is Lath's tree node for it (1:1). "panel" survives only in React component names (`TerminalPanel`, `BrowserPanel`, `IframePanel`, `AgentBrowserPanel`). | diff --git a/dor-lib-common/src/browser-providers.ts b/dor-lib-common/src/browser-providers.ts index 252f10c0b..5efbd1ece 100644 --- a/dor-lib-common/src/browser-providers.ts +++ b/dor-lib-common/src/browser-providers.ts @@ -24,7 +24,7 @@ const BARE_WALL_SCOPE = '1'; // A session name becomes a filesystem path (the daemon's socket dir), so both // halves are held to the charset `dor agent-browser --key` enforces CLI-side: the key // arrives over the control socket too, from clients that are not `dor`. -const UNSAFE_SESSION_CHARS = /[^A-Za-z0-9._-]/g; +const UNSAFE_SESSION_CHARS = /[^A-Za-z0-9_-]/g; /** Env var that overrides which agent-browser binary to run; shared so `dor agent-browser` * and the host key off the same name. */ @@ -278,19 +278,19 @@ export function isBrowserProvider(value: unknown): value is BrowserAutomationPro } /** - * Managed, scoped browser session name, `dormouse..`, for either + * Managed, scoped browser session name, `dormouse__`, for either * provider: the host passes the Workspace's id, or the scope a bare Wall mints - * for itself; `dormouse.1.` is what a caller with no host — `dor` outside + * for itself; `dormouse_1_` is what a caller with no host — `dor` outside * Dormouse — names. The scope is what keeps one `--key default` per Workspace * from being one shared browser (`docs/specs/dor-browser.md` → Managed * identity). * - * agent-browser session names become filesystem paths (the socket dir), so `/` - * can't separate the namespace — the daemon fails to start; dots keep it - * readable. Shared by `dor` (--key outside Dormouse) and the lib host (key + * agent-browser takes only letters, digits, `-` and `_` in a session name + * (from 0.41.1; it rejects a dot before starting anything), so `_` separates + * the namespace. Shared by `dor` (--key outside Dormouse) and the lib host (key * and GUI sessions). */ export function sessionForKey(key: string, workspaceId?: string): string { const scope = workspaceId ? workspaceId.replace(UNSAFE_SESSION_CHARS, '-') : BARE_WALL_SCOPE; - return `dormouse.${scope}.${key.replace(UNSAFE_SESSION_CHARS, '-')}`; + return `dormouse_${scope}_${key.replace(UNSAFE_SESSION_CHARS, '-')}`; } diff --git a/dor-lib-common/test/browser-providers.test.mjs b/dor-lib-common/test/browser-providers.test.mjs index cf31e279d..5c43d048f 100644 --- a/dor-lib-common/test/browser-providers.test.mjs +++ b/dor-lib-common/test/browser-providers.test.mjs @@ -3,19 +3,19 @@ import assert from 'node:assert/strict'; import { BROWSER_PROVIDER_IDS, BROWSER_PROVIDERS, isAllowedAgentBrowserBinary, isAllowedPlaywrightBinary, parseRenderMode, parseStreamPort, renderModeFor, sessionForKey } from '../dist/browser-providers.js'; test('sessionForKey namespaces a key under the workspace', () => { - assert.equal(sessionForKey('default'), 'dormouse.1.default'); - assert.equal(sessionForKey('gui-abc'), 'dormouse.1.gui-abc'); + assert.equal(sessionForKey('default'), 'dormouse_1_default'); + assert.equal(sessionForKey('gui-abc'), 'dormouse_1_gui-abc'); // A Workspace id's colon is scrubbed: Windows forbids it in the socket path. - assert.equal(sessionForKey('default', 'workspace:3'), 'dormouse.workspace-3.default'); - assert.equal(sessionForKey('tool.surface:7'), 'dormouse.1.tool.surface-7'); + assert.equal(sessionForKey('default', 'workspace:3'), 'dormouse_workspace-3_default'); + assert.equal(sessionForKey('tool.surface:7'), 'dormouse_1_tool-surface-7'); }); test('sessionForKey scrubs the key like the scope: a session name is a socket path', () => { // The key crosses the control socket from any client, not only `dor` (which // rejects this shape itself), so it cannot be allowed to escape the socket dir. - assert.equal(sessionForKey('../../../tmp/x', 'ws/1'), 'dormouse.ws-1...-..-..-tmp-x'); + assert.equal(sessionForKey('../../../tmp/x', 'ws/1'), 'dormouse_ws-1_---------tmp-x'); // A valid key is unchanged. - assert.equal(sessionForKey('a.b_c-D9', 'ws'), 'dormouse.ws.a.b_c-D9'); + assert.equal(sessionForKey('a.b_c-D9', 'ws'), 'dormouse_ws_a-b_c-D9'); }); test('parseRenderMode decodes every automated mode and renderModeFor inverts it', () => { @@ -38,7 +38,7 @@ test('parseRenderMode reads anything else as the embed, inherited names included test('each provider refuses a session name its CLI would read as an option or a path', () => { for (const provider of BROWSER_PROVIDER_IDS) { const { isSessionName } = BROWSER_PROVIDERS[provider]; - assert.equal(isSessionName('dormouse.1.default'), true, provider); + assert.equal(isSessionName('dormouse_1_default'), true, provider); for (const bad of ['../../tmp/evil', 'a/b', 'a\\b', 'a\nb', 'a\u0085b', '', 7]) { assert.equal(isSessionName(bad), false, `${provider} ${JSON.stringify(bad)}`); } diff --git a/dor/src/commands/agent-browser.ts b/dor/src/commands/agent-browser.ts index 82b25da67..fe7b28af7 100644 --- a/dor/src/commands/agent-browser.ts +++ b/dor/src/commands/agent-browser.ts @@ -57,7 +57,7 @@ export const agentBrowserCommand: Command = { dor intercepts exactly three mutually exclusive identity flags: --key Managed, workspace-scoped browser identity (default "default"). - Maps to agent-browser session dormouse.., + Maps to agent-browser session dormouse__, so the same key in another Workspace is another browser. --session Attach to a raw agent-browser session by its literal name. --surface Drive the browser Surface a handle names (surface:N, diff --git a/dor/src/commands/browser-cli.ts b/dor/src/commands/browser-cli.ts index 64c6c0393..bbca6748a 100644 --- a/dor/src/commands/browser-cli.ts +++ b/dor/src/commands/browser-cli.ts @@ -31,7 +31,7 @@ import { BROWSER_UNBOUND_EXIT, callerWorkingDirectory, errorMessage, fail, requi import { inferredHttpUrl, isSpecialOpenTarget, isSurfaceOpenTarget, resolveSurfaceOpenTarget } from './open-target.js'; import { callerWslDistro, linuxPathText, windowsPathArgs, type PathArgs } from './wsl-paths.js'; -const KEY_PATTERN = /^[A-Za-z0-9._-]+$/; +const KEY_PATTERN = /^[A-Za-z0-9_-]+$/; /** The three identity flags dor intercepts, in the order they are reported when * more than one is given. */ diff --git a/dor/test/browser-stdin.test.mjs b/dor/test/browser-stdin.test.mjs index 17188a360..00ca7f1ea 100644 --- a/dor/test/browser-stdin.test.mjs +++ b/dor/test/browser-stdin.test.mjs @@ -31,7 +31,7 @@ for (const provider of ['agent-browser', 'playwright']) { const result = await runCli([provider, 'open', 'http://localhost:5173'], { env: { PWD: process.cwd() }, client: { - resolveBrowser: async () => ({ binding: { session: 'dormouse.1.default', cwd: process.cwd() }, fresh: true, + resolveBrowser: async () => ({ binding: { session: 'dormouse_1_default', cwd: process.cwd() }, fresh: true, initialViewport: { mode: 'fixed', width: 390, height: 844, dpr: 2 }, launchViewport: { width: 390, height: 844, dpr: 2 } }), browserSurface: async () => ({ surfaceId: 'surface:2', status: 'created' }), diff --git a/dor/test/browser-viewport.test.mjs b/dor/test/browser-viewport.test.mjs index 3144383fe..0af92219b 100644 --- a/dor/test/browser-viewport.test.mjs +++ b/dor/test/browser-viewport.test.mjs @@ -71,7 +71,7 @@ test('new agent-browser managed launch prepares blank page before destination', env: { PWD: process.cwd() }, client: { resolveBrowser: async () => ({ - binding: { session: 'dormouse.1.default' }, fresh: true, + binding: { session: 'dormouse_1_default' }, fresh: true, initialViewport: { mode: 'fixed', width: 1440, height: 900 }, launchViewport: { width: 1440, height: 900 }, }), @@ -94,7 +94,7 @@ test('a launch measures the pixel ratio with content boundaries off', async () = const result = await runCli(['agent-browser', 'open', 'http://localhost:5173'], { env: { PWD: process.cwd(), AGENT_BROWSER_CONTENT_BOUNDARIES: '1' }, client: { - resolveBrowser: async () => ({ binding: { session: 'dormouse.1.default' }, fresh: true, + resolveBrowser: async () => ({ binding: { session: 'dormouse_1_default' }, fresh: true, initialViewport: { mode: 'fixed', width: 1440, height: 900 }, launchViewport: { width: 1440, height: 900 } }), browserSurface: async () => ({}), }, @@ -115,7 +115,7 @@ test('agent-browser preparation preserves valued flags and only replaces the des const options = { env: { PWD: process.cwd() }, client: { - resolveBrowser: async () => ({ binding: { session: 'dormouse.1.default' }, fresh: true, + resolveBrowser: async () => ({ binding: { session: 'dormouse_1_default' }, fresh: true, initialViewport: { mode: 'fixed', width: 1440, height: 900 }, launchViewport: { width: 1440, height: 900 } }), browserSurface: async () => ({}), }, @@ -135,7 +135,7 @@ for (const flags of [ const result = await runCli(['agent-browser', 'open', 'http://localhost:5173', ...flags, '--quiet'], { env: { PWD: process.cwd() }, client: { - resolveBrowser: async () => ({ binding: { session: 'dormouse.1.default' }, fresh: true, + resolveBrowser: async () => ({ binding: { session: 'dormouse_1_default' }, fresh: true, initialViewport: { mode: 'fixed', width: 1440, height: 900 }, launchViewport: { width: 1440, height: 900 } }), browserSurface: async () => ({}), }, @@ -145,30 +145,30 @@ for (const flags of [ }, }); assert.equal(result.exitCode, 0, result.stderr); - assert.deepEqual(calls[1], ['--session', 'dormouse.1.default', ...flags, '--content-boundaries', 'false', 'eval', 'window.devicePixelRatio']); - assert.deepEqual(calls[2], ['--session', 'dormouse.1.default', ...flags, 'set', 'viewport', '1440', '900', '2']); - assert.deepEqual(calls[3], ['--session', 'dormouse.1.default', 'open', 'http://localhost:5173', ...flags, '--quiet']); - assert.deepEqual(calls[4], ['--session', 'dormouse.1.default', 'stream', 'status', '--json', ...flags]); + assert.deepEqual(calls[1], ['--session', 'dormouse_1_default', ...flags, '--content-boundaries', 'false', 'eval', 'window.devicePixelRatio']); + assert.deepEqual(calls[2], ['--session', 'dormouse_1_default', ...flags, 'set', 'viewport', '1440', '900', '2']); + assert.deepEqual(calls[3], ['--session', 'dormouse_1_default', 'open', 'http://localhost:5173', ...flags, '--quiet']); + assert.deepEqual(calls[4], ['--session', 'dormouse_1_default', 'stream', 'status', '--json', ...flags]); }); test('stream discovery preserves custom configuration after a non-navigation command', async () => { const calls = []; const result = await runCli(['agent-browser', '--config=/tmp/browser.json', 'eval', 'window.devicePixelRatio'], { client: { - resolveBrowser: async () => ({ binding: { session: 'dormouse.1.default' }, fresh: false }), + resolveBrowser: async () => ({ binding: { session: 'dormouse_1_default' }, fresh: false }), browserSurface: async () => ({}), }, execAgentBrowser: async (_binary, args) => { calls.push(args); return { exitCode: 0, stdout: '1', stderr: '' }; }, }); assert.equal(result.exitCode, 0, result.stderr); - assert.deepEqual(calls[1], ['--session', 'dormouse.1.default', 'stream', 'status', '--json', '--config=/tmp/browser.json']); + assert.deepEqual(calls[1], ['--session', 'dormouse_1_default', 'stream', 'status', '--json', '--config=/tmp/browser.json']); }); test('open-target sugar ignores a proxy flag value', async () => { const argsSeen = []; const options = { env: { PWD: process.cwd() }, - client: { resolveBrowser: async () => ({ binding: { session: 'dormouse.1.default' } }), browserSurface: async () => ({}) }, + client: { resolveBrowser: async () => ({ binding: { session: 'dormouse_1_default' } }), browserSurface: async () => ({}) }, execAgentBrowser: async (_binary, args) => { argsSeen.push(args); return { exitCode: 0, stdout: '', stderr: '' }; }, }; await runCli(['agent-browser', '--proxy', 'localhost:7890', 'open', ':5173'], options); @@ -180,7 +180,7 @@ test('fresh agent-browser goto and navigate prepare before destination scripts', const argsSeen = []; const options = { env: { PWD: process.cwd() }, - client: { resolveBrowser: async () => ({ binding: { session: 'dormouse.1.default' }, fresh: true, + client: { resolveBrowser: async () => ({ binding: { session: 'dormouse_1_default' }, fresh: true, initialViewport: { mode: 'fixed', width: 1440, height: 900 }, launchViewport: { width: 1440, height: 900 } }), browserSurface: async () => ({}) }, execAgentBrowser: async (_binary, args) => { argsSeen.push(args); return { exitCode: 0, stdout: args.includes('eval') ? '2\n' : '', stderr: '' }; }, @@ -200,7 +200,7 @@ for (const stateArgs of [['--state', '/tmp/saved state.json'], ['--state=/tmp/st const result = await runCli(['agent-browser', ...stateArgs, 'open', 'http://localhost:5173'], { env: { PWD: process.cwd() }, client: { - resolveBrowser: async () => ({ binding: { session: 'dormouse.1.default' }, fresh: true, + resolveBrowser: async () => ({ binding: { session: 'dormouse_1_default' }, fresh: true, initialViewport: { mode: 'fixed', width: 1440, height: 900 }, launchViewport: { width: 1440, height: 900 } }), browserSurface: async () => ({}), }, @@ -214,26 +214,26 @@ for (const stateArgs of [['--state', '/tmp/saved state.json'], ['--state=/tmp/st }, }); assert.equal(result.exitCode, 0, result.stderr); - assert.deepEqual(calls[0], ['--session', 'dormouse.1.default', ...stateArgs, 'open', 'about:blank']); + assert.deepEqual(calls[0], ['--session', 'dormouse_1_default', ...stateArgs, 'open', 'about:blank']); assert.deepEqual(destinationViewport, ['1440', '900', '1']); - assert.deepEqual(calls[3], ['--session', 'dormouse.1.default', 'open', 'http://localhost:5173']); + assert.deepEqual(calls[3], ['--session', 'dormouse_1_default', 'open', 'http://localhost:5173']); }); } test('reusing a browser keeps an explicit state request on the native command', async () => { const calls = []; await runCli(['agent-browser', 'open', 'http://localhost:5173', '--state', '/tmp/state.json'], { - client: { resolveBrowser: async () => ({ binding: { session: 'dormouse.1.default' }, fresh: false }), browserSurface: async () => ({}) }, + client: { resolveBrowser: async () => ({ binding: { session: 'dormouse_1_default' }, fresh: false }), browserSurface: async () => ({}) }, execAgentBrowser: async (_binary, args) => { calls.push(args); return { exitCode: 0, stdout: '', stderr: '' }; }, }); - assert.deepEqual(calls[0], ['--session', 'dormouse.1.default', 'open', 'http://localhost:5173', '--state', '/tmp/state.json']); + assert.deepEqual(calls[0], ['--session', 'dormouse_1_default', 'open', 'http://localhost:5173', '--state', '/tmp/state.json']); }); test('unknown agent-browser option fails before destination navigation', async () => { const argsSeen = []; const options = { env: { PWD: process.cwd() }, - client: { resolveBrowser: async () => ({ binding: { session: 'dormouse.1.default' }, fresh: true, + client: { resolveBrowser: async () => ({ binding: { session: 'dormouse_1_default' }, fresh: true, initialViewport: { mode: 'fixed', width: 1440, height: 900 }, launchViewport: { width: 1440, height: 900 } }) }, execAgentBrowser: async (_binary, args) => { argsSeen.push(args); return { exitCode: 0, stdout: args.includes('eval') ? '2\n' : '', stderr: '' }; }, }; @@ -248,7 +248,7 @@ test('native agent-browser device and headed launches bypass the default viewpor const surfaces = []; const options = { env: { PWD: process.cwd() }, - client: { resolveBrowser: async () => ({ binding: { session: 'dormouse.1.default' }, fresh: true, + client: { resolveBrowser: async () => ({ binding: { session: 'dormouse_1_default' }, fresh: true, initialViewport: { mode: 'fixed', width: 1440, height: 900 }, launchViewport: { width: 1440, height: 900 } }), browserSurface: async request => { surfaces.push(request); return {}; } }, execAgentBrowser: async (_binary, args) => { argsSeen.push(args); return { exitCode: 0, stdout: '', stderr: '' }; }, @@ -265,7 +265,7 @@ test('new playwright managed launch supplies viewport only to open process', asy env: { PWD: process.cwd() }, client: { resolveBrowser: async () => ({ - binding: { session: 'dormouse.1.default', cwd: process.cwd() }, fresh: true, + binding: { session: 'dormouse_1_default', cwd: process.cwd() }, fresh: true, initialViewport: { mode: 'fixed', width: 1440, height: 900 }, launchViewport: { width: 1440, height: 900 }, }), @@ -283,7 +283,7 @@ test('playwright open restores saved viewport when it restarts an existing brows const options = { env: { PWD: process.cwd() }, client: { - resolveBrowser: async () => ({ binding: { session: 'dormouse.1.default', cwd: process.cwd() }, fresh: false, + resolveBrowser: async () => ({ binding: { session: 'dormouse_1_default', cwd: process.cwd() }, fresh: false, initialViewport: { mode: 'fixed', width: 1600, height: 1000 }, launchViewport: { width: 1600, height: 1000 } }), browserSurface: async request => { calls.push(['surface', request]); return {}; }, }, @@ -299,7 +299,7 @@ test('explicit playwright DPR is measured on a blank page before destination nav const options = { env: { PWD: process.cwd() }, client: { - resolveBrowser: async () => ({ binding: { session: 'dormouse.1.default', cwd: process.cwd() }, fresh: true, + resolveBrowser: async () => ({ binding: { session: 'dormouse_1_default', cwd: process.cwd() }, fresh: true, initialViewport: { mode: 'fixed', width: 1440, height: 900, dpr: 2 }, launchViewport: { width: 1440, height: 900 } }), browserSurface: async request => { calls.push(['surface', request]); return { status: 'created', surfaceId: 'browser-1' }; }, browserViewport: async request => { calls.push(['measure', request]); return { actual: { width: 1440, height: 900, dpr: 2 } }; }, @@ -324,7 +324,7 @@ test('playwright explicit DPR preparation keeps custom config for launch', async const options = { env: { PWD: process.cwd() }, client: { - resolveBrowser: async () => ({ binding: { session: 'dormouse.1.default', cwd: process.cwd() }, fresh: true, + resolveBrowser: async () => ({ binding: { session: 'dormouse_1_default', cwd: process.cwd() }, fresh: true, initialViewport: { mode: 'fixed', width: 1440, height: 900, dpr: 2 }, launchViewport: { width: 1440, height: 900 } }), browserSurface: async () => ({}), browserViewport: async () => ({ actual: { width: 1440, height: 900, dpr: 2 } }), @@ -343,7 +343,7 @@ test('playwright device, mobile, and headed options leave viewport choice to nat const surfaces = []; const options = { env: { PWD: process.cwd() }, - client: { resolveBrowser: async () => ({ binding: { session: 'dormouse.1.default', cwd: process.cwd() }, fresh: true, + client: { resolveBrowser: async () => ({ binding: { session: 'dormouse_1_default', cwd: process.cwd() }, fresh: true, initialViewport: { mode: 'fixed', width: 1440, height: 900 }, launchViewport: { width: 1440, height: 900 } }), browserSurface: async request => { surfaces.push(request); return {}; } }, execPlaywright: async (_binary, args, _cwd, env) => { calls.push([args, env]); return { exitCode: 0, stdout: '', stderr: '' }; }, @@ -360,7 +360,7 @@ for (const provider of ['agent-browser', 'playwright']) test(provider+' viewport const options={ env:{PWD:process.cwd()}, client:{ - resolveBrowser:async()=>({binding:{session:'dormouse.1.default'},fresh:true,initialViewport:{mode:'fixed',width:1440,height:900,dpr:2},launchViewport:{width:1440,height:900,dpr:2}}), + resolveBrowser:async()=>({binding:{session:'dormouse_1_default'},fresh:true,initialViewport:{mode:'fixed',width:1440,height:900,dpr:2},launchViewport:{width:1440,height:900,dpr:2}}), browserSurface:async request=>{calls.push(['surface',request]);return {};}, browserViewport:async()=>({actual:{width:1440,height:900,dpr:2}}), }, @@ -381,7 +381,7 @@ test('every agent-browser call states the pane\'s mode, unless the command gives const result = await runCli(['agent-browser', ...args], { env: { PWD: process.cwd() }, client: { - resolveBrowser: async () => ({ binding: { session: 'dormouse.1.default' }, fresh, headed, + resolveBrowser: async () => ({ binding: { session: 'dormouse_1_default' }, fresh, headed, ...(fresh ? { initialViewport: { mode: 'fixed', width: 1440, height: 900 }, launchViewport: { width: 1440, height: 900 } } : {}) }), browserSurface: async () => ({}), }, @@ -395,8 +395,8 @@ test('every agent-browser call states the pane\'s mode, unless the command gives assert.equal(launch.length, 5); for (const argv of launch) assert.equal(argv[argv.indexOf('--headed') + 1], 'false', argv.join(' ')); assert.deepEqual(await run(true, ['click', '@e1']), [ - ['--session', 'dormouse.1.default', '--headed', 'true', 'click', '@e1'], - ['--session', 'dormouse.1.default', '--headed', 'true', 'stream', 'status', '--json'], + ['--session', 'dormouse_1_default', '--headed', 'true', 'click', '@e1'], + ['--session', 'dormouse_1_default', '--headed', 'true', 'stream', 'status', '--json'], ]); - assert.deepEqual((await run(false, ['--headed', 'click', '@e1']))[0], ['--session', 'dormouse.1.default', '--headed', 'click', '@e1']); + assert.deepEqual((await run(false, ['--headed', 'click', '@e1']))[0], ['--session', 'dormouse_1_default', '--headed', 'click', '@e1']); }); diff --git a/dor/test/cli-output.test.mjs b/dor/test/cli-output.test.mjs index 960f14189..5c6526ffa 100644 --- a/dor/test/cli-output.test.mjs +++ b/dor/test/cli-output.test.mjs @@ -292,12 +292,12 @@ function fixtureClient(surfacesFixture = fixtureSurfaces) { request.workspace === `workspace-name:${row.name}` || request.workspace === row.id )); // `sessionForKey` scrubs the id's colon: a session name is a socket path. - return { binding: { session: `dormouse.${workspace ? workspace.id.replace(':', '-') : '1'}.${request.key}`, ...request.proposed } }; + return { binding: { session: `dormouse_${workspace ? workspace.id.replace(':', '-') : '1'}_${request.key}`, ...request.proposed } }; } if (request.surface === 'surface:1') { throw new Error("surface 'surface:1' has no browser (kind: terminal)"); } - return { binding: { session: 'dormouse.1.gui-a1b2c3' } }; + return { binding: { session: 'dormouse_1_gui-a1b2c3' } }; }, async listWorkspaces(request) { this.requests.push({ method: 'listWorkspaces', request }); @@ -1267,14 +1267,14 @@ test('agent-browser resolves --key to a namespaced session and opens a surface', // The command made the daemon, so `dor agent-browser` asks it for its stream port — under // its own socket directory and CLI — and hands that over. assert.deepEqual(ab.calls, [ - ['agent-browser', '--session', 'dormouse.1.storybook', 'open', 'http://localhost:6006'], - ['agent-browser', '--session', 'dormouse.1.storybook', 'stream', 'status', '--json'], + ['agent-browser', '--session', 'dormouse_1_storybook', 'open', 'http://localhost:6006'], + ['agent-browser', '--session', 'dormouse_1_storybook', 'stream', 'status', '--json'], ]); assert.deepEqual(client.requests, [ // The host names the session, because only the Workspace that will hold the // browser can namespace a key. { method: 'resolveBrowser', request: { provider: 'agent-browser', key: 'storybook', proposed: proposedHere } }, - { method: 'browserSurface', request: { focus: false, provider: 'agent-browser', key: 'storybook', session: 'dormouse.1.storybook', cwd: process.cwd(), wsPort: 61141 } }, + { method: 'browserSurface', request: { focus: false, provider: 'agent-browser', key: 'storybook', session: 'dormouse_1_storybook', cwd: process.cwd(), wsPort: 61141 } }, ]); }); @@ -1284,16 +1284,16 @@ test('agent-browser --key in another Workspace drives that Workspace own session await runCli(['agent-browser', '--workspace', 'workspace-name:build', '--key', 'default', 'open', 'http://localhost:6006'], { client, execAgentBrowser: ab.exec }); // The same key in another Workspace is another browser: the session name is // namespaced by the Workspace's stable id, so nothing here can reach the - // first Workspace's `dormouse.1.default`. + // first Workspace's `dormouse_1_default`. assert.deepEqual(ab.calls, [ - ['agent-browser', '--session', 'dormouse.workspace-2.default', 'open', 'http://localhost:6006'], - ['agent-browser', '--session', 'dormouse.workspace-2.default', 'stream', 'status', '--json'], + ['agent-browser', '--session', 'dormouse_workspace-2_default', 'open', 'http://localhost:6006'], + ['agent-browser', '--session', 'dormouse_workspace-2_default', 'stream', 'status', '--json'], ]); assert.deepEqual(client.requests, [ { method: 'resolveBrowser', request: { provider: 'agent-browser', key: 'default', proposed: proposedHere, workspace: 'workspace-name:build' } }, { method: 'browserSurface', - request: { focus: false, provider: 'agent-browser', key: 'default', session: 'dormouse.workspace-2.default', cwd: process.cwd(), wsPort: 61141, workspace: 'workspace-name:build' }, + request: { focus: false, provider: 'agent-browser', key: 'default', session: 'dormouse_workspace-2_default', cwd: process.cwd(), wsPort: 61141, workspace: 'workspace-name:build' }, }, ]); }); @@ -1302,8 +1302,8 @@ test('agent-browser defaults to --key default', async () => { const ab = fakeAgentBrowser(); const client = fixtureClient(); await runCli(['agent-browser', 'open', 'http://localhost:5173'], { client, execAgentBrowser: ab.exec }); - assert.equal(ab.calls[0][2], 'dormouse.1.default'); - assert.deepEqual(client.requests[1].request, { focus: false, provider: 'agent-browser', key: 'default', session: 'dormouse.1.default', cwd: process.cwd(), wsPort: 61141 }); + assert.equal(ab.calls[0][2], 'dormouse_1_default'); + assert.deepEqual(client.requests[1].request, { focus: false, provider: 'agent-browser', key: 'default', session: 'dormouse_1_default', cwd: process.cwd(), wsPort: 61141 }); }); test('agent-browser raw --session skips key namespacing', async () => { @@ -1325,8 +1325,8 @@ test('agent-browser --workspace names the Workspace and never reaches the binary // Intercepted like the identity flags: the browser opens in `build`, the // handle resolves there, and agent-browser sees neither the flag nor its value. assert.deepEqual(ab.calls, [ - ['agent-browser', '--session', 'dormouse.workspace-2.default', 'open', 'http://localhost:5173/'], - ['agent-browser', '--session', 'dormouse.workspace-2.default', 'stream', 'status', '--json'], + ['agent-browser', '--session', 'dormouse_workspace-2_default', 'open', 'http://localhost:5173/'], + ['agent-browser', '--session', 'dormouse_workspace-2_default', 'stream', 'status', '--json'], ]); // Every host round trip the run makes names it: the session namespace, the // handle resolution, and the surface the browser lands in. @@ -1343,8 +1343,8 @@ test('agent-browser open resolves a surface handle to a URL before forwarding', await runCli(['agent-browser', 'open', 'surface:1'], { client, execAgentBrowser: ab.exec }); // The surface handle is resolved via the host, then the URL is forwarded. assert.deepEqual(ab.calls, [ - ['agent-browser', '--session', 'dormouse.1.default', 'open', 'http://localhost:5173/'], - ['agent-browser', '--session', 'dormouse.1.default', 'stream', 'status', '--json'], + ['agent-browser', '--session', 'dormouse_1_default', 'open', 'http://localhost:5173/'], + ['agent-browser', '--session', 'dormouse_1_default', 'stream', 'status', '--json'], ]); assert.deepEqual(client.requests[1], { method: 'resolveOpenTarget', request: { surface: 'surface:1' } }); }); @@ -1387,7 +1387,7 @@ test('agent-browser open resolves a surface target behind a flag', async () => { const ab = fakeAgentBrowser(); const client = fixtureClient(); await runCli(['agent-browser', 'open', '--headed', 'surface:1'], { client, execAgentBrowser: ab.exec }); - assert.deepEqual(ab.calls[0], ['agent-browser', '--session', 'dormouse.1.default', 'open', '--headed', 'http://localhost:5173/']); + assert.deepEqual(ab.calls[0], ['agent-browser', '--session', 'dormouse_1_default', 'open', '--headed', 'http://localhost:5173/']); }); test('agent-browser leaves a plain open URL untouched', async () => { @@ -1411,7 +1411,7 @@ test('agent-browser close skips surface management', async () => { const ab = fakeAgentBrowser(); const client = fixtureClient(); await runCli(['agent-browser', 'close'], { client, execAgentBrowser: ab.exec }); - assert.deepEqual(ab.calls, [['agent-browser', '--session', 'dormouse.1.default', 'close']]); + assert.deepEqual(ab.calls, [['agent-browser', '--session', 'dormouse_1_default', 'close']]); assert.equal(surfaceRequest(client), undefined); }); @@ -1419,7 +1419,7 @@ test('agent-browser skills runs alone, without a stream probe or a surface', asy const ab = fakeAgentBrowser(); const client = fixtureClient(); await runCli(['agent-browser', 'skills', 'get', 'core'], { client, execAgentBrowser: ab.exec }); - assert.deepEqual(ab.calls, [['agent-browser', '--session', 'dormouse.1.default', 'skills', 'get', 'core']]); + assert.deepEqual(ab.calls, [['agent-browser', '--session', 'dormouse_1_default', 'skills', 'get', 'core']]); assert.equal(surfaceRequest(client), undefined); }); @@ -1428,7 +1428,7 @@ test('agent-browser without a control endpoint stays a pure passthrough', async const result = await runCli(['agent-browser', 'open', 'http://localhost:5173'], { execAgentBrowser: ab.exec }); assert.equal(result.exitCode, 0); assert.equal(result.stderr, ''); - assert.deepEqual(ab.calls, [['agent-browser', '--session', 'dormouse.1.default', 'open', 'http://localhost:5173']]); + assert.deepEqual(ab.calls, [['agent-browser', '--session', 'dormouse_1_default', 'open', 'http://localhost:5173']]); }); test('agent-browser forwards child exit code and skips surface on failure', async () => { @@ -1451,13 +1451,13 @@ test('agent-browser --surface drives the session the host says the surface is bo request: { provider: 'agent-browser', surface: 'surface:3' }, }); assert.deepEqual(ab.calls, [ - ['agent-browser', '--session', 'dormouse.1.gui-a1b2c3', 'click', '@e3'], - ['agent-browser', '--session', 'dormouse.1.gui-a1b2c3', 'stream', 'status', '--json'], + ['agent-browser', '--session', 'dormouse_1_gui-a1b2c3', 'click', '@e3'], + ['agent-browser', '--session', 'dormouse_1_gui-a1b2c3', 'stream', 'status', '--json'], ]); // No `key`: a surface-addressed session is not necessarily a managed one. assert.deepEqual(client.requests[1], { method: 'browserSurface', - request: { focus: false, provider: 'agent-browser', key: undefined, surface: 'surface:3', session: 'dormouse.1.gui-a1b2c3', cwd: process.cwd(), wsPort: 61141 }, + request: { focus: false, provider: 'agent-browser', key: undefined, surface: 'surface:3', session: 'dormouse_1_gui-a1b2c3', cwd: process.cwd(), wsPort: 61141 }, }); }); @@ -1466,7 +1466,7 @@ test('agent-browser --surface accepts --surface=handle and resolves an open targ const client = fixtureClient(); await runCli(['agent-browser', '--surface=surface:3', 'open', ':5173'], { client, execAgentBrowser: ab.exec }); assert.deepEqual(ab.calls[0], [ - 'agent-browser', '--session', 'dormouse.1.gui-a1b2c3', 'open', 'http://localhost:5173/', + 'agent-browser', '--session', 'dormouse_1_gui-a1b2c3', 'open', 'http://localhost:5173/', ]); }); @@ -2515,7 +2515,7 @@ test('browser providers read Dormouse options anywhere, as the native CLIs read const client = fixtureClient(); const result = await runCli(['agent-browser', 'open', ':5173', '--headed', '--key', 'app'], { client, execAgentBrowser: ab.exec }); assert.equal(result.exitCode, 0, result.stderr); - assert.deepEqual(ab.calls[0], ['agent-browser', '--session', 'dormouse.1.app', 'open', 'http://localhost:5173/', '--headed']); + assert.deepEqual(ab.calls[0], ['agent-browser', '--session', 'dormouse_1_app', 'open', 'http://localhost:5173/', '--headed']); assert.equal(client.requests[0].request.key, 'app'); assert.deepEqual(extractSessionFlags(['snapshot', '-i', '--workspace=workspace-name:build', '--session', 'raw'], { sessionNoun: 'session' }), { ok: true, value: { session: 'raw', rest: ['snapshot', '-i'], workspace: 'workspace-name:build' }, @@ -2541,7 +2541,7 @@ test('only a lone --help is Dormouse help; any other goes to the provider', asyn for (const argv of [['agent-browser', 'open', '--help'], ['agent-browser', 'snapshot', '--', '--help']]) { const native = fakeAgentBrowser(); await runCli(argv, { execAgentBrowser: native.exec, env: {} }); - assert.deepEqual(native.calls[0], ['agent-browser', '--session', 'dormouse.1.default', ...argv.slice(1)]); + assert.deepEqual(native.calls[0], ['agent-browser', '--session', 'dormouse_1_default', ...argv.slice(1)]); } }); diff --git a/dor/test/playwright.test.mjs b/dor/test/playwright.test.mjs index c3437399a..7d8cebbbd 100644 --- a/dor/test/playwright.test.mjs +++ b/dor/test/playwright.test.mjs @@ -30,7 +30,7 @@ function fixture(binding = null) { calls.push(['resolve', request]); if (binding) return { binding }; if (request.surface !== undefined) throw new Error(`surface '${request.surface}' has no playwright session yet`); - return { binding: { session: `dormouse.1.${request.key}`, ...request.proposed } }; + return { binding: { session: `dormouse_1_${request.key}`, ...request.proposed } }; }, browserSurface: async request => { calls.push(['surface', request]); return {}; }, }, @@ -44,7 +44,7 @@ test('full playwright command forwards native arguments and binds only to playwr const result = await runCli(['playwright', '--key', 'app', 'open', ':5173', '--headed'], options); assert.equal(result.stdout, 'native output\n'); assert.equal(result.exitCode, 0); - assert.deepEqual(calls.find(c => c[0] === 'exec'), ['exec', '/tools/playwright-cli', ['--session=dormouse.1.app', 'open', 'http://localhost:5173/', '--headed'], caller, undefined, 'inherit']); + assert.deepEqual(calls.find(c => c[0] === 'exec'), ['exec', '/tools/playwright-cli', ['--session=dormouse_1_app', 'open', 'http://localhost:5173/', '--headed'], caller, undefined, 'inherit']); assert.equal(calls.at(-1)[1].provider, 'playwright'); }); test('existing key pins executable, cwd and native session across terminal directories', async () => { diff --git a/dor/test/snapshots/help/agent-browser.md b/dor/test/snapshots/help/agent-browser.md index 3301fe8dd..63749833c 100644 --- a/dor/test/snapshots/help/agent-browser.md +++ b/dor/test/snapshots/help/agent-browser.md @@ -11,7 +11,7 @@ Forwards all arguments verbatim to your own agent-browser binary and binds the s dor intercepts exactly three mutually exclusive identity flags: --key Managed, workspace-scoped browser identity (default "default"). - Maps to agent-browser session dormouse.., + Maps to agent-browser session dormouse__, so the same key in another Workspace is another browser. --session Attach to a raw agent-browser session by its literal name. --surface Drive the browser Surface a handle names (surface:N, diff --git a/dor/test/wsl-paths.test.mjs b/dor/test/wsl-paths.test.mjs index 8e71024c0..1c8f7f726 100644 --- a/dor/test/wsl-paths.test.mjs +++ b/dor/test/wsl-paths.test.mjs @@ -37,7 +37,7 @@ function wslCall(stdout = '') { argsSeen, options: { env: { PWD: process.cwd(), WSL_DISTRO_NAME: 'Ubuntu' }, - client: { resolveBrowser: async () => ({ binding: { session: 'dormouse.1.default' } }), browserSurface: async () => ({}) }, + client: { resolveBrowser: async () => ({ binding: { session: 'dormouse_1_default' } }), browserSurface: async () => ({}) }, execAgentBrowser: exec, execPlaywright: exec, }, diff --git a/lib/src/components/Wall.test.tsx b/lib/src/components/Wall.test.tsx index 6ccde61ea..36f8cfead 100644 --- a/lib/src/components/Wall.test.tsx +++ b/lib/src/components/Wall.test.tsx @@ -845,7 +845,7 @@ describe('Wall on the Lath engine', () => { window.dispatchEvent(new CustomEvent('dormouse:control-request', { detail: { method: SURFACE_CONTROL_METHODS.browser, - params: { provider: 'agent-browser', session: 'dormouse.1.gate', binaryPath: '/usr/bin/curl' }, + params: { provider: 'agent-browser', session: 'dormouse_1_gate', binaryPath: '/usr/bin/curl' }, respond: (r: typeof response) => { response = r; }, }, })); @@ -856,7 +856,7 @@ describe('Wall on the Lath engine', () => { expect(response?.ok).toBe(true); expect(response?.error).toBeUndefined(); expect(response?.result?.surfaceId).toBeTruthy(); - expect(requests('attach')[0]).toEqual({ provider: 'agent-browser', binding: { session: 'dormouse.1.gate' }, op: 'attach' }); + expect(requests('attach')[0]).toEqual({ provider: 'agent-browser', binding: { session: 'dormouse_1_gate' }, op: 'attach' }); }); it('streams from a port `dor agent-browser` read itself, asking the host nothing; a Playwright port is the host\'s to report', async () => { @@ -882,8 +882,8 @@ describe('Wall on the Lath engine', () => { expect(requests('attach')).toEqual([]); expect(browser).toHaveBeenCalledWith(expect.objectContaining({ op: 'view', stream: 61218 })); - expect((await bind({ provider: 'playwright', session: 'dormouse.pw.x', cwd: '/project', wsPort: 61219 }))?.ok).toBe(false); - expect(requests('attach')).toEqual([{ provider: 'playwright', binding: { session: 'dormouse.pw.x', cwd: '/project' }, op: 'attach' }]); + expect((await bind({ provider: 'playwright', session: 'dormouse_pw_x', cwd: '/project', wsPort: 61219 }))?.ok).toBe(false); + expect(requests('attach')).toEqual([{ provider: 'playwright', binding: { session: 'dormouse_pw_x', cwd: '/project' }, op: 'attach' }]); }); it('reports the measured browser viewport and persists an explicit fixed size', async () => { @@ -1282,7 +1282,7 @@ describe('Wall on the Lath engine', () => { // The same command here opens a browser of its own, so neither pane's // close ends the other's. const again = (await control(SURFACE_CONTROL_METHODS.resolveBrowser, { provider, key: 'foo', proposed: { cwd: '/project' } }))?.result?.binding; - expect(again?.session).toBe(`${first!.session}.2`); + expect(again?.session).toBe(`${first!.session}_2`); expect(requests('attach')).toHaveLength(1); } finally { disposers.forEach((dispose) => dispose()); @@ -1978,13 +1978,13 @@ describe('Wall on the Lath engine', () => { expect(container.querySelector(`[data-door-id="${iframeId}"]`)).not.toBeNull(); await act(async () => { - resolveOpen({ ok: true, session: 'dormouse.1.gui-minimized', stream: 4321, binaryPath: '/usr/bin/agent-browser' }); + resolveOpen({ ok: true, session: 'dormouse_1_gui-minimized', stream: 4321, binaryPath: '/usr/bin/agent-browser' }); await openResult; }); await flush(); - expect(await dispatchResolveBrowser(iframeId)).toMatchObject({ ok: true, result: { binding: { session: 'dormouse.1.gui-minimized' }, fresh: false } }); - expect(requests('close').filter((request) => request.binding.session === 'dormouse.1.gui-minimized')).toEqual([]); + expect(await dispatchResolveBrowser(iframeId)).toMatchObject({ ok: true, result: { binding: { session: 'dormouse_1_gui-minimized' }, fresh: false } }); + expect(requests('close').filter((request) => request.binding.session === 'dormouse_1_gui-minimized')).toEqual([]); } finally { untouchedSpy.mockRestore(); } @@ -2196,7 +2196,7 @@ describe('Wall on the Lath engine', () => { await act(async () => { controller()?.actions.setRenderMode?.('playwright-screencast'); }); await flush(); expect(requests('launch')).toEqual([expect.objectContaining({ - provider: 'playwright', binding: { session: 'dormouse.1.tool.surface-tool-a', cwd: '/repo' }, op: 'launch', url: 'http://localhost:6006/', headed: false, + provider: 'playwright', binding: { session: 'dormouse_1_tool-surface-tool-a', cwd: '/repo' }, op: 'launch', url: 'http://localhost:6006/', headed: false, })]); } finally { offered.mockRestore(); @@ -2233,7 +2233,7 @@ describe('Wall on the Lath engine', () => { await act(async () => { getAgentBrowserScreenController('surface:tool-a')?.actions.setRenderMode?.('agent-browser-screencast'); }); await flush(); expect(requests('launch')).toEqual([expect.objectContaining({ - provider: 'agent-browser', binding: { session: 'dormouse.1.tool.surface-tool-a', cwd: '/repo' }, op: 'launch', url: 'http://localhost:6006/', headed: false, + provider: 'agent-browser', binding: { session: 'dormouse_1_tool-surface-tool-a', cwd: '/repo' }, op: 'launch', url: 'http://localhost:6006/', headed: false, })]); expect(getAgentBrowserScreenController('surface:tool-a')?.snapshot().renderMode).toBe('iframe'); } finally { @@ -2249,7 +2249,7 @@ describe('Wall on the Lath engine', () => { const { requests } = hostBrowsers({ launch: async (request) => request.provider === 'playwright' ? { ok: true, session: 'gui-pw', stream: 4322 } - : { ok: true, session: 'dormouse.1.gui-a1b2c3', stream: 4321 }, + : { ok: true, session: 'dormouse_1_gui-a1b2c3', stream: 4321 }, }); const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}); @@ -2301,10 +2301,10 @@ describe('Wall on the Lath engine', () => { // An ab-rendered surface bound to a GUI-minted session — the name no // `--key` can produce, which is the point of addressing by handle. - const abId = await dispatchAgentBrowser({ session: 'dormouse.1.gui-a1b2c3', surface: 'surface:a' }); + const abId = await dispatchAgentBrowser({ session: 'dormouse_1_gui-a1b2c3', surface: 'surface:a' }); const iframeId = (await dispatchIframe('http://localhost:5173/')).id; - expect(await dispatchResolveBrowser(abId)).toMatchObject({ ok: true, result: { binding: { session: 'dormouse.1.gui-a1b2c3' }, fresh: false, headed: false } }); + expect(await dispatchResolveBrowser(abId)).toMatchObject({ ok: true, result: { binding: { session: 'dormouse_1_gui-a1b2c3' }, fresh: false, headed: false } }); // A parked ab surface keeps its daemon session, so a minimized target resolves. await act(async () => { container.querySelector(`[data-lath-leaf="${abId}"] [aria-label="Minimize"]`)!.click(); @@ -2328,19 +2328,19 @@ describe('Wall on the Lath engine', () => { // mints a scope of its own: two webviews' `--key default` are two // browsers, and a Wall mounted afresh is another scope again. const keyed = await dispatchResolveAgentBrowserKey('storybook') as { ok: boolean; result: { binding: { session: string } } }; - expect(keyed.result.binding.session).toMatch(/^dormouse\.w[0-9a-f]{8}\.storybook$/); + expect(keyed.result.binding.session).toMatch(/^dormouse_w[0-9a-f]{8}_storybook$/); expect(await dispatchResolveAgentBrowserKey('storybook')).toEqual(keyed); await act(async () => { root.render(); }); await flush(); const remounted = await dispatchResolveAgentBrowserKey('storybook') as { ok: boolean; result: { binding: { session: string } } }; - expect(remounted.result.binding.session).toMatch(/^dormouse\.w[0-9a-f]{8}\.storybook$/); + expect(remounted.result.binding.session).toMatch(/^dormouse_w[0-9a-f]{8}_storybook$/); expect(remounted.result.binding.session).not.toBe(keyed.result.binding.session); // A key a Surface holds keeps the session it was bound to — a pane saved // under the old bare-Wall name included — through the merged pair. - await dispatchAgentBrowser({ key: 'app', session: 'dormouse.1.app', surface: 'surface:a' }); + await dispatchAgentBrowser({ key: 'app', session: 'dormouse_1_app', surface: 'surface:a' }); let resolved: unknown; await act(async () => { window.dispatchEvent(new CustomEvent('dormouse:control-request', { @@ -2352,7 +2352,7 @@ describe('Wall on the Lath engine', () => { })); }); await flush(); - expect(resolved).toEqual({ ok: true, result: { binding: { session: 'dormouse.1.app' }, fresh: false, headed: false } }); + expect(resolved).toEqual({ ok: true, result: { binding: { session: 'dormouse_1_app' }, fresh: false, headed: false } }); } finally { untouchedSpy.mockRestore(); } @@ -5143,7 +5143,7 @@ describe('Wall on the Lath engine', () => { window.dispatchEvent(new CustomEvent('dormouse:control-request', { detail: { method: SURFACE_CONTROL_METHODS.browser, - params: { provider: 'playwright', session: 'dormouse.pw.abc', cwd: '/tmp/project' }, + params: { provider: 'playwright', session: 'dormouse_pw_abc', cwd: '/tmp/project' }, respond: (r: typeof created) => { created = r; }, }, })); @@ -5155,7 +5155,7 @@ describe('Wall on the Lath engine', () => { error: `surface '${pwId}' is not agent-browser rendered (render_mode: playwright-screencast) — drive it with dor playwright --surface ${pwId}`, }); - const abId = await dispatchAgentBrowser({ session: 'dormouse.1.default', wsPort: 4321 }); + const abId = await dispatchAgentBrowser({ session: 'dormouse_1_default', wsPort: 4321 }); let resolved: unknown; await act(async () => { window.dispatchEvent(new CustomEvent('dormouse:control-request', { @@ -5233,9 +5233,9 @@ describe('Wall on the Lath engine', () => { })]); // The pane is there at once; `dor agent-browser --surface` has nothing to drive until the launch names it. expect(await dispatchResolveBrowser(tab)).toMatchObject({ ok: false }); - await act(async () => { launches[0]({ ok: true, session: 'dormouse.1.gui-abc', stream: 4321 }); }); + await act(async () => { launches[0]({ ok: true, session: 'dormouse_1_gui-abc', stream: 4321 }); }); await flush(); - expect(await dispatchResolveBrowser(tab)).toMatchObject({ ok: true, result: { binding: { session: 'dormouse.1.gui-abc' } } }); + expect(await dispatchResolveBrowser(tab)).toMatchObject({ ok: true, result: { binding: { session: 'dormouse_1_gui-abc' } } }); // Nor can it be swapped back into an iframe that would refuse it. const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}); diff --git a/lib/src/components/WorkspaceWindow.test.tsx b/lib/src/components/WorkspaceWindow.test.tsx index d3742266a..3a8233609 100644 --- a/lib/src/components/WorkspaceWindow.test.tsx +++ b/lib/src/components/WorkspaceWindow.test.tsx @@ -833,8 +833,8 @@ describe('WorkspaceWindow', () => { // name carries the Workspace's id, its colon scrubbed: a session name is a // socket path. expect(first).toBe('workspace:1'); - expect(sessionFor(first)).toBe('dormouse.workspace-1.default'); - expect(sessionFor('workspace:2')).toBe('dormouse.workspace-2.default'); + expect(sessionFor(first)).toBe('dormouse_workspace-1_default'); + expect(sessionFor('workspace:2')).toBe('dormouse_workspace-2_default'); }); it('keeps a hidden Workspace out of the window keyboard: its kill confirm outlives an Escape next door', async () => { @@ -1246,11 +1246,11 @@ describe('Surface moves between Workspaces', () => { it('drops a browser\'s key as it leaves its Workspace, keeping its session', async () => { const source = getActiveWorkspaceId(); createWorkspace({ id: 'workspace:2', activate: false }); - const meta = browserLeafMeta('default', { surfaceType: 'browser', renderMode: 'iframe', url: 'http://localhost:3000/', session: 'dormouse.workspace-1.default', key: 'default' }); + const meta = browserLeafMeta('default', { surfaceType: 'browser', renderMode: 'iframe', url: 'http://localhost:3000/', session: 'dormouse_workspace-1_default', key: 'default' }); await render(<>); const prepared = getWallHandle(source)!.prepareSurfaceMove('web'); expect(prepared.meta.params?.key).toBeUndefined(); - expect(prepared.meta.params?.session).toBe('dormouse.workspace-1.default'); + expect(prepared.meta.params?.session).toBe('dormouse_workspace-1_default'); }); /** A source holding only a plain iframe, beside two terminal Workspaces. */ diff --git a/lib/src/components/wall/AgentBrowserPanel.test.tsx b/lib/src/components/wall/AgentBrowserPanel.test.tsx index 16b83ec38..f38f93be4 100644 --- a/lib/src/components/wall/AgentBrowserPanel.test.tsx +++ b/lib/src/components/wall/AgentBrowserPanel.test.tsx @@ -159,14 +159,14 @@ describe('AgentBrowserPanel placeholders', () => { root.render( {})}> - + , ); }); expect(container.textContent).toContain(`run ${cli} --surface surface:7 open `); - expect(container.textContent).not.toContain('dormouse.1.gui-5f3a'); + expect(container.textContent).not.toContain('dormouse_1_gui-5f3a'); }); }); diff --git a/lib/src/components/wall/agent-browser-connection.test.ts b/lib/src/components/wall/agent-browser-connection.test.ts index a67a209b7..4c2779474 100644 --- a/lib/src/components/wall/agent-browser-connection.test.ts +++ b/lib/src/components/wall/agent-browser-connection.test.ts @@ -41,7 +41,7 @@ class WebSocketMock { function connect(deps: Partial = {}) { let granted = 0; const viewUrl = vi.fn(async () => `ws://127.0.0.1:9/view/${++granted}`); - const connection = createAgentBrowserConnection({ session: 'dormouse.1.default', stream: 1234, viewUrl, ...deps }); + const connection = createAgentBrowserConnection({ session: 'dormouse_1_default', stream: 1234, viewUrl, ...deps }); return { connection, viewUrl }; } diff --git a/lib/src/components/wall/agent-browser-surface-controller.test.ts b/lib/src/components/wall/agent-browser-surface-controller.test.ts index 55d970f08..8bf243c5d 100644 --- a/lib/src/components/wall/agent-browser-surface-controller.test.ts +++ b/lib/src/components/wall/agent-browser-surface-controller.test.ts @@ -691,7 +691,7 @@ describe('launch', () => { } it('a session-less pane opens its page, binds the session the host answers with, and streams', async () => { - const host = launchHost(async () => ({ ok: true, session: 'dormouse.1.gui-abc', stream: 4321, binaryPath: '/usr/bin/agent-browser' })); + const host = launchHost(async () => ({ ok: true, session: 'dormouse_1_gui-abc', stream: 4321, binaryPath: '/usr/bin/agent-browser' })); // A restored pane whose launch never landed is the same pane. const controller = acquireAgentBrowserSurfaceController('id', { renderMode: 'agent-browser-screencast', url: 'https://page.example/', binaryPath: '/usr/bin/agent-browser', @@ -704,19 +704,19 @@ describe('launch', () => { expect(host.requests('launch')).toEqual([expect.objectContaining({ provider: 'agent-browser', binding: { binaryPath: '/usr/bin/agent-browser' }, op: 'launch', url: 'https://page.example/', headed: false, })]); - expect(sink.updateParameters).toHaveBeenCalledWith({ session: 'dormouse.1.gui-abc', binaryPath: '/usr/bin/agent-browser' }); + expect(sink.updateParameters).toHaveBeenCalledWith({ session: 'dormouse_1_gui-abc', binaryPath: '/usr/bin/agent-browser' }); expect(streamSocket(4321)?.readyState).toBe(1); expect(host.requests('attach')).toEqual([]); // Driven as the session it bound. getAgentBrowserScreenController('id')!.chromeActions.reload(); expect(host.browser).toHaveBeenLastCalledWith({ - provider: 'agent-browser', binding: { session: 'dormouse.1.gui-abc', binaryPath: '/usr/bin/agent-browser' }, op: 'history', dir: 'reload', + provider: 'agent-browser', binding: { session: 'dormouse_1_gui-abc', binaryPath: '/usr/bin/agent-browser' }, op: 'history', dir: 'reload', }); // Params that predate that write — a remounted view feeding them before its // flush — do not take the session away and launch again. controller.updateParams({ renderMode: 'agent-browser-screencast', url: 'https://page.example/' }); - controller.updateParams({ renderMode: 'agent-browser-screencast', url: 'https://page.example/', session: 'dormouse.1.gui-abc' }); + controller.updateParams({ renderMode: 'agent-browser-screencast', url: 'https://page.example/', session: 'dormouse_1_gui-abc' }); await flushMicrotasks(); expect(host.requests('launch')).toHaveLength(1); expect(streamSockets(4321)).toHaveLength(1); @@ -778,17 +778,17 @@ describe('launch', () => { }); it('opens in the session params name, headed for a pop-out, and binds it', async () => { - const host = launchHost(async () => ({ ok: true, session: 'dormouse.1.tool.t', stream: 4321 })); + const host = launchHost(async () => ({ ok: true, session: 'dormouse_1_tool-t', stream: 4321 })); const controller = acquireAgentBrowserSurfaceController('id', { - renderMode: 'agent-browser-popout', url: 'http://localhost:6006/', launchSession: 'dormouse.1.tool.t', + renderMode: 'agent-browser-popout', url: 'http://localhost:6006/', launchSession: 'dormouse_1_tool-t', }); const sink = makeSink(); controller.attachView(sink); await flushMicrotasks(); expect(host.requests('launch')).toEqual([{ - provider: 'agent-browser', binding: { session: 'dormouse.1.tool.t' }, op: 'launch', url: 'http://localhost:6006/', headed: true, + provider: 'agent-browser', binding: { session: 'dormouse_1_tool-t' }, op: 'launch', url: 'http://localhost:6006/', headed: true, }]); - expect(sink.updateParameters).toHaveBeenCalledWith({ session: 'dormouse.1.tool.t', launchSession: undefined, launchFallback: undefined }); + expect(sink.updateParameters).toHaveBeenCalledWith({ session: 'dormouse_1_tool-t', launchSession: undefined, launchFallback: undefined }); }); it('a failed launch says why, in the pane and to whoever awaited it', async () => { @@ -809,14 +809,14 @@ describe('launch', () => { closeBrowserSurface('id', { surfaceType: 'browser', renderMode: 'agent-browser-screencast', url: 'https://page.example/' }); expect(host.requests('close')).toEqual([]); - launch.resolve({ ok: true, session: 'dormouse.1.gui-late', stream: 4321 }); + launch.resolve({ ok: true, session: 'dormouse_1_gui-late', stream: 4321 }); await flushMicrotasks(); - expect(host.requests('close')).toEqual([{ provider: 'agent-browser', binding: { session: 'dormouse.1.gui-late' }, op: 'close' }]); + expect(host.requests('close')).toEqual([{ provider: 'agent-browser', binding: { session: 'dormouse_1_gui-late' }, op: 'close' }]); expect(WebSocketMock.instances).toHaveLength(0); }); it('a navigation out of a failed launch launches at its page, and loads it once', async () => { - const answers: BrowserResult[] = [{ ok: false, error: 'boom' }, { ok: true, session: 'dormouse.1.gui-n', stream: 4321 }]; + const answers: BrowserResult[] = [{ ok: false, error: 'boom' }, { ok: true, session: 'dormouse_1_gui-n', stream: 4321 }]; const host = launchHost(async () => answers.shift()!); acquireAgentBrowserSurfaceController('id', { renderMode: 'agent-browser-screencast', url: 'https://page.example/' }).attachView(makeSink()); await flushMicrotasks(); @@ -832,21 +832,21 @@ describe('launch', () => { const launch = pending(); const host = launchHost(() => launch.promise); const controller = acquireAgentBrowserSurfaceController('id', { - renderMode: 'agent-browser-screencast', url: 'http://localhost:6006/', launchSession: 'dormouse.1.tool.t', + renderMode: 'agent-browser-screencast', url: 'http://localhost:6006/', launchSession: 'dormouse_1_tool-t', }); controller.attachView(makeSink()); await flushMicrotasks(); // A new announcement: the same session, another page. - controller.updateParams({ renderMode: 'agent-browser-screencast', url: 'http://localhost:6007/docs', launchSession: 'dormouse.1.tool.t' }); - launch.resolve({ ok: true, session: 'dormouse.1.tool.t', stream: 4321 }); + controller.updateParams({ renderMode: 'agent-browser-screencast', url: 'http://localhost:6007/docs', launchSession: 'dormouse_1_tool-t' }); + launch.resolve({ ok: true, session: 'dormouse_1_tool-t', stream: 4321 }); await flushMicrotasks(); expect(streamSocket(4321)?.readyState).toBe(1); expect(opens(host)).toEqual(['http://localhost:6007/docs']); }); it('ignores params that predate the session its launch bound', async () => { - const host = launchHost(async () => ({ ok: true, session: 'dormouse.1.gui-abc', stream: 4321 })); + const host = launchHost(async () => ({ ok: true, session: 'dormouse_1_gui-abc', stream: 4321 })); const controller = acquireAgentBrowserSurfaceController('id', { renderMode: 'agent-browser-screencast', url: 'https://page.example/' }); controller.attachView(makeSink()); await flushMicrotasks(); @@ -862,21 +862,21 @@ describe('launch', () => { const launch = pending(); const host = launchHost(() => launch.promise); const controller = acquireAgentBrowserSurfaceController('id', { - renderMode: 'agent-browser-screencast', url: 'http://localhost:6006/', launchSession: 'dormouse.1.tool.t', + renderMode: 'agent-browser-screencast', url: 'http://localhost:6006/', launchSession: 'dormouse_1_tool-t', }); controller.attachView(makeSink()); await flushMicrotasks(); - controller.updateParams({ renderMode: 'agent-browser-screencast', url: 'http://localhost:6006/', session: 'dormouse.1.tool.t' }); + controller.updateParams({ renderMode: 'agent-browser-screencast', url: 'http://localhost:6006/', session: 'dormouse_1_tool-t' }); controller.handOver(4321); - launch.resolve({ ok: true, session: 'dormouse.1.tool.t', stream: 4321 }); + launch.resolve({ ok: true, session: 'dormouse_1_tool-t', stream: 4321 }); await flushMicrotasks(); expect(host.requests('close')).toEqual([]); expect(streamSocket(4321)?.readyState).toBe(1); }); it('lets a fresh GUI launch resolve its own binary and retains the returned binding', async () => { - const host = launchHost(async () => ({ ok: true, session: 'dormouse.1.gui-b', stream: 4321, binaryPath: '/opt/ab/agent-browser' })); + const host = launchHost(async () => ({ ok: true, session: 'dormouse_1_gui-b', stream: 4321, binaryPath: '/opt/ab/agent-browser' })); acquireAgentBrowserSurfaceController('id', { renderMode: 'agent-browser-screencast', url: 'https://page.example/' }).attachView(makeSink()); await flushMicrotasks(); expect(host.requests('launch')).toEqual([expect.objectContaining({ @@ -901,7 +901,7 @@ describe('launch', () => { it('a launch released without a close leaves a session it named, and closes one the host minted', async () => { const answers: Array<(res: BrowserResult) => void> = []; const host = launchHost(() => new Promise((resolve) => { answers.push(resolve); })); - const named = acquireAgentBrowserSurfaceController('named', { renderMode: 'agent-browser-screencast', url: 'https://page.example/', launchSession: 'dormouse.1.tool.t' }); + const named = acquireAgentBrowserSurfaceController('named', { renderMode: 'agent-browser-screencast', url: 'https://page.example/', launchSession: 'dormouse_1_tool-t' }); named.attachView(makeSink()); const minted = acquireAgentBrowserSurfaceController('minted', { renderMode: 'agent-browser-screencast', url: 'https://page.example/' }); minted.attachView(makeSink()); @@ -910,10 +910,10 @@ describe('launch', () => { // A Workspace transfer: the destination opens the same named session. disposeAgentBrowserSurfaceController('named'); disposeAgentBrowserSurfaceController('minted'); - answers[0]({ ok: true, session: 'dormouse.1.tool.t', stream: 4321 }); - answers[1]({ ok: true, session: 'dormouse.1.gui-x', stream: 4322 }); + answers[0]({ ok: true, session: 'dormouse_1_tool-t', stream: 4321 }); + answers[1]({ ok: true, session: 'dormouse_1_gui-x', stream: 4322 }); await flushMicrotasks(); - expect(host.requests('close')).toEqual([{ provider: 'agent-browser', binding: { session: 'dormouse.1.gui-x' }, op: 'close' }]); + expect(host.requests('close')).toEqual([{ provider: 'agent-browser', binding: { session: 'dormouse_1_gui-x' }, op: 'close' }]); }); }); @@ -923,7 +923,7 @@ describe('a closed Surface and the next launch into its session', () => { // the next launch opens the same `tool.` session. The host orders // the two (docs/specs/dor-browser.md → "Browser Host"), so these run the // controller against the real one. - const session = 'dormouse.1.tool.t'; + const session = 'dormouse_1_tool-t'; const page = 'http://localhost:6006/'; /** `deliver` stands in for the transport: it hands a request to the host, * by default at once. */ @@ -1332,15 +1332,15 @@ describe('closeBrowserSurface', () => { it('closes the session a launch names, at once', async () => { const launch = pending(); const host = installBrowserHost({ launch: () => launch.promise }); - acquireAgentBrowserSurfaceController('id', { renderMode: 'agent-browser-screencast', url: 'http://localhost:6006/', launchSession: 'dormouse.1.tool.t', binaryPath: '/opt/agent-browser' }) + acquireAgentBrowserSurfaceController('id', { renderMode: 'agent-browser-screencast', url: 'http://localhost:6006/', launchSession: 'dormouse_1_tool-t', binaryPath: '/opt/agent-browser' }) .attachView(makeSink()); await flushMicrotasks(); void closeBrowserSurface('id', {}); // Through the binding the launch used, so the host orders the two. expect(host.requests('close')).toEqual([{ provider: 'agent-browser', binding: host.requests('launch')[0].binding, op: 'close' }]); - expect(host.requests('close')[0].binding).toMatchObject({ session: 'dormouse.1.tool.t', binaryPath: '/opt/agent-browser' }); - launch.resolve({ ok: true, session: 'dormouse.1.tool.t', stream: 4321 }); + expect(host.requests('close')[0].binding).toMatchObject({ session: 'dormouse_1_tool-t', binaryPath: '/opt/agent-browser' }); + launch.resolve({ ok: true, session: 'dormouse_1_tool-t', stream: 4321 }); await flushMicrotasks(); expect(host.requests('close')).toHaveLength(1); }); diff --git a/lib/src/components/wall/browser-binding-reservations.test.ts b/lib/src/components/wall/browser-binding-reservations.test.ts index fe09d3e4a..e55bd5a09 100644 --- a/lib/src/components/wall/browser-binding-reservations.test.ts +++ b/lib/src/components/wall/browser-binding-reservations.test.ts @@ -59,11 +59,11 @@ test('a key never mints a session a Surface in the Window, or another key\'s res // The pane first bound to `app` left for another Workspace, still bound. const held = new Set([base]); const binding = registry.resolve('playwright', 'app', 'ws', { cwd: '/project' }, (session) => held.has(session)); - expect(binding.session).toBe(`${base}.2`); + expect(binding.session).toBe(`${base}_2`); // Deterministic: the key resolves to it again, and its reservation keeps the // name from the next key that would number onto it. expect(registry.resolve('playwright', 'app', 'ws', { cwd: '/project' }, (session) => held.has(session))).toEqual(binding); - expect(registry.resolve('playwright', 'app.2', 'ws', { cwd: '/project' }, (session) => held.has(session)).session).toBe(`${base}.2.2`); + expect(registry.resolve('playwright', 'app_2', 'ws', { cwd: '/project' }, (session) => held.has(session)).session).toBe(`${base}_2_2`); // Another provider's session of that name is another browser. expect(registry.resolve('agent-browser', 'app', 'ws', { cwd: '/project' }).session).toBe(base); }); diff --git a/lib/src/components/wall/browser-binding-reservations.ts b/lib/src/components/wall/browser-binding-reservations.ts index e53f011b8..0264c8abe 100644 --- a/lib/src/components/wall/browser-binding-reservations.ts +++ b/lib/src/components/wall/browser-binding-reservations.ts @@ -32,7 +32,7 @@ export class BrowserBindingReservations { const reserved = new Set([...this.pending.values()].filter((entry) => entry.provider === provider).map((entry) => entry.binding.session)); const base = sessionForKey(key, scope); let session = base; - for (let n = 2; taken(session) || reserved.has(session); n++) session = `${base}.${n}`; + for (let n = 2; taken(session) || reserved.has(session); n++) session = `${base}_${n}`; const p = proposed as { cwd?: unknown; binaryPath?: unknown } | undefined; if (typeof p?.cwd !== 'string') return { session }; const binding: BrowserBinding = { diff --git a/lib/src/components/wall/browser-surface.ts b/lib/src/components/wall/browser-surface.ts index 1fe225470..aa8bc0149 100644 --- a/lib/src/components/wall/browser-surface.ts +++ b/lib/src/components/wall/browser-surface.ts @@ -330,7 +330,7 @@ export function toolBrowserLaunchParams(leafId: string, params: Record { toolPortConflict: [6006, 6007], url: 'http://localhost:6006/', renderMode: 'agent-browser-screencast', - session: 'dormouse.w.tool.p1', - launchSession: 'dormouse.w.tool.p1', + session: 'dormouse_w_tool-p1', + launchSession: 'dormouse_w_tool-p1', launchFallback: 'embed', }); expect(persistableLeafMeta(meta).params).toEqual({ diff --git a/lib/src/components/wall/tool-transfer.test.ts b/lib/src/components/wall/tool-transfer.test.ts index 655c19a70..553167ec5 100644 --- a/lib/src/components/wall/tool-transfer.test.ts +++ b/lib/src/components/wall/tool-transfer.test.ts @@ -7,7 +7,7 @@ import { beginToolStop, endToolStop } from '../../lib/tool-reap-store'; const params = { surfaceType: 'tool', command: 'pnpm storybook', toolRender: 'agent-browser-screencast', url: 'http://localhost:6006/edited', renderMode: 'agent-browser-screencast', - session: 'dormouse.1.tool-one', stream: 9222, toolAnnouncedPort: 6006, toolAnnouncedPath: '/token/view', + session: 'dormouse_1_tool-one', stream: 9222, toolAnnouncedPort: 6006, toolAnnouncedPath: '/token/view', }; function engine(initial: Parameters[1] = params) { diff --git a/lib/src/components/wall/use-tool-serving.test.tsx b/lib/src/components/wall/use-tool-serving.test.tsx index f9cca20cc..615ca7b1e 100644 --- a/lib/src/components/wall/use-tool-serving.test.tsx +++ b/lib/src/components/wall/use-tool-serving.test.tsx @@ -144,7 +144,7 @@ describe('port: announced', () => { it('launches a first browser in the Tool\'s own session', async () => { recordToolAnnounce('tool-1', { port: 6006, name: null, key: null, dehydrate: false, persist: null }); const { state } = await run({ ...announced, toolRender: 'agent-browser-screencast' }, [[tcp(6006)]]); - expect(state.params).toMatchObject({ url: 'http://127.0.0.1:6006/', renderMode: 'agent-browser-screencast', launchSession: 'dormouse.1.tool.tool-1' }); + expect(state.params).toMatchObject({ url: 'http://127.0.0.1:6006/', renderMode: 'agent-browser-screencast', launchSession: 'dormouse_1_tool-tool-1' }); expect(state.params.session).toBeUndefined(); }); @@ -471,7 +471,7 @@ describe('agent-browser retirement on command exit', () => { command: 'pnpm storybook', url: 'http://127.0.0.1:6006/', renderMode: 'agent-browser-screencast', - session: 'dormouse.1.tool-1', + session: 'dormouse_1_tool-1', binaryPath: '/opt/agent-browser', }; const { state } = await run(params, [[]]); @@ -484,7 +484,7 @@ describe('agent-browser retirement on command exit', () => { // Its session is closed with its controller, from the params it had. expect(controllerMocks.closeBrowserSurface).toHaveBeenCalledExactlyOnceWith('tool-1', expect.objectContaining({ - session: 'dormouse.1.tool-1', + session: 'dormouse_1_tool-1', binaryPath: '/opt/agent-browser', })); expect(state.params.url).toBeUndefined(); @@ -497,7 +497,7 @@ describe('a preview retarget', () => { it('releases the old agent-browser session once and frames the new Tool\'s port under its own render', async () => { recordToolAnnounce('tool-1', { port: 6006, name: null, key: null, dehydrate: false, persist: null }); const { lath, state, platform } = await run({ surfaceType: 'tool', command: 'x', toolRender: 'agent-browser-screencast', toolPort: 'announced' }, [[tcp(6006)]]); - state.set({ session: 'dormouse.1.tool.tool-1' }); + state.set({ session: 'dormouse_1_tool-tool-1' }); expect(state.params).toMatchObject({ url: 'http://127.0.0.1:6006/', renderMode: 'agent-browser-screencast' }); controllerMocks.closeBrowserSurface.mockClear(); @@ -511,7 +511,7 @@ describe('a preview retarget', () => { platform.getOpenPorts = vi.fn(async () => [tcp(7007)]); await act(async () => { await vi.advanceTimersByTimeAsync(POLL_MS); }); - expect(controllerMocks.closeBrowserSurface).toHaveBeenCalledExactlyOnceWith('tool-1', expect.objectContaining({ session: 'dormouse.1.tool.tool-1' })); + expect(controllerMocks.closeBrowserSurface).toHaveBeenCalledExactlyOnceWith('tool-1', expect.objectContaining({ session: 'dormouse_1_tool-tool-1' })); expect(state.params).toMatchObject({ url: 'http://127.0.0.1:7007/', renderMode: 'iframe' }); expect(state.params.session).toBeUndefined(); expect(state.params.launchSession).toBeUndefined(); diff --git a/lib/src/host/agent-browser-host.test.ts b/lib/src/host/agent-browser-host.test.ts index 6c9ba6240..2ae19317c 100644 --- a/lib/src/host/agent-browser-host.test.ts +++ b/lib/src/host/agent-browser-host.test.ts @@ -197,10 +197,10 @@ describe('agent-browser host relaunch', () => { ]); const host = makeHost(); - const result = await ab(host, { op: 'launch', url: 'https://example.com/', headed: true }, { session: 'dormouse.1.default', binaryPath: '/usr/local/bin/agent-browser' }); + const result = await ab(host, { op: 'launch', url: 'https://example.com/', headed: true }, { session: 'dormouse_1_default', binaryPath: '/usr/local/bin/agent-browser' }); expect(result).toEqual({ - ok: true, stream: 61218, headed: true, session: 'dormouse.1.default', nativeIdentity: 'dormouse.1.default', binaryPath: '/usr/local/bin/agent-browser', + ok: true, stream: 61218, headed: true, session: 'dormouse_1_default', nativeIdentity: 'dormouse_1_default', binaryPath: '/usr/local/bin/agent-browser', }); // Last first. await vi.waitFor(() => expect(cdp.closed).toEqual(['newtab', 'blank'])); @@ -209,7 +209,7 @@ describe('agent-browser host relaunch', () => { it('pop-out returns the relaunched daemon\'s port while `open` is still waiting on the page', async () => { // The killed daemon leaves its state files behind: a dead pid and a port // nothing listens on. The relaunch must not read those as the new daemon. - const session = 'dormouse.1.default'; + const session = 'dormouse_1_default'; const stale = await closedPort(); writeState(session, 'pid', DEAD_PID); writeState(session, 'stream', stale); @@ -245,7 +245,7 @@ describe('agent-browser host relaunch', () => { }); it('does not run an earlier relaunch\'s blank-tab sweep after a later relaunch begins', async () => { - const session = 'dormouse.1.default'; + const session = 'dormouse_1_default'; const firstOpened = deferred(); const secondClose = deferred(); let closeCount = 0; @@ -282,7 +282,7 @@ describe('agent-browser host relaunch', () => { }); it('does not run a relaunch blank-tab sweep after the session is explicitly closed', async () => { - const session = 'dormouse.1.default'; + const session = 'dormouse_1_default'; const opened = deferred(); const explicitClose = deferred(); let closeCount = 0; @@ -316,7 +316,7 @@ describe('agent-browser host relaunch', () => { }); it('does not run a relaunch blank-tab sweep during host shutdown', async () => { - const session = 'dormouse.1.default'; + const session = 'dormouse_1_default'; const opened = deferred(); let closeCount = 0; const calls = mockSpawnByCommand({ @@ -364,7 +364,7 @@ describe('agent-browser host relaunch', () => { stream: () => ({ stdout: JSON.stringify({ port: 61219 }) }), }); expect(await ab(host, { op: 'launch', url: 'https://slow.example/', headed: false })).toEqual({ - ok: true, session: expect.stringMatching(/^dormouse\.1\.gui-/), nativeIdentity: session, stream: 61219, headed: false, + ok: true, session: expect.stringMatching(/^dormouse_1_gui-/), nativeIdentity: session, stream: 61219, headed: false, }); // Failed with no daemon at all: fail, and close so nothing half-launched @@ -380,7 +380,7 @@ describe('agent-browser host relaunch', () => { it('states the mode it launched a session in on every call, so a configured headed cannot flip it', async () => { const provider = createAgentBrowserProvider(); - const b = { session: 'dormouse.1.mode' }; + const b = { session: 'dormouse_1_mode' }; spawnMock.mockImplementation(async () => spawnResult({})); await provider.open(b, 'https://example.com/', true); await provider.close(b, 1000); @@ -409,7 +409,7 @@ describe('agent-browser host relaunch', () => { '--headed open': () => ({}), stream: () => ({ stdout: '{}' }), }); - expect(await ab(host, { op: 'launch', url: 'https://example.com/', headed: true }, { session: 'dormouse.1.default' })).toEqual({ + expect(await ab(host, { op: 'launch', url: 'https://example.com/', headed: true }, { session: 'dormouse_1_default' })).toEqual({ ok: false, error: 'agent-browser published no stream port', }); @@ -418,7 +418,7 @@ describe('agent-browser host relaunch', () => { describe('agent-browser host daemon stop', () => { useTempSocketDir('dormouse-ab-host-stop-'); - const session = 'dormouse.1.tool.t'; + const session = 'dormouse_1_tool-t'; const page = 'http://localhost:6006/'; it('navigates a live headless daemon a named launch reopens, stopping nothing', async () => { @@ -531,13 +531,13 @@ describe('agent-browser host launch directory', () => { it('runs a verb other than open in the neutral directory even for a binding with a project', async () => { const project = mkdtempSync(join(tmpdir(), 'dormouse-ab-project-')); enqueueSpawnResults([{}]); - await ab(makeHost(), { op: 'close' }, { session: 'dormouse.1.neutral', cwd: project }); + await ab(makeHost(), { op: 'close' }, { session: 'dormouse_1_neutral', cwd: project }); expect(spawnMock.mock.calls[0][2]).toMatchObject({ cwd: neutralBrowserCwd() }); }); }); describe('agent-browser host attach', () => { - const session = 'dormouse.1.default'; + const session = 'dormouse_1_default'; useTempSocketDir('dormouse-ab-attach-test-'); it('reads a live daemon\'s port from its state files and spawns nothing', async () => { @@ -663,21 +663,21 @@ describe('agent-browser host attach', () => { const calls = mockSpawnByCommand({ close: () => ({}), open: () => { - writeState('dormouse.1.tool.a', 'pid', DEAD_PID); - writeState('dormouse.1.tool.a', 'stream', port); + writeState('dormouse_1_tool-a', 'pid', DEAD_PID); + writeState('dormouse_1_tool-a', 'stream', port); return {}; }, stream: () => ({ stdout: JSON.stringify({ port }) }), tab: () => ({ stdout: JSON.stringify({ tabs: [] }) }), }); try { - const binding = { session: 'dormouse.1.tool.a' }; + const binding = { session: 'dormouse_1_tool-a' }; expect(await ab(host, { op: 'launch', url: 'http://localhost:5173/', headed: false }, binding)).toEqual({ - ok: true, session: 'dormouse.1.tool.a', nativeIdentity: 'dormouse.1.tool.a', stream: port, headed: false, + ok: true, session: 'dormouse_1_tool-a', nativeIdentity: 'dormouse_1_tool-a', stream: port, headed: false, }); // Whatever held the session is closed first, so the launch lands headless. - expect(calls[0]).toEqual(['--session', 'dormouse.1.tool.a', 'close']); - expect(calls).toContainEqual(['--session', 'dormouse.1.tool.a', 'open', 'http://localhost:5173/']); + expect(calls[0]).toEqual(['--session', 'dormouse_1_tool-a', 'close']); + expect(calls).toContainEqual(['--session', 'dormouse_1_tool-a', 'open', 'http://localhost:5173/']); const spawned = calls.length; expect(await ab(host, { op: 'launch', url: 'http://localhost:5173/', headed: false }, { session: '../evil' })).toEqual({ ok: false, error: 'a valid session name is required' }); expect(calls).toHaveLength(spawned); @@ -688,7 +688,7 @@ describe('agent-browser host attach', () => { }); describe('agent-browser host viewer', () => { - const session = 'dormouse.1.default'; + const session = 'dormouse_1_default'; useTempSocketDir('dormouse-ab-view-test-'); const hosts: Host[] = []; const servers: WebSocketServer[] = []; @@ -1224,7 +1224,7 @@ describe('agent-browser host viewer', () => { describe('agent-browser host captures', () => { useTempSocketDir('dormouse-ab-shot-test-'); - const b = { session: 'dormouse.1.default', binaryPath: '/usr/local/bin/agent-browser' }; + const b = { session: 'dormouse_1_default', binaryPath: '/usr/local/bin/agent-browser' }; beforeEach(() => { running(b.session); }); // Stand in for agent-browser writing the frame where it is told, once // `release` lets it: each capture writes the next byte. @@ -1353,7 +1353,7 @@ describe('agent-browser host binary', () => { // `parseBrowserRequest` in browser-host.ts says why every field is checked. describe('agent-browser host requests', () => { useTempSocketDir('dormouse-ab-argv-test-'); - const session = { session: 'dormouse.1.gui-abc' }; + const session = { session: 'dormouse_1_gui-abc' }; beforeEach(() => { running(session.session); }); it('renders each operation to exactly one fixed argv', async () => { @@ -1374,7 +1374,7 @@ describe('agent-browser host requests', () => { spawnMock.mockReset(); enqueueSpawnResults([{}]); expect(await ab(host, op, session)).toEqual({ ok: true }); - expect(spawnMock.mock.calls[0][1]).toEqual(['--session', 'dormouse.1.gui-abc', ...argv]); + expect(spawnMock.mock.calls[0][1]).toEqual(['--session', 'dormouse_1_gui-abc', ...argv]); } }); @@ -1456,8 +1456,8 @@ describe('agent-browser host requests', () => { close: () => ({}), '--headed open': () => ({ code: 1, stderr: 'boom' }), }); - await ab(host, { op: 'launch', url: '--executable-path=/tmp/evil', headed: true }, { session: 'dormouse.1.default' }); - expect(calls).toContainEqual(['--session', 'dormouse.1.default', '--headed', 'open', 'about:blank']); + await ab(host, { op: 'launch', url: '--executable-path=/tmp/evil', headed: true }, { session: 'dormouse_1_default' }); + expect(calls).toContainEqual(['--session', 'dormouse_1_default', '--headed', 'open', 'about:blank']); expect(calls.flat()).not.toContain('--executable-path=/tmp/evil'); }); }); diff --git a/lib/src/host/browser-host.test.ts b/lib/src/host/browser-host.test.ts index 517f8e421..60ea61a0a 100644 --- a/lib/src/host/browser-host.test.ts +++ b/lib/src/host/browser-host.test.ts @@ -103,25 +103,25 @@ describe('createBrowserHost', () => { it('finishes a close of a session before a launch into it begins', async () => { const fake = fakeProvider(); const host = createBrowserHost({ writeClipboardText: vi.fn(), providers: { 'agent-browser': () => fake.provider } }); - const session = { session: 'dormouse.1.default' }; - fake.gate('close dormouse.1.default'); + const session = { session: 'dormouse_1_default' }; + fake.gate('close dormouse_1_default'); const closing = host.request({ provider: 'agent-browser', binding: session, op: 'close' }); // A failed swap reopening the browser it had just closed. const launching = host.request({ provider: 'agent-browser', binding: session, op: 'launch', url: 'http://localhost:5173/', headed: false }); await flush(); - expect(fake.calls).toEqual(['close dormouse.1.default']); - fake.release('close dormouse.1.default'); + expect(fake.calls).toEqual(['close dormouse_1_default']); + fake.release('close dormouse_1_default'); expect(await closing).toEqual({ ok: true }); - expect(await launching).toMatchObject({ ok: true, session: 'dormouse.1.default', stream: 4321 }); - expect(fake.calls).toEqual(['close dormouse.1.default', 'stop dormouse.1.default', 'open dormouse.1.default http://localhost:5173/']); + expect(await launching).toMatchObject({ ok: true, session: 'dormouse_1_default', stream: 4321 }); + expect(fake.calls).toEqual(['close dormouse_1_default', 'stop dormouse_1_default', 'open dormouse_1_default http://localhost:5173/']); }); it('closes a browser after the launch of it still running, superseding one sent before the close that has not begun', async () => { const fake = fakeProvider(); const host = createBrowserHost({ writeClipboardText: vi.fn(), providers: { 'agent-browser': () => fake.provider } }); - const tool = { provider: 'agent-browser', binding: { session: 'dormouse.1.tool.t' } } as const; + const tool = { provider: 'agent-browser', binding: { session: 'dormouse_1_tool-t' } } as const; const launch = { ...tool, op: 'launch', url: 'http://localhost:6006/', headed: false } as const; - fake.gate('stop dormouse.1.tool.t'); + fake.gate('stop dormouse_1_tool-t'); // A Tool's browser still coming up when its Surface closes; the next // Surface to launch the name is closed too before its turn comes, and a // third launches it after both closes. @@ -131,15 +131,15 @@ describe('createBrowserHost', () => { const superseded = host.request(launch); closes.push(host.request({ ...tool, op: 'close' })); const third = host.request(launch); - fake.release('stop dormouse.1.tool.t'); + fake.release('stop dormouse_1_tool-t'); expect(await first).toMatchObject({ ok: true, stream: 4321 }); expect(await superseded).toEqual({ ok: false, error: 'the browser was closed' }); expect(await Promise.all(closes)).toEqual([{ ok: true }, { ok: true }]); expect(await third).toMatchObject({ ok: true, stream: 4321 }); expect(fake.calls).toEqual([ - 'stop dormouse.1.tool.t', 'open dormouse.1.tool.t http://localhost:6006/', - 'close dormouse.1.tool.t', 'close dormouse.1.tool.t', - 'stop dormouse.1.tool.t', 'open dormouse.1.tool.t http://localhost:6006/', + 'stop dormouse_1_tool-t', 'open dormouse_1_tool-t http://localhost:6006/', + 'close dormouse_1_tool-t', 'close dormouse_1_tool-t', + 'stop dormouse_1_tool-t', 'open dormouse_1_tool-t http://localhost:6006/', ]); }); diff --git a/lib/src/lib/session-save.test.ts b/lib/src/lib/session-save.test.ts index b63bad5cc..731278a3e 100644 --- a/lib/src/lib/session-save.test.ts +++ b/lib/src/lib/session-save.test.ts @@ -247,7 +247,7 @@ describe('saveSession', () => { toolKey: ['storybook', '/repo'], // Derived state must stay in the Lath projection, never this row. url: 'http://localhost:6006/', - session: 'dormouse.1.tool', + session: 'dormouse_1_tool', }, }]);