diff --git a/.gitignore b/.gitignore index 981f4bc3..7acf00f1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .worktrees/ .private-journal/ .claude/ +.superpowers/ .DS_Store node_modules/ inspo diff --git a/skills/brainstorming/scripts/helper.js b/skills/brainstorming/scripts/helper.js index 41a3aa61..0d8098ad 100644 --- a/skills/brainstorming/scripts/helper.js +++ b/skills/brainstorming/scripts/helper.js @@ -14,7 +14,6 @@ // Everything below is browser-only; bail out when loaded in Node (tests). if (typeof window === 'undefined') return; - const WS_URL = 'ws://' + window.location.host; let ws = null; let eventQueue = []; let reconnectDelay = MIN_RECONNECT_MS; @@ -23,6 +22,27 @@ let everConnected = false; let tombstoneShown = false; + function sessionKey() { + try { + return window.sessionStorage && window.sessionStorage.getItem('brainstorm-session-key'); + } catch (e) {} + return null; + } + + function websocketUrl() { + const key = sessionKey(); + return 'ws://' + window.location.host + (key ? '/?key=' + encodeURIComponent(key) : ''); + } + + function reloadAfterRecovery() { + const key = sessionKey(); + if (key) { + window.location.replace('/?key=' + encodeURIComponent(key)); + } else { + window.location.reload(); + } + } + // Reflect connection state in the frame's status pill (absent on full-doc screens). function setStatus(state) { const el = document.querySelector('.status'); @@ -57,7 +77,7 @@ function connect() { if (reconnectTimer) { clearTimeout(reconnectTimer); reconnectTimer = null; } setStatus(everConnected ? 'reconnecting' : 'connecting'); - ws = new WebSocket(WS_URL); + ws = new WebSocket(websocketUrl()); ws.onopen = () => { const recovered = tombstoneShown; @@ -69,8 +89,9 @@ eventQueue.forEach(e => ws.send(JSON.stringify(e))); eventQueue = []; // Recovered from a tombstoned outage (e.g. the server restarted on the same - // port) — reload to pick up the restarted server's current screen. - if (recovered) window.location.reload(); + // port) — reload through the keyed bootstrap when possible so the cookie is + // refreshed before the visible URL returns to bare /. + if (recovered) reloadAfterRecovery(); }; ws.onmessage = (msg) => { diff --git a/skills/brainstorming/scripts/server.cjs b/skills/brainstorming/scripts/server.cjs index 86024f05..8728cc38 100644 --- a/skills/brainstorming/scripts/server.cjs +++ b/skills/brainstorming/scripts/server.cjs @@ -152,6 +152,20 @@ h1 { color: #333; } p { color: #666; } code { background: #f0f0f0; padding: 0.1e
This page needs the full URL your coding agent gave you, including the
?key=… part. Copy the complete URL and open it again.