fix(browser): opening a session ignores ones another process already closed

The worker's adapter still held a session the api process had closed,
so browser.navigate {siteId} from an agent run failed with "该站点/账号
已有未关闭的浏览器会话" (REAL-2 task 4). When the database has no live
session for the profile, stale in-memory ones are marked closed before
opening. Needs image rebuild.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-09-29 03:15:46 +08:00
1 parent e53d05a872
commit c115676e23
2 files changed
+9 -1

No files matched your search

+6 -1
View File
@@ -354,7 +354,7 @@ describe.skipIf(!hasPg)("E14 视觉自动化闭环", () => {
for (const l of ledger) expect((l.output as Any).modelImage).toBeNull();
}, 90_000);
it("另一个进程(api)在标签页被回收后重开,本进程(worker)按数据库换到新标签页", async () => {
it("多进程:api 重开被回收的标签页后 worker 换到新标签页;api 关闭会话后 worker 能重新打开", async () => {
await open(ids.site, ids.provider, `${ORIGIN}/torrents.php`);
const worker = new BrowserService(e.booted.ctx, svc.opts);
const auto = { kind: "automation", holder: "agent:e14" } as const;
@@ -368,5 +368,10 @@ describe.skipIf(!hasPg)("E14 视觉自动化闭环", () => {
);
expect((await svc.view(sid)).currentTabId).not.toBe(old);
await expect(snap(worker)).resolves.toMatchObject({ url: expect.stringContaining("/torrents.php") });
// api 关闭会话后,worker 能按站点重新打开(不被内存里的旧会话挡住)
await svc.close(sid);
const again = await worker.open({ siteId: ids.site, providerId: ids.provider, url: `${ORIGIN}/torrents.php` });
expect(again).not.toBe(sid);
await worker.close(again);
}, 60_000);
});