Skip to content

feat: adopt the record observer and remove the social graph - #185

Merged
LiranCohen merged 1 commit into
mainfrom
feat/adopt-record-observer
Jul 24, 2026
Merged

feat: adopt the record observer and remove the social graph#185
LiranCohen merged 1 commit into
mainfrom
feat/adopt-record-observer

Conversation

@LiranCohen

Copy link
Copy Markdown
Contributor

Summary

Adopts the Enbox release set that introduces records.observe() (api 0.6.72 / browser 0.3.64) and deletes the app-owned data-sync machinery it replaces. Net −2,135 lines.

Record observer

  • New useRecordsView — a reusable bridge from the async records.observe() view to useSyncExternalStore (starts loading, opens the view, forwards snapshots, closes on teardown).
  • WalletsTab observes connect.records.observe('wallet', …) instead of useQuery(fetchWallets). Wallet records now stay current on their own, so fetchWallets/fetchWalletsEffect and the wallet entry in the manual agent.sync.on → invalidateQueries bridge are both deleted.

Social graph removed

Feature deleted end to end: pages, tab, hooks, queries, routes, nav entries, query keys, tests.

The social-graph protocol install staysProfileDefinition composes it (role: 'social:friend' gates privateNote), so removing it would break Profile installation. Only the feature is gone.

Breaking-release migration

0.6.72 removed these APIs; the code that used them is gone rather than ported laterally:

  • repository(...) facade → typed records.query/create/read/delete. Singleton upsert (profile.set, profile.<image>.set) is now explicit query-then-update-or-create.
  • records.queryAll(...) drain → explicit cursor loop.
  • MessagesLiveQuery / reply.liveQuerysubscriptionHandler supplied at dispatch + reply.subscription.close().

Test plan

  • npx tsc --noEmit — clean
  • bun run lint — 0 errors
  • bun run test — 86 files, 761 passed, 10 skipped, 0 failed
  • tsc -b && vite build — succeeds
  • Runtime verification recommended (see below)

Reviewer notes — behaviour changes static checks can't catch

  1. $recordLimit is now a read-time visibility projection, not a write-time gate. Writes past the limit succeed (stored, projected out of reads) instead of being rejected. profile is therefore read as query-then-first rather than relying on a write-time singleton guarantee. Any flow that expected a rejection to enforce a singleton changes behaviour.
  2. Subscription handlers must be installed at dispatch. The old MessagesLiveQuery buffered dispatches until a listener attached; that buffering is gone, so a late handler would drop catch-up events. Handlers also receive raw DWN messages, not hydrated records, and there are no create/update/delete semantic events — only descriptor.method.
  3. The protocol-definition change may make verifyInstalled() report owner-can-update (owner sessions) or wallet-reapproval-required (delegate sessions).

I could not exercise the live app, so the wallet-observer reactivity and the sync-invalidation subscription path are worth a manual pass.

Adopts the Enbox release set that introduces `records.observe()` (api 0.6.72 /
browser 0.3.64) and deletes the app-owned data-sync machinery it replaces.

Record observer
- Add `useRecordsView`, a reusable bridge from the async `records.observe()`
  view to `useSyncExternalStore`.
- `WalletsTab` now observes `connect.records.observe('wallet', ...)` instead of
  `useQuery(fetchWallets)`, so wallet records stay current on their own. Drops
  `fetchWallets`/`fetchWalletsEffect` and the wallet entry from the manual
  `agent.sync.on -> invalidateQueries` bridge.

Social graph removed
- Deletes the social graph feature: pages, tab, hooks, queries, routes, nav
  entries, query keys and tests. The social-graph protocol stays installed
  because `ProfileDefinition` composes it (`role: 'social:friend'` gates
  `privateNote`).

Breaking-release migration (0.6.72 removed these APIs)
- `repository(...)` facade -> typed `records.query/create/read/delete`. Singleton
  upsert (`profile.set`, `profile.<image>.set`) is now explicit
  query-then-update-or-create.
- `records.queryAll(...)` drain -> explicit cursor loop.
- `MessagesLiveQuery` / `reply.liveQuery` -> `subscriptionHandler` supplied at
  dispatch, with `reply.subscription.close()` for teardown.

Note: `$recordLimit` is now a read-time visibility projection, so writes past
the limit succeed instead of being rejected; `profile` is read as
query-then-first rather than relying on a write-time singleton guarantee.
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 70.78% (🎯 25%) 3355 / 4740
🟢 Statements 68.81% (🎯 25%) 3548 / 5156
🟢 Functions 68.25% (🎯 30%) 1017 / 1490
🟢 Branches 63.77% (🎯 29%) 2231 / 3498
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/nav-items.tsx 100% 100% 100% 100%
src/routes.tsx 56% 100% 8.33% 100% 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
src/enbox/audience-key-delivery.ts 93.87% 91.11% 100% 93.87% 96, 101, 149
src/enbox/hooks/use-records-view.ts 4.65% 0% 6.25% 4.87% 30-118
src/enbox/hooks/use-sync-query-invalidation.ts 78.04% 53.08% 87.5% 77.5% 50-51, 59-67, 117, 123, 195, 210-214, 220-221, 225-228, 233-237, 268-272, 275, 288-289, 300, 304
src/enbox/hooks/use-wallets.ts 7.4% 0% 0% 8% 41-96
src/enbox/mutations/identity-mutations.ts 74.16% 61.33% 72.52% 74.03% 59, 66, 88, 93, 98, 132-133, 150-160, 179-180, 193-194, 367-368, 416-421, 446-452, 460-469, 490-536, 610-615, 638-643, 653
src/enbox/queries/identity-queries.ts 45.16% 50% 28.57% 46.66% 34-58, 118, 152-265
src/enbox/queries/query-keys.ts 100% 100% 100% 100%
src/features/identities/IdentityDetailsPage.tsx 44.87% 41.86% 34.78% 45.71% 73-108, 113, 117-127, 184-208, 250-351
src/features/identities/tabs/ActivityTab.tsx 0% 0% 0% 0% 12-91
src/features/identities/tabs/WalletsTab.tsx 0% 0% 0% 0% 12-61
Generated in workflow #434 for commit 1c06979 by the Vitest Coverage Report Action

@LiranCohen
LiranCohen merged commit 75253ea into main Jul 24, 2026
4 checks passed
@LiranCohen
LiranCohen deleted the feat/adopt-record-observer branch July 24, 2026 02:37
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.

1 participant