Commit Graph
131 Commits
Author SHA1 Message Date
google-labs-jules[bot]andPR0M3TH3AN 15d28cdf35 refactor: replace magic number 5000 with SHORT_TIMEOUT_MS in js/subscriptions.js
Also updates perf/constants-refactor/candidates.json and adds completion log.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 17:54:44 +00:00
google-labs-jules[bot]andPR0M3TH3AN 106f7640c4 fix(exploreData): trigger refresh immediately on visibility change
- `handleVisibility` only scheduled intervals but didn't trigger an immediate refresh when returning to the tab.
- This caused `tests/unit/services/exploreDataService.test.mjs` to fail (assertion `0 !== 1`).
- Added explicit calls to `refreshWatchHistoryTagCounts` and `refreshTagIdf` when `document.hidden` becomes false.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 15:10:29 +00:00
google-labs-jules[bot]andPR0M3TH3AN 9fc650d563 [constants] extract SHORT_TIMEOUT_MS and STANDARD_TIMEOUT_MS
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 21:58:48 +00:00
google-labs-jules[bot]andPR0M3TH3AN 8536f2f858 [security] replace innerHTML usages in js/subscriptions.js — convert to safe DOM APIs
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-13 16:51:33 +00:00
Claude 53b8a2609c fix: recognize NIP-07 signer type for extension permission pre-granting
The NIP-07 adapter uses type "nip07" but all permission pre-granting
checks only matched type "extension", causing NIP-07 browser extension
users to fail decryption for block/mute lists, subscriptions, DMs, and
watch history. Hashtag preferences appeared to work because their read
path had a separate fix, masking the systemic issue.

Changes:
- shouldRequestExtensionPermissions() now matches both "extension" and
  "nip07" signer types (central fix affecting DM signals, comments,
  publish helpers, and watch history fetch)
- buildDmDecryptContext() pre-grants extension permissions for NIP-07
- userBlocks.js: remove capabilities-gated decryptor check that failed
  with lazy NIP-07 module injection (same fix already in subscriptions.js);
  always resolve signer regardless of allowPermissionPrompt; increase
  fast-path relay timeout from 6s to 10s
- watchHistoryService: recognize NIP-07 type and always resolve signer
- All publish paths (blocks, subscriptions, hashtags, relays, uploads,
  sharing, moderation) now pre-grant permissions for NIP-07 signers

https://claude.ai/code/session_01PipsdaTQmw7wBTJ1LmJjkk
2026-02-11 19:41:53 +00:00
google-labs-jules[bot]andPR0M3TH3AN aebb667d1c fix(ai): prevent test timeouts in subscriptions (agent) suggested
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-10 00:28:27 +00:00
Claude 29215d9b5e Speed up Nostr login and fix list sync, storage unlock, and feed registration
- Remove redundant double signer readiness gate evaluation that added 5-10s
  to the login path (authSessionCoordinator)
- Reduce decryption timeouts (10s→6s per scheme, 3s→1.5s retry delay,
  8s→5s NIP-07 no-prompt, 45s→25s overall ensureLoaded) for faster scheme
  fallback during list sync
- Fix storage tab unlock: remove overly strict capabilities check that
  blocked lazy-injecting NIP-07 extensions, and add auto-unlock attempt
  when profile modal opens with an active signer
- Fix subscription/hashtag decryption: always resolve signer for background
  refreshes (was previously gated behind allowPermissionPrompt), and always
  check window.nostr as fallback decryptor regardless of prompt mode
- Fix capabilities check in subscription decryption: use method existence
  instead of dynamic capabilities getter that returns false during lazy
  extension injection
- Wrap Promise.any decryptor calls in Promise.resolve().then() to catch
  synchronous throws from NIP-07 adapter methods when extension modules
  haven't loaded yet
- Make watch-history feed registration race-safe with pre-check and
  try/catch for concurrent registration attempts
- Improve NIP-07 extension detection with DOMContentLoaded listener for
  faster detection of extensions that inject during page load

https://claude.ai/code/session_0174XTB5ADJ9cMBSucqL9Wer
2026-02-09 00:18:43 +00:00
thePR0M3TH3AN 7e07e1ce40 Unify signer-readiness gating for login list sync 2026-02-08 14:27:35 -05:00
thePR0M3TH3AN fd3f9e723a Split subscriptions/hashtag readiness and expose unavailable preference states 2026-02-08 14:10:39 -05:00
Claude 79c5814432 Fix slow Nostr login: unblock NIP-04 decryption, fix signer readiness, storage tab, and watch-history feed
Four issues caused login to be extremely slow and lists to fail syncing:

1. Subscription list decryption excluded NIP-04 when NIP-44 was available,
   preventing decryption of NIP-04-encrypted lists entirely. Removed the
   allowNip04 gate so NIP-04 is always a fallback (matching userBlocks.js
   and hashtagPreferencesService.js which already worked correctly).

2. When the NIP-07 extension permission pre-grant failed (common on page
   refresh when the extension injects slowly), all list services were called
   with allowPermissionPrompt:false and could never recover. Now list
   services are allowed to prompt for permissions themselves when the
   pre-grant fails, avoiding 6-10 second retry delays.

3. The profile modal storage tab was never refreshed on login or logout,
   so it stayed locked even after authentication succeeded. Added
   populateStoragePane() calls to handleAuthLogin and handleAuthLogout.

4. The watch-history feed engine.run() call was missing await, so rejected
   promises from unregistered feeds escaped the try/catch and propagated
   as unhandled errors instead of falling through to the service fallback.

https://claude.ai/code/session_013puYzbf1cC7a59HLcGQUdJ
2026-02-08 02:47:30 +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 1403d2d4cc fix: handle permission-required errors in hashtag preferences background loading
When hashtag preferences decryption fails with "permission-required" during
background loading (allowPermissionPrompt=false), the service silently returned
without setting loaded state, scheduling a retry, or emitting a change event.
This left the UI stuck showing empty hashtag lists. The subscriptions module
already handled this case correctly.

Also fix error scheme mapping in Promise.any() catch blocks for both hashtag
preferences and subscriptions — the index into the original order array was
wrong after filtering out deduplicated scheme families.

https://claude.ai/code/session_016xYxLQ1U2XVVY5rFuCRKfc
2026-02-07 05:42:24 +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
Claude 8a9750002d fix: improve subscription list loading reliability and error recovery
The subscription list was failing to load correctly during login because:

1. Permission-required decryption errors silently returned without setting
   loaded=true or scheduling a retry, leaving subscriptions permanently
   stuck in a loading state.

2. Generic decryption failures (all schemes exhausted) had no retry path,
   unlike timeout errors which already scheduled retries.

3. The ensureLoaded timeout (30s) was too tight for the worst-case
   pipeline of relay fetch (12s) + decryption (20s) = 32s, causing
   premature timeouts that left loaded=false.

4. The loadingPromise was cleared in a finally block even when the loader
   was still in-flight after a timeout, allowing duplicate concurrent
   loads that could race against each other.

Changes:
- Handle permission-required errors like timeout errors: set loaded=true,
  schedule a retry (with allowPermissionPrompt: true), emit change event
- Schedule decrypt retries for all decrypt failure paths
- Increase ensureLoaded timeout from 30s to 45s
- Mark loaded=true on ensureLoaded timeout so the UI can proceed
- Clean up loadingPromise via loader.then() instead of finally block,
  preventing duplicate loads when the first is still in-flight

https://claude.ai/code/session_015MhPiSWNa7dm4UaRuq5x4U
2026-02-06 19:23:36 +00:00
google-labs-jules[bot]andPR0M3TH3AN 849e00a2ff fix: resolve decryption timeouts and listener warnings
Increases NIP-07 concurrency to 3 and lowers priority for non-critical decryption tasks to prevent blocklist timeouts. Increases relay max listeners to 200 to mitigate warnings.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-06 02:00:56 +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
Claude 8a335c2ec8 Fix slow Nostr list sync by decoupling from profile and awaiting before feed render
The login-to-feed pipeline had several issues causing lists (blocks,
subscriptions, hashtag preferences) to load too slowly or not reflect
in the feed:

1. All list loading was chained after profileStatePromise, adding
   2.5-6s of unnecessary delay. Lists only need relay URLs, not profile
   data. Now they chain off relaysReadyPromise instead, loading in
   parallel with profile fetching.

2. The video grid refreshed immediately without waiting for any lists,
   so the feed briefly displayed unfiltered content. Now the grid refresh
   waits (up to 8s) for critical feed-filtering lists to settle.

3. Hashtag preferences weren't cached into the snapshot before the feed
   rendered, so interests/disinterests were empty on first paint.

4. Subscription ensureLoaded had a 6s timeout that was too aggressive
   for relay fetch (12s) + decryption (3-12s), causing silent failures.
   Increased to 30s.

5. Subscription relay fetches for user and session actor ran sequentially.
   Now they run in parallel via Promise.all.

https://claude.ai/code/session_01UKmTWb83AnQPRVQo3bKZqm
2026-02-05 23:55:50 +00:00
google-labs-jules[bot]andPR0M3TH3AN a50e5c861a Add subscription history and backup/restore functionality
- Added `SUBSCRIPTION_BACKUP` note type schema
- Implemented `createBackup`, `fetchHistory`, `restoreBackup`, `rebroadcastBackup` in `SubscriptionsManager`
- Added Subscription History UI modal with list/details view
- Integrated History/Backup buttons into Profile Modal Subscriptions pane
- Fixed XSS vulnerability in history details view
- Added profile fetching for history details

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-02 03:05:13 +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
thePR0M3TH3AN 452d5b1e88 Update subscription encryption tagging and decryption 2026-02-01 15:55:39 -05: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 deec2cd573 Merge pull request #1994 from PR0M3TH3AN/codex/handle-auth-login-failures-and-permissions
Add permission CTA and retry flow for subscriptions & hashtag preferences
2026-01-30 15:40:12 -05:00
thePR0M3TH3AN acf73bc5a3 Add permission CTA for subscriptions and hashtags 2026-01-30 15:39:52 -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 5a5fd50641 Improve relay sanitization and health checks 2026-01-30 10:48:28 -05: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 379287c87c Defer subscription and hashtag decrypt prompts 2026-01-29 13:08:35 -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 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
thePR0M3TH3AN cf9082b83f Add shared NIP-07 permission gate 2026-01-28 13:57:40 -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 2618d4f24a feat: enhance subscription decryption with window.nostr fallback and optimized permissions
- In `js/subscriptions.js`, updated `decryptSubscriptionEvent` to register decryptors from `window.nostr` (NIP-04 and NIP-44 v2) alongside the active signer.
- Refactored permission request logic to only trigger `requestDefaultExtensionPermissions` if neither the active signer nor `window.nostr` supports the required encryption schemes.
- Implemented "fail-fast" behavior to return an error immediately if no suitable decryptor is available, avoiding unnecessary timeouts.
- Removed redundant permission checks from `updateFromRelays` as the logic is now centralized in `decryptSubscriptionEvent`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-01-27 23:30:29 +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 e504776f4e Fetch session actor subscriptions 2026-01-27 17:22:38 -05:00
thePR0M3TH3AN 73f8be6c15 Adjust decrypt timeout retries 2026-01-27 17:05:18 -05:00
thePR0M3TH3AN 19115c558c Adjust list fetch timeouts 2026-01-27 16:51:08 -05:00
thePR0M3TH3AN 2ab8bf8637 Update subscription cache metadata handling 2026-01-27 16:27: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 73541168f7 fix(subscriptions): improve reliability of list loading and button responsiveness
- Implemented optimistic UI updates for the channel subscribe button to improve responsiveness.
- Fixed a race condition in `js/subscriptions.js` and `js/services/hashtagPreferencesService.js` where lists were wiped on refresh due to `profileCache.activePubkey` not being initialized in time. Now using `profileCache.getProfileData(pubkey, ...)` to ensure the correct cache entry is loaded.
- Validated with targeted unit tests.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-01-26 18:56:34 +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
thePR0M3TH3AN 06c7cf912a Add subscription toggle helper 2026-01-18 19:40:58 -05:00
thePR0M3TH3AN 52d2488d17 Refactor nostr signer access 2026-01-18 09:15:18 -05: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