Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): refresh stale desktop endpoints when Connections reopens #16026

Mergedarthurkatcher(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/16026/headmerged by juliusmarminge View on GitHub

Problem

Connections keeps an old endpoint list after Tailscale connects or disconnects. Although the atom specifies a 30-second stale time and revalidateOnMount: true, keepAlive retains its SWR wrapper across Settings visits, preventing the stale remount check.

Closes #15751. The separate endpoint-identification defect is addressed in #15753.

Change

Move Atom.keepAlive before Atom.swr. The underlying snapshot and in-flight request stay cached, while the wrapper can dispose and revalidate when Connections reopens. Fresh snapshots remain cached; stale snapshots trigger a new desktop bridge read. The existing explicit refresh path continues to work.

Scope and approval

This restores the existing revalidation policy with one combinator move and a comment in one frontend state module, plus focused tests. It fits the small, focused obvious-bug exception. The issue triage confirms the defect and identifies this composition change as an option; no explicit human maintainer approval is claimed.

This applies to the desktop Connections section of the shared web renderer. There is no new timer, focus policy, button, contract, or provider change. Network changes while the screen remains open are outside this fix. It can merge independently of #15753.

Verification

Rebased onto main at 4ae976dbae39b3e80243b864a8b61da00f642dc4; frontend head 73613a490b875f7eade3de85f589b483e5555f78. Focused tests, web typecheck, changed-file lint and formatting pass on this head with Effect 4.0.1. Its deferred revalidation is handled by awaiting the second bridge-read milestone in the stale-remount tests, without sleeps or polling.

  • vp test run apps/web/src/state/desktopNetworkAccess.test.ts: 6 passed. Covers the fresh-cache boundary at 29,999 ms, address appearance and disappearance at 30,000 ms, explicit refresh with an in-flight remount, and preserved causes for both bridge errors.
  • At the original base (4ee6bfd5), restoring only the production module made both stale-list cases fail, while the other four passed. Restoring the fix made all six pass.
  • Changed-file lint, formatting, git diff --check, and vp run --filter @t3tools/web typecheck: passed.
  • UI before reproduction: real Connections route in an isolated dev instance, with a simulated desktop bridge. After its response gained a Tailscale endpoint, reopening the route after about 41 seconds still left the bridge at one read. The expanded list still omitted Tailscale. Actual network interfaces and the live desktop database were not changed.

Before: Connections still omits the simulated Tailscale IP after a stale remount

Before recording · Bridge fixture and reproduction notes

After verification

The same real Connections route refreshed on stale remounts at the pre-rebase head 35deb1dd13e04df105204e686bea51ff9764d015:

  • After 53.4 seconds, reconnecting the simulated Tailscale interface and reopening Connections adds its IP and increases bridge reads from 1 to 2.
  • Reopening 25.2 seconds after the second read reuses the cached snapshot and keeps reads at 2.
  • After 66.9 seconds since that read, reopening after simulated disconnection removes the IP and increases reads to 3.

After: a stale remount discovers the Tailscale IP

After disconnect: a stale remount removes the Tailscale IP

After recording, including cache waits · Observed bridge counts and timing

The before and after checks use the actual web renderer with controlled desktop IPC responses in isolated development state. Browser time was not mocked. This verifies route/atom integration; it does not claim a packaged Electron test or live OS network switching. The subsequent rebase adopts upstream Effect import paths and adapts test synchronization to deferred revalidation; the production composition fix is unchanged. The screenshots and recordings are from the stated pre-rebase head; the focused tests and typecheck were rerun on the current head.

Model: GPT-6-Astra. Harness: Codex in T3 Code.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 7d3a0387-46b2-41f5-9569-812adc7c83a6
      📥 Commits

      Reviewing files that changed from the base of the PR and between 7812230572f2d7e042d8d14ada2381fc71377560 and 35deb1dd13e04df105204e686bea51ff9764d015.

      📒 Files selected for processing (2)
      • apps/web/src/state/desktopNetworkAccess.test.ts
      • apps/web/src/state/desktopNetworkAccess.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


      📝 Walkthrough

      Walkthrough

      The desktop network access atom changes the order of its keep-alive and stale-while-revalidate wrappers. Effect-based tests cover snapshot retention on remount, refresh behavior, endpoint changes after 30 seconds, and load-failure causes.

      Changes

      Desktop network access cache

      Layer / File(s)Summary
      Cache behavior and test coverage
      apps/web/src/state/desktopNetworkAccess.ts, apps/web/src/state/desktopNetworkAccess.test.ts
      Atom.keepAlive now wraps the atom before Atom.swr; the stale time and revalidate-on-mount settings are unchanged. Effect-based tests check snapshot retention, explicit refresh, endpoint appearance and disappearance after 30 seconds, and tagged load failures.

      Priority: ⬇️ Low

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix · Severity of issue fixed: Low

      Merge Risk: ⚪ Minimal · up to 35deb

      The Connections cache change is ready to merge after normal checks; no concrete remaining issue is identified.

      Security Architecture Review

      Security architecture risk: 🔵 Low · up to 35deb

      The change is confined to refreshing cached desktop connection information, with existing permission checks and bridge operations unchanged. No introduced security weakness was established, but overlapping refreshes and recovery after refresh failures remain unverified.

      Retained concerns No architecture-level concerns identified.

      Security review details

      Security Blast Radius

      • inferred — The demonstrated changed exposure is the freshness of one renderer's desktop network-access snapshot. Revalidation invokes the same two bridge reads; it does not add a server mutation, remote caller, or privilege-bearing operation to the loader.

      Trust Boundaries and Controls

      • observed — Endpoint data already participates in pairing URL selection, and exposure state already informs network-setting controls. Those consumers are unchanged. Server exposure and Tailscale configuration changes remain separate bridge mutations followed by explicit snapshot refresh; automatic remount revalidation performs only reads.
      🚥 Pre-merge checks | ✅ 4 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Linked Issues check✅ Passed[#15751] The atom now applies Atom.keepAlive before Atom.swr, so the snapshot remains cached while the SWR wrapper can revalidate on a stale Settings remount. Tests cover fresh reuse before 30 sec…
      Out of Scope Changes check✅ PassedThe production change and tests are limited to desktop network-access snapshot caching and stale-remount behavior requested by [#15751]. No unrelated implementation appears in the whole-PR diff. The s…
      Title check✅ PassedThe title clearly identifies the fix: refreshing stale desktop endpoints when Connections reopens.
      Description check✅ PassedThe description covers the problem, change, scope and approval rationale, and focused verification results. It also states the limits of the verification and the behavior outside the fix’s scope.
      • Fix all pre-merge checks with AI
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR
      • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Comment `@coderabbitai help` to get the list of available commands.
    3. juliusmarminge added labelsmacroscope-review

    4. Approvability

      Verdict: Approved at 73613a4

      Macroscope's review found this PR approvable — This is a small, self-contained frontend bug fix that restores stale-cache revalidation for desktop endpoints when Connections reopens. The production change is limited to atom composition, with focused regression tests and no schema, deployment, security, billing, or default-setting impact.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. juliusmarminge merged this7686c57

    6. juliusmarminge closed this

Sign in to join this conversation.