Refactor ProfileCache memoryCache from a flat Map to a nested Map (Pubkey -> Section -> Data).
This allows clearing a user's cache in O(1) time instead of O(N) by deleting the user's entry directly, avoiding a full scan of all cache keys.
Benchmark showed improvement from ~58ms to ~0.0014ms for clearing a user in a cache with 20,000 users (100,000 entries).
Co-authored-by: PR0M3TH3AN <[email protected]>
- Introduce incremental similarity updates in `createExploreDiversitySorter`.
- Cache max similarity for each candidate to avoid redundant calculations.
- Reduces sort time for 1000 items from ~33s to ~170ms.
Co-authored-by: PR0M3TH3AN <[email protected]>
Add a detailed guide for AI assistants working with the bitvid codebase.
The document covers:
- Project overview and technology stack
- Codebase structure and essential files
- Development workflow and setup instructions
- CI/CD pipeline overview with job timeouts
- Code conventions (logging, styling, Nostr events, magnets)
- Architecture patterns (bitvidApp vs controllers)
- Feature flags and runtime configuration
- Nostr integration details and NIP usage
- Testing guidelines and common troubleshooting
- Quick reference for imports and content schema
This complements AGENTS.md (mission/architecture) and CONTRIBUTING.md
(setup/PR process) by providing AI-specific context and patterns.
https://claude.ai/code/session_014BfcJJAuzSHDwdoyYKoHZG
- Removed force flag (!) from `/* /index.html 200` in `_redirects` to allow static assets to be served.
- Restored `scripts/build-dist.mjs` to properly clean `dist/`, build CSS, and copy assets.
- Updated `package.json` to use the new build script and serve `dist`.
- Updated `netlify.toml` to publish the `dist` directory.
- Updated `dist/` artifacts to match current source.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Restore `scripts/build-dist.mjs` to clean `dist/`, build CSS, and copy assets.
- Update `package.json` to use the new build script and serve `dist`.
- Update `netlify.toml` to publish the `dist` directory.
- Update `dist/` artifacts to match current source.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Fix `ReferenceError: plainCall is not defined` in `tests/nostr-login-permissions.test.mjs` which caused CI failures.
- Add `_redirects` file for Netlify SPA routing to fix deployment redirect rule errors.
- Parallelize `deleteAllVersions` in `js/nostr/client.js` to significantly improve batch deletion performance by decoupling network publishing from serial signing.
The batch deletion optimization reduces execution time by ~40% for large batches (500+ events) by running network requests concurrently while maintaining serial signing for NIP-07 compatibility.
Co-authored-by: PR0M3TH3AN <[email protected]>
Handle the `TypeError: Cannot set property navigator of #<Object> which has only a getter` by attempting to set `globalThis.navigator` directly and falling back to `Object.defineProperty` if it's read-only. This ensures compatibility with environments where `navigator` is non-writable (like newer Node.js versions or certain test runners).
Co-authored-by: PR0M3TH3AN <[email protected]>
Use `tailwindcss` directly in the `build:css` script instead of `npx tailwindcss`. This ensures the local binary (installed in `node_modules/.bin`) is used, avoiding potential `npx` path resolution failures or network requests in restricted CI environments (like Netlify).
Co-authored-by: PR0M3TH3AN <[email protected]>
1. Move build-critical dependencies (`tailwindcss`, `postcss`, `autoprefixer`, etc.) to `dependencies` in `package.json` to prevent build failures in production environments (like Netlify) that prune `devDependencies`.
2. Ensure `_redirects` exists in the root directory (copied from `dist/_redirects`) so Netlify processes redirect rules correctly when publishing from root.
Co-authored-by: PR0M3TH3AN <[email protected]>
Optimize `executePendingRetry` in `js/channelProfile.js` to run zap attempts in parallel using `Promise.allSettled`, improving performance when retrying multiple shares.
Refactor `splitAndZap` in `js/payments/zapSplit.js` to accept `overrideFee` as an argument, eliminating reliance on a global variable and ensuring thread safety during parallel execution.
Update `js/ui/zapController.js` to use the new `splitAndZap` API.
Fix: Resolve ReferenceError in `tests/nostr-login-permissions.test.mjs` by correctly destructuring `plainCall` from `env.enableCalls`.
Co-authored-by: PR0M3TH3AN <[email protected]>
Adds a `_redirects` file to the root directory with the rule `/* /index.html 200!` to support Single Page Application (SPA) routing on Netlify.
This resolves the "Redirect rules" CI failure and ensures that client-side routes (e.g., `/video/:id`) do not return 404s when accessed directly.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Fix `ReferenceError: plainCall is not defined` in `tests/nostr-login-permissions.test.mjs` which caused CI failures.
- Parallelize `deleteAllVersions` in `js/nostr/client.js` to significantly improve batch deletion performance by decoupling network publishing from serial signing.
The batch deletion optimization reduces execution time by ~40% for large batches (500+ events) by running network requests concurrently while maintaining serial signing for NIP-07 compatibility.
Co-authored-by: PR0M3TH3AN <[email protected]>
Fix `ReferenceError: plainCall is not defined` in `tests/nostr-login-permissions.test.mjs` by properly destructuring the `plainCall` variable from the `env.enableCalls` array in the failing test case.
This fixes a regression that was blocking CI execution.
Co-authored-by: PR0M3TH3AN <[email protected]>
Refactor `createResolvePostedAtStage` to execute timestamp resolution tasks concurrently using `Promise.allSettled` instead of a serial loop. This significantly reduces execution time when multiple items require resolution (e.g., waiting for network or async processing).
Benchmarks showed a reduction from ~1000ms to ~23ms for 50 items with a simulated 20ms delay each.
Co-authored-by: PR0M3TH3AN <[email protected]>
Correctly destructure the `plainCall` variable in `tests/nostr-login-permissions.test.mjs` to prevent a ReferenceError during test execution. This ensures the test properly validates that the plain enable() fallback is not invoked when structured payloads fail.
Co-authored-by: PR0M3TH3AN <[email protected]>
Optimizes the batch deletion process by decoupling the network publishing step from the serial signing loop. This allows publishing to happen concurrently with the signing of subsequent batches, significantly reducing the total time for large deletions.
- Wraps `publishEventToRelays` in a non-blocking promise within the deletion loop.
- Collects all publish promises and awaits them using `Promise.all` at the end of the loop.
- Preserves serial signing order to ensure compatibility with NIP-07 extensions.
- Maintains existing logging and state update logic.
Measured improvement: ~40% reduction in execution time for 500 events (5 chunks) in simulated benchmark.
Co-authored-by: PR0M3TH3AN <[email protected]>
Optimize `executePendingRetry` in `js/channelProfile.js` to run zap attempts in parallel using `Promise.allSettled`, improving performance when retrying multiple shares.
Refactor `splitAndZap` in `js/payments/zapSplit.js` to accept `overrideFee` as an argument, eliminating reliance on a global variable and ensuring thread safety during parallel execution.
Update `js/ui/zapController.js` to use the new `splitAndZap` API.
Co-authored-by: PR0M3TH3AN <[email protected]>
Refactors `listDirectMessages` to use `Promise.all` for parallel decryption, reducing execution time significantly (benchmark: ~1021ms -> ~14ms for 100 messages).
Also fixes CI stability:
- Fix race condition in `overlay-layers.spec.ts` visual test.
- Fix environment conflicts in unit tests.
- Add `_redirects` for Netlify.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Created `_redirects` with `/* /index.html 200` to support client-side routing on Netlify.
- This addresses the "Redirect rules" failure in the CI deployment checks.
- Verified visual tests pass locally (`npx playwright test tests/visual/overlay-layers.spec.ts`).
- Verified build passes locally (`npm run build`).
Co-authored-by: PR0M3TH3AN <[email protected]>
- Fixed `ReferenceError: plainCall is not defined` in `tests/nostr-login-permissions.test.mjs` by correctly destructuring the variable.
- Fixed `TypeError: Cannot assign to read only property '__BITVID_CANONICAL_NOSTR_TOOLS__'` in `tests/nostr/dm-direct-message-flow.test.mjs` by using `Object.defineProperty` to override the read-only property during test setup.
- These fixes resolve the `agent-review` CI job failures.
- Also verified optimization of `listDirectMessages` in `js/nostr/client.js` is syntactically correct and doesn't introduce regressions in related tests.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Fixed `ReferenceError: plainCall is not defined` in `tests/nostr-login-permissions.test.mjs` by correctly destructuring the variable.
- Fixed `TypeError: Cannot assign to read only property '__BITVID_CANONICAL_NOSTR_TOOLS__'` in `tests/nostr/dm-direct-message-flow.test.mjs` by using `Object.defineProperty` to override the read-only property during test setup.
- These fixes resolve the `agent-review` CI job failures.
- Also verified optimization of `listDirectMessages` in `js/nostr/client.js` is syntactically correct and doesn't introduce regressions in related tests.
Co-authored-by: PR0M3TH3AN <[email protected]>
Replaced serial decryption loop in `listDirectMessages` with `Promise.all` to process messages concurrently. This significantly reduces execution time when handling multiple encrypted events, especially when decryption involves async operations (like extension calls or workers).
Measured improvement: Reduced processing time for 100 simulated messages from ~1021ms to ~14ms in benchmark.
Co-authored-by: PR0M3TH3AN <[email protected]>
Scanned the repository for TODO/FIXME/XXX comments.
Identified known flaky test TODOs in tests/visual/moderation.spec.ts, which are already tracked in issues/todo-moderation-tests.md.
No other actionable TODOs found in JS/TS sources.
Generated artifacts/todos.txt as a triage report.
Co-authored-by: PR0M3TH3AN <[email protected]>