Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
docs([characterdetaileditor-listrow-row-draft-hook]): archive to DONE.md
[._.]/ Adam Eivy150839c95611
diff --git a/DONE.md b/DONE.mdindex 06f882f66c..7ada8a2cb9 100644--- a/DONE.md+++ b/DONE.md@@ -10,6 +10,7 @@ For active roadmap see [PLAN.md](./PLAN.md). For project goals see [GOALS.md](./### 2026-05-19+- **[characterdetaileditor-listrow-row-draft-hook] Extract `ListRow`'s multi-column row-draft state into a shared `useRowDraft` hook.** `client/src/components/universe/CharacterDetailEditor.jsx`'s `ListRow` carried 19 lines of inline `useState({})` draft buffer + `draftFor`/`setDraft`/`commit` triple, with the load-bearing sibling-draft "ride-along" merge (`{...row, ...drafts, [col]: v}`) that keeps a fast A-blur → B-blur sequence from losing column A when the parent hasn't re-rendered yet. Lifted into new `client/src/hooks/useRowDraft.js` — the row-level analogue of `useFieldDraft` (single-field draft+blur). Hook signature is `useRowDraft(row, onChange)` returning `{ draftFor, setDraft, commit }`; preserves the ride-along merge verbatim and coerces `null`/`undefined` persisted columns to `''` so inputs stay controlled. `ListRow` collapses to a single hook call. 9 new vitest cases cover persisted/empty fallback, draft buffering without firing onChange, commit no-op when value equals persisted, commit no-op when no draft set, null-as-empty equivalence, the ride-along race-protection invariant (committing column B with a pending column-A draft ships both in one onChange), and that commit clears only the committed column from the drafts map. All 112 client tests pass.- **[clear-pending-sheet-slot-on-entry-delete] Prune `_latestPendingByCharacter` on character / universe delete.** The in-process slot map that supersede-checks character reference-sheet renders previously persisted entries for the full Node process lifetime — even after the character or its universe was deleted. Extracted the Map + its `claim`/`get`/`release` helpers into `server/services/universeCharacterSheetSlot.js` (standalone module so `universeBuilder.js` can clear slots without a `universeCharacterSheet.js → universeBuilder.js` import cycle) and added two delete-path helpers: `clearPendingSheetSlot(universeId, entryId)` (unconditional single-character drop) and `clearPendingSheetSlotsForUniverse(universeId)` (walks the map once, drops every `${universeId}:` prefix). `universeCharacterSheet.js` now consumes `claimPendingSheetSlot` / `getPendingSheetSlot` / `releasePendingSheetSlot` instead of inline `_latestPendingByCharacter.set/.get/.delete` — behavior is unchanged, the supersede-aware contract still holds. Wired into two paths: (a) `deleteUniverse` calls `clearPendingSheetSlotsForUniverse(id)` after the file-write queue releases, alongside the existing `unlinkCollectionsForUniverse` cascade; (b) `updateUniverse` computes a `prevIds`/`nextIds` diff against `cur.characters` vs `mergedRecord.characters` INSIDE the write queue (so the diff sees the freshest persisted state) and calls `clearPendingSheetSlot(id, removedId)` for each dropped id after the queue returns. The in-flight render path is unaffected — if a render's character is deleted mid-flight the slot becomes empty, `onSheetComplete` treats itself as superseded, saves the file on disk, and skips stamping a now-orphaned `referenceSheetImageRef` pointer (the `updateUniverse` mutator inside `onSheetComplete` is also a no-op since the character record is gone). Coverage: 11 new tests in `universeCharacterSheetSlot.test.js` covering claim/get/release contracts, unconditional vs conditional drop, prefix-anchored universe sweep (with explicit anti-collision case proving `u-a` doesn't match `u-ab`), falsy-id no-ops; 3 new integration tests in `universeBuilder.test.js#"pending sheet slot cleanup"` covering character-drop via PATCH, character-preserve when the patch keeps them, and universe-delete clearing only that universe's slots. All 5703 server tests + 14 reused `universeCharacterSheet.test.js` cases pass.- **[purge-reference-sheet-image-ref-on-sheet-delete] Active-purge `character.referenceSheetImageRef` on sheet delete.** Shipped both the sheet-delete route the original PLAN entry was gated on AND the eager purge it needed. New `purgeReferenceSheetFromAllUniverses(filename)` helper in `server/services/universeCanon.js` mirrors `purgeImageRefFromAllUniverses` but targets the single-string sheet pointer; uses `updateUniverse`'s mutator form because `referenceSheetImageRef` is in `SERVER_OWNED_CHARACTER_FIELDS` and a literal-object PATCH would be guarded against clobbering the pointer. New `deleteCharacterReferenceSheet(universeId, entryId)` in `server/services/universeCharacterSheet.js` reads the character's current pointer, re-validates via `assertSafeFilename` as defense-in-depth, unlinks the PNG from `PATHS.imageRefs` (ENOENT is benign — surfaced via `fileDeleted: false`), then calls the purge to clear every matching pointer across all universes. Mirrors the renderer's lock guard (`UNIVERSE_CANON_LOCKED` 409) so locked characters' sheets stay delete-protected. New `DELETE /api/universe-builder/:id/characters/:entryId/reference-sheet` route. Client: `deleteCharacterReferenceSheet` helper in `apiUniverseBuilder.js` (silent option), trash button in `CharacterReferenceSheetPanel.jsx` (only rendered when a sheet exists + not in-flight) with inline `[Cancel] [Delete sheet]` confirm row per the user's confirmation-UX preference, `onSheetDeleted` callback wired through `characterExtensions` in `CanonCard.jsx` → `UniverseCanonSection.jsx` (`handleSheetDeleted` mirrors `handleSheetCompleted`'s `latestUniverseRef` read so a parallel edit during the DELETE isn't clobbered). Coverage: 3 new tests in `universeCanon.test.js` for `purgeReferenceSheetFromAllUniverses` + 2 backfill tests for the previously-untested `purgeImageRefFromAllUniverses`; new `universeCharacterSheetDelete.test.js` with 8 tests covering happy path, ENOENT benign, non-ENOENT propagation, no-pointer no-op, 404 character, 409 locked, traversal-rejection, and cross-universe purge. All 5710 server tests + 103 client tests pass; client build clean.- **[per-field-locks-arc-and-stage-granularity] Per-field arc locks + per-stage issue locks.** Follow-on to per-season locks (`[per-season-and-per-field-locks-extend-arc-lock]`). Two layered ratchets, both enforced server-side and surfaced in the UI. (1) **Per-field arc locks** — `series.locked.arcFields` carries an opt-in sub-map (`{ logline, summary, themes, protagonistArc, shape }`); new `mergeArcWithLocks(currentArc, nextArc, lockedFields)` helper in `arcPlanner.js` rewrites the incoming arc to preserve locked field values verbatim from the existing arc, called from `commitSeasonsWithRemap` so both auto-resolve (via `resolveVerifyIssues`) and the `/series/:id/arc/generate?commit=true` path honor the lock; new `ARC_LOCKABLE_FIELDS = ['logline','summary','protagonistArc','themes','shape']` export in `pipeline/series.js` is mirrored as the Zod schema in `seriesLockedSchema`. Arc Canvas read view now renders a small `FieldLockToggle` icon (subtle 4×4 inline button, Lock/Unlock-with-spinner) next to each field that's currently displayed — logline paragraph, story-shape badge, themes chip row, summary `<summary>`, protagonistArc `<summary>` — toggling PATCHes through `updatePipelineSeries({ locked: { ...series.locked, arcFields: nextFields } })` with optimistic update + toast. (2) **Per-stage issue locks** — every `issue.stages.{id}` (text + visual + audio) carries `locked: boolean` (default `false`, strict-true coercion so `locked: 'yes'` typos can't accidentally freeze the stage). New `assertStageUnlocked(issue, stageId)` helper in `pipeline/issues.js` throws `ServerError({ status: 400, code: 'PIPELINE_STAGE_LOCKED' })` and is called from every regeneration entry point: `textStages.generateStage`, `visualStages.enqueueComicCoverLike` / `enqueueVisualComicPage` / `enqueueVisualImage` / `enqueueStoryboardSceneVideo` / `enqueueStoryboardShotStartFrame` / `refineComicPanelPrompt` / `refineStoryboardScenePrompt`, `episodeVideo.startEpisodeVideoForIssue` (fresh-start branch only; reuse of existing `cdProjectId` is still permitted), `arcPlanner.generateComicCoverConcepts` (`commit: true` path), and the four route-level audio/extract paths (`/audio/extract-lines`, `/audio/lines/:n/render`, `/storyboards/extract-scenes`, `/comicPages/extract-pages`). The text-stage gate runs *before* `updateStage({ status: 'generating' })` so a locked stage doesn't get stuck at "generating" only to be reset. `PipelineIssue.jsx` (a) gates the per-tab `<Lock>` indicator on per-stage `locked` first (then falls back to the ambient arc/season-wide lock); (b) adds a Lock/Unlock toggle button to the action bar that targets the currently-active stage and PATCHes `{ stages: { [stageId]: { locked: next } } }` via `updatePipelineIssue`; (c) the lock-banner under the TabPills strip prefers the per-stage message when the active tab is locked. Coverage: 11 new tests — 4 in `issues.test.js` (default `locked: false` on every stage, PATCH round-trip, non-boolean coerce-to-false, `assertStageUnlocked` throw/no-op), 1 in `textStages.test.js` (refuse + leave status untouched on locked stage), 6 in `arcPlanner.test.js` (`mergeArcWithLocks` per-field preservation, empty/null/undefined locks pass through, no-current-arc passthrough, null/undefined next no-op, unknown lock keys ignored, full `commitSeasonsWithRemap` round-trip with locked logline + themes). All 5689 server tests + 103 client tests pass.diff --git a/PLAN.md b/PLAN.mdindex 4e3a34db3d..4b455fadfd 100644--- a/PLAN.md+++ b/PLAN.md@@ -12,7 +12,7 @@ _Nothing currently parked — pick the next item from the Backlog._### Universe-as-Canon — Phase 2 + extensions-- [ ] [characterdetaileditor-listrow-row-draft-hook] **Extract `ListRow`'s multi-column row-draft state in `CharacterDetailEditor.jsx` into a shared `useRowDraft` hook.** `useFieldDraft` shipped with `[character-bible-simplify-followups]` covers single-field draft+blur, but the `ListRow` component has multi-column row-level state with sibling-draft "ride-along" race protection (`{...row, ...drafts, [col]: v}` so a fast A-blur → B-blur sequence doesn't lose column A). Splitting per-column would lose that protection. A `useRowDraft(row, columns)` hook keyed by column name would expose the same `draftFor(col)`/`setDraft(col, v)`/`commit(col)` API and let CharacterDetailEditor's `ListRow` drop the inline state. Low priority — single consumer today; revisit when a second multi-column-row editor lands.+- [ ] [wardroberow-migrate-to-userowdraft] **Migrate `WardrobeRow` to consume `useRowDraft`.** `client/src/components/pipeline/CanonCard.jsx:104-149` currently runs two separate `useFieldDraft` calls (one per column: `name`, `description`). Switching to a single `useRowDraft` call would shrink the row and pick up the same sibling-draft ride-along race protection that landed for `ListRow` in `[characterdetaileditor-listrow-row-draft-hook]`. Non-trivial because `WardrobeSection.commit` (lines 171-193) does pending-row promotion on per-field `name` commits, not on whole-row commits — switching to row-shaped `onCommit(nextRow)` changes the promotion trigger. Surfaced by /simplify during the `useRowDraft` extraction PR; deferred because the promotion semantics need their own design pass.- [x] ~~**Drop the default `characters` category.**~~ Shipped via the Universe Builder redesign Phase A migration; default `characters` bucket retired, variations backfilled into `universe.characters[]`.- [x] ~~**Universe expand LLM contract enrichment.**~~ Shipped via the Universe Builder redesign Phase B — expand contract now returns rich canon arrays alongside categories.