[Game Systems] Inline stat-value editing during draft review (convert_stats / generate_statblock) #213

Closed
opened 2026-07-19 00:21:33 +00:00 by claude-bot · 1 comment
Contributor

Motivation/Context

v3.9.0 follow-up (flagged in #142 and #145). The schema-targeted generate_statblock (#142) and the convert_stats conversion wizard (#145) both stage a structured stats envelope on the draft (LoreEntryDraft.current_stats, with current_stats_notes provenance for convert). The draft-review page (WikiDraftReview.jsx) renders those proposed values read-only — the GM can only approve them as-is, iterate (re-run the LLM), or discard.

draft_service.patch_draft / the PATCH …/drafts/{id} endpoint currently accepts inline edits to current_title / current_body / current_sidebar_fields, but not current_stats. So a GM who spots one wrong mapped value (e.g. AC 15 should be 17) can't just fix it before approving — they have to iterate or edit manually after approval via the #140 stat-block editor.

Approach

Backend — extend LoreDraftPatch + patch_draft (services/draft_service.py, routers/campaigns.py) to accept an optional current_stats value edit for generate_statblock / convert_stats drafts:

  • Re-validate the edited values against the entry's linked active schema via game_system_service.validate_entry_stats (re-stamping system/schema_version, visibility default gm); reject invalid edits with 400, same as the create/approve paths.
  • Persist the normalized envelope to draft.current_stats. Leave current_stats_notes as-is (provenance for the LLM's original mapping); a GM-edited field's note simply becomes advisory.

Frontend — in WikiDraftReview.jsx, for generate_statblock / convert_stats drafts, make the proposed stat block editable (reuse #140's StatBlockEditor field inputs / type-aware widgets) rather than read-only, autosaving edits through patchLoreDraft (mirror the existing debounced body autosave). Approve then writes the possibly-edited current_stats (the approval path already reads draft.current_stats). Keep the confidence/source annotations visible for convert drafts.

Out of scope

  • Editing current_stats_notes themselves (provenance is informational).
  • Any schema/validation changes (all reused from #139). No migration — current_stats already exists (#142).

Acceptance criteria

  • A GM reviewing a generate_statblock or convert_stats draft can edit a proposed stat value; the edit is validated server-side (bad type/range/enum/unknown field → 400 surfaced inline).
  • On approve, the entry's stats reflects the GM's edits (not just the LLM's original values); the version snapshot captures it.
  • Read-only-then-approve (no edits) still works unchanged; other draft modes (rephrase/merge/expand_backstory) are untouched.
  • Backend + frontend tests cover an inline stat edit that validates, one that 400s, and approve-persists-edits.
## Motivation/Context v3.9.0 follow-up (flagged in #142 and #145). The schema-targeted `generate_statblock` (#142) and the `convert_stats` conversion wizard (#145) both stage a structured `stats` envelope on the draft (`LoreEntryDraft.current_stats`, with `current_stats_notes` provenance for convert). The draft-review page (`WikiDraftReview.jsx`) renders those proposed values **read-only** — the GM can only approve them as-is, iterate (re-run the LLM), or discard. `draft_service.patch_draft` / the `PATCH …/drafts/{id}` endpoint currently accepts inline edits to `current_title` / `current_body` / `current_sidebar_fields`, but **not** `current_stats`. So a GM who spots one wrong mapped value (e.g. AC 15 should be 17) can't just fix it before approving — they have to iterate or edit manually after approval via the #140 stat-block editor. ## Approach **Backend** — extend `LoreDraftPatch` + `patch_draft` (`services/draft_service.py`, `routers/campaigns.py`) to accept an optional `current_stats` value edit for `generate_statblock` / `convert_stats` drafts: - Re-validate the edited `values` against the entry's linked active schema via `game_system_service.validate_entry_stats` (re-stamping `system`/`schema_version`, `visibility` default `gm`); reject invalid edits with 400, same as the create/approve paths. - Persist the normalized envelope to `draft.current_stats`. Leave `current_stats_notes` as-is (provenance for the LLM's original mapping); a GM-edited field's note simply becomes advisory. **Frontend** — in `WikiDraftReview.jsx`, for `generate_statblock` / `convert_stats` drafts, make the proposed stat block **editable** (reuse #140's `StatBlockEditor` field inputs / type-aware widgets) rather than read-only, autosaving edits through `patchLoreDraft` (mirror the existing debounced body autosave). Approve then writes the possibly-edited `current_stats` (the approval path already reads `draft.current_stats`). Keep the confidence/source annotations visible for convert drafts. ## Out of scope - Editing `current_stats_notes` themselves (provenance is informational). - Any schema/validation changes (all reused from #139). No migration — `current_stats` already exists (#142). ## Acceptance criteria - A GM reviewing a `generate_statblock` or `convert_stats` draft can edit a proposed stat value; the edit is validated server-side (bad type/range/enum/unknown field → 400 surfaced inline). - On approve, the entry's `stats` reflects the GM's edits (not just the LLM's original values); the version snapshot captures it. - Read-only-then-approve (no edits) still works unchanged; other draft modes (rephrase/merge/expand_backstory) are untouched. - Backend + frontend tests cover an inline stat edit that validates, one that 400s, and approve-persists-edits.
Author
Contributor

Picking this up as part of the v3.9.1 patch (with #214), on fix/v3.9.1-game-aware-followups → PR to main. Extends patch_draft/LoreDraftPatch to accept validated current_stats edits and makes the proposed stat block editable in WikiDraftReview for generate_statblock/convert_stats drafts (reusing #140's inputs, autosave via patchLoreDraft).

Picking this up as part of the **v3.9.1** patch (with #214), on `fix/v3.9.1-game-aware-followups` → PR to `main`. Extends `patch_draft`/`LoreDraftPatch` to accept validated `current_stats` edits and makes the proposed stat block editable in `WikiDraftReview` for `generate_statblock`/`convert_stats` drafts (reusing #140's inputs, autosave via `patchLoreDraft`).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rbrooks/Quest-Board#213
No description provided.