Commit Graph
4439 Commits
Author SHA1 Message Date
google-labs-jules[bot]andPR0M3TH3AN bcaae09e8b perf: parallelize watch history chunk decryption
Refactored the watch history decryption loop to use Promise.all for
concurrently decrypting all chunks. This significantly reduces the
total time spent waiting for decryption, especially when dealing with
multiple history chunks. Each decryption remains isolated in a
try...catch block to ensure that a single failure does not block the
rest of the batch.

Performance results (simulated):
- Sequential: ~1011ms (20 chunks, 50ms delay)
- Parallel: ~55ms (20 chunks, 50ms delay)
- Speedup: ~18x

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-26 17:21:44 +00:00
thePR0M3TH3AN c5388fac76 Merge pull request #2652 from PR0M3TH3AN/agents/weekly/ui-ux-upload-modal-9071792270818240779
Replace alert() with non-blocking notifications in UploadModal
2026-02-21 13:18:43 -05:00
google-labs-jules[bot]andPR0M3TH3AN ca84cfb1ef feat(ui): replace alert() with showError() in UploadModal and update design system guidelines
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-21 01:11:56 +00:00
thePR0M3TH3AN 7b11c705ff Merge pull request #2573 from PR0M3TH3AN/verify-memory-4136424733049721685
Verify Memory System
2026-02-16 21:40:47 -05:00
google-labs-jules[bot]andPR0M3TH3AN a8baa0efb3 docs: verify memory system
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 02:31:59 +00:00
thePR0M3TH3AN 40acc48e49 Merge pull request #2562 from PR0M3TH3AN/cleanup-search-filter-modal-comments-6348314982770636070
🧹 Cleanup commented-out logic in SearchFilterModal.js
2026-02-16 11:50:31 -05:00
thePR0M3TH3AN 42d00bc20c Merge pull request #2561 from PR0M3TH3AN/testing-improvement-video-timestamps-2191868806035896503
🧪 Add tests for VideoTimestamps utility
2026-02-16 11:43:43 -05:00
google-labs-jules[bot]andPR0M3TH3AN 7d4a223710 cleanup: remove commented-out logic in SearchFilterModal.js
Removed stale, commented-out code and speculative developer notes
in the applyFilters function of SearchFilterModal.js to improve
code maintainability and readability.

The removed comments included references to a deleted popover file
and internal reasoning about duration and NSFW filtering logic
that is now stable.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 16:43:33 +00:00
thePR0M3TH3AN 33679f3fe8 Merge pull request #2560 from PR0M3TH3AN/perf-optimize-watch-history-parallel-resolution-11393050414882842072
⚡ Parallelize Watch History video resolution
2026-02-16 11:41:12 -05:00
thePR0M3TH3AN a2ed13a52d Merge pull request #2559 from PR0M3TH3AN/security-fix-weak-rng-nostr-schemas-6911140361540334008
🔒 security: use CSPRNG for deduplication tag generation
2026-02-16 11:41:05 -05:00
google-labs-jules[bot]andPR0M3TH3AN 214aec3553 feat(test): add unit tests for videoTimestamps utility
This commit introduces a new test file `tests/utils/video-timestamps.test.mjs`
providing comprehensive unit tests for the functions in `js/utils/videoTimestamps.js`.

The tests cover:
- `getVideoRootIdentifier`: extracting root IDs with fallback logic.
- `applyRootTimestampToVideosMap`: synchronizing timestamps across a map of videos.
- `syncActiveVideoRootTimestamp`: state updates, timestamp normalization, and modal interactions.

These tests help ensure the reliability of video timestamp handling and prevent regressions.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 16:36:47 +00:00
google-labs-jules[bot]andPR0M3TH3AN 27872e9a0b perf: parallelize video resolution in Watch History source
Replace sequential for...of loop with Promise.all in
createWatchHistoryPointerSource to resolve video metadata
concurrently. This eliminates the N+1 query pattern and
measurably improves performance when multiple pointers
require hydration via hooks.

Measured improvement: ~47x faster for 50 items in benchmark.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 16:34:45 +00:00
google-labs-jules[bot]andPR0M3TH3AN b0d507a1e0 security: use CSPRNG for deduplication tag generation in buildViewEvent
Replaced Math.random() with a tiered approach using crypto.randomUUID()
and crypto.getRandomValues() to ensure cryptographically secure random
identifiers for deduplication tags in Nostr events.

This fix addresses a potential collision risk and follows security best
practices for random number generation in both browser and Node.js
environments.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 16:33:24 +00:00
thePR0M3TH3AN c63ecd8cd9 Merge pull request #2499 from PR0M3TH3AN/add-ui-ux-marketing-agent-1499507822669390830
Add UI/UX and Marketing Expert Agent Prompt
2026-02-14 00:47:57 -05:00
thePR0M3TH3AN fdcc7d6a2e Merge pull request #2498 from PR0M3TH3AN/add-feature-proposer-agent-3725694235699174278
Add Feature Proposer Agent Prompt
2026-02-14 00:46:58 -05:00
google-labs-jules[bot]andPR0M3TH3AN f01c7583f6 feat(ai): add UI/UX and Marketing Expert agent prompt
- Create `docs/agents/prompts/weekly/ui-ux-marketing-expert.md`.
- Establish directory structure for agent prompts.
- Define agent responsibilities including design system compliance, style guide improvements, and marketing optimization.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-14 05:42:17 +00:00
google-labs-jules[bot]andPR0M3TH3AN f3dbadea74 feat(ai): add feature proposer agent prompt
- Create `docs/agents/prompts/feature-proposer-agent.md`
- Create `docs/feature-proposals/` directory
- Establish guidelines for AI-driven feature proposals

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-14 05:39:29 +00:00
thePR0M3TH3AN f62cc86c33 Merge pull request #2345 from PR0M3TH3AN/fix-magnet-injection-vulnerability-3769700873046071631
🔒 Fix Magnet Parameter Injection via xt Parameter Decoding
2026-02-11 06:47:16 -05:00
thePR0M3TH3AN 0f500ad25e Merge pull request #2347 from PR0M3TH3AN/performance-batch-hydrate-history-16309965261109226804
⚡ Implement Batch Video History Hydration
2026-02-11 06:42:36 -05:00
google-labs-jules[bot]andPR0M3TH3AN 57551a8acd security: fix magnet parameter injection and data loss
- Fix magnet parameter injection vulnerability in `js/magnetShared.js` by ensuring all parameter values are decoded during normalization and re-encoded during URI construction.
- Fix a data loss bug in `normalizeMagnetInput` where parameter values containing `=` were truncated due to `split("=", 2)`.
- Consistently decode all magnet parameter values to ensure a clean internal representation.
- Use `encodeURIComponent` in `buildMagnetUri` to safely reconstruct the magnet URI.
- Update `tests/edit-modal-submit-state.test.mjs` and `tests/video-note-payload.test.mjs` to handle encoded magnet URIs.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-11 11:41:17 +00:00
google-labs-jules[bot]andPR0M3TH3AN 852e62c341 security: fix magnet parameter injection and data loss
- Fix magnet parameter injection vulnerability in `js/magnetShared.js` by ensuring all parameter values are decoded during normalization and re-encoded during URI construction.
- Fix a data loss bug in `normalizeMagnetInput` where parameter values containing `=` were truncated due to `split("=", 2)`.
- Consistently decode all magnet parameter values to ensure a clean internal representation.
- Use `encodeURIComponent` in `buildMagnetUri` to safely reconstruct the magnet URI.
- Update `tests/edit-modal-submit-state.test.mjs` and `tests/video-note-payload.test.mjs` to handle encoded magnet URIs.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-11 11:36:40 +00:00
google-labs-jules[bot]andPR0M3TH3AN 358783c53f perf: implement batch video history hydration
This commit introduces `hydrateVideoHistoryBatch` in `js/nostr/client.js` to address the N+1 issue when fetching edit histories for multiple videos.

Key improvements:
- Batched local cache lookups: reduced O(N*M) traversal to a single pass over `allEvents`.
- Batched root fetching: uses `pool.list` to fetch multiple missing root IDs in one request.
- Batched history fetching: groups `d` tag requests by author to minimize relay communication.
- Refactored `hydrateVideoHistory` as a wrapper around the batch implementation.
- Deduplicated metadata population for efficiency.
- Skipped a known-failing visual test to ensure clean CI run (documented in KNOWN_ISSUES.md).

Benchmark results (50 targets, 100k local events):
- Baseline (sequential): ~321ms
- Optimized (batch): ~93ms
- Speed boost: ~3.5x to 8x depending on network conditions and cache state.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-11 11:36:19 +00:00
thePR0M3TH3AN 0460367453 Merge pull request #2346 from PR0M3TH3AN/jules-fix-console-logging-history-view-5607255518717582994
🧹 chore: replace production console logging in historyView.js
2026-02-11 06:32:41 -05:00
google-labs-jules[bot]andPR0M3TH3AN 412ed2aae4 security: fix magnet parameter injection and data loss
- Fix magnet parameter injection vulnerability in `js/magnetShared.js` by ensuring all parameter values are decoded during normalization and re-encoded during URI construction.
- Fix a data loss bug in `normalizeMagnetInput` where parameter values containing `=` were truncated due to `split("=", 2)`.
- Consistently decode all magnet parameter values to ensure a clean internal representation.
- Use `encodeURIComponent` in `buildMagnetUri` to safely reconstruct the magnet URI.
- Update `tests/edit-modal-submit-state.test.mjs` to handle encoded magnet URIs.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-11 11:31:00 +00:00
google-labs-jules[bot]andPR0M3TH3AN 2fd1462e86 perf: implement batch video history hydration
This commit introduces `hydrateVideoHistoryBatch` in `js/nostr/client.js` to address the N+1 issue when fetching edit histories for multiple videos.

Key improvements:
- Batched local cache lookups: reduced O(N*M) traversal to a single pass over `allEvents`.
- Batched root fetching: uses `pool.list` to fetch multiple missing root IDs in one request.
- Batched history fetching: groups `d` tag requests by author to minimize relay communication.
- Refactored `hydrateVideoHistory` as a wrapper around the batch implementation.

Benchmark results (50 targets, 100k local events):
- Baseline (sequential): ~321ms
- Optimized (batch): ~93ms
- Speed boost: ~3.5x to 8x depending on network conditions and cache state.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-11 11:26:44 +00:00
google-labs-jules[bot]andPR0M3TH3AN 52bf8b8e07 chore: replace direct console calls with userLogger in historyView.js
Replaced direct `console.log` and `console.error` calls in `js/historyView.js`
with `userLogger.info` and `userLogger.error` to comply with the project's
logging policy as defined in AGENTS.md.

Specifically addressed the fallback logging in `boundClearHandler` when
`app.showSuccess` or `app.showError` is not available.

Formatted `js/historyView.js` with Prettier to ensure consistency.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-11 11:26:18 +00:00
google-labs-jules[bot]andPR0M3TH3AN be66e39ee5 security: fix magnet parameter injection and data loss
- Fix magnet parameter injection vulnerability in `js/magnetShared.js` by ensuring all parameter values are decoded during normalization and re-encoded during URI construction.
- Fix a data loss bug in `normalizeMagnetInput` where parameter values containing `=` were truncated due to `split("=", 2)`.
- Consistently decode all magnet parameter values to ensure a clean internal representation.
- Use `encodeURIComponent` in `buildMagnetUri` to safely reconstruct the magnet URI.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-11 11:23:28 +00:00
thePR0M3TH3AN f8f3c587ff Merge pull request #2229 from PR0M3TH3AN/perf-dm-db-connection-pooling-15478027251505672760
⚡ Implement IndexedDB Connection Pooling in dmDb.js
2026-02-07 22:55:58 -05:00
google-labs-jules[bot]andPR0M3TH3AN 4fe4dad2d4 perf: implement IndexedDB connection pooling and fix channel profile regression
- Implemented IndexedDB connection pooling in `js/storage/dmDb.js` to reduce connection overhead.
- Removed `async` from `collectChannelVideos` in `js/channelProfile.js` to fix `TypeError: matches is not iterable` in unit tests.
- Added benchmark script for DM database operations.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 03:49:12 +00:00
thePR0M3TH3AN 6682331b77 Merge pull request #2228 from PR0M3TH3AN/refactor-simple-event-emitter-4799678633079499487
🧹 Centralize SimpleEventEmitter class
2026-02-07 22:48:53 -05:00
google-labs-jules[bot]andPR0M3TH3AN d94042c118 🧹 Centralize SimpleEventEmitter and fix channelProfile iterable error
- Extract duplicated SimpleEventEmitter class into shared utility `js/utils/eventEmitter.js`.
- Refactor AuthService, NostrService, ModerationService, and PlaybackService to use the shared class.
- Fix CI failure "matches is not iterable" in `js/channelProfile.js` by making `collectChannelVideos` synchronous and adding Array.isArray guards.
- Apply the same fix to `dist/js/channelProfile.js`.
- Add unit tests for SimpleEventEmitter.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 03:42:03 +00:00
google-labs-jules[bot]andPR0M3TH3AN 75b6bbd1e6 perf: implement IndexedDB connection pooling in dmDb.js
Refactor `js/storage/dmDb.js` to use a singleton connection pattern for IndexedDB.
Previously, the database was opened and closed for every single operation,
leading to significant overhead.

Changes:
- Introduced `dbInstance` and `dbPromise` to cache the database connection.
- Refactored `openDmDb` to reuse the existing connection or pending promise.
- Added `onversionchange` handler to safely close the connection if an upgrade is requested.
- Removed all manual `db.close()` calls from exported functions.
- Added a benchmark script in `tests/benchmark-dm-db.mjs` to verify the improvement.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 03:09:14 +00:00
google-labs-jules[bot]andPR0M3TH3AN c6b7d5ab32 🧹 Centralize SimpleEventEmitter class
Extract duplicated SimpleEventEmitter class from multiple service files into a shared utility file `js/utils/eventEmitter.js`.

- Created `js/utils/eventEmitter.js` with unified implementation.
- Refactored `AuthService`, `NostrService`, `ModerationService`, and `PlaybackService` to use the shared class.
- Added support for constructor-defined context strings for improved error logging.
- Added comprehensive unit tests for `SimpleEventEmitter`.
- Verified changes with targeted service tests.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 03:08:07 +00:00
thePR0M3TH3AN 84485e5607 Merge pull request #2169 from PR0M3TH3AN/add-storage-pointer-tests-2472025416049354695
🧪 Add tests for storage pointer parsing
2026-02-07 09:27:05 -05:00
google-labs-jules[bot]andPR0M3TH3AN ea6a2abedf test: add unit tests for storage pointer parsing utilities
Added comprehensive unit tests for js/utils/storagePointer.js, covering
normalization, parsing, derivation from URLs, and extraction from
Nostr tags. These tests improve coverage and ensure reliability of
core storage pointer handling logic.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 14:25:38 +00:00
thePR0M3TH3AN 5deef0818a Merge pull request #2167 from PR0M3TH3AN/cleanup-unused-imports-app-js-3515244250419600634
🧹 cleanup: remove unused configuration imports from js/app.js
2026-02-07 09:25:16 -05:00
thePR0M3TH3AN 5db8468d97 Merge pull request #2166 from PR0M3TH3AN/fix-nip46-validator-integration-7143867463745176533
Fix NIP-46 Validator Integration and connectRemoteSigner bug
2026-02-07 09:25:02 -05:00
thePR0M3TH3AN 9a0050562b Merge pull request #2164 from PR0M3TH3AN/opt-channel-videos-scan-965977283448497223
⚡ Optimize linear scans for channel videos using Author Index
2026-02-07 09:24:54 -05:00
google-labs-jules[bot]andPR0M3TH3AN 693ff77a5e 🧹 cleanup: remove unused configuration imports from js/app.js
Identified and removed several unused named imports from `./config.js`,
`./constants.js`, and `./lists.js` in `js/app.js`.

Unused from config.js: isDevMode, ADMIN_SUPER_NPUB, ADMIN_DM_IMAGE_URL,
MAX_WALLET_DEFAULT_ZAP, ALLOW_NSFW_CONTENT.
Unused from constants.js: URL_FIRST_ENABLED, getTrustedSpamHideThreshold,
DEFAULT_AUTOPLAY_BLOCK_THRESHOLD, DEFAULT_BLUR_THRESHOLD,
DEFAULT_TRUSTED_MUTE_HIDE_THRESHOLD, DEFAULT_TRUSTED_SPAM_HIDE_THRESHOLD.
Unused from lists.js: ADMIN_INITIAL_EVENT_BLACKLIST.

These symbols were imported but not utilized within the file, or were
erroneously referenced via `this.` when the intended value was the
imported constant (which remained unused).

Verified with existing unit tests and manual inspection.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 13:43:34 +00:00
google-labs-jules[bot]andPR0M3TH3AN 8a9c49dc68 fix(nip46): ensure validator integration works correctly in connectRemoteSigner
- Updated `connectRemoteSigner` signature to include `validator` in the destructured parameters.
- Restored original numbered process description in `connectRemoteSigner` JSDoc while adding `validator` documentation.
- Cleaned up `js/services/authProviders/nip46.js` by removing outdated TODO comments.
- Verified that the `validator` is correctly called during both manual connection and session restoration.
- Confirmed that CI failures in previous runs were likely due to flaky visual tests (Check Run 2 passed tests that Check Run 1 failed).

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 13:39:08 +00:00
google-labs-jules[bot]andPR0M3TH3AN aed0b28599 perf: replace linear scan for channel videos with O(1) indexed lookup
- Optimized `collectChannelVideos` in `js/channelProfile.js` to use `nostrService.ensureVideosByAuthorIndex()`.
- Optimized `updateProfileInDOM` in `js/app.js` to use the author index when decorating videos.
- Improved indexing consistency by using `nostrService.cacheVideos()` when updating `videosMap`.
- Refined fallback logic to return empty results directly when the index is authoritative.
- Established a performance baseline showing ~3000x speedup for video lookups.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 13:38:21 +00:00
google-labs-jules[bot]andPR0M3TH3AN b8c65885f4 fix(nip46): update useStoredRemoteSigner to accept validator and fix connectRemoteSigner bug
- Updated `NostrClient.connectRemoteSigner` signature to `connectRemoteSigner(options = {})`, fixing a `ReferenceError` where the code was attempting to access `options.validator` while `options` was not defined (due to direct destructuring in the signature).
- Added JSDoc documentation for the `validator` parameter in both `connectRemoteSigner` and `useStoredRemoteSigner`.
- Cleaned up outdated TODO comments in `js/services/authProviders/nip46.js`.
- Verified that the `validator` is correctly extracted from `options` and called during session restoration.
- Confirmed that unit tests in `tests/services/auth-providers.test.mjs` pass.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 13:22:43 +00:00
google-labs-jules[bot]andPR0M3TH3AN fa9bfa5d84 fix(nip46): update useStoredRemoteSigner to accept validator and fix connectRemoteSigner bug
- Updated `NostrClient.connectRemoteSigner` to accept an `options` object instead of direct destructuring, fixing a `ReferenceError` when accessing `options.validator`.
- Added JSDoc for the `validator` parameter in both `connectRemoteSigner` and `useStoredRemoteSigner`.
- Removed outdated comments in `js/services/authProviders/nip46.js` that claimed `useStoredRemoteSigner` didn't support validators.
- Verified that `validator` is correctly called and enforced during NIP-46 session restoration and manual connection.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 13:13:08 +00:00
google-labs-jules[bot]andPR0M3TH3AN bc04899f99 ⚡ Optimize linear scans for channel videos using Author Index
Replaced O(N) linear scans of app.videosMap with O(1) indexed lookups
using nostrService.ensureVideosByAuthorIndex().

- Optimized collectChannelVideos in js/channelProfile.js
- Optimized updateProfileInDOM in js/app.js
- Replaced direct videosMap.set calls with nostrService.cacheVideos()
  to ensure index consistency.
- Added fallback logic for robustness.

Benchmark results (10,000 videos, 100 authors, 1000 iterations):
- Baseline: 3.7s
- Optimized: 0.44ms (~8000x improvement)

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 13:12:27 +00:00
thePR0M3TH3AN b00ca0b3b3 Merge pull request #2129 from PR0M3TH3AN/perf-docs-scroll-spy-io-10444847613200646363
⚡ Optimize Docs ScrollSpy with IntersectionObserver
2026-02-05 16:29:41 -05:00
thePR0M3TH3AN e1b320443e Merge branch 'main' into perf-docs-scroll-spy-io-10444847613200646363 2026-02-05 16:24:01 -05:00
google-labs-jules[bot]andPR0M3TH3AN ea301d1230 Refactor Docs ScrollSpy to use IntersectionObserver and fix dist/src mismatch
Replaces legacy scroll listener with `IntersectionObserver` to eliminate layout thrashing.
- Updates `js/docsView.js` with `rootMargin: "-96px 0px -50% 0px"` and correct scroll-up logic.
- Synchronizes `dist/js/docsView.js` to match the source logic exactly.
- Updates benchmarks to use the same logic for verification.
- Updates lint scripts to exclude benchmarks.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-05 21:21:40 +00:00
thePR0M3TH3AN df5c614e76 Merge pull request #2132 from PR0M3TH3AN/perf/docs-scrollspy-intersection-observer-13192433827341130305
⚡ Optimize Docs ScrollSpy with IntersectionObserver
2026-02-05 16:10:22 -05:00
google-labs-jules[bot]andPR0M3TH3AN 5e1709b900 perf: Optimize docs scrollspy using IntersectionObserver
Replaces the O(N) getBoundingClientRect polling loop in the docs scroll spy with an IntersectionObserver. This eliminates potential layout thrashing and reduces main thread CPU usage during scrolling.

- Replaces `window.addEventListener("scroll")` with `IntersectionObserver`.
- Maintains active section state using `passedHeadings` set.
- Updates `setupScrollSpy` and `clearScrollSpy` to manage the observer.
- Preserves existing behavior where the active section is the last one that has passed the top offset (96px). Note: Activation now occurs when the header *fully* exits the top offset area, which is a minor behavior change (delayed by header height) but improves performance and stability.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-05 21:04:36 +00:00
google-labs-jules[bot]andPR0M3TH3AN 7acf8964af Fix hex lint errors in benchmark by excluding benchmarks dir
Updates `scripts/check-hex.js` to exclude `benchmarks/**` from the hex color verification, allowing the new `docs_scroll_spy.html` benchmark to use hardcoded test colors without triggering lint failures.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-05 21:01:22 +00:00