mirror of
https://github.com/Tencent/BrowserSkill.git
synced 2026-09-10 13:01:23 +08:00
fix(extension): classify the home tab by id, not a racy boot flag (issue #57)
SessionManager.classifyNewTab's `initializing` branch relied on a windowInitializing flag that start() cleared *before* the home tab's chrome.tabs.onCreated event was dispatched (the event is asynchronous), so the branch never ran in production and the home tab's classification was subject to a timing race. Match the home tab by its tab id instead — the id is already returned by ensureActiveTab and is reliable regardless of event ordering. Also refresh the overlay-bridge docstring: overlay.ready now makes the background *push* the per-tab overlay state (and the Agent Window also pushes on tab create / control-mode change), rather than a request/reply.
This commit is contained in:
@@ -175,10 +175,11 @@ export default defineBackground(() => {
|
||||
if (typeof tab.windowId !== "number") return;
|
||||
pushOverlayStateForAgentWindow(tab.windowId);
|
||||
});
|
||||
// A new tab inside an Agent Window is either agent-created (via
|
||||
// tool.tab_create, flagged by the pending count) or user-created (via
|
||||
// Chrome UI). Classify it so user-opened tabs are kept free and can be
|
||||
// pushed a hidden overlay immediately. See SessionManager.classifyNewTab.
|
||||
// A new tab inside an Agent Window is agent-owned (the home tab, matched by
|
||||
// homeTabId, or a tool.tab_create flagged by the pending count) or
|
||||
// user-created (via Chrome UI). Classify it so user-opened tabs are kept
|
||||
// free and can be pushed a hidden overlay immediately. See
|
||||
// SessionManager.classifyNewTab.
|
||||
chrome.tabs.onCreated.addListener((tab) => {
|
||||
if (typeof tab.windowId !== "number" || typeof tab.id !== "number") return;
|
||||
const kind = sessions.classifyNewTab(tab.id, tab.windowId);
|
||||
@@ -190,7 +191,7 @@ export default defineBackground(() => {
|
||||
mode: "hidden",
|
||||
generation: overlayGeneration,
|
||||
});
|
||||
} else if (kind === "agent" || kind === "initializing") {
|
||||
} else if (kind === "agent") {
|
||||
// Agent tab (or home tab): make sure it reflects the session's
|
||||
// current control mode.
|
||||
void pushOverlayStateForAgentWindow(tab.windowId);
|
||||
|
||||
Reference in New Issue
Block a user