Commit Graph
183 Commits
Author SHA1 Message Date
google-labs-jules[bot]andPR0M3TH3AN bd6ca5b54e [decompose] extract BlockList and EditProfile from ProfileModalController
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 20:10:37 +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 d22785bb87 [decompose] extract helpers from js/ui/profileModalController.js
Extracted DM Relay UI logic and DM Attachment logic into separate binder modules to reduce the size of ProfileModalController.js. Updated file size baseline.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 01:03:43 +00:00
google-labs-jules[bot]andPR0M3TH3AN 5338942ea3 docs: document profileModalController.js and add architecture overview (docs-code-investigator)
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-14 17:41:32 +00:00
google-labs-jules[bot]andPR0M3TH3AN 6209d32b52 fix: add missing moderation aliases to ProfileModalController
- Added aliases/delegate properties for `moderationBlurInput`, `moderationAutoplayInput`, `moderationMuteHideInput`, `moderationSpamHideInput`, `moderationSaveButton`, `moderationResetButton`, `moderationStatusText`, `moderationOverridesList`, `moderationOverridesEmpty`, `moderationTrustedContactsCount`, `moderationTrustedMuteCount`, `moderationTrustedReportCount`, `moderationSeedOnlyIndicator`, `moderationHideControlsGroup`, `moderationHideControlElements` to `ProfileModalController.js`.
- Added delegate methods for `handleModerationSettingsSave`, `handleModerationSettingsReset`, `getModerationSettingsDefaults`.
- This ensures backward compatibility for existing tests like `tests/ui/profile-modal-moderation-settings.test.mjs`.
- Verified with unit tests (`tests/profile-modal-controller.test.mjs` and `tests/ui/profile-modal-moderation-settings.test.mjs`).

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-14 11:07:08 +00:00
google-labs-jules[bot]andPR0M3TH3AN f35d27d471 fix: repair profileModalController decomposition by adding delegate methods
- Added delegate methods for `refreshAdminPaneState`, `refreshModerationSettingsUi`, `updateModerationTrustStats`, `runAdminMutation`, `sendAdminListNotification`, `describeAdminError`, `describeNotificationError`, `notifyAdminError` to `ProfileModalController.js`.
- Added aliases for properties like `moderatorSection` in `ProfileModalController.js` to satisfy tests.
- Removed duplicated method implementations from `ProfileModalController.js`.
- Verified with unit tests (`tests/profile-modal-controller.test.mjs`) and linting.
- Reduced `ProfileModalController.js` size by ~2000 lines.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-14 10:59:14 +00:00
google-labs-jules[bot]andPR0M3TH3AN 4059d52847 fix(ui): profile modal controller instantiation order
- Moved controller instantiation (DM, Relay, Hashtag) to after services setup in `ProfileModalController.js`.
- Fixed `ProfileHashtagController` usage of uninitialized services.
- Updated `profile-modal-controller.test.mjs` mock to include `uiReady/dataReady` flags and use correct service access pattern.
- Resolved CI failures in `profile-modal-controller.test.mjs`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-13 03:50:42 +00:00
google-labs-jules[bot]andPR0M3TH3AN 393c06c749 [decompose] extract ProfileHashtagController from js/ui/profileModalController.js
Extracts all hashtag preference related logic into a new controller
`js/ui/profileModal/ProfileHashtagController.js` to reduce the size of `js/ui/profileModalController.js` and improve maintainability.

- Moves `normalizeHashtagTag`, `formatHashtagTag`, `getResolvedHashtagPreferences`, `setHashtagStatus`, `refreshHashtagBackgroundStatus`, `populateHashtagPreferences`, `renderHashtagList`, `sanitizeHashtagList`, `createHashtagListItem`, `persistHashtagPreferences`, `handleAddHashtagPreference`, `handleRemoveHashtagPreference`, `handleHashtagPreferencesChange`, `describeHashtagPreferencesError`.
- Updates `ProfileModalController` to delegate to `ProfileHashtagController`.
- Adds delegate getters/methods in `ProfileModalController` to maintain backward compatibility for tests.
- Reduces `js/ui/profileModalController.js` by ~600 lines.
- Updates file size baseline in `scripts/check-file-size.mjs`.

Passes `npm run lint` and `npm run test:unit`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-13 02:06:08 +00:00
google-labs-jules[bot]andPR0M3TH3AN 5f1edebea7 [decompose] extract ProfileHashtagController from js/ui/profileModalController.js
Extracts all hashtag preference related logic into a new controller
`js/ui/profileModal/ProfileHashtagController.js` to reduce the size of `js/ui/profileModalController.js` and improve maintainability.

- Moves `normalizeHashtagTag`, `formatHashtagTag`, `getResolvedHashtagPreferences`, `setHashtagStatus`, `refreshHashtagBackgroundStatus`, `populateHashtagPreferences`, `renderHashtagList`, `sanitizeHashtagList`, `createHashtagListItem`, `persistHashtagPreferences`, `handleAddHashtagPreference`, `handleRemoveHashtagPreference`, `handleHashtagPreferencesChange`, `describeHashtagPreferencesError`.
- Updates `ProfileModalController` to delegate to `ProfileHashtagController`.
- Reduces `js/ui/profileModalController.js` by ~600 lines.
- Updates file size baseline in `scripts/check-file-size.mjs`.

Passes `npm run lint` and `npm run test:unit`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-13 01:39:22 +00:00
google-labs-jules[bot]andPR0M3TH3AN df62585106 perf: enable lazy loading for avatars and thumbnails
Added `loading="lazy"` and `decoding="async"` attributes to dynamically created `<img>` elements in:
- `js/historyView.js` (avatars)
- `js/ui/subscriptionHistoryController.js` (channel icons)
- `js/searchView.js` (added `decoding="async"`)
- `js/ui/profileModal/ProfileDirectMessageRenderer.js` (attachment previews, avatars)
- `js/ui/profileModalController.js` (attachment previews, saved profile avatars)

This reduces initial page load impact and bandwidth usage by deferring off-screen image loading.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-12 16:56:06 +00:00
google-labs-jules[bot]andPR0M3TH3AN 7300977a6d [decompose] extract DM and Relay controllers from ProfileModalController
Extracted ProfileDirectMessageController (split into Controller, Actions, Renderer, Helper) and ProfileRelayController from ProfileModalController to reduce file size and improve maintainability.

ProfileModalController.js size reduced from ~12000 lines to ~8750 lines.
Updated unit tests to reflect the new structure.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-11 21:15:06 +00:00
thePR0M3TH3AN b1f06695a6 Merge pull request #2339 from PR0M3TH3AN/suppress-nip17-relay-warning-3701543430430345832
Add config to suppress NIP-17 relay warnings
2026-02-10 23:06:50 -05:00
google-labs-jules[bot]andPR0M3TH3AN 5ca378bb96 Add ENABLE_NIP17_RELAY_WARNING config to suppress privacy warnings
Added a new configuration variable `ENABLE_NIP17_RELAY_WARNING` to `config/instance-config.js` (defaulting to `false`) to control the display of NIP-17 relay fallback warnings. Updated `js/ui/profileModalController.js` and `js/app.js` to respect this setting.

This change allows instance operators to disable "Privacy warning: direct messages are using your default relays because no NIP-17 relay list is available" and related notifications.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-11 04:05:36 +00:00
thePR0M3TH3AN ca57f9caaf Merge pull request #2336 from PR0M3TH3AN/decompose-profile-modal-controller-5857031998313460612
Decompose ProfileModalController: Extract Wallet and Storage Controllers
2026-02-10 22:57:11 -05:00
google-labs-jules[bot]andPR0M3TH3AN 48d33f45eb [decompose] Extract Wallet and Storage controllers from ProfileModalController
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-11 03:30:40 +00:00
google-labs-jules[bot]andPR0M3TH3AN 8ca4a71240 [security] Migrate innerHTML in profileModalController.js
Replaced 26 instances of `innerHTML` assignment with safe DOM APIs (`textContent`, `replaceChildren`, `document.createElement`) in `js/ui/profileModalController.js`.
Updated the `scripts/check-innerhtml.mjs` baseline to reflect the reduction (from 27 to 1). The remaining instance loads a static HTML template.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-11 03:11:39 +00:00
google-labs-jules[bot]andPR0M3TH3AN 319e2f4c9e [decompose] Extract profile modal logic
Extract contracts, default settings, and helpers from `js/ui/profileModalController.js` to `js/ui/profileModalContract.js`.
This reduces the file size of `js/ui/profileModalController.js` by 884 lines.

- Moved `SERVICE_CONTRACT`, `STATE_CONTRACT` and their builders.
- Moved internal settings helpers (`createInternalDefaultNwcSettings`, etc).
- Moved badge helpers (`resolveProviderBadgeClass`).
- Updated `scripts/check-file-size.mjs` with new line count.
- Cleaned up imports in `profileModalController.js`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-10 04:04:55 +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 44dfcc363b Improve storage unlock permission and decrypt error handling 2026-02-08 14:38:21 -05:00
thePR0M3TH3AN fd3f9e723a Split subscriptions/hashtag readiness and expose unavailable preference states 2026-02-08 14:10:39 -05:00
thePR0M3TH3AN ffc248ecd3 Track auth list sync outcomes and expose retryable auth status 2026-02-08 13:52:04 -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 416a809ae4 fix: apply block/mute list filtering to DM messages and conversations
The user's block/mute list (NIP-51) was not being checked when
processing direct messages, allowing blocked users' messages to appear
in conversations, trigger notifications, and increment unseen counts.

This adds block filtering at four layers:
- nostrService.applyDirectMessage: drops incoming DMs from blocked users
  before they enter the in-memory message cache
- nostrService.persistDirectMessageRecord: prevents blocked DM senders
  from being persisted to IndexedDB or triggering notifications
- profileModalController.buildDmConversationData: filters blocked users
  from the conversation list UI (catches pre-block persisted messages)
- applicationBootstrap: excludes blocked-user conversations from the
  unread DM badge count

The block checker is injected via setDmBlockChecker() to keep
nostrService decoupled from userBlocks, wired up in app.js init().

https://claude.ai/code/session_01EAVLtAM14GN99Eik8otLg2
2026-02-06 19:41:50 +00:00
google-labs-jules[bot]andPR0M3TH3AN d45b115f07 Fix annoying DM relay warning and clarify settings UI
- Throttle the "Privacy warning: direct messages are using your default relays..." message so it only appears once per session/identity change.
- Rename "DM Relay Hints" to "NIP-17 Relay List" in the DM Settings modal to match the warning message and reduce user confusion.
- Add regression test for the warning throttling logic.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-04 16:16:15 +00:00
google-labs-jules[bot]andPR0M3TH3AN b3f37058a2 Defer profile modal data loading to improve responsiveness
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-03 14:44:32 +00:00
google-labs-jules[bot]andPR0M3TH3AN 9485003ffd Refactor DM settings into a dedicated modal
- Created `DMSettingsModalController` to manage the new settings modal UI.
- Added `components/dm-settings-modal.html` with sections for Privacy and DM Relay Hints.
- Updated `AppShell.js` to delegate the settings action to `onOpenSettings` callback, bypassing the legacy popover.
- Updated `ProfileModalController.js` to wire up the new modal controller, handling state persistence for relays and privacy settings.
- This improves the UX for managing NIP-17 DM relay hints and privacy options.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-02 19:43:06 +00:00
google-labs-jules[bot]andPR0M3TH3AN 5df489e504 Combine relay list with relay health check
- Remove separate relay health panel from profile modal.
- Merge health indicators (latency, errors) directly into the relay list items.
- Consolidate refresh logic to update both list configuration and health status.
- Move telemetry toggle to the bottom of the relay section.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-02 14:03:09 +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 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
thePR0M3TH3AN ee3923f169 Update DM focus on default selection 2026-02-01 12:57:04 -05:00
thePR0M3TH3AN b1418d02e5 Render DM threads before profile hydration 2026-02-01 12:36:16 -05:00
google-labs-jules[bot]andPR0M3TH3AN 51087fad7e refactor(ai): extract handleAddProfile from js/app.js (agent)
Moves `handleAddProfile` logic from the main application class into `ProfileModalController` to improve separation of concerns as per `AGENTS.md`.

- Extracts `handleAddProfile` to `js/ui/profileModalController.js`.
- Updates `ProfileModalController` to handle add account flow internally.
- Removes legacy callback wiring from `js/app.js` and `js/ui/applicationBootstrap.js`.
- Adds unit tests for the extracted logic in `tests/ui/profileModalController-addProfile.test.mjs`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-01-31 03:32:52 +00:00
thePR0M3TH3AN acf73bc5a3 Add permission CTA for subscriptions and hashtags 2026-01-30 15:39:52 -05:00
thePR0M3TH3AN 09c0ac8127 Add relay health summary banner 2026-01-30 11:08:02 -05:00
thePR0M3TH3AN 25ac2a2c6b Handle NIP-44 decryptor DM errors 2026-01-30 10:32:40 -05:00
thePR0M3TH3AN abdfa4b68b Defer NIP-07 encryption permissions 2026-01-30 10:29:00 -05:00
thePR0M3TH3AN 2726ee9ed4 Batch direct message UI updates 2026-01-29 19:07:29 -05:00
thePR0M3TH3AN 379287c87c Defer subscription and hashtag decrypt prompts 2026-01-29 13:08:35 -05:00
thePR0M3TH3AN c4a00653f4 Move DM relay settings into DM settings popover 2026-01-29 11:52:41 -05:00
thePR0M3TH3AN f116fff337 Wire profile modal refresh buttons 2026-01-29 11:35:15 -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 c14b29031c Handle empty block list when signed out 2026-01-28 16:49:31 -05:00
thePR0M3TH3AN dd9b9f1968 Defer login hydration loads 2026-01-28 15:15:52 -05:00
thePR0M3TH3AN 7c47208255 Adjust NIP-07 permissions for decrypt flows 2026-01-28 14:47:06 -05:00
google-labs-jules[bot]andPR0M3TH3AN 63d4b3ffd1 feat(dm): implement incremental delivery for direct messages
- Added `onMessage` callback to `NostrClient.listDirectMessages` to stream decrypted messages.
- Updated `NostrService.loadDirectMessages` to use the callback and trigger `applyDirectMessage` incrementally.
- Updated `ProfileModalController` to allow rendering updates during the initial load if the reason is `load-incremental`.
- Verified changes with existing tests and code review.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-01-28 00:11:32 +00:00
google-labs-jules[bot]andPR0M3TH3AN bc51f21c0d Fix profile modal opening latency by deferring expensive UI updates
The profile modal was slow to open (~100ms+ delay) when a user has many trusted contacts, blocked users, or moderation reports, because `refreshModerationSettingsUi` and `populateBlockedList` were called synchronously before making the modal visible.

This change refactors `ProfileModalController.show()` to:
1. Render the header synchronously (fast).
2. Call `open()` immediately to make the modal visible.
3. Defer expensive data population (`refreshModerationSettingsUi`, `populateBlockedList`, `refreshWalletPaneState`) to the next animation frame using `requestAnimationFrame`.

This significantly improves the perceived responsiveness of the profile button.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-01-27 19:03:03 +00:00
google-labs-jules[bot]andPR0M3TH3AN fd4318c2f9 fix(core): optimize moderation subscriptions and reduce log noise (agent)
- Refactor `ModerationService` to use batched subscriptions for trusted mute lists, reducing relay load.
- Fix `WebTorrent` memory leak by setting `setMaxListeners(0)` on client instances.
- Suppress "Failed to connect to relay" warnings in `countDiagnostics.js`.
- Degrade benign DM sync errors (e.g. "no-decryptors") to info/debug logs in `profileModalController.js`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-01-26 23:40:59 +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