fix: sidebar arrow hint stays visible until sidebar actually opens

Previously the welcome page arrow hid immediately when the extension's
content script loaded — but extension loaded ≠ sidebar open. Now the
signal flow is: sidepanel connects → tells background.js → relays to
content script → dispatches gstack-extension-ready → arrow hides.

Adds welcome-page.test.ts: 14 tests verifying arrow, branding, feature
cards, dark theme, and auto-hide behavior via real HTTP server.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-04-04 07:13:12 -07:00
parent 41dccfd25e
commit 43dba47237
5 changed files with 172 additions and 18 deletions

View File

@@ -286,7 +286,7 @@ chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
const ALLOWED_TYPES = new Set([
'getPort', 'setPort', 'getServerUrl', 'fetchRefs',
'openSidePanel', 'command', 'sidebar-command',
'openSidePanel', 'sidebarOpened', 'command', 'sidebar-command',
// Inspector message types
'startInspector', 'stopInspector', 'elementPicked', 'pickerCancelled',
'applyStyle', 'toggleClass', 'injectCSS', 'resetAll',
@@ -332,6 +332,20 @@ chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
return;
}
// Sidebar opened — tell active tab's content script so the welcome page
// can hide its arrow hint. Only fires when the sidebar actually connects.
if (msg.type === 'sidebarOpened') {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
const tabId = tabs?.[0]?.id;
if (tabId) {
chrome.tabs.sendMessage(tabId, { type: 'sidebarOpened' }).catch(() => {
// Expected: tab may not have content script
});
}
});
return;
}
// Inspector: inject + start picker
if (msg.type === 'startInspector') {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {

View File

@@ -326,11 +326,18 @@ function startBasicPicker() {
document.addEventListener('keydown', onBasicKeydown, true);
}
// Notify the page that the gstack extension is active (used by welcome page)
document.dispatchEvent(new CustomEvent('gstack-extension-ready'));
// Do NOT dispatch gstack-extension-ready here — the extension being loaded
// does not mean the sidebar is open. The welcome page arrow hint should only
// hide when the sidebar is actually open. We dispatch it when we receive
// a 'sidebarOpened' message from background.js.
// Listen for messages from background worker
chrome.runtime.onMessage.addListener((msg) => {
// Sidebar actually opened — now hide the welcome page arrow hint
if (msg.type === 'sidebarOpened') {
document.dispatchEvent(new CustomEvent('gstack-extension-ready'));
return;
}
if (msg.type === 'startBasicPicker') {
startBasicPicker();
return;

View File

@@ -1352,6 +1352,9 @@ function updateConnection(url, token) {
document.getElementById('footer-port').textContent = `:${port}`;
setConnState('connected');
setActionButtonsEnabled(true);
// Tell the active tab's content script the sidebar is open — this hides
// the welcome page arrow hint. Only fires on actual sidebar connection.
chrome.runtime.sendMessage({ type: 'sidebarOpened' }).catch(() => {});
connectSSE();
connectInspectorSSE();
if (chatPollInterval) clearInterval(chatPollInterval);