Commit Graph
460 Commits
Author SHA1 Message Date
google-labs-jules[bot] 9d06f43321 feat: implement incremental fetching for Nostr lists
Implements a `SyncMetadataStore` to persist last-seen timestamps for replaceable lists (Kind 10000, 30000, 30002, 30015).
Adds `fetchListIncrementally` helper to `NostrClient` which performs per-relay `since` queries.
Updates `SubscriptionsManager`, `UserBlockListManager`, `HashtagPreferencesService`, and `adminListStore` to utilize incremental fetching.
Prevents local cache wipes when incremental fetches return empty results (indicating "no updates").
2026-01-17 21:11:48 +00:00
google-labs-jules[bot] 86ffb8cb2a Define centralized cache policies and wire them into fetchers 2026-01-17 19:12:09 +00:00
google-labs-jules[bot] b059d66d80 Fix watch history mobile layout and sort order
- Updated CSS for `.watch-history-card` to use `flex-col` on mobile for stacked layout, switching to `sm:flex-row` on larger screens.
- Added `w-full` to `.watch-history-card__thumbnail` on mobile to constrain image width.
- Fixed a bug in `js/nostr/watchHistory.js` where `computeWatchHistoryFingerprintForItems` was sorting the live history array in-place by ID, causing the UI to display an incorrect (non-chronological) order. The fix involves creating a shallow copy before sorting.
- Updated `tests/nostr/watchHistory.test.js` to verify behavior against the current storage version (`v5`).
2026-01-17 13:35:37 +00:00
google-labs-jules[bot] cbd8af42a6 Enforce v=2 tag and mandatory encryption for watch history 2026-01-17 11:32:31 +00:00
google-labs-jules[bot] 1d8ab920ce Fix inconsistent subscriptions loading with persistent caching
Implements a stale-while-revalidate strategy for the SubscriptionsManager.
- Loads subscriptions from localStorage immediately to show UI state.
- Fetches fresh data from relays in the background.
- Preserves cached data if relays fail or return empty results (preventing "No subscriptions found" errors).
- Updates cache optimistically on subscribe/unsubscribe actions.
2026-01-16 16:18:02 +00:00
thePR0M3TH3AN d2d55849b9 Add trusted moderation stats to profile modal 2026-01-16 09:55:10 -05:00
google-labs-jules[bot] 98e63e29e6 Expand tests for generic connection payloads and R2-specific mapping
This change adds comprehensive unit and integration tests to cover:
1. `signerKeyManager.js`: Verification of key derivation from signatures and passphrases.
2. `storageService.js`: Tests for saving, retrieving, and decrypting connections, specifically verifying that generic S3 payloads (endpoint, region, bucket) are preserved alongside R2 payloads.
3. `UploadModal.js`: Integration tests mocking the storage service to verify that R2 connection details correctly map to the UI input fields and that the "Unlock" flow updates the UI state.

It also introduces `fake-indexeddb` as a dev dependency to enable reliable testing of IndexedDB interactions in the Node/JSDOM test environment.
2026-01-16 12:07:17 +00:00
google-labs-jules[bot] 7428a6c99f docs: add detailed comments to webtorrent.js and fix test infrastructure
- Added comprehensive comments to `js/webtorrent.js` explaining the playback strategy, service worker integration, and browser-specific quirks (Brave/Firefox).
- Patched `tests/ui/helpers/jsdom-test-helpers.mjs` to expose `HTMLStyleElement` and other globals to JSDOM, fixing `ReferenceError` in UI tests.
- Fixed `tests/ui/similar-content-card.test.mjs` to align with the current component implementation (handling detached elements) and resolving environment issues.
- Updated `tests/video-modal-accessibility.test.mjs` to safely mock `navigator` and `HTMLCanvasElement.getContext`, resolving `TypeError` and "Not implemented" errors during testing.
2026-01-15 22:35:29 +00:00
google-labs-jules[bot] 4cd85b8096 Fix JSDOM reference error and assertion in popover tests
- Exposed `HTMLStyleElement` globally in `tests/ui/popoverEngine.test.mjs` to resolve a `ReferenceError` during `instanceof` checks.
- Updated assertion in "applies token-based sizing and arrow positioning" to check the `--popover-arrow-top` CSS variable instead of the `top` property, as JSDOM does not compute layout properties from variables.
- Verified all tests in the file pass.
2026-01-14 04:29:16 +00:00
google-labs-jules[bot] d9c6cce97d Update subscription manager tests to remove legacy kind requirement
- Modified `tests/subscriptions-manager.test.mjs` to remove the assertion for legacy Kind 30002 support.
- Updated the test to verify that only the current `SUBSCRIPTION_SET_KIND` (30000) is queried.
- Fixed JSDOM `navigator` mocking in the test file to resolve `TypeError: Cannot set property navigator...` errors.
- Verified all tests pass with the new implementation.
2026-01-14 04:17:13 +00:00
google-labs-jules[bot] 4bf3605fd2 Fix: Ensure history pane refreshes on subsequent visits
This change ensures that the profile history pane refreshes its content when the user navigates back to it, addressing a bug where stale data could be displayed.

It implements an optimized strategy:
- On the first load, `ensureInitialLoad` is called, which handles the initial fetch internally.
- On subsequent visits (when the renderer is already initialized), `refresh({ force: true })` is called explicitly to update the list.

The unit test `history pane lazily initializes the watch history renderer` was updated to reflect this behavior, verifying that `ensureInitialLoad` is called once and `refresh` is called on subsequent opens.
2026-01-14 04:05:23 +00:00
google-labs-jules[bot] 05c091c26f Fix unit tests: Expose HTMLStyleElement in JSDOM setup
This change addresses a `ReferenceError: HTMLStyleElement is not defined` failure in `tests/position-floating-panel.test.mjs`. The `popoverEngine.js` source code performs an `instanceof HTMLStyleElement` check, which requires the class to be available in the global scope. While JSDOM provides this class, the test setup was not exposing it to the global object.

- Updated `tests/position-floating-panel.test.mjs` to add `global.HTMLStyleElement = windowRef.HTMLStyleElement;` in the `beforeEach` block.
2026-01-14 03:52:53 +00:00
google-labs-jules[bot] 6735eb0dea Fix comment event validation test case
Added missing root kind (K) and root author (P) tags to the mock event in `tests/nostr/comment-events.test.mjs`. This fixes a test failure where the event was being rejected by strict validation logic in `isVideoCommentEvent` because the tags derived from the definition address were not present in the event itself.

The added tags use whitespace and mixed casing to preserve the test's intent of verifying robust tag parsing.
2026-01-14 03:42:53 +00:00
google-labs-jules[bot] f3075b8929 Fix unit tests for comment events and improve target normalization logic
- Updated `subscribeVideoComments` test to expect `#A` filter keys (uppercase), matching the implementation and other tests.
- Improved `normalizeCommentTarget` in `js/nostr/commentEvents.js` to correctly derive `parentKind` and `parentAuthorPubkey` from the `parentCommentEvent` object if available.
- Enhanced `parentAuthorRelay` resolution to look up the specific `p` tag for the author pubkey instead of defaulting to the first found `p` tag.
- Updated `publishComment` test expectations to remove duplicate tags (implementation correctly deduplicates) and reflect improved metadata derivation (correct `K` tag and `P` relay).
- Added async wait to `subscribeVideoComments` test to prevent race condition in unsubscribe assertion.
2026-01-14 03:22:25 +00:00
thePR0M3TH3AN b48edbb055 Refactor inline styles to CSS rules 2026-01-13 21:13:32 -05:00
google-labs-jules[bot] d6882fb5bb Fix CI, environment, linting, and unit test issues
- Fix circular dependency in `js/adminListStore.js` by importing from `js/nostrClientRegistry.js`.
- Update `js/services/hashtagPreferencesService.js` to include legacy kind 30005 in filters.
- Fix JSDOM mocking in `tests/modal-accessibility.test.mjs` (navigator getter) and `UploadModal` selectors.
- Add `getRoot()` to `js/ui/components/UploadModal.js` for API consistency.
- Update `tests/magnet-utils.test.mjs` expectations to reflect removed default tracker.
- Mock `ensureActiveSignerForPubkey` in `tests/moderation/submit-report.test.mjs`.
- Fix mock loader path in `tests/moderation/trust-seeds.test.mjs` to target `trustBootstrap.js`.
- Fix duplicate pointer tags in `js/nostrEventSchemas.js`'s `buildCommentEvent`.
- Update `tests/nostr/comment-events.test.mjs` and `tests/comment-event-builder.test.mjs` to match current code behavior (legacy kinds, unique tags).
2026-01-13 20:32:06 +00:00
google-labs-jules[bot] e77418f0a8 feat: overlay moderation badge on blurred video thumbnails
Moves the moderation warning badge ("Content blocked...") to overlay the blurred thumbnail image instead of sitting below it or increasing card height. This logic is applied to both the main `VideoCard` and the `SimilarContentCard` to ensure layout consistency.

Changes:
- VideoCard.js: Refactor `updateModerationBadge` to append the badge container as a child of the `anchorEl` (thumbnail wrapper) with absolute positioning.
- SimilarContentCard.js: Implement `refreshModerationUi` logic to generate and overlay a simplified moderation badge on the thumbnail when `trustedMuted` context is present.
- Fix tests/moderation/video-card.test.mjs: Patch test environment to mock `globalThis.navigator`.
2026-01-13 04:29:36 +00:00
google-labs-jules[bot] 85883aa5c6 feat: increase default trusted mute hide threshold to 20
- Updated `DEFAULT_TRUSTED_MUTE_HIDE_THRESHOLD` in `config/instance-config.js` from 1 to 20.
- Updated `tests/moderation/trusted-mute-lists.test.mjs` to explicitly override the threshold to 1 for tests verifying the hide mechanism.
- Updated documentation (`docs/moderation/*.md`, `docs/instance-config.md`, `content/community-guidelines.md`) to reflect the new default and upstream examples.
- Verified that existing blurring logic in `js/feedEngine/stages.js` and `js/ui/components/VideoCard.js` handles the intermediate state (1-19 mutes) correctly.
2026-01-11 21:30:23 +00:00
google-labs-jules[bot] 124a2330ad Update block list selection to prioritize tagged events
- Prioritize Kind 10000 events with `d=user-blocks` over plain mute lists in `loadBlocks`.
- Add `isTaggedBlockListEvent` helper for differentiation.
- Add regression test case to `tests/user-blocks.test.mjs` verifying that tagged lists override newer plain lists.
2026-01-11 21:08:01 +00:00
google-labs-jules[bot] 009eb4c6e2 Fix: Handle tag-only Kind 10000 mute lists in UserBlockListManager
This commit modifies `js/userBlocks.js` to correctly parse Kind 10000 events that have empty content but populated `p` tags (used by clients like Primal). Previously, these events were treated as empty block lists, causing the user's block list to be cleared.

Changes:
- Refactored `loadBlocks` to check for empty content and fallback to extracting pubkeys from tags using `extractPubkeysFromTags`.
- Updated `loadBlocks` to use a sequential promise strategy (`Promise.any` then `Promise.allSettled`) to ensure eventual consistency without race conditions or double-processing.
- Added extensive tests in `tests/user-blocks.test.mjs` covering tag-only lists, whitespace content, and concurrency scenarios.
2026-01-11 20:01:39 +00:00
google-labs-jules[bot] c322fcee14 fix(watch-history): add manual refresh and fix dynamic pulling
This commit addresses issues with the watch history not updating dynamically and adds a manual refresh mechanism.

Changes:
- Added a "Refresh" button to the watch history view in `views/history.html` and `js/historyView.js`.
- Updated `watchHistoryService.js` to accept a `forceRefresh` option in `loadLatest`, which bypasses the cache freshness check and triggers a relay fetch.
- Updated `js/feedEngine/watchHistoryFeed.js` to propagate the `forceRefresh` flag from the runtime context to the service.
- Added user feedback (toast messages and logs) for "Clear Local History" and "Republish Now" actions.
- Updated `tests/watch-history.test.mjs` to align with the new `fetchHistory` signature.
2026-01-07 14:05:21 +00:00
google-labs-jules[bot] 41ff140982 feat: enable dynamic comment loading and sorting 2026-01-07 03:03:46 +00:00
google-labs-jules[bot] cced268982 Fix: Ensure comments controller is initialized when opening video modal
This addresses an issue where comments would not display on the first load of the video modal if the DOM elements were not fully bound. The `open()` method now checks if the `commentsList` is missing or disconnected and re-initializes the `CommentsController` if necessary.

Also updated `tests/video-modal-accessibility.test.mjs` to fix a JSDOM environment issue with `navigator` mocking.
2026-01-07 00:59:47 +00:00
google-labs-jules[bot] 4ab81ce28e Ensure view counts are monotonic during hydration
- Updated `hydratePointer` in `js/viewCounter.js` to only update local view counts if the network count is strictly greater (or if local state is uninitialized).
- This prevents regressions where a partial or stale network response would overwrite a higher, accurate local count.
- Updated `tests/view-counter.test.mjs` to reflect that fresh view events are additive to the cached high watermark (fixing a test expectation that relied on the old non-monotonic behavior).
- Updated `tests/view-counter.test.mjs` to match `resolveVideoPointer` behavior which prioritizes `dTag` (NIP-33) over `videoRootId`, fixing a legacy test failure.
2026-01-07 00:43:18 +00:00
google-labs-jules[bot] f5eba4121f Remove legacy auth cache migration docs and add regression test
Removes obsolete "Migration notes" from `docs/nostr-auth.md` and
adds a regression test to `tests/state/cache-saved-profiles.test.mjs`
to confirm that the legacy `userPubKey` localStorage key is ignored
during startup. Also polyfills localStorage for the test suite.
2026-01-07 00:20:01 +00:00
google-labs-jules[bot] 873b534867 fix(watch-history): use localStorage for pending video queue
Replace sessionStorage with localStorage to ensure pending watch history updates persist across tab closures and sessions. Update `loadLatest` to always restore queue state on initialization to catch any pending uploads.
2026-01-07 00:11:56 +00:00
thePR0M3TH3AN 891226697d Simplify watch history pipeline 2026-01-06 18:53:27 -05:00
google-labs-jules[bot] 4df81f7f19 Remove legacy V1 magnet and unstructured event support
Removed the `ACCEPT_LEGACY_V1` flag and associated logic that supported parsing magnet links from unstructured text notes or tags, as well as support for video events with version < 2.
This simplifies `js/videoEventUtils.js` and `js/nostr/nip71.js`, and removes legacy regex scanning.
Deleted `tests/legacy-infohash.test.mjs` which tested this deprecated functionality.
2026-01-06 21:34:19 +00:00
thePR0M3TH3AN 5979d4e25f Use uppercase tags for comment events 2026-01-06 16:22:49 -05:00
thePR0M3TH3AN bc8bfd1ed5 Remove legacy view filter flag 2026-01-06 15:36:37 -05:00
thePR0M3TH3AN 3996986e63 Remove nostr shim and retarget imports 2026-01-06 15:32:21 -05:00
google-labs-jules[bot] 1b577d3326 Refactor: remove legacy compatibility systems
- Removed `WATCH_HISTORY_LEGACY_KIND` (30078) support from watch history fetch and config.
- Removed `WATCH_HISTORY_LEGACY_LIST_IDENTIFIERS` from config.
- Removed `LEGACY_EVENTS_STORAGE_KEY` (bitvidEvents) migration logic from client.
- Removed `loadLegacyAdminState` and `LEGACY_STORAGE_KEYS` from admin list store.
- Updated tests to remove references to legacy kinds.
2026-01-06 19:48:55 +00:00
google-labs-jules[bot] b3aeb95a0b 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.
2026-01-06 19:03:03 +00:00
google-labs-jules[bot] ac071cb74e Fix(viewCounter): Retain stale view counts for smoother hydration
- Removes the logic in `restoreCacheSnapshot` that deleted cached view counts if they were older than `VIEW_COUNT_CACHE_TTL_MS`.
- Updates `tests/view-counter.test.mjs` to assert that stale cache data is preserved and used as a baseline during hydration, preventing view counts from dropping to zero or lower fallback values during network issues.
2026-01-05 21:01:53 +00:00
google-labs-jules[bot] 99c3f60a23 feat: implement video hydration stage for watch history feed
This introduces a new stage in the watch history feed pipeline that fetches missing video metadata from relays. Since watch history storage was optimized to store only event IDs, this hydration step ensures that the UI can display titles and thumbnails without requiring them to be persisted in the history payload itself.

- Implemented `createWatchHistoryHydrationStage` in `js/feedEngine/watchHistoryFeed.js`.
- Integrated `convertEventToVideo` to transform fetched events into usable video objects.
- Added a comprehensive integration test in `tests/watch-history.test.mjs` verifying the full flow from ID-only storage to hydrated feed items.
2026-01-05 20:22:34 +00:00
google-labs-jules[bot] 4c7230f540 Remove metadata storage and handling from watch history
Removes the metadata argument from `WatchHistoryService.publishView` and cleans up the associated caching and resolution logic in `watchHistory.js` and `watchHistoryFeed.js`. Deletes `js/watchHistoryMetadata.js` as it is no longer used.

This simplification ensures watch history strictly manages pointers and timestamps, leaving metadata resolution to higher-level consumers. It also reduces the payload size and complexity of persisted history records.

Tests have been updated to reflect the API changes.
2026-01-05 16:58:59 +00:00
google-labs-jules[bot] ac3873e5d7 Refactor watch history service to use idempotent monthly upsert logic.
Removes legacy snapshot/chunk retry scheduling in favor of a monthly upsert approach.
Updates state persistence to remove `pendingSnapshotId`.
Fixes race condition in `scheduleRepublishForQueue` by using selective queue pruning.
Ensures data is not lost on publish failure in `snapshot`.
Updates tests to align with new architecture.
2026-01-05 15:42:48 +00:00
google-labs-jules[bot] e9ba3f6681 Refactor watch history to use plaintext monthly buckets
- Update `js/nostrEventSchemas.js` to remove encryption tagging and update schema for `WATCH_HISTORY`.
- Update `js/nostr/watchHistory.js` to:
  - Bump storage version to 4.
  - Bucket items by `YYYY-MM`.
  - Publish plaintext JSON payloads with only event IDs and timestamps.
  - Remove encryption logic from publishing.
  - Update fetching to handle plaintext and fallback to legacy parsing.
- Update `js/watchHistoryService.js` to strip metadata from queued items and handle new snapshot response.
- Update `tests/watch-history.test.mjs` to reflect new plaintext behavior and disabled obsolete tests.
2026-01-05 15:26:31 +00:00
google-labs-jules[bot] cc25635ce6 Refactor watch history to use monthly buckets (v3)
Refactors `js/nostr/watchHistory.js` to store and publish watch history items in monthly buckets (`YYYY-MM`) instead of using chunk splitting. Updates storage version to 3, migrates existing data, and simplifies fetch/merge logic to handle monthly records. Removes legacy chunk rebalancing code. Updates tests to verify monthly bucketing behavior.
2026-01-05 14:11:57 +00:00
google-labs-jules[bot] b79a8eb0d0 Refactor watch history to use monthly payload schema
* Redefine `parseWatchHistoryPayload` to support `month`, `events` (IDs), and `watchedAt` map.
* Update `mergeWatchHistoryItemsWithFallback` to merge new monthly fields with fallback items.
* Update `buildWatchHistoryPayload` to produce payloads with `events` instead of `items`.
* Update `WatchHistoryManager` to remove legacy chunk index handling.
* Ensure backward compatibility for legacy chunk payloads.
2026-01-04 22:15:27 +00:00
google-labs-jules[bot] 595d4cbe07 Refactor watch history to use single monthly event
Replaces the legacy chunked storage architecture with a single encrypted event per month.
- Renames `buildWatchHistoryChunkEvent` to `buildWatchHistoryEvent`.
- Updates `WatchHistoryManager` to publish and fetch single events, maintaining read compatibility for legacy chunks.
- Simplifies payload construction and removes chunk indexing logic.
- Updates tests to verify single-event publishing and legacy fallback.
2026-01-04 22:03:34 +00:00
google-labs-jules[bot] 34b835d4e1 Refactor watch history to use single monthly payload event
Replaces the chunked watch history implementation with a single monthly payload.
This simplifies the event structure and removes chunking logic while maintaining backward compatibility for reading legacy chunked events.
Updates `parseWatchHistoryPayload`, `buildWatchHistoryPayload`, `publishSnapshot` and `fetch` in `js/nostr/watchHistory.js`.
Updates tests to reflect the new single-event behavior.
2026-01-04 21:19:41 +00:00
thePR0M3TH3AN ba666bdaba Refactor watch history payload building 2026-01-03 13:57:46 -05:00
thePR0M3TH3AN e9ce494ccd Remove watch history metadata caching 2026-01-03 09:11:26 -05:00
thePR0M3TH3AN 9310929f0d Ensure trusted seeds hydrate before app creation 2026-01-02 12:18:57 -05:00
thePR0M3TH3AN 16539400e8 Ensure comment snapshots show in video modal on first open 2026-01-02 11:37:22 -05:00
thePR0M3TH3AN 2c8066fd9d Handle synchronous comment snapshots in video modal 2026-01-02 11:24:04 -05:00
thePR0M3TH3AN 9d859b07ed Render guest comment snapshots before auth gating 2026-01-02 11:08:28 -05:00
thePR0M3TH3AN a8119f5b43 Handle login-required comment visibility 2026-01-02 10:13:45 -05:00
thePR0M3TH3AN 3e27f06a13 Add comment thread and modal regression tests 2025-12-29 22:00:32 -05:00