Commit Graph
79 Commits
Author SHA1 Message Date
google-labs-jules[bot]andPR0M3TH3AN c47392aba6 Refactor numeric constants to centralized module
- Introduce `js/constants.js` with semantic time constants (e.g., `ONE_MINUTE_MS`, `STANDARD_TIMEOUT_MS`) and feature-specific TTLs.
- Export `KIND_MUTE_LIST` from `js/nostrEventSchemas.js` to standardize NIP-51 mute list kind usage.
- Refactor `js/state/cache.js`, `js/nostr/cachePolicies.js`, `js/channelProfile.js`, and various services to use centralized constants instead of hardcoded magic numbers.
- Update `js/nostr/relayConstants.js` to derive values from the shared time constants.
- Replace duplicate definitions of timeouts and retry delays across the codebase.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-11 03:27:26 +00: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
Claude 71c153f68d perf: speed up post-login list sync with shared decryption cache
Three performance bottlenecks were causing slow list loading after NIP-07 login:

1. Each list service (blocks, subscriptions, hashtag preferences) maintained
   its own isolated decryptionSuccessCache. When blocks decrypted with nip44_v2,
   subscriptions and hashtag preferences had no way to know — they each had to
   independently probe all schemes through the NIP-07 extension queue, tripling
   the number of extension calls during the critical login path.

2. List loading was gated on both relaysReadyPromise AND permissionPromise in
   the coordinator. Since the NIP-07 extension already grants decrypt permissions
   during loginWithExtension(), the redundant pre-grant was adding 2-5 seconds
   of unnecessary latency before any list fetching could begin.

3. The DECRYPT_RETRY_DELAY_MS was 10 seconds across all services. When a decrypt
   attempt failed transiently (extension still initializing), the retry waited
   far too long before trying again.

Changes:
- Create shared decryptionSchemeCache module used by all three list services
- Add fast-path: when shared cache knows the correct scheme, try ONLY that
  scheme before falling back to parallel Promise.any() probe
- Remove permissionPromise from the list-loading gate in authSessionCoordinator
- Reduce DECRYPT_RETRY_DELAY_MS from 10s to 3s in all three services
- Clear shared cache on logout

https://claude.ai/code/session_013QrGMnxtMTsGTPqaP35jMj
2026-02-07 13:43:15 +00:00
Claude 47e900ebef perf: speed up nostr login by parallelizing list sync and decryption
Login with NIP-07 extensions was extremely slow because list loading
(blocks, subscriptions, hashtag preferences) happened sequentially and
each list's decryption tried encryption schemes one at a time.

Changes:
- Load blocks, subscriptions, and hashtags in parallel instead of
  sequentially (blocks no longer blocks other lists from starting)
- Use Promise.any() to try all decryption schemes simultaneously
  instead of trying nip44_v2 → nip44 → nip04 one-by-one
- Deduplicate same-family schemes (nip44/nip44_v2) to avoid redundant
  extension calls
- Increase NIP-07 request queue concurrency from 3 to 5 to support
  parallel decrypt operations during login
- Raise no-prompt decrypt timeout from 3s/5s to 8s since extensions
  that have already granted permission still need time to decrypt
- Increase feed sync timeout from 8s to 12s to give lists more time
  to settle before rendering unfiltered content

https://claude.ai/code/session_01V6m1gTecsppPrBHQnUyPnF
2026-02-06 22:23:46 +00:00
google-labs-jules[bot]andPR0M3TH3AN a375b8336b Fix slow/failing NIP-07 private-list sync & decryption
- Implemented concurrent queue for NIP-07 requests (max 2)
- Added pre-authorization step at login to prevent redundant prompts
- Sequentialized critical list loading (blocks, subscriptions)
- Optimized decryption with result caching and high priority for critical lists
- Fixed MaxListenersExceededWarning by increasing relay listener limit
- Added concurrency tests

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-06 01:26:41 +00:00
thePR0M3TH3AN 1dbac77753 update from claude 2026-02-05 19:31:19 -05:00
google-labs-jules[bot]andPR0M3TH3AN 13023b1af0 fix(userBlocks): increase decryption timeout and priority
Increases the background decryption timeout for User Block Lists from 5s to 30s and raises the NIP-07 request priority from LOW to NORMAL. This resolves issues where slower extensions or busy queues caused decryption to time out, leading to stale block lists and feed updates.

- Bump `DECRYPT_TIMEOUT_MS` and `BACKGROUND_DECRYPT_TIMEOUT_MS` to 30000ms.
- Use `NIP07_PRIORITY.NORMAL` instead of `LOW` for decryption requests.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-04 16:13:04 +00:00
google-labs-jules[bot]andPR0M3TH3AN cab964e41e Fix user block list decryption timeout and state wiping
Refactored `js/userBlocks.js` to handle NIP-07 decryption timeouts gracefully.
Previously, if a background decryption timed out (common with busy extensions or queues), the user's block list was reset to an empty state, exposing them to blocked content until the next successful retry.
The fix ensures that if a timeout occurs, the existing (stale) block list is preserved while a retry is scheduled in the background.
Also increased the `BACKGROUND_DECRYPT_TIMEOUT_MS` from 2500ms to 5000ms to reduce false positives.

Added `tests/user-blocks-decryption.test.mjs` to verify the fix and audit the decryption flow.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-03 13:31:48 +00:00
google-labs-jules[bot]andPR0M3TH3AN 1954739624 Fix NIP-07 decryption fallback and storage unlock issues
- Updated `StorageService` to check `signer.capabilities` before calling encryption methods, ensuring graceful fallback from NIP-44 to NIP-04.
- Updated `UserBlockList` to check `signer.capabilities` before registering decryptors, preventing "Decryption timed out" errors caused by queueing unsupported method calls.
- Fixed flakiness in `tests/user-blocks.test.mjs` by adding delays to allow background promises to settle between tests.
- Verified changes with reproduction test case and existing test suite.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-02 19:59:24 +00:00
google-labs-jules[bot]andPR0M3TH3AN 9c38ce5105 Fix resource contention between Block List decryption and View Counter signing
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-02 14:20:28 +00:00
google-labs-jules[bot]andPR0M3TH3AN 24a8d1da80 optimize user block list loading performance
Prioritizes fetching standard NIP-51 (Kind 10000) mute lists with a fail-fast timeout (6s) and applies them immediately upon receipt. Legacy block lists (Kind 30002, Kind 10000 d=user-blocks) are now fetched in the background without blocking the UI initialization.

This resolves an issue where slow relays handling legacy queries could cause the entire block list loading process to hang for minutes.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-02 02:47:05 +00:00
google-labs-jules[bot]andPR0M3TH3AN de5e453b34 Refactor user blocking to prioritize standard NIP-51 Mute Lists
- Updates `js/userBlocks.js` to write block entries to a standard Kind 10000 Mute List event.
- Implements a hybrid storage model: unencrypted public mutes are stored in `p` tags, while private blocks are stored in the encrypted event content.
- Maintains read compatibility with legacy `d=user-blocks` lists (both Kind 10000 and Kind 30002) by merging and prioritizing the newest event timestamp.
- Updates local caching to persist both public mutes and private blocks, preventing data loss or "zombie" entries on reload.
- Updates `js/subscriptions.js` to correctly detect NIP-44 capabilities on `Nip07Adapter` signers, fixing a regression where NIP-04 fallback was skipped.
- Updates `js/nostrEventSchemas.js` to mark `USER_BLOCK_LIST` as legacy and define `MUTE_LIST`.
- Updates unit tests to verify the new multi-kind fetching and merged publishing logic.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-01 22:10:42 +00:00
google-labs-jules[bot]andPR0M3TH3AN 8383a4f18b Migrate user blocks to standard NIP-51 Mute List
- Updates `js/userBlocks.js` to treat Kind 10000 (standard Mute List) as the primary write target.
- Public mutes are stored in `p` tags, and private blocks are stored in encrypted content within the same event.
- Legacy `d=user-blocks` lists are still read for backward compatibility (preferring the newest event), but no longer written.
- Updates `js/nostrEventSchemas.js` to mark `USER_BLOCK_LIST` as legacy and standardise `MUTE_LIST`.
- Updates UI controllers (`MoreMenuController`, `ProfileModalController`) to use "Mute/Block List" terminology and delegate all mute/block actions to `userBlocks`.
- Updates `ModerationService` to delegate viewer mute operations to `userBlocks` and disable direct Kind 10000 publishing to prevent overwrites.
- Documentation updated in `docs/nostr-event-schemas.md`.
- Fixes regressions in `more-menu-controller.test.mjs`, `moderation-service.test.mjs`, `trusted-mute-lists.test.mjs`, and `user-blocks.test.mjs`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-01 21:47:29 +00:00
google-labs-jules[bot]andPR0M3TH3AN a920032993 fix(ci): prevent signer timeouts in background tests
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-01-31 07:14:47 +00:00
thePR0M3TH3AN 7ef420e1e2 Defer block list permission prompts during login 2026-01-30 15:53:57 -05:00
google-labs-jules[bot]andPR0M3TH3AN 6347ab0db1 fix(auth): optimize login speed and list decryption
- Reduced decryption timeout for user lists from 90s to 15s to fail faster.
- Optimized NIP-07 decryption calls to avoid retries and long timeouts during critical loading paths.
- Fixed a bug where `loginWithExtension` triggered `getPublicKey` twice, doubling the user interaction time.
- Added a 10s grace period for relay health warnings to prevent false positives on startup.
- Verified `deferBlocks` logic in `authService` prevents blocking the login UI on slow list decryption.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-01-30 20:31:24 +00:00
google-labs-jules[bot]andPR0M3TH3AN 5bdca14364 Fix list loading reliability and optimize NIP-07 login performance
- Fixes issue where user lists (subscriptions, blocks) fail to load if local cache is stale but metadata store is fresh.
- Updates `js/userBlocks.js` and `js/subscriptions.js` to persist `createdAt` timestamp and use it for incremental fetch `since` parameter.
- Optimizes `js/nostr/client.js` `ensureActiveSignerForPubkey` to reduce redundant `getPublicKey` calls to NIP-07 extension by 50%.
- Adds `preloadedPubkey` support to `createNip07Adapter`.
- Adds reproduction test for NIP-07 concurrency issue.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-01-30 19:35:05 +00:00
thePR0M3TH3AN abdfa4b68b Defer NIP-07 encryption permissions 2026-01-30 10:29:00 -05:00
thePR0M3TH3AN a196e95127 Centralize relay list subscriptions 2026-01-29 16:32:11 -05:00
thePR0M3TH3AN 89b8d124fa Consolidate profile metadata fetches 2026-01-29 15:25:08 -05:00
thePR0M3TH3AN 21ec20fc3f Improve user block list decryption handling 2026-01-29 10:27:22 -05:00
google-labs-jules[bot]andPR0M3TH3AN cfbbf78941 chore(ai): add automated PR review report
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-01-28 23:49:33 +00:00
thePR0M3TH3AN 10d628fe35 Fix ensureLoaded pubkey guard 2026-01-28 16:57:24 -05:00
thePR0M3TH3AN e4ad07b2cf Add fast relay fallback for list fetches 2026-01-28 15:28:58 -05:00
thePR0M3TH3AN 7c47208255 Adjust NIP-07 permissions for decrypt flows 2026-01-28 14:47:06 -05:00
google-labs-jules[bot]andPR0M3TH3AN e92c95995f feat: prioritize profile and feed data sync
- Implements a priority queue for NIP-07 (browser extension) requests to allow critical tasks (blocklist/prefs decryption) to jump the line.
- Updates NIP-46 client and adapters to support priority overrides for encryption/decryption.
- Updates UserBlockListManager, SubscriptionsManager, and HashtagPreferencesService to request HIGH priority when decrypting data.
- Ensures strict serialization for NIP-07 to prevent extension errors while optimizing latency for critical data.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-01-28 15:00:15 +00:00
google-labs-jules[bot]andPR0M3TH3AN 498909d60e fix(nostr): serialize nip-07 requests to prevent extension timeouts and crashes
Introduced a request queue in `js/nostr/nip07Permissions.js` to serialize all interactions with the NIP-07 extension (`window.nostr`).
Updated `js/userBlocks.js`, `js/services/hashtagPreferencesService.js`, and `js/auth/signingAdapter.js` to wrap direct extension calls with `runNip07WithRetry`, ensuring they participate in the queue.
This resolves "message channel closed" errors and timeouts caused by concurrent requests flooding the extension during sync operations.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-01-28 14:35:56 +00:00
google-labs-jules[bot]andPR0M3TH3AN 018fd6d599 refactor: update user block fetch logic to prioritize kind 10000 with d-tag
Changes `loadBlocks` to fetch `kind: 10000` with `d=user-blocks` instead of `kind: 30002` for block lists, while keeping the generic `kind: 10000` fetch for mute lists.
Updates `applyEvents` to separate block lists (tagged or legacy 30002) from mute lists (untagged 10000) and merge them instead of prioritizing one over the other.
Updates tests to reflect the merged behavior.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-01-27 23:59:58 +00:00
google-labs-jules[bot]andPR0M3TH3AN 5b69722f72 Improve relay selection and fault tolerance for list fetching
- Updated `NostrClient.fetchListIncrementally` to prioritize user's NIP-65 read relays, cap concurrent requests, and temporarily mark failing relays as unreachable.
- Added `markRelayUnreachable` to `NostrClient` for temporary relay exclusion.
- Updated `SubscriptionsManager`, `HashtagPreferencesService`, and `UserBlockListManager` to use `relayManager.getReadRelayUrls()` for selecting relays, ensuring consistency with user preferences.
- Added structured logging for relay selection in `fetchListIncrementally`.
- Updated unit tests to mock `relayManager` behavior correctly.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-01-27 22:54:31 +00:00
thePR0M3TH3AN 73f8be6c15 Adjust decrypt timeout retries 2026-01-27 17:05:18 -05:00
thePR0M3TH3AN e0bb0edf7a Update user block relay selection 2026-01-27 16:54:37 -05:00
thePR0M3TH3AN 19115c558c Adjust list fetch timeouts 2026-01-27 16:51:08 -05:00
thePR0M3TH3AN 4b407f7ce3 Update user block decryptor signer handling 2026-01-27 16:31:56 -05:00
thePR0M3TH3AN df4a70bfa6 Scope user block cache by profile 2026-01-27 16:29:23 -05:00
google-labs-jules[bot]andPR0M3TH3AN dab94a5cfe Fix slow loading and NIP-07 decryption issues
- Reduced `fetchListIncrementally` timeout to 4000ms to fail faster on bad relays.
- Added 15s timeout to decryption calls in `HashtagPreferencesService`, `UserBlockListManager`, and `SubscriptionsManager` to prevent infinite hangs.
- Added handling for "message channel closed" error in `nip07Adapter` with a backoff delay to allow extension recovery.
- Prioritized preserving cached data on decryption failure instead of resetting to empty state.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-01-27 18:51:34 +00:00
google-labs-jules[bot]andPR0M3TH3AN 3c7a396da9 refactor(auth): decouple NIP-07 logic and optimize list fetching (agent)
- Moved NIP-07 extension detection and permission logic from `NostrClient` to `nip07` provider.
- Removed redundant `login` method from `NostrClient`.
- Increased concurrency and added timeouts to `fetchListIncrementally` to prevent hanging on slow relays.
- Updated `UserBlocks` to force full fetch on cache miss, fixing "empty list" issues.
- Updated unit tests for login permissions and hashtag preferences to reflect architectural changes.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-01-26 21:48:52 +00:00
google-labs-jules[bot]andPR0M3TH3AN 9d820c27e9 fix(nostr): prevent list data loss on fetch failure and optimize login timeout
- Update `fetchListIncrementally` in `js/nostr/client.js` to throw an error if all relays fail, preventing empty returns from being interpreted as data loss.
- Update `HashtagPreferencesService`, `UserBlockListManager`, and `SubscriptionsManager` to handle fetch errors gracefully without wiping local state.
- Update `js/nostr/nip07Permissions.js` to use a short timeout (3s) for experimental permission requests, fixing "clunky" login issues while preserving user interaction time for standard login.
- Remove `try/catch` in `adminListStore.js` fetch logic to allow error propagation to the fallback cache logic.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-01-26 20:16:08 +00:00
thePR0M3TH3AN 5123944a7d update 2026-01-26 13:23:11 -05:00
thePR0M3TH3AN 27b71ba9bb Revert "perf(profile): implement stale-while-revalidate for lists and messages" 2026-01-26 13:18:51 -05:00
google-labs-jules[bot] d61074e200 perf(profile): implement stale-while-revalidate for lists and messages 2026-01-26 18:16:45 +00:00
google-labs-jules[bot] 6884d06192 chore(ai): event schema validation tool + fixes
- Added `scripts/agent/validate-events.mjs` for builder validation.
- Enhanced `js/nostrEventSchemas.js` with `validateEventStructure`.
- Fixed `safeStringify` to handle objects correctly.
- Added `NOTE_TYPES.HTTP_AUTH` and `NOTE_TYPES.REPORT` with builders.
- Refactored `js/userBlocks.js`, `js/auth/signingAdapter.js`, `js/services/moderationService.js` to use builders.
- Updated `tests/user-blocks.test.mjs` mocks and assertions.
- Updated documentation.
2026-01-24 05:36:40 +00:00
google-labs-jules[bot] 4d2bb8bf3d chore(ai): event schema validation tool + fixes
- Added `scripts/agent/validate-events.mjs` to validate event builders against schemas.
- Fixed `NOTE_TYPES.REPOST` schema content format (json instead of empty).
- Added `NOTE_TYPES.MUTE_LIST` and `buildMuteListEvent`.
- Added `buildProfileMetadataEvent` to standardise Kind 0 creation.
- Updated `js/ui/profileModalController.js` to use `buildProfileMetadataEvent`.
- Updated `js/userBlocks.js` to use `buildMuteListEvent` for publishing mute list snapshots.
- Updated `docs/nostr-event-schemas.md` with new schemas and builders.
2026-01-19 05:47:37 +00:00
google-labs-jules[bot] b49a294dc0 feat: isolate view telemetry and restrict session actor publishing
- Add `isSessionActor` helper to `js/nostr/sessionActor.js` to identify ephemeral keys.
- Update `js/nostr/viewEvents.js` to namespace view deduplication caches by `actorPubkey` to prevent data leakage between sessions.
- Block comment publishing for session actors in `js/nostr/commentEvents.js`.
- Block watch history list publishing for session actors in `js/nostr/client.js`.
- Block user block list publishing for session actors in `js/userBlocks.js`.
- Block hashtag preference publishing for session actors in `js/services/hashtagPreferencesService.js`.
- Add inline documentation clarifying variable sources.
2026-01-17 22:48:31 +00:00
google-labs-jules[bot] 3deb8d08f0 Implement profile-scoped caching and signer invalidation logic
- Updated `profileCache.js` to support clearing runtime memory on signer change.
- Updated `NostrClient` to trigger `clearSignerRuntime` on `setActiveSigner`.
- Updated list services (`subscriptions`, `userBlocks`, `hashtagPreferences`, `watchHistory`) to listen for `runtimeCleared` and reload data.
- Updated `NostrClient` sync metadata methods to default to the active profile pubkey.
- Added `partition-updated` event emission to `profileCache`.
2026-01-17 21:43:35 +00:00
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] 926e6ebf39 Refactor user-specific lists to use centralized profileCache 2026-01-17 20:47:27 +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] 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] 146719a32b Fix block/mute list conflict and update trust thresholds
- Refactored `js/userBlocks.js` to merge Kind 10000 and Kind 30002 events on load, preventing overwritten mutes.
- Updated `js/constants.js` to set `DEFAULT_TRUSTED_MUTE_HIDE_THRESHOLD` to 4, enabling soft-hide (blur) behavior for lower mute counts.
2026-01-11 18:58:55 +00:00