From a3c753654394bba6d96c07928df86f056e777904 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 5 Jan 2026 03:23:32 +0000 Subject: [PATCH] Refactor watch history to use month-centric context - Rename `WATCH_HISTORY_CHUNK` schema to "Watch history monthly payload" in `js/nostrEventSchemas.js`. - Update `js/nostr/watchHistory.js` to replace `snapshotId` with `recordId` and `monthIdentifier` in logging and error tracking context. - Ensure `fetch` logic uses `recordId` and `month` in chunk decryption context for clarity. - Fix indentation for added fields in logging objects. --- js/nostr/watchHistory.js | 7 +++++-- js/nostrEventSchemas.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/js/nostr/watchHistory.js b/js/nostr/watchHistory.js index c2367db9..4eac5c01 100644 --- a/js/nostr/watchHistory.js +++ b/js/nostr/watchHistory.js @@ -1486,6 +1486,7 @@ class WatchHistoryManager { devLogger.warn("[nostr] Unable to build watch history payload for month.", { actor: actorKey, monthIdentifier, + recordId: snapshotId, }); return { ok: false, error: "invalid-month", retryable: false }; } @@ -1516,7 +1517,7 @@ class WatchHistoryManager { } devLogger.info("[nostr] Preparing to publish watch history snapshot.", { actor: actorKey, - snapshotId, + recordId: snapshotId, monthIdentifier, itemCount: canonicalItems.length, payloadCount: Array.isArray(payload.items) ? payload.items.length : 0, @@ -1619,7 +1620,7 @@ class WatchHistoryManager { const tryEncryptWithCandidate = async (candidate, plaintext, context = {}) => { const details = { actor: actorKey, - snapshotId, + recordId: snapshotId, monthIdentifier, payloadSize: plaintext.length, scheme: candidate.scheme, @@ -2401,6 +2402,8 @@ class WatchHistoryManager { const ciphertext = typeof event.content === "string" ? event.content : ""; const ciphertextPreview = ciphertext.slice(0, 32); const chunkContext = { + recordId: snapshotId, + month: snapshotId, eventId: event.id ?? null, }; const availableSchemes = Array.from(decryptorCandidates.keys()); diff --git a/js/nostrEventSchemas.js b/js/nostrEventSchemas.js index 751cbb92..dab3a351 100644 --- a/js/nostrEventSchemas.js +++ b/js/nostrEventSchemas.js @@ -370,7 +370,7 @@ const BASE_SCHEMAS = { }, [NOTE_TYPES.WATCH_HISTORY_CHUNK]: { type: NOTE_TYPES.WATCH_HISTORY_CHUNK, - label: "Watch history month payload", + label: "Watch history monthly payload", kind: WATCH_HISTORY_KIND, identifierTag: { name: "d",