fix(auth): stop eagerly preloading watch history on login

The eager watch-history preload (0c8a17e3) — even deferred after the critical
lists — saturated the serialized nip-07 extension with ~150+ chunk decrypts for
~18s after login. If the profile modal was opened in that window, its hashtag /
subscription / DM loads competed for the extension and failed/timed out, and DMs
felt broken.

Revert to lazy loading: watch history loads when the For You feed or History view
is opened, keeping login light so the critical lists and the modal work. Re-add
an eager preload only after the cold-load decrypt cost is reduced (task #14).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
thePR0M3TH3ANandClaude Opus 4.8 committed 2026-06-12 20:32:03 -04:00
1 parent ed90ddc2bb
commit 3d0564feea
1 file changed
+6 -17
+6 -17
View File
@@ -12,7 +12,6 @@
import { clearDecryptionSchemeCache } from "../nostr/decryptionSchemeCache.js";
import { clearWatchHistoryConversationKeyCache } from "../nostr/watchHistory.js";
import { clearWatchHistoryDecryptedChunkCache } from "../nostr/watchHistoryDecryptCache.js";
import watchHistoryService from "../watchHistoryService.js";
import { FEED_TYPES } from "../constants.js";
/**
@@ -493,22 +492,12 @@ export function createAuthSessionCoordinator(deps) {
const taskOutcomes = await Promise.all(parallelListTasks);
// Warm watch history AFTER the critical lists decrypt: the serialized
// nip-07 extension + a cold watch history (~150+ decrypts) starved them.
if (
activePubkey &&
watchHistoryService &&
typeof watchHistoryService.loadLatest === "function"
) {
Promise.resolve(
watchHistoryService.loadLatest(activePubkey, { allowStale: true }),
).catch((error) => {
devLogger.warn(
"[auth] Background watch-history preload failed:",
error,
);
});
}
// NOTE: watch history is intentionally NOT eagerly preloaded on login.
// A cold watch history is ~150+ serialized nip-07 decrypts; preloading it
// here (even after the lists) saturated the extension and starved the
// profile modal's hashtag/subscription/DM loads. It now loads lazily when
// the For You feed or History view is opened. Re-enable an eager preload
// only once the cold-load decrypt cost is reduced (see task: ~180 calls).
const requiredTaskOutcomes = taskOutcomes.filter((outcome) =>
["blocks", "subscriptions", "hashtags"].includes(outcome.name),