fix(extension): claim agent tabs explicitly

This commit is contained in:
drakezhang
2026-09-04 11:17:05 +08:00
parent a77353bce8
commit 0dc11b30ea
17 changed files with 187 additions and 263 deletions
@@ -302,7 +302,7 @@ describe("handleSessionStop window release (issue #57)", () => {
ctx.agentCreatedTabs.add(11);
ctx.agentCreatedTabs.add(12);
// home tab id from ensureActiveTab override
ctx.homeTabId = 10;
ctx.agentCreatedTabs.add(10); // home tab
// user tab 99 (created via Chrome UI, NOT in agentCreatedTabs)
const state: FakeState = {
tabs: new Map([
@@ -340,7 +340,7 @@ describe("handleSessionStop window release (issue #57)", () => {
const sm = new SessionManager({ agentWindow: aw });
const ctx = await sm.start("aa11");
ctx.agentCreatedTabs.add(11);
ctx.homeTabId = 10;
ctx.agentCreatedTabs.add(10); // home tab
const state: FakeState = {
tabs: new Map([
[10, { id: 10, windowId: agentWindowId } as chrome.tabs.Tab],
@@ -369,7 +369,7 @@ describe("handleSessionStop window release (issue #57)", () => {
const sm = new SessionManager({ agentWindow: aw });
const ctx = await sm.start("aa11");
ctx.agentCreatedTabs.add(11); // no longer in state → remove throws
ctx.homeTabId = 10;
ctx.agentCreatedTabs.add(10); // home tab
const state: FakeState = {
tabs: new Map([[10, { id: 10, windowId: agentWindowId } as chrome.tabs.Tab]]),
windowsClosed: new Set(),
@@ -399,7 +399,7 @@ describe("handleSessionStop window release (issue #57)", () => {
const sm = new SessionManager({ agentWindow: aw });
const ctx = await sm.start("aa11");
ctx.agentCreatedTabs.add(11);
ctx.homeTabId = 10;
ctx.agentCreatedTabs.add(10); // home tab
const state: FakeState = {
tabs: new Map([
[10, { id: 10, windowId: agentWindowId } as chrome.tabs.Tab],
@@ -427,7 +427,7 @@ describe("handleSessionStop window release (issue #57)", () => {
const sm = new SessionManager({ agentWindow: aw });
const ctx = await sm.start("aa11");
ctx.agentCreatedTabs.add(11);
ctx.homeTabId = 10;
ctx.agentCreatedTabs.add(10); // home tab
const state: FakeState = {
tabs: new Map([[11, { id: 11, windowId: agentWindowId } as chrome.tabs.Tab]]),
windowsClosed: new Set(),
@@ -473,7 +473,7 @@ describe("handleSessionStop window release (issue #57)", () => {
const sm = new SessionManager({ agentWindow: aw });
const ctx = await sm.start("aa11");
ctx.agentCreatedTabs.add(11); // Step 4 remove() will throw for this tab
ctx.homeTabId = 10;
ctx.agentCreatedTabs.add(10); // home tab
const state: FakeState = {
tabs: new Map([
[10, { id: 10, windowId: agentWindowId } as chrome.tabs.Tab],