Skip to content

refactor(ui): extract reconnect magic numbers into named constants#30435

Closed
NaturalTensor wants to merge 1 commit intoopenclaw:mainfrom
NaturalTensor:fix/extract-reconnect-constants
Closed

refactor(ui): extract reconnect magic numbers into named constants#30435
NaturalTensor wants to merge 1 commit intoopenclaw:mainfrom
NaturalTensor:fix/extract-reconnect-constants

Conversation

@NaturalTensor
Copy link

Summary

Extracts raw magic numbers in GatewayBrowserClient reconnect logic into documented top-level constants:

Constant Value Purpose
INITIAL_BACKOFF_MS 800 Initial delay before first reconnect attempt
MAX_BACKOFF_MS 15,000 Maximum delay between reconnect attempts
BACKOFF_MULTIPLIER 1.7 Multiplier applied after each failed attempt
CONNECT_QUEUE_DELAY_MS 750 Delay before sending connect frame after WS opens

Changes

  • Added 4 named constants with JSDoc comments at the top of ui/src/ui/gateway.ts
  • Replaced all inline magic numbers with the corresponding constants
  • Zero behavioral change

Closes #30402

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 1, 2026

Greptile Summary

Extracted four magic numbers from WebSocket reconnect logic into well-documented top-level constants (INITIAL_BACKOFF_MS, MAX_BACKOFF_MS, BACKOFF_MULTIPLIER, CONNECT_QUEUE_DELAY_MS). All constants are correctly defined, consistently applied, and include clear JSDoc comments. Zero behavioral changes detected.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Score reflects a clean, zero-risk refactoring: all constant values match original magic numbers exactly, all usages are correct, no behavioral changes introduced, and improved code maintainability through clear documentation
  • No files require special attention

Last reviewed commit: 3d51e3b

Replace raw numeric literals in GatewayBrowserClient reconnect logic
with documented top-level constants:

- INITIAL_BACKOFF_MS (800)
- MAX_BACKOFF_MS (15_000)
- BACKOFF_MULTIPLIER (1.7)
- CONNECT_QUEUE_DELAY_MS (750)

No behavioral change; improves readability and maintainability.

Closes openclaw#30402
@steipete
Copy link
Contributor

steipete commented Mar 2, 2026

Thanks for the PR! Multiple PRs address the same gateway reconnect magic-numbers refactor (#30407, #30414, #30435, #30498, #31587). Keeping #30407 as the earliest submission. Closing this one to reduce noise. This is an AI-assisted triage review. If we got this wrong, feel free to reopen or start a new PR — happy to revisit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI: Extract magic numbers in GatewayBrowserClient reconnect logic into named constants

2 participants