UI: extract gateway reconnect magic numbers into named constants#30407
UI: extract gateway reconnect magic numbers into named constants#30407DhineshPonnarasan wants to merge 1 commit intoopenclaw:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Improves readability/maintainability of the UI WebSocket reconnect flow by replacing inline “magic numbers” in GatewayBrowserClient with named constants in ui/src/ui/gateway.ts (per #30402).
Changes:
- Introduces documented module-level constants for reconnect backoff parameters and connect-queue delay.
- Updates reconnect scheduling and connect-handshake timing to reference the new constants (no behavioral intent).
| export const INITIAL_BACKOFF_MS = 800; | ||
|
|
||
| /** | ||
| * Reconnect backoff: maximum delay (ms) between reconnect attempts. | ||
| * Prevents unbounded growth during prolonged disconnections. | ||
| */ | ||
| export const MAX_BACKOFF_MS = 15_000; | ||
|
|
||
| /** | ||
| * Reconnect backoff: exponential growth multiplier applied after each failed attempt. | ||
| * e.g. 800 → 1360 → 2312 → ... → capped at MAX_BACKOFF_MS. | ||
| */ | ||
| export const BACKOFF_MULTIPLIER = 1.7; | ||
|
|
||
| /** | ||
| * Delay (ms) between WebSocket open and sending the connect handshake. | ||
| * Provides a window for the server to send a challenge nonce before the | ||
| * client initiates authentication. | ||
| */ | ||
| export const CONNECT_QUEUE_DELAY_MS = 750; |
There was a problem hiding this comment.
These reconnect tuning values are exported, but they appear to be only used internally within this module right now. If they aren’t intended to be part of the module’s supported surface area, consider removing export to avoid growing a de-facto public API (and making future tuning changes harder). If the export is intentional (e.g., for tests/config), it may be worth adding a brief note indicating the intended external consumers.
| export const INITIAL_BACKOFF_MS = 800; | |
| /** | |
| * Reconnect backoff: maximum delay (ms) between reconnect attempts. | |
| * Prevents unbounded growth during prolonged disconnections. | |
| */ | |
| export const MAX_BACKOFF_MS = 15_000; | |
| /** | |
| * Reconnect backoff: exponential growth multiplier applied after each failed attempt. | |
| * e.g. 800 → 1360 → 2312 → ... → capped at MAX_BACKOFF_MS. | |
| */ | |
| export const BACKOFF_MULTIPLIER = 1.7; | |
| /** | |
| * Delay (ms) between WebSocket open and sending the connect handshake. | |
| * Provides a window for the server to send a challenge nonce before the | |
| * client initiates authentication. | |
| */ | |
| export const CONNECT_QUEUE_DELAY_MS = 750; | |
| const INITIAL_BACKOFF_MS = 800; | |
| /** | |
| * Reconnect backoff: maximum delay (ms) between reconnect attempts. | |
| * Prevents unbounded growth during prolonged disconnections. | |
| */ | |
| const MAX_BACKOFF_MS = 15_000; | |
| /** | |
| * Reconnect backoff: exponential growth multiplier applied after each failed attempt. | |
| * e.g. 800 → 1360 → 2312 → ... → capped at MAX_BACKOFF_MS. | |
| */ | |
| const BACKOFF_MULTIPLIER = 1.7; | |
| /** | |
| * Delay (ms) between WebSocket open and sending the connect handshake. | |
| * Provides a window for the server to send a challenge nonce before the | |
| * client initiates authentication. | |
| */ | |
| const CONNECT_QUEUE_DELAY_MS = 750; |
Greptile SummaryExtracted 4 magic numbers from
Confidence Score: 5/5
Last reviewed commit: 704d702 |
Summary
Replaces raw magic numbers in
GatewayBrowserClientreconnect logic with named, JSDoc-documented constants.Fixes #30402
Changes
ui/src/ui/gateway.tsINITIAL_BACKOFF_MS = 800— initial delay before first reconnectMAX_BACKOFF_MS = 15_000— reconnect backoff ceilingBACKOFF_MULTIPLIER = 1.7— exponential growth factor per attemptCONNECT_QUEUE_DELAY_MS = 750— grace window for server challenge nonceNotes
pnpm check)