[PR #7739] [MERGED] feat(state-editor): edit values as fields, plus State Editor docs #7908

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

📋 Pull Request Information

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

Base: staging ← Head: feat/state-editor-form-view


📝 Commits (4)

  • 4f47ade feat(state-editor): edit simple values as fields next to the JSON
  • 2efde1a docs(state-editor): explain the State Editor and where to open it
  • 35253c4 fix(state-editor): keep text fields focused while they grow past one line
  • a3ca2a8 fix(state-editor): keep only the open view's search target

📊 Changes

8 files changed (+404 additions, -27 deletions)

View changed files

📝 docs/agents/approvals-and-agent-suite.md (+3 -1)
📝 docs/chats/chat-settings.md (+2 -0)
📝 docs/roleplay/hud-and-trackers.md (+14 -0)
📝 packages/client/src/components/ui/state-editor/StateEditor.tsx (+91 -25)
➕ packages/client/src/components/ui/state-editor/StateFieldsView.tsx (+228 -0)
📝 packages/client/src/lib/state-editor/state-editor-json.ts (+38 -1)
📝 packages/client/src/localization/locales/en.json (+10 -0)
📝 scripts/regressions/state-editor.regression.ts (+18 -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

Part of #7736 (State Editor). Follows #7737, which shipped slices 1–3.

Why this change

Before: the State Editor showed each section as raw JSON only. Fixing one mood or one HP number meant finding it in a wall of braces and keeping the commas right, which is fiddly on a phone.

After: each section opens as Fields: text, numbers and on/off values as boxes, grouped the way the data nests, with characters, items and quests as cards. JSON is one tap away for adding or removing entries. A search result jumps to its field and focuses it. The State Editor also has user docs now.

What changed

Slice Commit What
5. Fields view 4f47ade StateFieldsView renders a section's simple values as inputs and writes the same JSON draft as the JSON view, so both views always show the same edit, review and save. Numbers only reach the draft once they parse. null and structural changes stay in JSON. If the JSON draft doesn't parse, Fields offers a button back to JSON instead of guessing. Search results carry their path, so a click scrolls to and focuses the field.
Docs 2efde1a New The State Editor section in docs/roleplay/hud-and-trackers.md (opening it, the turn line, sections, search, Fields/JSON, review/save, and the reload refusals). Pointers from Chat Variables in docs/chats/chat-settings.md and from the Agent Suite blocks in docs/agents/approvals-and-agent-suite.md.
Fix (local CodeRabbit) 35253c4 Text fields are always a textarea that grows with the text, instead of swapping from <input> to <textarea> past 48 characters or on Enter, which dropped focus mid-typing.

How: setStateValueAtPath copies only the containers on the edited path, so untouched entries keep their identity and keys keep their order; humanizeStateKey turns currentMood into "Current mood" for labels while the raw key stays as a tooltip. Both are covered in state-editor.regression.ts.

Slice 4 (game mode) is not in this PR. Game state already works in the editor through the trackers. Editing the game's own data (party, NPCs, inventory, world) needs a validating server route and a checkpoint before saving, so it will come as its own PR once the approach is agreed with the game mode maintainers.

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

Ran: pnpm lint, pnpm format:check, pnpm localization:check, client tsc --noEmit, and the state-editor and open-issues regressions. All pass. Local CodeRabbit found one issue (focus lost when a text field grew past one line), fixed in 35253c4.

Manual verification notes

  • Opened the State Editor on a roleplay chat with trackers. Scene opens in Fields; edited Location and saw the section's dot appear.
  • Present Characters: each character is a card named by its name; edited a mood, switched to JSON and saw the same edit there, then back.
  • Searched mood, clicked a result: the Fields view scrolled to that character's Mood and focused it.
  • Typed a 70-character mood, pressed Enter and kept typing: the field grew and kept focus (desktop and phone).
  • Broke the JSON in JSON view, switched to Fields: shows "Fix the JSON to edit fields again".
  • Review changes listed the field edit line by line; Save wrote it to the turn.
  • Repeated on a phone-sized viewport (390px).

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): #7740
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

Scene in Fields, and Present Characters as cards:

A search result focusing its field, and the edit:

Review before saving:

Phone:

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • The State Editor now offers Fields and JSON views for tracker data, with searchable, editable fields and focused search results. Longer text is easier to edit, and invalid JSON can be corrected in JSON view. Saving is unavailable until the JSON is valid.
  • Documentation
    • Updated guides cover editing tracker data and chat variables, reviewing changes, and reloading stale drafts. They also explain that saving chat-variable edits preserves other values saved in the meantime, and that Agent Suite JSON blocks show line numbers and parse errors.

🔄 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/7739 **Author:** [@ylli-selmani](https://github.com/ylli-selmani) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@ylli-selmani](https://github.com/ylli-selmani) **Base:** `staging` ← **Head:** `feat/state-editor-form-view` --- ### 📝 Commits (4) - [`4f47ade`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4f47ade1c2434e1542f65aa6aa4b5090c2c6d6f7) feat(state-editor): edit simple values as fields next to the JSON - [`2efde1a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2efde1ab0286eea0c2dee3c0f15d5db1133d2df3) docs(state-editor): explain the State Editor and where to open it - [`35253c4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/35253c458ebfffaca3455b201c01defd065a4f50) fix(state-editor): keep text fields focused while they grow past one line - [`a3ca2a8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a3ca2a85f09923cf1986d6ecdd31e44dead898f4) fix(state-editor): keep only the open view's search target ### 📊 Changes **8 files changed** (+404 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `docs/agents/approvals-and-agent-suite.md` (+3 -1) 📝 `docs/chats/chat-settings.md` (+2 -0) 📝 `docs/roleplay/hud-and-trackers.md` (+14 -0) 📝 `packages/client/src/components/ui/state-editor/StateEditor.tsx` (+91 -25) ➕ `packages/client/src/components/ui/state-editor/StateFieldsView.tsx` (+228 -0) 📝 `packages/client/src/lib/state-editor/state-editor-json.ts` (+38 -1) 📝 `packages/client/src/localization/locales/en.json` (+10 -0) 📝 `scripts/regressions/state-editor.regression.ts` (+18 -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`. ## Linked issue Part of #7736 (State Editor). Follows #7737, which shipped slices 1–3. ## Why this change Before: the State Editor showed each section as raw JSON only. Fixing one mood or one HP number meant finding it in a wall of braces and keeping the commas right, which is fiddly on a phone. After: each section opens as **Fields**: text, numbers and on/off values as boxes, grouped the way the data nests, with characters, items and quests as cards. **JSON** is one tap away for adding or removing entries. A search result jumps to its field and focuses it. The State Editor also has user docs now. ## What changed | Slice | Commit | What | | --- | --- | --- | | 5. Fields view | 4f47ade | `StateFieldsView` renders a section's simple values as inputs and writes the same JSON draft as the JSON view, so both views always show the same edit, review and save. Numbers only reach the draft once they parse. `null` and structural changes stay in JSON. If the JSON draft doesn't parse, Fields offers a button back to JSON instead of guessing. Search results carry their path, so a click scrolls to and focuses the field. | | Docs | 2efde1a | New **The State Editor** section in `docs/roleplay/hud-and-trackers.md` (opening it, the turn line, sections, search, Fields/JSON, review/save, and the reload refusals). Pointers from Chat Variables in `docs/chats/chat-settings.md` and from the Agent Suite blocks in `docs/agents/approvals-and-agent-suite.md`. | | Fix (local CodeRabbit) | 35253c4 | Text fields are always a textarea that grows with the text, instead of swapping from `<input>` to `<textarea>` past 48 characters or on Enter, which dropped focus mid-typing. | How: `setStateValueAtPath` copies only the containers on the edited path, so untouched entries keep their identity and keys keep their order; `humanizeStateKey` turns `currentMood` into "Current mood" for labels while the raw key stays as a tooltip. Both are covered in `state-editor.regression.ts`. **Slice 4 (game mode) is not in this PR.** Game state already works in the editor through the trackers. Editing the game's own data (party, NPCs, inventory, world) needs a validating server route and a checkpoint before saving, so it will come as its own PR once the approach is agreed with the game mode maintainers. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` Ran: `pnpm lint`, `pnpm format:check`, `pnpm localization:check`, client `tsc --noEmit`, and the `state-editor` and `open-issues` regressions. All pass. Local CodeRabbit found one issue (focus lost when a text field grew past one line), fixed in 35253c4. ### Manual verification notes - Opened the State Editor on a roleplay chat with trackers. Scene opens in Fields; edited Location and saw the section's dot appear. - Present Characters: each character is a card named by its name; edited a mood, switched to JSON and saw the same edit there, then back. - Searched `mood`, clicked a result: the Fields view scrolled to that character's Mood and focused it. - Typed a 70-character mood, pressed Enter and kept typing: the field grew and kept focus (desktop and phone). - Broke the JSON in JSON view, switched to Fields: shows "Fix the JSON to edit fields again". - Review changes listed the field edit line by line; Save wrote it to the turn. - Repeated on a phone-sized viewport (390px). ## 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): #7740 - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) Scene in Fields, and Present Characters as cards: <img src="https://raw.githubusercontent.com/ylli-selmani/Marinara-Engine-Ylli-Edits/pr-assets/state-editor/11-desktop-fields-scene.png" width="49%"> <img src="https://raw.githubusercontent.com/ylli-selmani/Marinara-Engine-Ylli-Edits/pr-assets/state-editor/12-desktop-fields-characters.png" width="49%"> A search result focusing its field, and the edit: <img src="https://raw.githubusercontent.com/ylli-selmani/Marinara-Engine-Ylli-Edits/pr-assets/state-editor/13-desktop-fields-search-jump.png" width="49%"> <img src="https://raw.githubusercontent.com/ylli-selmani/Marinara-Engine-Ylli-Edits/pr-assets/state-editor/14-desktop-fields-edited.png" width="49%"> Review before saving: <img src="https://raw.githubusercontent.com/ylli-selmani/Marinara-Engine-Ylli-Edits/pr-assets/state-editor/15-desktop-fields-review.png" width="70%"> Phone: <img src="https://raw.githubusercontent.com/ylli-selmani/Marinara-Engine-Ylli-Edits/pr-assets/state-editor/16-phone-fields.png" width="100%"> 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * The State Editor now offers Fields and JSON views for tracker data, with searchable, editable fields and focused search results. Longer text is easier to edit, and invalid JSON can be corrected in JSON view. Saving is unavailable until the JSON is valid. * **Documentation** * Updated guides cover editing tracker data and chat variables, reviewing changes, and reloading stale drafts. They also explain that saving chat-variable edits preserves other values saved in the meantime, and that Agent Suite JSON blocks show line numbers and parse errors. <!-- 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:43 +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#7908
No description provided.