Commit Graph
2065 Commits
Author SHA1 Message Date
google-labs-jules[bot]andPR0M3TH3AN e16eecb4e3 Refactor revertVideo to use helper function for payload construction
- Extracted payload construction logic from `revertVideo` in `js/nostr/client.js` to `buildRevertVideoPayload` in `js/nostr/publishHelpers.js`.
- Moved `resolveStoragePointerValue` from `js/nostr/client.js` to `js/utils/storagePointer.js` to fix circular dependencies and improve code organization.
- Updated imports in `js/nostr/client.js` and `js/nostr/publishHelpers.js`.
- Verified with existing tests.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 03:44:15 +00:00
thePR0M3TH3AN 88227bd4ce Merge pull request #2226 from PR0M3TH3AN/claude/speed-up-nostr-login-BZBNv
Fix auto-login signer restoration and optimize critical login path
2026-02-07 21:09:02 -05:00
Claude 8bf8da03b9 Speed up Nostr login and fix list sync, signer persistence, and feed registration
The NIP-07 login flow was extremely slow because list decryption (blocks,
subscriptions, hashtag preferences) started before the signer was ready.
On page refresh, all three services failed with "permission-required" and
scheduled 3-second retry delays, adding 6-10 seconds to every login.

Key fixes:
- List loading now waits for the permission pre-grant to complete before
  attempting decryption, ensuring the signer is available on first try
- Extension wait timeout increased from 3s to 5s for slower extensions
- Decrypt timeouts reduced from 20s to 10s (signer is guaranteed ready)
- Auto-login now forwards authType/providerId from saved profiles
- Storage tab unlock falls back to ensureActiveSignerForPubkey when the
  global signer is not yet registered
- Watch history feed registration adds defensive re-registration and
  try/catch fallback to prevent "Feed not registered" errors
- Decryption scheme cache TTL extended from 10 minutes to 2 hours
- ensureExtensionPermissions waits for extension injection when there
  are outstanding permissions to request (was returning immediately)

https://claude.ai/code/session_01T4wwPu7m5qp1Nxx3H2v57j
2026-02-08 02:02:51 +00:00
thePR0M3TH3AN 07a9284cb1 Merge branch 'unstable' into test-hashtag-strip-helper-resize-7955570684281399740 2026-02-07 21:00:57 -05:00
thePR0M3TH3AN 32cd6dc2a2 Merge pull request #2222 from PR0M3TH3AN/nip04-worker-tests-17203445750544777231
🧪 Add tests for NIP-04 worker client
2026-02-07 20:54:07 -05:00
google-labs-jules[bot]andPR0M3TH3AN 555df62529 fix: resolve SyntaxError in js/app.js due to duplicate code block
Removed a duplicate/malformed code block in `js/app.js` that was causing `SyntaxError: Unexpected token '.'` during module loading. This error was breaking tests in `tests/app/channel-profile-moderation.test.mjs` and others.

Also restored `_initNostr` and `_initSessionActor` methods which were partially clobbered or malformed in the file structure.

Verified by running the affected unit tests locally.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 01:50:26 +00:00
thePR0M3TH3AN ce16140343 Merge pull request #2225 from PR0M3TH3AN/fix-feed-coordinator-refresh-feed-error-14415813432609543851
Fix TypeError: this.refreshFeed is not a function in Application
2026-02-07 20:39:01 -05:00
google-labs-jules[bot]andPR0M3TH3AN b1e93046fd Fix: Add missing refreshFeed method to Application class to prevent TypeError
The `feedCoordinator` logic assumes `this.refreshFeed` exists on the Application instance (because methods are bound via `bindCoordinator`). However, `Application` previously only implemented `refreshRecentFeed`, `refreshForYouFeed`, etc., but not the generic `refreshFeed`.

This caused a `TypeError: this.refreshFeed is not a function` when `loadFeedVideos` (which calls `refreshFeed`) was invoked.

This commit adds `async refreshFeed(...args)` to `Application` in `js/app.js`, delegating to `this._feed.refreshFeed(...args)`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 01:34:41 +00:00
google-labs-jules[bot]andPR0M3TH3AN 2e2ea34d3c fix: Resolve js/app.js syntax error and update test mocks
- Removed orphaned code block in `js/app.js` that caused syntax errors during module loading.
- Updated `tests/helpers/moderation-test-helpers.mjs` to implement `resumePendingModeratedPlayback` and decoration logic in `MockApplication`, fixing `tests/app/moderation-overrides.test.mjs` and `tests/app/moderation-settings-refresh.test.mjs` failures.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 01:29:09 +00:00
google-labs-jules[bot]andPR0M3TH3AN e734f9ca79 fix: restore _initNostr and fix syntax error in app.js
- Restored missing `_initNostr` method in `js/app.js` which was causing `SyntaxError: Unexpected token '.'` and `nostrClient.init is not a function` errors.
- Removed dangling code block that was causing the syntax error (orphaned `accessControl.refresh()...` block).
- This fixes unit tests (e.g. `tests/app/channel-profile-moderation.test.mjs`) and application initialization.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 01:26:43 +00:00
google-labs-jules[bot]andPR0M3TH3AN db76432ab6 fix(app.js): resolve syntax error and restore _initNostr method
Removes a malformed code block that was causing an "Unexpected token '.'" syntax error and restores the `_initNostr` method which correctly initializes the Nostr client.

Fixes: #1083 (SyntaxError in app.js)

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 01:20:48 +00:00
thePR0M3TH3AN ae5174600d Merge branch 'unstable' into chore/code-health/remove-unused-promises-app-init-18262315909809877684 2026-02-07 20:07:22 -05:00
thePR0M3TH3AN 91cc2781b0 Merge pull request #2218 from PR0M3TH3AN/refactor-application-srp-12044709703939300356
🧹 Refactor Application to use AuthService and PlaybackService for state access
2026-02-07 20:04:32 -05:00
thePR0M3TH3AN 018d3ee7a2 Merge pull request #2220 from PR0M3TH3AN/perf-channel-profile-scan-9174167552854109818
⚡ Optimize channel profile event lookup using author index
2026-02-07 19:42:43 -05:00
thePR0M3TH3AN 55269077ae Merge pull request #2217 from PR0M3TH3AN/refactor-feed-refresh-logic-11328377621655034485
Refactor duplicate feed refresh logic
2026-02-07 19:40:45 -05:00
thePR0M3TH3AN d65b26e892 Merge pull request #2219 from PR0M3TH3AN/refactor-app-init-2582209971545822131
🧹 Refactor Application.init for improved readability
2026-02-07 19:40:25 -05:00
google-labs-jules[bot]andPR0M3TH3AN 67aa8ad2aa Optimize channel profile event lookup with author index
- Replaced `NostrClient.rawEvents` standard Map with `EventsMap`
- Implemented `EventsMap` to maintain an author-based index
- Updated `js/channelProfile.js` to use `getEventsByAuthor` for efficient lookup
- Added unit tests for `EventsMap`
- Added benchmark script verifying ~15x performance improvement (637ms -> 41ms for 1M events)

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:38:42 +00:00
thePR0M3TH3AN effe152c25 Merge pull request #2214 from PR0M3TH3AN/clean-up-legacy-moderation-overrides-18282916472860729392
🧹 Remove legacy moderation overrides support
2026-02-07 19:37:23 -05:00
thePR0M3TH3AN d32ab04c50 Merge pull request #2213 from PR0M3TH3AN/add-nip07-signing-adapter-tests-7079316761627658374
🧪 Add tests for NIP-07 signing adapter factory
2026-02-07 19:37:11 -05:00
google-labs-jules[bot]andPR0M3TH3AN 23b9e36958 Refactor Application.init method to improve readability and maintainability.
- Extracted logic into `_init*` private helper methods.
- Preserved execution order and async behavior.
- Cleaned up the main `init` method to act as an orchestrator.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:36:14 +00:00
google-labs-jules[bot]andPR0M3TH3AN bcacf46f8b Refactor Application to delegate state management to services
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:36:05 +00:00
google-labs-jules[bot]andPR0M3TH3AN b094d2a035 Refactor duplicate feed refresh logic into unified refreshFeed method
- Unify `refreshForYouFeed`, `refreshKidsFeed`, `refreshExploreFeed`, and `refreshRecentFeed` into `refreshFeed(feedType, options)`.
- Update `js/app/feedCoordinator.js` to implement `refreshFeed` and use it in `loadFeedVideos`.
- Update `js/app.js` to delegate specific methods to `refreshFeed`.
- Add `FEED_TYPES` import to `js/app.js`.
- Update `tests/app/feedCoordinator.test.mjs` to match the refactoring.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:35:47 +00:00
thePR0M3TH3AN 50ab3c7b08 Merge pull request #2209 from PR0M3TH3AN/test/relay-health-improvements-4329305953965740034
test: improve relay health service error handling and robustness
2026-02-07 19:35:37 -05:00
thePR0M3TH3AN cc4ff6ff15 Merge pull request #2211 from PR0M3TH3AN/refactor-webtorrent-handlers-11970156008572777463
Refactor WebTorrent handlers
2026-02-07 19:34:45 -05:00
thePR0M3TH3AN a1d6ef31b9 Merge pull request #2210 from PR0M3TH3AN/refactor-build-comment-event-3814978219549166211
Refactor buildCommentEvent logic
2026-02-07 19:34:04 -05:00
thePR0M3TH3AN 15648a5cae Merge pull request #2212 from PR0M3TH3AN/nip46-logging-refactor-8970006357846081703
🧹 Extract NIP-46 logging helpers to utility module
2026-02-07 19:33:49 -05:00
google-labs-jules[bot]andPR0M3TH3AN d4beed100a Remove legacy moderation overrides support
Removed the legacy support for version 1 moderation overrides in `js/state/cache.js`. This includes removing the `LEGACY_MODERATION_OVERRIDE_STORAGE_KEY`, the migration logic in `loadModerationOverridesFromStorage`, and the cleanup logic in `persistModerationOverridesToStorage`.
Updated `tests/state/cache.test.mjs` to include tests verifying that legacy overrides are ignored and not migrated.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:33:27 +00:00
google-labs-jules[bot]andPR0M3TH3AN 0020759231 Add tests for NIP-07 signing adapter factory
- Implements `createNip07SigningAdapter` in `js/auth/signingAdapter.js`.
- Adds unit tests in `tests/auth/signingAdapter.test.mjs` verifying explicit extension handling and window fallback.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:33:13 +00:00
thePR0M3TH3AN 5a1f28d8d5 Merge pull request #2206 from PR0M3TH3AN/test/grid-health-prioritization-7598004344208681336
test: improve gridHealth prioritization testing
2026-02-07 19:30:01 -05:00
google-labs-jules[bot]andPR0M3TH3AN c32e95f372 Refactor NIP-46 logging helpers to dedicated utility module
Moved logging helpers (`summarizeHexForLog`, `summarizeSecretForLog`, etc.) from `js/nostr/nip46Client.js` to `js/nostr/nip46LoggingUtils.js` to reduce clutter and improve reuse. Updated `js/nostr/client.js` and `js/services/authProviders/nip46.js` to import from the new module, removing duplicate definitions in the latter. Verified with existing tests.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:27:45 +00:00
google-labs-jules[bot]andPR0M3TH3AN b2eedb46df Refactor WebTorrent handlers to reduce duplication
- Merged `handleChromeTorrent` and `handleFirefoxTorrent` into `handleTorrentStream` with a `context` parameter.
- Preserved browser-specific logic (CORS workaround for Chrome, highWaterMark for Firefox).
- Added `tests/webtorrent-handlers.test.mjs` to cover the refactored logic.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:27:41 +00:00
google-labs-jules[bot]andPR0M3TH3AN 75753b92fd Refactor buildCommentEvent to use helper functions
Extracted parameter normalization, context resolution, and tag building into dedicated helper functions (`normalizeCommentInputs`, `resolveCommentContext`, `buildCommentTags`) to improve readability and maintainability of `buildCommentEvent`. This simplifies the main function logic and makes it easier to test individual components in the future if exported.

No functional changes intended. Verified with existing unit and integration tests.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:26:53 +00:00
google-labs-jules[bot]andPR0M3TH3AN 596da72cb1 test: improve relay health service error handling and robustness
- Adds a default connection timeout of 5000ms to `RelayHealthService.checkRelay`.
- Adds comprehensive tests for `RelayHealthService` covering:
    - Connection timeouts (mocked).
    - Failure thresholds for user logging.
    - Logging cooldowns (mocked time).
    - Relay `disconnect` and `error` event handling.
    - `nostrClient.markRelayUnreachable` integration.
- Refactors tests to use manual mocking for `setTimeout` and `Date.now` for stability.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:25:42 +00:00
google-labs-jules[bot]andPR0M3TH3AN a7d19fc1db test: improve gridHealth prioritization testing
- Extract `prioritizeEntries` logic to `js/gridHealthLogic.js` for testability
- Add comprehensive unit tests in `tests/grid-health.test.mjs`
- Improve `getIntersectionRect` to robustly handle invalid rects
- Ensure 0x0 rects are filtered out explicitly

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:22:16 +00:00
thePR0M3TH3AN 8108e3dcb7 Merge pull request #2198 from PR0M3TH3AN/unify-hashtag-preferences-key-9274648867585622352
Unify profile cache keys for hashtag preferences
2026-02-07 19:11:11 -05:00
thePR0M3TH3AN 329ce5d842 Merge pull request #2203 from PR0M3TH3AN/test/max-listener-diagnostics-11773877660411760257
test: add tests for max listener diagnostics logic
2026-02-07 19:10:02 -05:00
google-labs-jules[bot]andPR0M3TH3AN ab75153e0b test: add tests for max listener diagnostics logic
Exports `collectCandidateStrings` and `shouldSuppressWarning` from `js/nostr/maxListenerDiagnostics.js` to enable unit testing.
Adds `tests/nostr/maxListenerDiagnostics.test.mjs` to test the warning suppression logic and verify the `process.emitWarning` patch side effect.
Fixes missing `jsdom` dependency issue by running `npm install`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:57:14 +00:00
google-labs-jules[bot]andPR0M3TH3AN 12ba9f07e6 chore: remove dead code and unused promises in Application.init
Removes commented-out `await Promise.all` and refactors the associated
`accessControlPromise` and `adminPanePromise` variables in `js/app.js`.

The promises were only assigned for use in the commented-out line.
This change:
- Converts `accessControl.refresh()` to a direct expression statement.
- Simplifies `adminPanePromise` logic into a direct `if` block, removing
  the unnecessary `else { Promise.resolve(null) }` branch.
- Preserves the existing fire-and-forget behavior for these initialization tasks.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:56:45 +00:00
google-labs-jules[bot]andPR0M3TH3AN 9571e3aedb Fix crash in feed loading by delegating loadFeedVideos
The `loadFeedVideos` method was missing from the `Application` class in `js/app.js`, but was being called by `loadVideos` inside the feed coordinator (which is bound to the application instance). This caused a `TypeError: this.loadFeedVideos is not a function` at runtime.

This change adds the missing delegation method to `Application` in `js/app.js`, forwarding the call to `this._feed.loadFeedVideos`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:55:17 +00:00
google-labs-jules[bot]andPR0M3TH3AN 273cbfd9cc Refactor HashtagPreferencesService to use unified profile cache key
Replaced the legacy "interests" string literal with NOTE_TYPES.HASHTAG_PREFERENCES
in profileCache calls to unify key usage. Updated migration logic and comments.
Verified that the underlying storage key remains consistent for backward compatibility.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:50:18 +00:00
thePR0M3TH3AN a20d01a412 Merge pull request #2197 from PR0M3TH3AN/chore/refactor-remove-custom-bech32-2289762197289114271
🧹 Remove custom Bech32 implementation in nip46Client
2026-02-07 18:40:17 -05:00
google-labs-jules[bot]andPR0M3TH3AN a892d78c4e chore: remove custom bech32 implementation in nip46Client
Removes the custom `bech32Polymod` and related Bech32 decoding functions from `js/nostr/nip46Client.js` in favor of using `nostr-tools` library implementation via `nip19.decode`. This reduces code duplication and relies on the standard library for decoding npubs.

Breaking Changes:
- None. `decodeNpubToHex` now strictly requires `nostr-tools` to be available, which is consistent with the rest of the file's dependencies.

Tests:
- Verified with targeted unit tests (`tests/nostr/nip46Client.test.js`).
- Verified with a reproduction script (`tests/repro_issue.mjs`) ensuring `decodeNpubToHex` correctly decodes valid npubs and handles invalid inputs.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:25:08 +00:00
thePR0M3TH3AN e897bfe44b Merge pull request #2196 from PR0M3TH3AN/perf/channel-profile-render-loop-optimization-15025405161037801037
⚡ Remove dead code execution in channel profile render loop
2026-02-07 18:24:37 -05:00
thePR0M3TH3AN d6b606a6e3 Merge pull request #2185 from PR0M3TH3AN/refactor/remove-unused-import-nostrevent-schemas-1391210410040613476
🧹 Remove unused import WATCH_HISTORY_LIST_IDENTIFIER in nostrEventSchemas.js
2026-02-07 18:20:50 -05:00
google-labs-jules[bot]andPR0M3TH3AN 99d217e778 perf: remove dead code in channel profile render loop
Removes the call to `app.persistWatchHistoryMetadataForVideo` in `renderChannelVideosFromList` within `js/channelProfile.js`. This function was identified as a no-op (delegating to a deprecated empty method), adding unnecessary overhead to the rendering loop.

Benchmark results (100M iterations):
- With call: ~1278ms
- Without call: ~88ms
- Improvement: ~14x speedup in the tight loop simulation.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:20:39 +00:00
thePR0M3TH3AN b549069fc4 Merge pull request #2194 from PR0M3TH3AN/refactor/feed-coordinator-load-logic-7944534665779205819
🧹 Refactor feed loading logic into shared loadFeedVideos method
2026-02-07 18:19:51 -05:00
thePR0M3TH3AN 135841c851 Merge pull request #2193 from PR0M3TH3AN/security/fix-nip46-session-storage-10018068311908189559
🔒 Fix insecure storage of NIP-46 session keys
2026-02-07 18:19:43 -05:00
thePR0M3TH3AN c290959a7e Merge pull request #2192 from PR0M3TH3AN/perf/batch-profile-refresh-14711465702211977594
⚡ Optimize profile refreshing with batch requests
2026-02-07 18:18:50 -05:00
thePR0M3TH3AN 619596d8e5 Merge pull request #2189 from PR0M3TH3AN/security/fix-login-modal-open-redirect-13235976572682331262
🔒 Fix Open Redirect and XSS via NIP-46 Authentication URL
2026-02-07 18:18:41 -05:00
google-labs-jules[bot]andPR0M3TH3AN afd64ba1ce Refactor feed loading logic into shared loadFeedVideos method
- Introduce `loadFeedVideos(feedType, forceFetch)` in `js/app/feedCoordinator.js` to consolidate video loading logic.
- Update `loadForYouVideos`, `loadKidsVideos`, `loadExploreVideos`, and `loadVideos` to use the shared method.
- Parameterize feed-specific configuration (telemetry context, tags, loading messages, relay health checks) based on feed type.
- Add `tests/app/feedCoordinator.test.mjs` to verify the new logic.

Signed-off-by: Jules <[email protected]>

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:15:56 +00:00