From b3aeb95a0be2d06d998535d357d65661376b54a7 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 6 Jan 2026 19:03:03 +0000 Subject: [PATCH] Fix watch history reliability by migrating to Kind 30003 Migrates watch history persistence from Kind 30078 (Application Data) to Kind 30003 (Bookmark List) to resolve blocking issues on some relays. Updates fetch logic to query both kinds for backward compatibility. --- config/instance-config.js | 3 ++- js/config.js | 2 ++ js/nostr/watchHistory.js | 11 ++++++++++- tests/watch-history.test.mjs | 5 +++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/config/instance-config.js b/config/instance-config.js index c4997e67..abeb30fd 100644 --- a/config/instance-config.js +++ b/config/instance-config.js @@ -301,7 +301,8 @@ export const THEME_ACCENT_OVERRIDES = Object.freeze({ * example, a NIP-51 collection) can flip this number so long as their relays * accept the chosen kind. */ -export const WATCH_HISTORY_KIND = 30078; +export const WATCH_HISTORY_KIND = 30003; +export const WATCH_HISTORY_LEGACY_KIND = 30078; /** * Identifier applied to the watch-history list when storing it on relays. diff --git a/js/config.js b/js/config.js index 32c5c207..214bdeb1 100644 --- a/js/config.js +++ b/js/config.js @@ -28,6 +28,7 @@ import { DEFAULT_TRUSTED_MUTE_HIDE_THRESHOLD, DEFAULT_TRUSTED_SPAM_HIDE_THRESHOLD, WATCH_HISTORY_KIND, + WATCH_HISTORY_LEGACY_KIND, WATCH_HISTORY_LIST_IDENTIFIER, WATCH_HISTORY_LEGACY_LIST_IDENTIFIERS, WATCH_HISTORY_MAX_ITEMS, @@ -118,6 +119,7 @@ export { ADMIN_WHITELIST_MODE_STORAGE_KEY }; // ----------------------------------------------------------------------------- export { WATCH_HISTORY_KIND }; +export { WATCH_HISTORY_LEGACY_KIND }; export { WATCH_HISTORY_LIST_IDENTIFIER }; export { WATCH_HISTORY_LEGACY_LIST_IDENTIFIERS }; export { WATCH_HISTORY_MAX_ITEMS }; diff --git a/js/nostr/watchHistory.js b/js/nostr/watchHistory.js index 5932242c..debdb485 100644 --- a/js/nostr/watchHistory.js +++ b/js/nostr/watchHistory.js @@ -1,5 +1,6 @@ import { WATCH_HISTORY_KIND, + WATCH_HISTORY_LEGACY_KIND, WATCH_HISTORY_LIST_IDENTIFIER, WATCH_HISTORY_LEGACY_LIST_IDENTIFIERS, WATCH_HISTORY_MAX_ITEMS, @@ -1883,9 +1884,17 @@ class WatchHistoryManager { } let pointerEvents = []; try { + const kinds = [WATCH_HISTORY_KIND]; + if ( + Number.isFinite(WATCH_HISTORY_LEGACY_KIND) && + WATCH_HISTORY_LEGACY_KIND > 0 && + WATCH_HISTORY_LEGACY_KIND !== WATCH_HISTORY_KIND + ) { + kinds.push(WATCH_HISTORY_LEGACY_KIND); + } const filters = [ { - kinds: [WATCH_HISTORY_KIND], + kinds, authors: [actorKey], // Fetch all parameterized replaceables of this kind to get history across all months limit, diff --git a/tests/watch-history.test.mjs b/tests/watch-history.test.mjs index a083debf..b2eec13b 100644 --- a/tests/watch-history.test.mjs +++ b/tests/watch-history.test.mjs @@ -11,6 +11,7 @@ const { WATCH_HISTORY_BATCH_PAGE_SIZE, WATCH_HISTORY_LIST_IDENTIFIER, WATCH_HISTORY_KIND, + WATCH_HISTORY_LEGACY_KIND, } = await import("../js/config.js"); const { @@ -2524,7 +2525,7 @@ async function testWatchHistoryFeedHydration() { poolHarness.reset(); watchHistoryService.resetProgress(); - const actor = "feed-hydration-actor"; + const actor = "f".repeat(64); const videoId = "hydration-video-id"; const videoTitle = "Hydrated Video Title"; const videoEvent = { @@ -2563,7 +2564,7 @@ async function testWatchHistoryFeedHydration() { results.push(videoEvent); } - if (filter.kinds && filter.kinds.includes(WATCH_HISTORY_KIND)) { + if (filter.kinds && (filter.kinds.includes(WATCH_HISTORY_KIND) || filter.kinds.includes(WATCH_HISTORY_LEGACY_KIND))) { results.push({ id: "history-event-id", kind: WATCH_HISTORY_KIND,