fix(web): refresh stale desktop endpoints when Connections reopens #16026
main fromrefs/pull/16026/head·merged by juliusmarminge View on GitHubProblem#
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, andvp 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 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 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
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
juliusmarminge added labelsmacroscope-review
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Approvability#
Verdict: Approved at
73613a4Macroscope'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).juliusmarminge merged this7686c57
juliusmarminge closed this
Sign in to join this conversation.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
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.tsapps/web/src/state/desktopNetworkAccess.tsIncluded 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
apps/web/src/state/desktopNetworkAccess.ts,apps/web/src/state/desktopNetworkAccess.test.tsAtom.keepAlivenow wraps the atom beforeAtom.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
35debThe 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
35debThe 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
Trust Boundaries and Controls
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
#15751] The atom now appliesAtom.keepAlivebeforeAtom.swr, so the snapshot remains cached while the SWR wrapper can revalidate on a stale Settings remount. Tests cover fresh reuse before 30 sec…#15751]. No unrelated implementation appears in the whole-PR diff. The s…✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.