diff --git a/extension/background.js b/extension/background.js index c7020b68..75503b43 100644 --- a/extension/background.js +++ b/extension/background.js @@ -406,9 +406,10 @@ if (chrome.sidePanel && chrome.sidePanel.setPanelBehavior) { chrome.sidePanel.setPanelBehavior({ openPanelOnActionClick: true }).catch(() => {}); } -// Auto-open side panel on install/update — zero friction +// Auto-open side panel on install/update AND every service worker startup. +// onInstalled fires on first install / extension update. +// The startup block below fires every time the browser launches (persistent context reuse). chrome.runtime.onInstalled.addListener(async () => { - // Small delay to let the browser window fully initialize setTimeout(async () => { try { const [win] = await chrome.windows.getAll({ windowTypes: ['normal'] }); @@ -419,6 +420,16 @@ chrome.runtime.onInstalled.addListener(async () => { }, 1000); }); +// Also auto-open on every browser launch (not just install) +setTimeout(async () => { + try { + const [win] = await chrome.windows.getAll({ windowTypes: ['normal'] }); + if (win && chrome.sidePanel?.open) { + await chrome.sidePanel.open({ windowId: win.id }); + } + } catch {} +}, 1500); + // ─── Tab Switch Detection ──────────────────────────────────────── // Notify sidepanel instantly when the user switches tabs in the browser. // This is faster than polling — the sidebar swaps chat context immediately.