Skip to content

Use idiomatic Effect primitives for websocket reconnects#3047

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/idiomatic-effect-patterns-a2a8
Draft

Use idiomatic Effect primitives for websocket reconnects#3047
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/idiomatic-effect-patterns-a2a8

Conversation

@cursor

@cursor cursor Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • Modeled websocket reconnect backoff delays with effect/Duration and retry exhaustion with Option.
  • Kept a millisecond compatibility helper for UI surfaces that still display delays in milliseconds.
  • Replaced the ad-hoc websocket pong JSON.parse check with a Schema.fromJsonString tagged decoder.
  • Updated reconnect backoff tests to use @effect/vitest with assert.

Why

This keeps the reconnect policy closer to Effect primitives end-to-end, makes absence explicit with Option, and gives heartbeat parsing typed schema validation while preserving existing runtime behavior.

UI Changes

Not applicable; no user-facing UI rendering changed.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Validation:

  • pnpm exec vp run --filter @t3tools/client-runtime test -- --run src/reconnectBackoff.test.ts src/wsTransport.test.ts (24 files, 180 tests passed)
  • pnpm exec vp check (passed; existing lint warnings only)
  • pnpm exec vp run typecheck (passed; existing suggestion outside this change remains)
Open in Web View Automation 

Note

Replace millisecond primitives with Effect Duration and Option types in websocket reconnect backoff

  • Refactors ReconnectBackoffConfig in reconnectBackoff.ts to use Duration.Input for delay fields and Option<number> for maxRetries instead of raw numbers and null.
  • Adds a new getReconnectDelay function returning Option<Duration>, with getReconnectDelayMs kept as a compatibility wrapper returning milliseconds or null.
  • Updates wsRpcProtocol.ts to consume the new Option/Duration backoff API and replaces manual JSON pong detection with a schema-based decoder.
  • Updates wsConnectionState.ts to derive exported millisecond constants via Duration conversion and Option.getOrThrow.
  • Risk: if DEFAULT_RECONNECT_BACKOFF.maxRetries is Option.none, module evaluation in wsConnectionState.ts will now throw rather than silently produce undefined.

Macroscope summarized cd89779.

cursoragent and others added 2 commits June 11, 2026 16:07
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jun 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Expo continuous deployment is ready!

  • Project → t3-code
  • Platforms → android, ios
  • Scheme → t3code-preview
  🤖 Android 🍎 iOS
Fingerprint ae17d94b35f91f9c608a63dadbc3ddd9f4ba056e 313e506a7f15a9c3f15b01d787d68a12382432bf
Build Details Build Permalink
DetailsDistribution: INTERNAL
Build profile: preview:dev
Runtime version: ae17d94b35f91f9c608a63dadbc3ddd9f4ba056e
App version: 0.1.0
Git commit: b5f4c20e4d53a53d3c746100fca97f8f18ec9065
Build Permalink
DetailsDistribution: INTERNAL
Build profile: preview:dev
Runtime version: 313e506a7f15a9c3f15b01d787d68a12382432bf
App version: 0.1.0
Git commit: b5f4c20e4d53a53d3c746100fca97f8f18ec9065
Update Details Update Permalink
DetailsBranch: pr-3047
Runtime version: ae17d94b35f91f9c608a63dadbc3ddd9f4ba056e
Git commit: b5f4c20e4d53a53d3c746100fca97f8f18ec9065
Update Permalink
DetailsBranch: pr-3047
Runtime version: 313e506a7f15a9c3f15b01d787d68a12382432bf
Git commit: b5f4c20e4d53a53d3c746100fca97f8f18ec9065
Update QR

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

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant