Skip to content

feat: establish terminal reconnection foundation #18693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

BrunoQuaresma
Copy link
Collaborator

  • Update ConnectionStatus type: replace 'initializing' with 'connecting'
  • Create useRetry hook with exponential backoff logic
  • Add comprehensive tests for useRetry hook
  • Export useRetry from hooks index

Implements:

  • Initial delay: 1 second
  • Max delay: 30 seconds
  • Backoff multiplier: 2
  • Max retry attempts: 10

Related to: coder/internal#659

- Update ConnectionStatus type: replace 'initializing' with 'connecting'
- Create useRetry hook with exponential backoff logic
- Add comprehensive tests for useRetry hook
- Export useRetry from hooks index

Implements:
- Initial delay: 1 second
- Max delay: 30 seconds
- Backoff multiplier: 2
- Max retry attempts: 10

Co-authored-by: BrunoQuaresma <[email protected]>
@BrunoQuaresma BrunoQuaresma changed the title feat: Phase 1 - Terminal reconnection foundation feat: terminal reconnection foundation Jul 1, 2025
@BrunoQuaresma BrunoQuaresma changed the title feat: terminal reconnection foundation feat: establish terminal reconnection foundation Jul 1, 2025
blink-so bot and others added 5 commits July 1, 2025 14:34
- Fix startRetrying to immediately perform first retry
- Adjust retry scheduling conditions
- Fix delay calculation for exponential backoff

Still debugging test failures
- Fix attemptCount to represent attempts started, not completed
- Fix exponential backoff delay calculation
- Fix retry scheduling conditions for proper max attempts handling
- All 10 useRetry tests now pass
- No regressions in existing test suite

Implements correct behavior:
- attemptCount increments when retry starts
- Exponential backoff: 1s, 2s, 4s, 8s, 16s, 30s (capped)
- Respects maxAttempts limit
- Manual retry cancels automatic retries
- State resets properly on success

Co-authored-by: BrunoQuaresma <[email protected]>
- Add parentheses around arrow function parameter
- Fix indentation

Co-authored-by: BrunoQuaresma <[email protected]>
- Replace setTimeout/setInterval with window.setTimeout/window.setInterval
- Replace clearTimeout/clearInterval with window.clearTimeout/window.clearInterval
- Fixes TypeScript error: Type 'Timeout' is not assignable to type 'number'
- Ensures proper browser environment timer types

Co-authored-by: BrunoQuaresma <[email protected]>
Convert useRetry hook from multiple useState calls to a single useReducer
for cleaner state management. This improves code clarity and makes state
transitions more predictable.

Changes:
- Replace 5 useState calls with single useReducer
- Add RetryState interface and RetryAction union type
- Implement retryReducer function for all state transitions
- Update all state access to use state object
- Replace setState calls with dispatch calls throughout

Co-authored-by: BrunoQuaresma <[email protected]>
@BrunoQuaresma BrunoQuaresma requested review from code-asher and a team July 1, 2025 16:13
@blink-so blink-so bot force-pushed the feature/terminal-reconnection branch from 417b053 to dd7adda Compare July 1, 2025 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant