mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-21 20:28:24 +08:00
feat: auto-open sidebar on every browser launch, not just first install
- Add top-level setTimeout in background.js that fires on every service worker startup (onInstalled only fires on install/update) - Remove misaligned arrow from welcome page, replace with text fallback that hides when extension content script fires gstack-extension-ready
This commit is contained in:
@@ -406,9 +406,10 @@ if (chrome.sidePanel && chrome.sidePanel.setPanelBehavior) {
|
|||||||
chrome.sidePanel.setPanelBehavior({ openPanelOnActionClick: true }).catch(() => {});
|
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 () => {
|
chrome.runtime.onInstalled.addListener(async () => {
|
||||||
// Small delay to let the browser window fully initialize
|
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
try {
|
try {
|
||||||
const [win] = await chrome.windows.getAll({ windowTypes: ['normal'] });
|
const [win] = await chrome.windows.getAll({ windowTypes: ['normal'] });
|
||||||
@@ -419,6 +420,16 @@ chrome.runtime.onInstalled.addListener(async () => {
|
|||||||
}, 1000);
|
}, 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 ────────────────────────────────────────
|
// ─── Tab Switch Detection ────────────────────────────────────────
|
||||||
// Notify sidepanel instantly when the user switches tabs in the browser.
|
// Notify sidepanel instantly when the user switches tabs in the browser.
|
||||||
// This is faster than polling — the sidebar swaps chat context immediately.
|
// This is faster than polling — the sidebar swaps chat context immediately.
|
||||||
|
|||||||
Reference in New Issue
Block a user