Skip to content

Convert subscriptions to useSyncExternalStore (bd-06s9sufx) - #925

Merged
shikokuchuo merged 1 commit into
bugfix/bd-lsf2v5n0-useeffect-phase1from
refactor/bd-06s9sufx-useeffect-phase2
Oct 27, 2026
Merged

shikokuchuo merged 1 commit into
bugfix/bd-lsf2v5n0-useeffect-phase1from
refactor/bd-06s9sufx-useeffect-phase2

Conversation

@shikokuchuo

Copy link
Copy Markdown
Member

Stacked on #924. Phase 2 of claude-notes/plans/2026-10-24-hub-client-useeffect-refactor.md.

  • Convert useDocBranches, usePreference, and usePresence to useSyncExternalStore.
  • Memoize snapshots in branchService and presenceService so getSnapshot stays stable between changes.
  • Add shared useNow and useOnlineStatus hooks; use them in SyncStatusBadge and ConnectionStatusDialog in place of duplicated ticker and online/offline effects.
  • Document the intentional polling in DebugInspectorPanel.

This fixes a possible tearing bug in useDocBranches under concurrent rendering. The other conversions are simplifications. No user-visible change, so no changelog entry.

Tests: full npm run test:ci green (1720 unit, 225 integration, 434 WASM) and npm run build green. Characterization tests were pinned before each refactor.

@posit-snyk-bot

posit-snyk-bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

- useDocBranches: replace version-bump re-render with useSyncExternalStore
  over new memoized per-path branchService snapshots (getBranchSnapshot) —
  the one site that could actually tear under concurrent rendering
- usePreference: convert the custom-event subscription; the writer's local
  echo was redundant (setPreference dispatches synchronously)
- usePresence: convert onPresenceChange; presenceService now memoizes
  getRemotePresences on a version bumped before the visibility gate, so
  data freshness is never deferred, only notifications
- Add shared useNow(intervalMs) (one ticking store per interval) and
  useOnlineStatus() hooks; replace the duplicated 1s ticker + online/
  offline blocks in SyncStatusBadge and ConnectionStatusDialog
- Document the intentional polling in DebugInspectorPanel (debug-only)

Characterization tests pinned first for the uncovered sites
(useDocBranches, ConnectionStatusDialog).

Phase 2 of claude-notes/plans/2026-10-24-hub-client-useeffect-refactor.md.
@shikokuchuo
shikokuchuo force-pushed the refactor/bd-06s9sufx-useeffect-phase2 branch from fccb7c9 to c2096bc Compare October 27, 2026 11:50
@shikokuchuo
shikokuchuo merged commit 875e7fd into main Oct 27, 2026
12 checks passed
@shikokuchuo
shikokuchuo deleted the refactor/bd-06s9sufx-useeffect-phase2 branch October 27, 2026 17:33
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.

2 participants