Commit Graph
39 Commits
Author SHA1 Message Date
Claude 445262110b refactor(agents): simplify scheduler to Nostr-only locking
Remove the git push and GitHub API fallback methods from the scheduler
flow, leaving only the Nostr lock as the single locking mechanism.

This significantly reduces the agent reasoning chain:
- scheduler-flow.md: 10 steps → 8 steps, single code path
- META_PROMPTS.md: 5 MUST blocks → 4, no jq pipeline or branching
- AGENTS.md: 3-method protocol → 2 commands (check + lock)

The agent no longer needs to parse jq output, decide between methods,
handle cascading fallbacks, or perform manual race detection. It runs
two scripts and checks exit codes.

https://claude.ai/code/session_01BpDsVSAkVWtJLnfKxsB9ib
2026-02-13 20:59:44 +00:00
Claude 86f322550a feat(agents): add Nostr-based distributed task locking via NIP-78
Replace GitHub draft PR as the primary locking mechanism with Nostr
relay-based locks. Each agent generates an ephemeral keypair, publishes
a NIP-78 (Kind 30078) lock event with NIP-40 auto-expiration, and
discards the key. No tokens, no secrets, no git push required.

New script: scripts/agent/nostr-lock.mjs
  - check: query relays for active locks, return JSON exclusion set
  - lock: claim a task with built-in race detection (exit 3 = lost)
  - list: human-readable table of all active locks

The locking fallback chain is now:
  1. Nostr lock (no credentials needed, works in any sandbox)
  2. git push + draft PR (traditional method)
  3. GitHub API via curl (needs GITHUB_TOKEN)

Updated scheduler-flow.md, META_PROMPTS.md, and AGENTS.md to document
all three methods with Nostr as the preferred primary.

https://claude.ai/code/session_01BpDsVSAkVWtJLnfKxsB9ib
2026-02-13 20:53:14 +00:00
Claude 9e5797c5e0 fix(agents): add GitHub API fallback for task locking in restricted environments
Jules agents cannot git push due to sandbox restrictions, which breaks the
draft PR-based distributed lock mechanism. Multiple agents can pick up the
same task because the claim is never visible remotely.

This adds scripts/agent/claim-task-api.sh which creates the remote branch,
started.md log file, and draft PR entirely via curl and the GitHub REST API,
bypassing git push. The scheduler-flow.md, META_PROMPTS.md, and AGENTS.md
are updated to document the fallback: try git push first, fall back to the
API script if push is blocked, fail-closed if neither method works.

https://claude.ai/code/session_01BpDsVSAkVWtJLnfKxsB9ib
2026-02-13 20:29:38 +00:00
Claude ce72c4bbad fix(agents): replace gh CLI with curl for PR checking to prevent duplicate work
Agents do not have access to gh CLI, causing them to skip the pre-flight
PR check and collide on duplicate work. This replaces all gh-based PR
checking commands with curl + jq using the GitHub REST API, updates the
task claiming protocol to use branch push + started log file as the
primary lock mechanism, and updates automation scripts to use curl for
PR listing and git fetch for PR checkout.

Files updated:
- AGENTS.md (Section 12 coordination rules)
- CLAUDE.md (coordination rules)
- META_PROMPTS.md (daily + weekly meta prompts)
- daily-scheduler.md (pre-flight gate, task claiming, error handling)
- weekly-scheduler.md (pre-flight gate, task claiming, error handling)
- bitvid-pr-review-agent.md (PR enumeration + checkout)
- bitvid-ci-health-agent.md (CI run gathering)
- bitvid-weekly-synthesis-agent.md (PR metadata gathering)
- bitvid-changelog-agent.md (PR metadata verification)
- scripts/agent/review-open-prs.mjs (PR listing + checkout)
- scripts/automated-pr-review.mjs (--all mode PR listing + checkout)

https://claude.ai/code/session_01L5bzzGpZ6YTiLXcfqaL81G
2026-02-13 15:47:42 +00:00
Claude f794971bfc fix(agents): rewrite scheduler prompts to force pre-flight execution
Agents were skipping the pre-flight curl/gh check for in-progress work,
causing duplicate task runs. Root causes:

1. Two-document indirection (meta prompt → scheduler) caused the pre-flight
   instructions to get lost when the agent opened the second file
2. No proof-of-execution gate — agents could assert "no conflicts" without
   actually running the commands
3. curl|jq pipeline silently fails when jq is unavailable
4. "Step 0" labeling felt like skippable preamble

Changes:
- Make the commands the literal first instruction ("run NOW, paste output")
- Use gh CLI as primary (authenticated, no jq needed), curl as fallback
- Require raw terminal output pasted before proceeding (output gate)
- Rename "Step 0" to "PRE-FLIGHT GATE" to signal it's not optional
- Eliminate duplication between meta prompt and scheduler files
- Add explicit "STOP HERE" checkpoint after command execution
- Add skip-ahead clause for agents arriving from meta prompt

https://claude.ai/code/session_01S7jaQb9ctJ4bzqRhEcm28Q
2026-02-13 05:21:25 +00:00
Claude 0e46902ed0 chore(agents): run event-schema-agent weekly task — enhance validator with CLI, reporting, and registry checks
Enhanced scripts/agent/validate-events.mjs with:
- CLI options: --dry-run, --out=<path>, --only=<builder>
- JSON report output (artifacts/validate-events-YYYYMMDD.json)
- sanitizeAdditionalTags test cases (3 tests)
- Schema registry verification via getAllNostrEventSchemas (35 checks)
- Runtime construction site mapping (29 call sites across codebase)
- Structured report format per agent prompt spec

All 66 validation checks pass. No schema failures found.

https://claude.ai/code/session_018HLVbfKYtfPMWcSMaC1W7N
2026-02-13 05:12:52 +00:00
Claude 00b103cf6e chore(agents): claim event-schema-agent weekly task
https://claude.ai/code/session_018HLVbfKYtfPMWcSMaC1W7N
2026-02-13 05:03:26 +00:00
Claude 17a736b8da refactor(agents): migrate task logs from CSV to directory-based format
Replace shared CSV files (AGENT_TASK_LOG.csv, WEEKLY_AGENT_TASK_LOG.csv)
with per-entry files in docs/agents/task-logs/{daily,weekly}/. Each log
entry is now a separate file named YYYY-MM-DD_HH-MM-SS_<agent>_<status>.md,
eliminating git merge conflicts and race conditions when multiple agents
run concurrently.

Updated files:
- daily-scheduler.md: rewritten for directory-based log format
- weekly-scheduler.md: rewritten for directory-based log format
- META_PROMPTS.md: updated pre-flight scan and claiming instructions
- AGENTS.md: updated scheduler reference from CSV to directory-based

Migrated all existing CSV entries to individual files in the new
directory structure.

https://claude.ai/code/session_01P62EWUXwupgxPhpnRejUuz
2026-02-13 04:41:05 +00:00
Claude 857e820d65 fix(agents): prevent duplicate job selection in scheduler prompts
Agents were repeatedly picking up content-audit-agent because:
1. CSV only updated after task completion — crashes left no trace
2. PR claim check (Step 1.5) was buried and easy to skip
3. No "started" status meant failed runs were invisible to rotation
4. Pre-flight scan was too narrow (checked one agent, not all)

Changes:
- Add Step 0 (mandatory pre-flight) that scans ALL open PRs and CSV
  for in-progress work before selecting any task
- Introduce "started" CSV status logged immediately upon claiming,
  before task execution begins — ensures rotation advances on crash
- Promote claim check from sub-step 1.5 to full Step 2 with explicit
  MANDATORY warnings
- Add 24-hour stale claim timeout for abandoned "started" entries
- Add fallback: if gh is unavailable, CSV "started" rows still work
- Strengthen META_PROMPTS.md to front-load deduplication as Step 0
  with explicit "this has happened before" warning language
- Add Quick Reference table summarizing all 5 deduplication layers

https://claude.ai/code/session_017QCJvunQJ7ATr6uZBHV5iA
2026-02-13 00:08:36 +00:00
Claude 749dece7dd docs(agents): add draft PR task claiming protocol to prevent duplicate work
When multiple agents (Claude Code, Codex, Jules) run schedulers concurrently,
they can pick up the same task because neither has committed yet. This adds a
"Draft PR Lock" protocol: agents must check for and create a draft PR before
starting work, acting as a distributed lock visible to all platforms.

Changes:
- AGENTS.md §12: new "Task Claiming Protocol" subsection with check/claim/race
  handling steps
- daily-scheduler.md: new Step 1.5 with concrete gh CLI commands
- weekly-scheduler.md: same Step 1.5 addition

https://claude.ai/code/session_01Vnih5ZARbEmnh3EGTDQAXX
2026-02-12 22:02:37 +00:00
Claude 843f1a8c2d docs(agents): add prompt library supporting docs
Add three supporting documents for prompt library maintenance:

- PROMPT_LIBRARY_STATUS.md: current health, inventory of all 36
  prompts, changes this run, known remaining issues
- STYLE_GUIDE.md: canonical prompt template, naming conventions,
  voice/tone guidance, anti-patterns to avoid
- RESEARCH_LOG.md: web research on prompt-engineering best practices
  from Anthropic and OpenAI (2025-2026), with library impact analysis

https://claude.ai/code/session_01Nz6FJopPp2YHEscJrRAFNv
2026-02-12 20:42:41 +00:00
Claude 6a79cb52c5 docs(agents): fix behavioral defects in agent prompts (P2)
- Remove AI generation artifacts (:contentReference) from
  docs-code-investigator (4 occurrences)
- Fix require() -> import in event-schema-agent example
  (project uses ES modules)
- Clarify nonexistent script reference in const-refactor-agent
  (scripts/find-numeric-literals.js must be created, not assumed)
- Close truncated code blocks and add TODO notices in interop-agent
  and smoke-agent (both missing Failure Modes and Outputs sections)

No agent mission changes.

https://claude.ai/code/session_01Nz6FJopPp2YHEscJrRAFNv
2026-02-12 20:42:22 +00:00
Claude c96982f469 docs(agents): fix policy violations in agent prompts (P1)
- Fix agent name typo: bitvd -> bitvid in content-audit-agent
- Remove emoji from PR titles in content-audit, docs-alignment, perf,
  and perf-optimization agents (CLAUDE.md prohibits emoji)
- Fix identity/filename mismatch: style-agent.md said stylelint-agent

No agent mission changes.

https://claude.ai/code/session_01Nz6FJopPp2YHEscJrRAFNv
2026-02-12 20:42:00 +00:00
Claude de5296e44c docs(agents): add race-condition-agent to weekly rotation
Add a weekly race condition agent that systematically audits the codebase
for concurrency hazards, timing bugs, and initialization races. The agent
covers relay connection ordering, signer availability, playback fallback
negotiation, cache state consistency, and DOM-ready assumptions.

https://claude.ai/code/session_01AudwR75Y4Bi4WLSYEAJPVW
2026-02-12 19:57:15 +00:00
Claude 2e0bcefa4b docs(agents): add scheduler-update-agent to daily rotation
Add a new daily agent whose job is to keep the daily and weekly scheduler
rosters in sync with the actual prompt files on disk. It scans the prompt
directories, diffs against the roster tables, and applies additions,
removals, or filename corrections as needed.

- New file: docs/agents/prompts/daily/bitvid-scheduler-update-agent.md
- Updated daily-scheduler.md roster (20 -> 21 agents)

https://claude.ai/code/session_01KZQjoJKmPH74AK3QF1pzSq
2026-02-12 19:43:46 +00:00
Claude d559bd6d0b chore(agents): add weekly agent scheduler prompt and task log
- Add weekly-scheduler.md with rotation logic for 3 weekly agents
  (changelog-agent, frontend-console-debug-agent, perf-deepdive-agent)
- Add separate WEEKLY_AGENT_TASK_LOG.csv to keep weekly and daily
  rotations independent
- Mirrors the daily-scheduler.md structure with the same authority
  hierarchy, error handling, and log format

https://claude.ai/code/session_017PuKrVuAUbo1seo7jBTbw6
2026-02-12 19:34:50 +00:00
Claude 647abfdd05 chore(agents): add daily agent scheduler prompt and task log
Replace the ad-hoc scheduling instructions with a structured
scheduler prompt that handles task rotation, error cases, and
CSV-based run tracking.

https://claude.ai/code/session_019EdLsbzCWtht1R3qk7pptb
2026-02-12 19:22:43 +00:00
Claude 33851013d8 docs: add Agent Execution Protocol (AGENTS.md §15)
Introduces a structured meta-workflow for AI agents that ensures
safe incremental changes, persistent state across context resets,
and a clear decision trail for multi-agent coordination.

Key additions:
- Work scoping (goal, success criteria, non-goals)
- External notes files (CONTEXT.md, TODO.md, DECISIONS.md, TEST_LOG.md)
- Locate → Implement → Verify → Update notes work loop
- Context recovery procedure for new agent sessions
- Quality bar principles
- Cross-references from CLAUDE.md to the new section

https://claude.ai/code/session_0159eSJrqKvKpgDiwYZ2iGxK
2026-02-12 18:54:14 +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
Claude f43cad1902 docs: add agent testing infrastructure documentation to AGENTS.md and CLAUDE.md
Section 14 in AGENTS.md covers the full test harness API, mock relay
HTTP endpoints, Playwright fixture usage, and data-testid selector
reference. CLAUDE.md testing section updated with quick-start example.

https://claude.ai/code/session_01XnrszNmdqrAGd8g8qhAn4G
2026-02-10 05:24:54 +00:00
Claude d0a6c9622b feat: add Playwright agent testability infrastructure
Add test harness (window.__bitvidTest__), data-testid attributes, relay
override support, and Playwright fixtures so agents can programmatically
login, seed relay data, and inspect app state during E2E testing.

- js/testHarness.js: exposes loginWithNsec, getAppState, relay overrides
- data-testid attrs on login/upload/video modals, header buttons, feed
- simple-relay.mjs: HTTP seeding API (POST /seed, GET /events, /health)
- bitvidTestFixture.ts: reusable Playwright fixture with mock relay
- agent-testability.spec.ts: E2E tests validating the infrastructure

https://claude.ai/code/session_01XnrszNmdqrAGd8g8qhAn4G
2026-02-10 05:09:46 +00:00
Claude 804b3323c4 Add code health lint guards, consolidate relay constants, document agent prompts
Three CI-enforced lint scripts to prevent common codebase growth problems:

- lint:file-size — enforces 1000-line max for new JS files, grandfathers
  existing oversized files and prevents them from growing further
- lint:innerhtml — tracks innerHTML usage per-file with a baseline count,
  blocks new innerHTML additions (guides agents toward safe DOM APIs)
- Relay constants consolidated from duplicate definitions in client.js and
  ConnectionManager.js into shared js/nostr/relayConstants.js
- AGENTS.md Section 13: documents all three rules with examples
- docs/scheduled-agent-prompts.md: copy-paste prompts for recurring
  file decomposition, innerHTML migration, and constant dedup tasks

https://claude.ai/code/session_01LzErpH9FNw4hAPsjoYb1v9
2026-02-10 03:25:18 +00:00
Claude 1ebfefe9c8 Add multi-agent coordination guide to AGENTS.md and CLAUDE.md
- AGENTS.md Section 12: subsystem boundary table, PR discipline rules,
  in-flight work reservation section, and signaling conventions for
  parallel AI agent workflows (Claude Code, Codex, Jules)
- CLAUDE.md: document the unstable→beta→main promotion pipeline,
  add multi-agent workflow section with coordination rules for both
  agents and human maintainers, fix Node.js version reference (20→22)

https://claude.ai/code/session_01LzErpH9FNw4hAPsjoYb1v9
2026-02-10 02:44:35 +00:00
Claude 696a30051b Fix lint failures, console.* convention violations, and CI Node version mismatch
- Add docs/capacitor-native-app-plan.md to hex-lint ignore list (code examples
  naturally reference hex colors in Capacitor config)
- Replace direct console.error/console.log calls with logger utility in
  historyView.js, profileCache.js, EventDetailsModal.js, ZapInterface.js,
  and notificationController.js
- Update CI workflow from Node 20 to Node 22 to match package.json engines

https://claude.ai/code/session_01LzErpH9FNw4hAPsjoYb1v9
2026-02-10 02:35:24 +00:00
Claude bc1341d989 Add Capacitor native app migration plan
Comprehensive plan for wrapping bitvid as native apps using Capacitor
for Android, iOS, and desktop (Windows/macOS/Linux via Electron).
Covers architecture, phased implementation, CI/CD workflows, testing
strategy, platform risks, and app store submission guidance.

https://claude.ai/code/session_01RBdcFkjzXaawaLY68MMhxc
2026-02-10 02:07:24 +00:00
Claude b5df7517cd Fix CI test failures: signer wiring, permission checks, and missing methods
- Export resolveSignerCapabilities, hydrateExtensionSignerCapabilities,
  and attachNipMethodAliases from SignerManager so they can be used by
  the module-level setActiveSigner in client.js
- Fix ensureExtensionPermissions: pass the extension object to
  requestEnablePermissions (was passing methods array as extension),
  check response.ok instead of response.enabled
- Hydrate extensionPermissionCache from localStorage on construction
  so fresh NostrClient instances recognize previously granted permissions
- Cache individual permission method names (not just composite keys)
  so tests and code checking specific methods work correctly
- Guard extension.signEvent.bind() against missing signEvent
- Add extensionPermissionCache getter to NostrClient
- Add derivePrivateKeyFromSecret and registerPrivateKeySigner methods
  to SignerManager and NostrClient (needed by nsec auth provider)
- Add installNip46Client method for NIP-46 test infrastructure
- Apply signer hydration in module-level setActiveSigner
- Proxy ensureExtensionPermissions through NostrClient in
  loginWithExtension to support test monkey-patching
- Fix nostr-signer-race test to use Map.set() instead of Set.add()

Fixes 5 previously-failing CI tests:
- tests/nostr/signers.test.mjs
- tests/nostr/dm-direct-message-flow.test.mjs
- tests/nostr/dmSignalEvents.test.mjs
- tests/nostr-login-permissions.test.mjs
- tests/nostr-signer-race.test.mjs

https://claude.ai/code/session_01KuHrohbGvitA41A2fPD5p5
2026-02-09 15:33:21 +00:00
Claude 95f47c761c Fix moderation lists error: import and instantiate RelayBatchFetcher
The NostrClient.fetchListIncrementally() method delegates to
this.relayBatchFetcher, but RelayBatchFetcher was never imported or
instantiated in client.js, causing "Cannot read properties of undefined
(reading 'fetchListIncrementally')" on every page load when admin lists
try to load.

https://claude.ai/code/session_01KuHrohbGvitA41A2fPD5p5
2026-02-09 13:40:46 +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
Claude 47fdad0ef2 Fix logout button not actually logging out the user
The auth:logout event listener in applicationBootstrap.js fires
synchronously during authService.logout(), setting __handled = true and
starting handleAuthLogout as fire-and-forget. When requestLogout() then
checked detail.__handled, it saw true and returned early — before
applyLoggedOutUiState() could update the UI.

Two changes fix this:

1. Remove the __handled early-return guard from requestLogout() so it
   always awaits handleAuthLogout.

2. Add a promise-based dedup guard to handleAuthLogout so the event
   listener's fire-and-forget call and requestLogout's awaited call
   share a single execution instead of running the logout cleanup twice.

https://claude.ai/code/session_01ArpiYU9bNdzme5xBHWnKuS
2026-02-08 19:09:50 +00: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 3a55e1bf03 fix: resolve coordinator refactoring regressions breaking DM, lists, and feed pipeline
- Remove undefined hashtagPreferencesPromise reference in handleAuthLogin
  that caused the feed sync Promise.allSettled to silently fail, preventing
  proper list/profile synchronization before grid refresh
- Add missing getModerationSettings and getActiveProfilePubkey dependency
  injection to authSessionCoordinator, fixing crashes during logout
  moderation reset and profile switch pubkey resolution
- Parallelize NIP-07 permission request with relay readiness instead of
  gating list loading behind it; parallelize subscriptions and hashtag
  preference loading (independent of each other, only blocks must sequence)
- Add native run() alias to feedEngine so callers don't rely solely on
  the applicationBootstrap compatibility shim
- Remove redundant refreshVisibleModerationUi call from renderVideoList
  that re-decorated every video immediately after decoration
- Avoid re-normalizing moderation settings on every getActiveModerationThresholds
  call when settings are already an object

https://claude.ai/code/session_01FCosieUXjEn95KtUeyGemY
2026-02-06 21:42:49 +00:00
Claude 41a12669f6 refactor: extract Application method clusters into coordinator modules
Move cohesive method groups out of the monolithic Application class
(js/app.js, ~10K lines) into five coordinator modules under js/app/:

- feedCoordinator: feed registration, runtime building, refresh,
  video loading, URL-health helpers, and feed telemetry
- playbackCoordinator: URL-first + magnet fallback pipeline, probing,
  torrent status intervals, and video timestamp resolution
- authSessionCoordinator: signer lifecycle, profile switching,
  relay/block/wallet management, and cleanup
- modalCoordinator: modal open/close, view-count subscriptions,
  watch-history metadata, and playback logging
- moderationCoordinator: moderation settings, video decoration,
  override/block/hide action routing

Each coordinator factory receives injected dependencies instead of
importing globals. Application retains thin delegator methods so all
public call-sites remain unchanged. Coordinator initialisation is
idempotent (via _initCoordinators) and supports both constructor-based
and Object.create()-based instantiation used by test harnesses.

All existing unit tests, lint checks, and syntax validation pass.

https://claude.ai/code/session_01C3PKJTCdavsGbk5jjC85EB
2026-02-06 20:47:10 +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
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
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