Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions skills/brainstorming/scripts/frame-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
flex-shrink: 0;
}
.header h1 { font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); }
.header .status { font-size: 0.7rem; color: var(--success); display: flex; align-items: center; gap: 0.4rem; }
.header .status::before { content: ''; width: 6px; height: 6px; background: var(--success); border-radius: 50%; }
.header .status { font-size: 0.7rem; color: var(--success); display: flex; align-items: center; gap: 0.4rem; --status-color: var(--success); }
.header .status::before { content: ''; width: 6px; height: 6px; background: var(--status-color); border-radius: 50%; }

.main { flex: 1; overflow-y: auto; }
#claude-content { padding: 2rem; min-height: 100%; }
Expand Down
36 changes: 30 additions & 6 deletions skills/brainstorming/scripts/helper.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,49 @@
(function() {
const WS_URL = 'ws://' + window.location.host;
const BACKOFF_INITIAL = 500;
const BACKOFF_MAX = 30000;

let ws = null;
let eventQueue = [];
let backoff = BACKOFF_INITIAL;
let reconnectTimer = null;

function setStatus(state) {
var el = document.querySelector('.header .status');
if (!el) return;
var labels = { connected: 'Connected', reconnecting: 'Reconnecting\u2026', disconnected: 'Disconnected' };
var colors = { connected: 'var(--success)', reconnecting: 'var(--warning)', disconnected: 'var(--error)' };
el.textContent = labels[state] || state;
el.style.color = colors[state] || '';
el.style.setProperty('--status-color', colors[state] || 'var(--success)');
}

function connect() {
if (reconnectTimer) { clearTimeout(reconnectTimer); reconnectTimer = null; }
setStatus('reconnecting');
ws = new WebSocket(WS_URL);

ws.onopen = () => {
eventQueue.forEach(e => ws.send(JSON.stringify(e)));
ws.onopen = function() {
backoff = BACKOFF_INITIAL;
setStatus('connected');
eventQueue.forEach(function(e) { ws.send(JSON.stringify(e)); });
eventQueue = [];
};

ws.onmessage = (msg) => {
const data = JSON.parse(msg.data);
ws.onmessage = function(msg) {
var data = JSON.parse(msg.data);
if (data.type === 'reload') {
window.location.reload();
}
};

ws.onclose = () => {
setTimeout(connect, 1000);
ws.onclose = function() {
ws = null;
setStatus('reconnecting');
reconnectTimer = setTimeout(function() {
backoff = Math.min(backoff * 2, BACKOFF_MAX);
connect();
}, backoff);
};
}

Expand Down