Skip to content
Source
Sign inSign up
pingdotgg/t3code

Skip healthy env reconnects after browser resume #2677

Mergedjuliusmarmingemerged 2 commits intomain fromrefs/pull/2677/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Summary

  • Skip environment reconnects on browser resume when the WS heartbeat is still fresh.
  • Add a isHeartbeatFresh() passthrough on the WebSocket RPC client so resume logic can check connection health.
  • Extend runtime service tests to cover both healthy and stale resume behavior.

Testing

  • bun fmt
  • bun lint
  • bun typecheck
  • bun run test apps/web/src/environments/runtime/service.threadSubscriptions.test.ts

Note

Medium Risk Changes browser-resume reconnection behavior for environment WebSocket streams, which could impact connection recovery if heartbeat freshness is misreported or edge cases bypass reconnects.

Overview On browser resume, environment connections now only reconnect if the underlying WebSocket heartbeat is stale, avoiding unnecessary reconnect churn for healthy streams.

This adds an isHeartbeatFresh() passthrough to the WsRpcClient and updates runtime service tests to cover both healthy (no reconnect) and stale (reconnect) resume scenarios.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 0f663fd2143f4e73a8c52d91e77e7258fed741bf. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Skip reconnection for healthy environment connections on browser resume

  • Adds isHeartbeatFresh() to the WsRpcClient interface and implementation, delegating to the underlying transport.
  • reconnectEnvironmentConnectionsAfterBrowserResume now checks heartbeat freshness per connection and skips reconnection if the heartbeat is fresh.
  • The cooldown timestamp lastBrowserResumeReconnectAt is only updated when at least one reconnect is actually attempted.
  • Behavioral Change: previously, all environment connections were reconnected on browser resume; now only stale connections are reconnected.
Macroscope summarized 0f663fd.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro

      Run ID: b0e49c84-2d3c-42f3-bee8-a58d0d81284b

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `t3code/f9ab9fd5`

      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. Cursor Bugbot has reviewed your changes and found 1 potential issue.

      Fix All in Cursor Bugbot Autofix is [ON](https://www.cursor.com/dashboard/bugbot). A cloud agent has been kicked off to fix the reported issue. Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit b28fb9a4679ec84aed1abf07cf8f093ccc6dd5c0. Configure [here](https://www.cursor.com/dashboard/bugbot).
    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved

      Small optimization that skips reconnecting environment connections on browser resume if the connection's heartbeat is still fresh. Leverages existing heartbeat tracking, includes comprehensive tests, and the author wrote the original code being modified.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. juliusmarminge merged this90eea04

    6. juliusmarminge closed this

Sign in to join this conversation.