|
8 | 8 | <!-- ====================================================================== --> |
9 | 9 |
|
10 | 10 | ## Last Updated |
11 | | -2026-03-12 -- **Sprint F-4 done + F-4.5 planned.** |
| 11 | +2026-03-12 -- **Post-F-5 QoL: NPC sidebar link + plan reorg.** |
| 12 | + |
| 13 | +40. **Post-F-5 QoL: NPC sidebar navigation link.** |
| 14 | + - Added "NPCs" entry to campaign sidebar in `internal/templates/layouts/app.templ` below "All Pages" link. |
| 15 | + - Uses `fa-users` icon, `isPathPrefix` for active highlighting, links to `/campaigns/:id/npcs`. |
| 16 | + - Updated `.ai/phases.md` with 6-phase priority rewrite (already done in session 36). |
| 17 | + - Phase X sprints (X-1 through X-5) already present in `todo.md`. |
| 18 | + - **Next up:** Phase 1 continues — Sprint F-4.5/F-QoL/F-5 all complete. Next is Phase 2 (X-1: System Upload UX) or Phase 6 (F-6: Armory/Inventory), depending on owner priority. |
| 19 | + |
| 20 | +39. **Sprint F-5: NPC Viewer / Hall (DONE).** |
| 21 | + - **NPC plugin** — New `internal/plugins/npcs/` with model/repo/service/handler/templates/routes. View-layer plugin — no new database tables, queries existing `entities` table filtered by character type + visibility. |
| 22 | + - **Gallery page** — `/campaigns/:id/npcs` shows a responsive grid of revealed character entities. Search by name (debounced HTMX), sort (name/updated/created), tag filter, pagination. Players see non-private characters; Scribes/Owners see all. |
| 23 | + - **NPC card** — Portrait (aspect 3:4 or placeholder), name, type label/race/class, tags. Responsive grid (2→6 columns). |
| 24 | + - **Reveal toggle** — Eye icon on each card (Scribe+). Toggles `is_private` via `POST /npcs/:eid/reveal` with HTMX swap. Green eye = visible, red eye-slash = hidden. |
| 25 | + - **Entity service** — Added `TogglePrivate(entityID)` to `EntityService` interface. New `UpdatePrivate(entityID, isPrivate)` on `EntityRepository`. Publishes entity "updated" event via WebSocket. |
| 26 | + - **npc_gallery layout block** — Registered in block registry (no addon required). Shows compact 3-4 column grid of up to 8 NPCs with "View all" link. Configurable via `{"limit": N}`. |
| 27 | + - **Foundry sync** — Bidirectional NPC visibility sync. Chronicle→Foundry: entity `is_private` change updates actor's `prototypeToken.hidden`. Foundry→Chronicle: actor hidden toggle calls `POST /entities/:id/reveal` API. |
| 28 | + - **Sync API** — New `POST /api/v1/campaigns/:id/entities/:entityID/reveal` endpoint. Accepts `{"is_private": bool}` or toggles if omitted. Verifies entity belongs to campaign. |
| 29 | + - **Tests** — 7 tests: `ListNPCs_ReturnsCards`, `ListNPCs_EmptyWhenNoCharacterType`, `CountNPCs`, `NPCListOptions_Offset`, `NPCListOptions_OrderByClause`, `NPCCard_FieldString`, `TogglePrivate_EntityService`. All pass. |
| 30 | + - **Wiring** — `npcEntityTypeFinderAdapter` and `npcVisibilityTogglerAdapter` in `app/routes.go`. Routes registered with `RequireRole(Player)` for view, `RequireRole(Scribe)` for reveal. |
| 31 | + |
| 32 | +38. **Sprint F-QoL: Foundry Sync Diagnostics (DONE).** |
| 33 | + - **Validation report** — New `ValidationReport` type and `BuildValidationReport()` on `SystemManifest`. Analyzes categories, fields, presets, Foundry compatibility, mapped/writable fields, and generates warnings. Shown in custom system section after upload. |
| 34 | + - **Template update** — `SystemValidationReport` templ component renders capability badges (categories, fields, presets, character fields), Foundry compatibility status, field mapping summary, and warnings. |
| 35 | + - **API client health metrics** — `api-client.mjs` now tracks REST success/error counts, reconnect attempts, connection uptime, last success/error timestamps. New `_errorLog` array with structured error entries (method, path, status, message). `getUptimePercent()` computes session uptime. |
| 36 | + - **Retry queue** — New `queueForRetry()` method for failed write operations. `processRetryQueue()` runs on WebSocket reconnect, retrying up to 3 times with structured logging. Queue capped at 50 entries. |
| 37 | + - **Dashboard diagnostics** — Status tab now shows: 4-column diagnostics grid (uptime%, API OK, API errors, reconnects), last success/error timestamps, pending retry count, field mapping debug info (adapter type, system ID, character type slug), and separate error log section. |
| 38 | + - **Dashboard CSS** — Added `.diagnostics-grid`, `.diagnostics-detail`, `.error-value`, `.error-text`, `.error-log` styles. |
| 39 | + - **Tests** — 3 new tests: `BuildValidationReport_FullSystem`, `BuildValidationReport_MinimalSystem`, `BuildValidationReport_NoFoundryPaths`. All pass. |
| 40 | + - **Dagger Heart** added to deferred systems list alongside Draw Steel. |
| 41 | + |
| 42 | +37. **Sprint F-4.5: Generic System Adapter (DONE).** |
| 43 | + - **Manifest schema** — Added `foundry_system_id` to `SystemManifest`, `foundry_path` and `foundry_writable` to `FieldDef`. `IsFoundryWritable()` helper defaults to true when nil. New `CharacterFieldsForAPI()` builds API response with field annotations. |
| 44 | + - **API endpoint** — `GET /api/v1/campaigns/:id/systems/:systemId/character-fields` returns field definitions with Foundry path annotations. Supports both built-in and custom campaign systems via `CampaignSystemLister` interface. |
| 45 | + - **Manifest annotations** — dnd5e: all 15 character fields annotated with `foundry_path`; AC, speed, proficiency_bonus marked `foundry_writable: false`. PF2e: all 15 fields annotated; only hp_current/hp_max writable (everything else derived). DrawSteel: `foundry_system_id: "draw-steel"` added. |
| 46 | + - **Foundry sync-manager.mjs** — `_detectSystem()` now API-driven: queries `/systems` and matches by `foundry_system_id` first, falls back to `SYSTEM_MAP_FALLBACK` for legacy support. Custom-uploaded systems with `foundry_system_id` auto-match. |
| 47 | + - **Foundry generic-adapter.mjs** — New data-driven adapter that fetches field definitions from `/systems/:id/character-fields` API. Auto-generates `toChronicleFields()` and `fromChronicleFields()` from field annotations. Respects `foundry_writable` and field types for casting. |
| 48 | + - **Foundry actor-sync.mjs** — `_loadAdapter()` tries built-in adapters (dnd5e, pf2e) first, then falls back to generic adapter for any other system. |
| 49 | + - **Tests** — Added 7 tests for `IsFoundryWritable`, `CharacterPreset`, `CharacterFieldsForAPI`, and `LoadManifest` with Foundry annotations. All pass. |
| 50 | + - **Impact:** Any game system (including custom uploads) can now participate in character sync by including `foundry_system_id` and `foundry_path` annotations in its manifest. |
| 51 | + |
| 52 | +36. **Phase & Sprint Plan Reorg.** |
| 53 | + - Rewrote `.ai/phases.md` with 6 phases in new priority order based on owner direction: |
| 54 | + (1) Foundry Completion & QoL (F-4.5, F-QoL, F-5), |
| 55 | + (2) System Modularity & Owner Experience (X-1 through X-5 — new phase), |
| 56 | + (3) Maps & Spatial (W-2, W-2.5), |
| 57 | + (4) Collaboration & Polish (U-series, W-1, W-4), |
| 58 | + (5) Content & Integrations (T-3/4, W-3/5/6), |
| 59 | + (6) Foundry Advanced (F-6, F-7). |
| 60 | + - Added new Phase X sprints to `todo.md`: X-1 (upload UX wizard), X-2 (auto entity presets), |
| 61 | + X-3 (system-provided widgets), X-4 (system diagnostics), X-5 (character sheet blocks). |
| 62 | + - Added F-QoL sprint (Foundry sync diagnostics & error handling). |
| 63 | + - Key insight: the system framework needs end-to-end validation that a non-technical |
| 64 | + owner can upload a custom system and get full functionality (presets, tooltips, |
| 65 | + Foundry sync, widgets, character sheets) without manual setup. |
| 66 | + - Next up: Sprint F-4.5 (generic system adapter). |
12 | 67 |
|
13 | 68 | 35. **F-4.5 planning: Generic System Adapter & Dynamic Matching.** |
14 | 69 | - Identified that F-4's `SYSTEM_MAP` and `_loadAdapter()` switch are hardcoded to only dnd5e/pf2e/drawsteel. Custom-uploaded game systems can't participate in character sync despite having the server infrastructure (entity presets, `CharacterPreset()` helper, campaign system upload). |
@@ -150,13 +205,15 @@ Branch: `claude/fix-journal-button-placement-UF4hD`. |
150 | 205 |
|
151 | 206 | ## Phase & Sprint Plan |
152 | 207 | See `.ai/phases.md` for the full roadmap. Phases organized by priority: |
153 | | -- **V**: Obsidian-Style Notes & Discovery ← CURRENT |
154 | | -- **W**: Polish, Ecosystem & Delight |
155 | | -- **T**: Game System Modules & Worldbuilding Tools |
156 | | -- **U**: Collaboration & Platform Maturity |
| 208 | +1. **F**: Foundry Completion & QoL (F-4.5, F-QoL, F-5) ← CURRENT |
| 209 | +2. **X**: System Modularity & Owner Experience (X-1 through X-5) |
| 210 | +3. **W**: Maps & Spatial (W-2, W-2.5) |
| 211 | +4. **U**: Collaboration & Polish (U-1/2/3/4/5, W-1, W-4) |
| 212 | +5. **T**: Content & Integrations (T-3/4, W-3/5/6) |
| 213 | +6. **F**: Foundry Advanced (F-6, F-7) |
157 | 214 |
|
158 | 215 | ## Current Phase |
159 | | -**Phase V (Obsidian-Style Notes & Discovery) — Sprint V-2 COMPLETE.** |
| 216 | +**Phase 1: Foundry Completion — Sprint F-4.5 IN PROGRESS.** |
160 | 217 |
|
161 | 218 | ### Sprint V-2: Backlinks Panel & Entity Aliases (COMPLETE) |
162 | 219 | - **Fixed migration 060**: Removed incorrect first ALTER that tried to drop 'module' from ENUM directly, causing Error 1265. Kept correct 3-step approach. |
@@ -597,9 +654,9 @@ Created `.ai/audit.md` — comprehensive feature parity and completeness audit c |
597 | 654 | - Updated architecture.md directory structure to reflect systems/ path |
598 | 655 |
|
599 | 656 | ## Next Session Should |
600 | | -- **Sprint U-2: Invite System** — campaign invite links for easier player onboarding |
601 | | -- **Sprint V-1: Quick Capture** — Obsidian-style notes rapid entry |
602 | | -- **Sprint T-3: Guided Worldbuilding Prompts** — Writing prompts panel on entity edit page (deferred) |
| 657 | +- **Sprint F-4.5: Generic System Adapter** — Remove hardcoded SYSTEM_MAP, dynamic matching via API |
| 658 | +- **Sprint F-QoL: Foundry Sync Diagnostics** — Validation report, health dashboard, error recovery |
| 659 | +- **Sprint F-5: NPC Viewer / Hall** — Gallery of revealed NPCs |
603 | 660 | - See `.ai/phases.md` for full execution order |
604 | 661 |
|
605 | 662 | ## Known Issues Right Now |
|
0 commit comments