From ad01cf852f4efc65f2f3dcaf37ceb54b623452f7 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Sat, 25 Oct 2025 17:38:31 -0400 Subject: [PATCH] Propagate tag preferences through feed runtimes --- js/app.js | 15 +++++++++++++++ js/feedEngine/stages.js | 4 ++++ js/historyView.js | 13 +++++++++++++ js/subscriptions.js | 15 ++++++++++++++- 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/js/app.js b/js/app.js index 7b84a3f3..16c44557 100644 --- a/js/app.js +++ b/js/app.js @@ -6434,6 +6434,9 @@ class Application { return this.feedEngine.registerFeed("recent", { source: createActiveNostrSource({ service: this.nostrService }), stages: [ + // TODO(tag-preferences): introduce a dedicated stage here to filter by + // viewer interests/disinterests once the runtime metadata is wired up + // to filtering helpers. createBlacklistFilterStage({ shouldIncludeVideo: (video, options) => this.nostrService.shouldIncludeVideo(video, options), @@ -6475,6 +6478,8 @@ class Application { return this.feedEngine.registerFeed("subscriptions", { source: createSubscriptionAuthorsSource({ service: this.nostrService }), stages: [ + // TODO(tag-preferences): introduce preference-aware filtering ahead of + // the blacklist stage when tag-based ranking lands. createBlacklistFilterStage({ shouldIncludeVideo: (video, options) => this.nostrService.shouldIncludeVideo(video, options), @@ -6533,9 +6538,19 @@ class Application { ? new Set(this.blacklistedEventIds) : new Set(); + const preferenceSource = + typeof this.getHashtagPreferences === "function" + ? this.getHashtagPreferences() + : {}; + const { interests = [], disinterests = [] } = preferenceSource || {}; + return { blacklistedEventIds: blacklist, isAuthorBlocked: (pubkey) => this.isAuthorBlocked(pubkey), + tagPreferences: { + interests: Array.isArray(interests) ? [...interests] : [], + disinterests: Array.isArray(disinterests) ? [...disinterests] : [], + }, }; } diff --git a/js/feedEngine/stages.js b/js/feedEngine/stages.js index afc90094..ff6327b7 100644 --- a/js/feedEngine/stages.js +++ b/js/feedEngine/stages.js @@ -97,6 +97,10 @@ export function createBlacklistFilterStage({ const options = { blacklistedEventIds: blacklist, isAuthorBlocked }; + // TODO(tag-preferences): incorporate context.runtime.tagPreferences once the + // filtering helpers are in place so this stage can drop disinterested tags + // without disturbing existing blacklist logic. + const results = []; for (const item of items) { diff --git a/js/historyView.js b/js/historyView.js index 20952f1a..1a385529 100644 --- a/js/historyView.js +++ b/js/historyView.js @@ -103,6 +103,19 @@ function buildWatchHistoryFeedRuntime({ actor, cursor = 0 } = {}) { } }; + const preferenceSource = + typeof app?.getHashtagPreferences === "function" + ? app.getHashtagPreferences() + : {}; + runtime.tagPreferences = { + interests: Array.isArray(preferenceSource?.interests) + ? [...preferenceSource.interests] + : [], + disinterests: Array.isArray(preferenceSource?.disinterests) + ? [...preferenceSource.disinterests] + : [] + }; + if (normalizedActor) { runtime.actor = normalizedActor; } diff --git a/js/subscriptions.js b/js/subscriptions.js index 0ccbff18..dd10460e 100644 --- a/js/subscriptions.js +++ b/js/subscriptions.js @@ -878,12 +878,25 @@ class SubscriptionsManager { ? Math.floor(limitCandidate) : null; + const preferenceSource = + typeof app?.getHashtagPreferences === "function" + ? app.getHashtagPreferences() + : {}; + return { subscriptionAuthors: normalizedAuthors, authors: normalizedAuthors, blacklistedEventIds: blacklist, isAuthorBlocked, - limit: normalizedLimit + limit: normalizedLimit, + tagPreferences: { + interests: Array.isArray(preferenceSource?.interests) + ? [...preferenceSource.interests] + : [], + disinterests: Array.isArray(preferenceSource?.disinterests) + ? [...preferenceSource.disinterests] + : [], + }, }; }