mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-17 18:32:19 +02:00
fix(extension): delete the dead chat-queue client surface
The sidebar-command handler in background.js POSTed to a server endpoint that no longer exists (deleted with the chat queue) — ~35 lines of fully-wired dead code including error handling for the permanent 404, plus its allowlist entry. No sender in the extension ever emitted the message type. chatEnabled leaves the /health contract (server hardcoded false, background.js re-derived it, nothing consumed it — the chat input element it guarded is gone from sidepanel.html). BROWSE_SIDEBAR_CHAT env flag had zero readers. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
ef03646e07
commit
44d58aa6ee
@@ -1085,7 +1085,6 @@ Refs: After 'snapshot', use @e1, @e2... as selectors:
|
|||||||
const serverEnv: Record<string, string> = {
|
const serverEnv: Record<string, string> = {
|
||||||
BROWSE_HEADED: '1',
|
BROWSE_HEADED: '1',
|
||||||
BROWSE_PORT: '34567',
|
BROWSE_PORT: '34567',
|
||||||
BROWSE_SIDEBAR_CHAT: '1',
|
|
||||||
// Disable parent-process watchdog: the user controls the headed browser
|
// Disable parent-process watchdog: the user controls the headed browser
|
||||||
// window lifecycle. The CLI exits immediately after connect, so watching
|
// window lifecycle. The CLI exits immediately after connect, so watching
|
||||||
// it would kill the server ~15s later. Cleanup happens via browser
|
// it would kill the server ~15s later. Cleanup happens via browser
|
||||||
|
|||||||
@@ -1832,10 +1832,6 @@ export function buildFetchHandler(cfg: ServerConfig): ServerHandle {
|
|||||||
mode: browserManager.getConnectionMode(),
|
mode: browserManager.getConnectionMode(),
|
||||||
uptime: Math.floor((Date.now() - startTime) / 1000),
|
uptime: Math.floor((Date.now() - startTime) / 1000),
|
||||||
tabs: browserManager.getTabCount(),
|
tabs: browserManager.getTabCount(),
|
||||||
// The chat queue is gone — Terminal pane is the sole sidebar
|
|
||||||
// surface. Keep `chatEnabled: false` so any older extension
|
|
||||||
// build still treats the chat input as disabled.
|
|
||||||
chatEnabled: false,
|
|
||||||
// Security module status — drives the shield icon in the sidepanel.
|
// Security module status — drives the shield icon in the sidepanel.
|
||||||
// Returns {status: 'protected'|'degraded'|'inactive', layers: {...}}.
|
// Returns {status: 'protected'|'degraded'|'inactive', layers: {...}}.
|
||||||
// The chat-path classifier no longer feeds this since
|
// The chat-path classifier no longer feeds this since
|
||||||
|
|||||||
@@ -205,8 +205,9 @@ describe('server.ts: chat / sidebar-agent endpoints are gone', () => {
|
|||||||
expect(slice).not.toContain('agentStatus');
|
expect(slice).not.toContain('agentStatus');
|
||||||
expect(slice).not.toContain('messageQueue');
|
expect(slice).not.toContain('messageQueue');
|
||||||
expect(slice).not.toContain('agentStartTime');
|
expect(slice).not.toContain('agentStartTime');
|
||||||
// chatEnabled is hardcoded false now (older clients still see the field).
|
// chatEnabled is gone entirely — the chat pane no longer exists in any
|
||||||
expect(slice).toMatch(/chatEnabled:\s*false/);
|
// extension build, so /health stopped advertising a chat mode.
|
||||||
|
expect(slice).not.toContain('chatEnabled');
|
||||||
// terminalPort survives.
|
// terminalPort survives.
|
||||||
expect(slice).toContain('terminalPort');
|
expect(slice).toContain('terminalPort');
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-38
@@ -81,8 +81,7 @@ async function checkHealth() {
|
|||||||
// already flips to disconnected on a 403.
|
// already flips to disconnected on a 403.
|
||||||
const gotToken = await loadAuthToken();
|
const gotToken = await loadAuthToken();
|
||||||
if (!gotToken && !authToken) return;
|
if (!gotToken && !authToken) return;
|
||||||
// Forward chatEnabled so sidepanel can show/hide chat tab
|
setConnected(data);
|
||||||
setConnected({ ...data, chatEnabled: !!data.chatEnabled });
|
|
||||||
} else {
|
} else {
|
||||||
setDisconnected();
|
setDisconnected();
|
||||||
}
|
}
|
||||||
@@ -297,7 +296,7 @@ chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
|
|||||||
|
|
||||||
const ALLOWED_TYPES = new Set([
|
const ALLOWED_TYPES = new Set([
|
||||||
'getPort', 'setPort', 'getServerUrl', 'getToken', 'fetchRefs',
|
'getPort', 'setPort', 'getServerUrl', 'getToken', 'fetchRefs',
|
||||||
'openSidePanel', 'sidebarOpened', 'command', 'sidebar-command',
|
'openSidePanel', 'sidebarOpened', 'command',
|
||||||
'getTabState',
|
'getTabState',
|
||||||
// Inspector message types
|
// Inspector message types
|
||||||
'startInspector', 'stopInspector', 'elementPicked', 'pickerCancelled',
|
'startInspector', 'stopInspector', 'elementPicked', 'pickerCancelled',
|
||||||
@@ -447,41 +446,6 @@ chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sidebar → Claude Code (file-based message queue)
|
|
||||||
if (msg.type === 'sidebar-command') {
|
|
||||||
const base = getBaseUrl();
|
|
||||||
if (!base || !authToken) {
|
|
||||||
sendResponse({ error: 'Not connected' });
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// Capture the active tab's URL so the sidebar agent knows what page
|
|
||||||
// the user is actually looking at (Playwright's page.url() can be stale
|
|
||||||
// if the user navigated manually in headed mode).
|
|
||||||
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
|
|
||||||
const activeTabUrl = tabs?.[0]?.url || null;
|
|
||||||
fetch(`${base}/sidebar-command`, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Authorization': `Bearer ${authToken}`,
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ message: msg.message, activeTabUrl }),
|
|
||||||
})
|
|
||||||
.then(r => {
|
|
||||||
if (!r.ok) {
|
|
||||||
console.error(`[gstack bg] sidebar-command failed: ${r.status} ${r.statusText}`);
|
|
||||||
return r.json().catch(() => ({ error: `Server returned ${r.status}` }));
|
|
||||||
}
|
|
||||||
return r.json();
|
|
||||||
})
|
|
||||||
.then(data => sendResponse(data))
|
|
||||||
.catch(err => {
|
|
||||||
console.error('[gstack bg] sidebar-command error:', err.message);
|
|
||||||
sendResponse({ error: err.message });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// ─── Side Panel ─────────────────────────────────────────────────
|
// ─── Side Panel ─────────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user