Add exponential backoff and status indicator to brainstorm WebSocket client#856
Add exponential backoff and status indicator to brainstorm WebSocket client#856chuanghiduoc wants to merge 2 commits intoobra:mainfrom
Conversation
…client helper.js reconnected with a fixed 1-second delay and gave no visual feedback when disconnected. If the connection dropped (e.g., laptop sleep, server restart), users had no indication and had to manually refresh. Changes: - Exponential backoff: 500ms → 1s → 2s → ... → 30s cap, resets on success - Status indicator: header dot updates color and text for Connected (green), Reconnecting (yellow), Disconnected (red) - onerror handler prevents duplicate reconnect attempts - Null-ify ws reference on close to avoid sends on dead socket - frame-template.html: status dot color now uses CSS custom property so JavaScript can update it dynamically
There was a problem hiding this comment.
Pull request overview
Improves the brainstorm companion frame’s WebSocket resilience and user feedback by adding exponential reconnection backoff and a UI connection status indicator.
Changes:
- Add exponential backoff reconnect logic to the WebSocket client (initial 500ms, cap 30s, reset on successful connect).
- Add header status text + color updates for connected/reconnecting/disconnected states.
- Update the status dot styling to use a CSS custom property so JS can change the dot color dynamically.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| skills/brainstorming/scripts/helper.js | Implements reconnect backoff logic and updates .header .status to reflect connection state. |
| skills/brainstorming/scripts/frame-template.html | Switches the status dot color to --status-color so JS can control it. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Remove no-op onerror handler (onclose always fires after onerror) - Change onclose status from 'disconnected' to 'reconnecting' since a reconnect attempt is always scheduled
|
Thanks for the review! Both comments addressed in 824d4f2:
|
Summary
The brainstorm companion's WebSocket client (
helper.js) reconnected with a fixed 1-second delay and provided no visual feedback when the connection dropped. If a user's laptop slept or the server restarted, the browser showed "Connected" indefinitely while the WebSocket was dead, and events were silently queued without any indication.Changes
skills/brainstorming/scripts/helper.js:.statuselement — Connected (green), Reconnecting… (yellow), Disconnected (red) — with matching dot color.onerrorhandler: delegates tooncloseto avoid duplicate reconnect attempts.ws = nullon close: preventssendEvent()from writing to a dead socket.clearTimeout: cancels pending reconnect timer before creating a new connection.skills/brainstorming/scripts/frame-template.html:::beforepseudo-element now uses a CSS custom property (--status-color) instead of hardcodedvar(--success), allowing JavaScript to update the dot color dynamically.Existing tests
All 24 passing brainstorm-server tests remain passing (the 1 pre-existing failure —
"serves waiting page"expects"Waiting for Claude"but server says"Waiting for the agent"— is unrelated, introduced in v5.0.4). All 31 WebSocket protocol tests pass.Test plan