diff options
| author | Igor Soarez <igor@soarez.org> | 2026-11-08 17:11:15 +0000 |
|---|---|---|
| committer | Igor Soarez <igor@soarez.org> | 2026-11-08 17:11:15 +0000 |
| commit | b8b63ea4d1bad9c4bbac6b05b03cce5f2cfa3f94 (patch) | |
| tree | 255a0979c1d590ea759e27980ca3d9d655b690f5 /test-suite/unit/background-policy.test.mjs | |
| parent | b5f7a9eb2cf46867085b46514d6c9faf0d552fad (diff) | |
tabs: back to one window per session; keep new tabs out of the user's window
A window shows only one tab, so sessions sharing one hid each other's tabs: no
real input and blank screenshots for every session but the one whose tab was
active (castle-pirc-web, 2026-11-08). Time-sharing the active tab would flip tabs
under the user while they sign in for an agent, so revert 66fbd30: a session
gets its own unfocused window. Kept: chrome_tab new for a session with no window
opens one for it instead of landing in the user's focused window. The primer
and chrome_tab description now say why to reuse a tab.
Diffstat (limited to 'test-suite/unit/background-policy.test.mjs')
| -rw-r--r-- | test-suite/unit/background-policy.test.mjs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/test-suite/unit/background-policy.test.mjs b/test-suite/unit/background-policy.test.mjs index efbca78..ea08be0 100644 --- a/test-suite/unit/background-policy.test.mjs +++ b/test-suite/unit/background-policy.test.mjs @@ -297,6 +297,14 @@ function workerHarness({ withWindows = true } = {}) { }; return h; } +// A new Pi tab must not take over the user's window: it is either inactive, or the only tab of a +// new, unfocused window of the session's own (so it is visible to the agent without stealing focus). +function assertNewTabStaysOutOfTheWay(h, tab) { + if (tab.active === false) return; + assert.notEqual(tab.windowId, 1, "an active new tab must not be in the user's window"); + assert.ok(h.calls.some((c) => c.action === "windows.create" && c.params.focused === false), "its window was created unfocused"); +} + function assertNoFocus(h) { assert.equal(h.focusedWindow(), 1); assert.equal(h.tabs.get(1).active, true); @@ -325,7 +333,7 @@ test("worker advertises support, keeps new tabs inactive, and rejects activation assert.equal((await h.w.dispatch("tab.version", {})).capabilities.hardBackground, true); for (const flags of [{}, { foreground: false }, { background: true, foreground: true }]) { const result = await h.w.dispatch("tab.new", { ...flags, sessionKey: "alpha", groupTitle: "Pi Session: alpha" }); - assert.equal(result.tab.active, false); + assertNewTabStaysOutOfTheWay(h, result.tab); await assert.rejects(h.w.dispatch("tab.activate", { ...flags, targetId: "missing" }), /background mode/); } assertNoFocus(h); @@ -339,7 +347,7 @@ test("worker advertises support, keeps new tabs inactive, and rejects activation test("background-only worker aliases force safe behavior even with foreground flags", async () => { const h = workerHarness(); const opened = await h.w.dispatch("tab.new.background", { foreground: true, background: false }); - assert.equal(opened.tab.active, false); + assertNewTabStaysOutOfTheWay(h, opened.tab); const shot = await h.w.dispatch("page.screenshot.background", { targetId: "2", foreground: true, background: false }); assert.equal(shot.method, "cdp"); assertNoFocus(h); |
