MCPcopy Create free account
hub / github.com/garrytan/gstack / updateConnection

Function updateConnection

extension/sidepanel.js:1159–1197  ·  view source on GitHub ↗
(url, token)

Source from the content-addressed store, hash-verified

1157}
1158
1159function updateConnection(url, token) {
1160 const wasConnected = !!serverUrl;
1161 serverUrl = url;
1162 serverToken = token || null;
1163 // Expose for sidepanel-terminal.js (PTY surface). The terminal pane needs
1164 // the bootstrap token to POST /pty-session and the port to derive the WS
1165 // URL. We never expose the PTY token — it lives in an HttpOnly cookie.
1166 if (url) {
1167 try { window.gstackServerPort = parseInt(new URL(url).port, 10); } catch {}
1168 window.gstackAuthToken = token || null;
1169 } else {
1170 window.gstackServerPort = null;
1171 window.gstackAuthToken = null;
1172 }
1173 if (url) {
1174 document.getElementById('footer-dot').className = 'dot connected';
1175 const port = new URL(url).port;
1176 document.getElementById('footer-port').textContent = `:${port}`;
1177 setConnState('connected');
1178 setActionButtonsEnabled(true);
1179 // Tell the active tab's content script the sidebar is open — this hides
1180 // the welcome page arrow hint. Only fires on actual sidebar connection.
1181 chrome.runtime.sendMessage({ type: 'sidebarOpened' }).catch(() => {});
1182 connectSSE();
1183 connectInspectorSSE();
1184 startMemPolling();
1185 } else {
1186 document.getElementById('footer-dot').className = 'dot';
1187 document.getElementById('footer-port').textContent = '';
1188 const memEl = document.getElementById('footer-mem');
1189 if (memEl) {
1190 memEl.textContent = '';
1191 memEl.classList.remove('warn', 'bad');
1192 }
1193 stopMemPolling();
1194 setActionButtonsEnabled(false);
1195 if (wasConnected) startReconnect();
1196 }
1197}
1198
1199// ─── Port Configuration ─────────────────────────────────────────
1200

Callers 2

tryConnectFunction · 0.85
sidepanel.jsFile · 0.85

Calls 7

setConnStateFunction · 0.85
setActionButtonsEnabledFunction · 0.85
connectSSEFunction · 0.85
connectInspectorSSEFunction · 0.85
startMemPollingFunction · 0.85
stopMemPollingFunction · 0.85
startReconnectFunction · 0.85

Tested by

no test coverage detected