mirror of
https://github.com/block/buzz.git
synced 2026-12-01 13:42:45 +00:00
perf(desktop): defer archive-seed hooks behind startupReady
Finding [L5] AppShell.tsx:161-164 — 4 archive/ingestion hooks mounted unconditionally at first render competed with first paint. Gate the two archive *seed* hooks (useObserverArchiveSeed, useAgentMetricArchiveSeed) behind startupReady by passing deferredPubkey instead of the eager identityQuery pubkey, matching the existing presence/user-status deferral pattern. useArchiveSync (the eager live-save path) stays unchanged — it owns live event ingestion and must not be deferred. Only the one-shot first-run seeds (mergeSaveSubscriptionKinds) move off the boot critical path. The seeds' explicit-choice guard is untouched: each hook already early-returns on `if (!pubkey) return`, so a deferred (undefined) pubkey is a no-op until startup completes, then the seed fires exactly once with identical semantics. Confirmed by useObserverArchiveSeed/ useAgentMetricArchiveSeed test suites (18/18), incl. test_undefined_pubkey_does_nothing and test_explicit_choice_set_does_not_reseed. Co-authored-by: Tyler Longwell <tlongwell@block.xyz> Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
This commit is contained in:
parent
5dce80aff5
commit
a9f63b7699
@@ -160,10 +160,16 @@ export function AppShell() {
|
||||
// guard here would drop managed-agent coverage during startup.
|
||||
useAgentObserverIngestion();
|
||||
useArchiveSync();
|
||||
useObserverArchiveSeed(identityQuery.data?.pubkey);
|
||||
useAgentMetricArchiveSeed(identityQuery.data?.pubkey);
|
||||
const profileQuery = useProfileQuery();
|
||||
// Defer the archive *seeds* until startup is idle: they're first-run catch-up
|
||||
// config (a one-shot mergeSaveSubscriptionKinds), not live-ingest — that's
|
||||
// useArchiveSync's job, which stays eager above. Passing deferredPubkey makes
|
||||
// each seed hook wait on its own `if (!pubkey) return` guard until the shell
|
||||
// is interactive, so their IPC + sqlite archive open doesn't compete with
|
||||
// first paint. The explicit-choice guard inside each hook is unchanged.
|
||||
const deferredPubkey = startupReady ? identityQuery.data?.pubkey : undefined;
|
||||
useObserverArchiveSeed(deferredPubkey);
|
||||
useAgentMetricArchiveSeed(deferredPubkey);
|
||||
const profileQuery = useProfileQuery();
|
||||
useRelayAutoHeal();
|
||||
usePresenceSubscription();
|
||||
useUserStatusSubscription();
|
||||
|
||||
Reference in New Issue
Block a user