diff --git a/context/CONTEXT_2026-02-18_00-02-50.md b/context/CONTEXT_2026-02-18_00-02-50.md new file mode 100644 index 00000000..fe756194 --- /dev/null +++ b/context/CONTEXT_2026-02-18_00-02-50.md @@ -0,0 +1,22 @@ +# Context: Content Audit & Bug Fix + +**Agent:** content-audit-agent +**Date:** 2026-02-18 +**Goal:** Audit `content/docs/guides/upload-content.md` against codebase. Fix identified bug in NIP-71 hashtag handling. + +## Scope +- `content/docs/guides/upload-content.md` +- `js/services/videoNotePayload.js` +- `js/ui/components/UploadModal.js` +- `components/upload-modal.html` + +## Identified Issue +Hashtags entered in the Upload Modal are collected as `{ t: [...] }` by `Nip71FormManager` (due to `data-nip71-list="t"`). +However, `videoNotePayload.js`'s `normalizeNip71Metadata` only looks for `rawMetadata.hashtags`. +This causes user-entered hashtags to be dropped during payload construction. + +## Plan +1. Inventory and verify all claims in `upload-content.md`. +2. Create a unit test to reproduce the hashtag bug. +3. Fix the bug in `videoNotePayload.js` to support `t` alias. +4. Verify fix with tests. diff --git a/decisions/DECISIONS_2026-02-18_00-02-50.md b/decisions/DECISIONS_2026-02-18_00-02-50.md new file mode 100644 index 00000000..93a68273 --- /dev/null +++ b/decisions/DECISIONS_2026-02-18_00-02-50.md @@ -0,0 +1,6 @@ +# Decisions + +## NIP-71 Hashtag Handling +**Issue:** `Nip71FormManager` uses the `data-nip71-list` attribute as the key for collected data. The Upload Modal uses `data-nip71-list="t"` for hashtags, matching the NIP-71 tag name. However, the normalizer `normalizeNip71Metadata` expects `hashtags` property. + +**Decision:** Update `normalizeNip71Metadata` in `js/services/videoNotePayload.js` to check `rawMetadata.t` if `rawMetadata.hashtags` is missing. This aligns the backend logic with the existing UI behavior without requiring a change to the HTML structure or Form Manager generic logic. diff --git a/docs/agents/task-logs/daily/2026-02-18_00-02-50_content-audit-agent_completed.md b/docs/agents/task-logs/daily/2026-02-18_00-02-50_content-audit-agent_completed.md new file mode 100644 index 00000000..d92ffe86 --- /dev/null +++ b/docs/agents/task-logs/daily/2026-02-18_00-02-50_content-audit-agent_completed.md @@ -0,0 +1,15 @@ +# Content Audit Agent Completed + +**Date:** 2026-02-18 +**Agent:** content-audit-agent +**Status:** Success + +## Summary +Audited `content/docs/guides/upload-content.md` and verified claims against the codebase. +Identified and fixed a bug where hashtags entered in the Upload Modal were dropped during payload normalization. + +## Actions +- Verified file types, size limits, and permissions claims (Found accurate). +- Fixed `js/services/videoNotePayload.js` to normalize `t` field (from UI) to `hashtags` property. +- Added regression test `tests/unit/services/videoNotePayload.test.mjs`. +- Generated audit artifacts in `artifacts/docs-audit/2026-02-18/`. diff --git a/js/services/videoNotePayload.js b/js/services/videoNotePayload.js index 1496c6ef..e95749a3 100644 --- a/js/services/videoNotePayload.js +++ b/js/services/videoNotePayload.js @@ -304,7 +304,7 @@ function normalizeNip71Metadata(rawMetadata) { normalized.segments = segments; } - const hashtags = normalizeStringArray(rawMetadata.hashtags); + const hashtags = normalizeStringArray(rawMetadata.hashtags || rawMetadata.t); if (hashtags.length) { normalized.hashtags = hashtags; } diff --git a/test_logs/TEST_LOG_2026-02-18_00-02-50.md b/test_logs/TEST_LOG_2026-02-18_00-02-50.md new file mode 100644 index 00000000..9f6ba2d7 --- /dev/null +++ b/test_logs/TEST_LOG_2026-02-18_00-02-50.md @@ -0,0 +1,20 @@ +# Test Log + +## Initial State +- Agent locked. +- Audit started. +- Bug identified in `videoNotePayload.js`. + +## Test Run 1: Reproduction +- **Command:** `node scripts/run-unit-tests.mjs tests/unit/services/videoNotePayload.test.mjs` +- **Result:** FAIL +- **Error:** `Cannot read properties of undefined (reading 'hashtags')` +- **Confirmation:** Bug reproduced. `normalizeVideoNotePayload` failed to produce `nip71` object from `{ t: [] }` input. + +## Fix Applied +- Modified `js/services/videoNotePayload.js` to support `t` alias for hashtags. + +## Test Run 2: Verification +- **Command:** `node scripts/run-unit-tests.mjs tests/unit/services/videoNotePayload.test.mjs` +- **Result:** PASS +- **Details:** 2 tests passed. Hashtags are now correctly extracted from `t` property. diff --git a/tests/unit/services/videoNotePayload.test.mjs b/tests/unit/services/videoNotePayload.test.mjs new file mode 100644 index 00000000..0b15c26a --- /dev/null +++ b/tests/unit/services/videoNotePayload.test.mjs @@ -0,0 +1,35 @@ +import { test, describe, it } from "node:test"; +import assert from "node:assert"; +import { normalizeVideoNotePayload } from "../../../js/services/videoNotePayload.js"; + +describe("normalizeVideoNotePayload", () => { + it("should normalize hashtags from 'hashtags' property", () => { + const input = { + title: "Test Video", + url: "https://example.com/video.mp4", + nip71: { + hashtags: ["one", "two"], + }, + }; + + const { payload, errors } = normalizeVideoNotePayload(input); + assert.strictEqual(errors.length, 0); + assert.deepStrictEqual(payload.nip71.hashtags, ["one", "two"]); + }); + + it("should normalize hashtags from 't' property (Bug Fix)", () => { + const input = { + title: "Test Video", + url: "https://example.com/video.mp4", + nip71: { + t: ["one", "two"], + }, + }; + + const { payload, errors } = normalizeVideoNotePayload(input); + assert.strictEqual(errors.length, 0); + + // This assertion is expected to FAIL before the fix + assert.deepStrictEqual(payload.nip71.hashtags, ["one", "two"], "Hashtags should be extracted from 't' property"); + }); +}); diff --git a/todo/TODO_2026-02-18_00-02-50.md b/todo/TODO_2026-02-18_00-02-50.md new file mode 100644 index 00000000..437102db --- /dev/null +++ b/todo/TODO_2026-02-18_00-02-50.md @@ -0,0 +1,10 @@ +- [ ] Inventory `upload-content.md` claims +- [ ] Verify claims against code +- [ ] Create `tests/unit/services/videoNotePayload.test.mjs` +- [ ] Run test to confirm failure (reproduce bug) +- [ ] Fix `js/services/videoNotePayload.js` +- [ ] Run test to confirm success +- [ ] Generate `artifacts/docs-audit/2026-02-18/inventory.md` +- [ ] Generate `artifacts/docs-audit/2026-02-18/verification.md` +- [ ] Run lint +- [ ] Submit