[PR #7793] [MERGED] feat(state-editor): fill in empty values and add entries from the Fields view #7931

Closed
opened 2026-10-24 04:08:56 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7793
Author: @ylli-selmani
Created: 10/18/2026
Status: ✅ Merged
Merged: 10/18/2026
Merged by: @ylli-selmani

Base: staging ← Head: feat/state-editor-field-add


📝 Commits (9)

  • 48e9a48 feat(state-editor): fill in empty values and add entries from the Fields view
  • 83e4a9c fix(state-editor): review fixes for the Fields view
  • 03f5ce4 fix(state-editor): reveal row controls by hover capability, not viewport
  • 936c579 fix(state-editor): key the row shapes by the names the sections use
  • b030cbe fix(state-editor): row shape for a section that is one list, and a wider × hit area
  • 5bab059 fix(state-editor): give a list name the shape its own section declares
  • b963ba5 fix(state-editor): anchor the on/off knob to its track
  • 3de317b fix(state-editor): let entry cards grow, and give null fields a way back
  • 9036098 fix(state-editor): repair a comment a backtick escape mangled

📊 Changes

6 files changed (+474 additions, -32 deletions)

View changed files

📝 docs/roleplay/hud-and-trackers.md (+5 -1)
📝 packages/client/src/components/ui/state-editor/StateEditor.tsx (+4 -0)
📝 packages/client/src/components/ui/state-editor/StateFieldsView.tsx (+254 -28)
📝 packages/client/src/lib/state-editor/state-editor-json.ts (+92 -0)
📝 packages/client/src/localization/locales/en.json (+11 -3)
📝 scripts/regressions/state-editor.regression.ts (+108 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7792

Why this change

  • The Fields view could change values that were already there, and nothing else. A value the trackers left empty ("date": null) rendered as "No value. Set one in the JSON view." — dead text. Adding or removing an entry (a stat, a custom field, a character) meant switching to JSON and editing it by hand.
  • The tracker panel has always done both — + Add, + Add stat, + Add custom field, delete — so the two surfaces disagreed about what "editing state" means, and the editor is meant to be the one place a value gets fixed.

What changed

  • An empty value gets a kind. A null leaf now shows No value plus Text / Number / On/off; picking one writes "", 0 or false, so the field becomes editable. The × beside a value puts it back to null, which is how the game stores a field the trackers didn't know — and how a date can go back to being unknown.
  • Lists can add and remove. Add item appends an entry; the × on a card removes that entry. Rows are spliced, not nulled: a null row would be a card the tracker has to reconcile.
  • An added entry copies the shape above it. There is no schema to fetch — the shapes are implicit in what each tracker writes — so blankStateValueLike clones the nearest entry with its values cleared. For an empty list there is nothing to copy, so blankStateArrayItem starts from the shape GameState declares for that key: worldCustomFields → { name, value, icon }, stats → { name, value, max, color }, inventory rows → { name, qty, description, location }, inventory items → { name, description, quantity, location }. That is why a custom field added from scratch still has its Icon row.
  • A half-filled entry shows the rows it is missing. shapeStateEntry lays the declared keys under the stored values, so an entry the agent wrote as { "name": "Guard" } shows Value and Icon as No value. Those rows reach the draft only when one of them is edited.
  • Objects can gain fields. Add field writes a real key/value pair, shown on the section itself or on an object that is still empty (adding a field to every character card was noise).
  • Deliberately not covered: lists whose entries need ids the editor can't invent safely — present characters (characterId) and active quests (questEntryId) — keep the generic Add field row rather than starting from an empty-id card. That is a follow-up, not a silent gap.
  • Docs: docs/roleplay/hud-and-trackers.md covers the kind chooser, add/remove, the declared empty shapes and the half-filled rows.
  • Regression: scripts/regressions/state-editor.regression.ts pins the clearing rule, the empty-list shapes, cloning over declared shapes, and shapeStateEntry.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

Run on this branch's own worktree (dev stack on port 6990). The boxes above are still a to-do list for a human.

  • pnpm check — exit 0 (format, lint, localization, type checks, full build).
  • node ./scripts/run-regressions.mjs --filter scripts/regressions/state-editor.regression.ts — passed.
  • A chat seeded with a Scene whose date, time and weather are null shows the three kind choices on those rows; picking Number writes 0, and the × returns the row to No value.
  • Add item on World custom fields appends a card with Name / Value / Icon; removing it splices the card and leaves the list empty; Add item again starts from the declared shape, not from an empty object.
  • A hand-written partial entry ({ "name": "Guard" }, set through the JSON view) shows Name = Guard with Value and Icon as No value.
  • Add field on the Scene section writes a key and a value, and the key appears in the JSON view.
  • Desktop 1440×900 and phone 390×844 both checked; the per-row × is always visible on a phone and appears on hover on desktop.
  • Not covered yet: light theme and a non-default accent (the controls use the same theme tokens as the rest of the editor).

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

A half-filled entry shows what it is missing. { "name": "Guard" } shows Value and Icon as No value, next to the Scene's own null fields:

A half-filled custom field, with its missing rows

Phone, 390×844. Text / Number / On/off on the empty Scene values, and the per-value × visible without hover:

Kind chooser and clear controls on a phone

A custom field added from an empty list starts with Name, Value and Icon:

A new custom field with all three fields

Summary by CodeRabbit

  • New Features
    • The State Editor’s Fields view lets you add and remove fields and array entries without editing JSON directly.
    • Edit empty or partially populated tracker entries, set empty values to text, numbers, or booleans, and reset editable fields to no value. Read-only fields remain unchanged.
    • New entries follow the preceding entry’s shape or use the entry type’s defaults. Character and quest cards can’t be added in the editor, but their lists can.
    • Empty arrays and objects show options for adding entries or fields.
  • Documentation
    • Updated the State Editor guide to explain Fields view editing and JSON editing options.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7793 **Author:** [@ylli-selmani](https://github.com/ylli-selmani) **Created:** 10/18/2026 **Status:** ✅ Merged **Merged:** 10/18/2026 **Merged by:** [@ylli-selmani](https://github.com/ylli-selmani) **Base:** `staging` ← **Head:** `feat/state-editor-field-add` --- ### 📝 Commits (9) - [`48e9a48`](https://github.com/Pasta-Devs/Marinara-Engine/commit/48e9a4852db42f94d6d3edf114bcf6ec21de4579) feat(state-editor): fill in empty values and add entries from the Fields view - [`83e4a9c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/83e4a9c872111da64f72c5798e4bb62aefe1eb29) fix(state-editor): review fixes for the Fields view - [`03f5ce4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/03f5ce487ba052553d6eb26b171884614e9a2915) fix(state-editor): reveal row controls by hover capability, not viewport - [`936c579`](https://github.com/Pasta-Devs/Marinara-Engine/commit/936c5790b883add3ba87dc39b32a819ca1fc26c2) fix(state-editor): key the row shapes by the names the sections use - [`b030cbe`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b030cbe5419075e6cb84d729a910efcd449faeb9) fix(state-editor): row shape for a section that is one list, and a wider × hit area - [`5bab059`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5bab059313f8ab7d6fde8b6b45ef0a6255f4f0aa) fix(state-editor): give a list name the shape its own section declares - [`b963ba5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b963ba5d102fec3c38f77a6f0f869241f56110d6) fix(state-editor): anchor the on/off knob to its track - [`3de317b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3de317b8f95da76e8842b0300fe9a07a5859f387) fix(state-editor): let entry cards grow, and give null fields a way back - [`9036098`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9036098ee3700fd90be4f59016783dcfae2fd62c) fix(state-editor): repair a comment a backtick escape mangled ### 📊 Changes **6 files changed** (+474 additions, -32 deletions) <details> <summary>View changed files</summary> 📝 `docs/roleplay/hud-and-trackers.md` (+5 -1) 📝 `packages/client/src/components/ui/state-editor/StateEditor.tsx` (+4 -0) 📝 `packages/client/src/components/ui/state-editor/StateFieldsView.tsx` (+254 -28) 📝 `packages/client/src/lib/state-editor/state-editor-json.ts` (+92 -0) 📝 `packages/client/src/localization/locales/en.json` (+11 -3) 📝 `scripts/regressions/state-editor.regression.ts` (+108 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #7792 ## Why this change - The Fields view could change values that were already there, and nothing else. A value the trackers left empty (`"date": null`) rendered as *"No value. Set one in the JSON view."* — dead text. Adding or removing an entry (a stat, a custom field, a character) meant switching to JSON and editing it by hand. - The tracker panel has always done both — **+ Add**, **+ Add stat**, **+ Add custom field**, delete — so the two surfaces disagreed about what "editing state" means, and the editor is meant to be the one place a value gets fixed. ## What changed - **An empty value gets a kind.** A null leaf now shows **No value** plus **Text / Number / On/off**; picking one writes `""`, `0` or `false`, so the field becomes editable. The **×** beside a value puts it back to `null`, which is how the game stores a field the trackers didn't know — and how a `date` can go back to being unknown. - **Lists can add and remove.** **Add item** appends an entry; the **×** on a card removes that entry. Rows are spliced, not nulled: a null row would be a card the tracker has to reconcile. - **An added entry copies the shape above it.** There is no schema to fetch — the shapes are implicit in what each tracker writes — so `blankStateValueLike` clones the nearest entry with its values cleared. For an **empty** list there is nothing to copy, so `blankStateArrayItem` starts from the shape `GameState` declares for that key: `worldCustomFields` → `{ name, value, icon }`, `stats` → `{ name, value, max, color }`, inventory rows → `{ name, qty, description, location }`, inventory items → `{ name, description, quantity, location }`. That is why a custom field added from scratch still has its **Icon** row. - **A half-filled entry shows the rows it is missing.** `shapeStateEntry` lays the declared keys under the stored values, so an entry the agent wrote as `{ "name": "Guard" }` shows **Value** and **Icon** as *No value*. Those rows reach the draft only when one of them is edited. - **Objects can gain fields.** **Add field** writes a real key/value pair, shown on the section itself or on an object that is still empty (adding a field to every character card was noise). - **Deliberately not covered:** lists whose entries need ids the editor can't invent safely — present characters (`characterId`) and active quests (`questEntryId`) — keep the generic **Add field** row rather than starting from an empty-id card. That is a follow-up, not a silent gap. - Docs: `docs/roleplay/hud-and-trackers.md` covers the kind chooser, add/remove, the declared empty shapes and the half-filled rows. - Regression: `scripts/regressions/state-editor.regression.ts` pins the clearing rule, the empty-list shapes, cloning over declared shapes, and `shapeStateEntry`. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes Run on this branch's own worktree (dev stack on port 6990). The boxes above are still a to-do list for a human. - `pnpm check` — exit 0 (format, lint, localization, type checks, full build). - `node ./scripts/run-regressions.mjs --filter scripts/regressions/state-editor.regression.ts` — passed. - A chat seeded with a Scene whose `date`, `time` and `weather` are `null` shows the three kind choices on those rows; picking **Number** writes `0`, and the **×** returns the row to **No value**. - **Add item** on World custom fields appends a card with **Name / Value / Icon**; removing it splices the card and leaves the list empty; **Add item** again starts from the declared shape, not from an empty object. - A hand-written partial entry (`{ "name": "Guard" }`, set through the JSON view) shows **Name = Guard** with **Value** and **Icon** as **No value**. - **Add field** on the Scene section writes a key and a value, and the key appears in the JSON view. - Desktop 1440×900 and phone 390×844 both checked; the per-row **×** is always visible on a phone and appears on hover on desktop. - Not covered yet: light theme and a non-default accent (the controls use the same theme tokens as the rest of the editor). ## Docs and release impact - [ ] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README) as needed - [x] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) **A half-filled entry shows what it is missing.** `{ "name": "Guard" }` shows Value and Icon as *No value*, next to the Scene's own null fields: ![A half-filled custom field, with its missing rows](https://raw.githubusercontent.com/ylli-selmani/Marinara-Engine-Ylli-Edits/pr-assets/state-editor-fields/01-partial-entry.png) **Phone, 390×844.** `Text / Number / On/off` on the empty Scene values, and the per-value **×** visible without hover: ![Kind chooser and clear controls on a phone](https://raw.githubusercontent.com/ylli-selmani/Marinara-Engine-Ylli-Edits/pr-assets/state-editor-fields/02-phone-chooser.png) **A custom field added from an empty list** starts with Name, Value and Icon: ![A new custom field with all three fields](https://raw.githubusercontent.com/ylli-selmani/Marinara-Engine-Ylli-Edits/pr-assets/state-editor-fields/03-new-custom-field.png) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * The State Editor’s Fields view lets you add and remove fields and array entries without editing JSON directly. * Edit empty or partially populated tracker entries, set empty values to text, numbers, or booleans, and reset editable fields to no value. Read-only fields remain unchanged. * New entries follow the preceding entry’s shape or use the entry type’s defaults. Character and quest cards can’t be added in the editor, but their lists can. * Empty arrays and objects show options for adding entries or fields. * **Documentation** * Updated the State Editor guide to explain Fields view editing and JSON editing options. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:08:56 +07:00
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
Pasta-Devs/Marinara-Engine#7931
No description provided.