[GH-ISSUE #7736] [Feature]: Reusable State Editor, starting with roleplay game state #4270

Closed
opened 2026-10-21 06:13:53 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @ylli-selmani on GitHub (Oct 16, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7736

Originally assigned to: @ylli-selmani on GitHub.

What problem does this solve?

Roleplay chats carry a lot of state that the tracker agents maintain: the scene (date, time, location, weather), present characters, persona stats, custom tracker fields, the Inventory Tracker, and active quests. Agents read it back every turn as <current_game_state>.

When an agent gets something wrong (a character who left is still "present", an item got duplicated, a quest is stuck), fixing it is awkward:

  • The tracker panel edits individual fields well, but it isn't built for bulk fixes, or for finding where a value lives across sections.
  • Agent Suite can edit the same data as raw JSON, but only one slice at a time, in a plain textarea, with no search and no preview of what is about to change.
  • Editing the files under data/storage/tables doesn't work while the server runs. Tables live in memory and get flushed back over the files, so hand edits are lost.

The client also has several separate hand-rolled raw-JSON editors (Agent Suite tracker slices and memory keys, the agent-run field in the RP HUD actions menu, GameJsonRepairModal). Each one does its own parsing, validation and error display.

Proposed solution

A reusable State Editor component in Marinara's own visual language, plus a first use: editing the current roleplay game state.

The component (components/ui/state-editor/):

  • A sections list (sidebar on desktop, a compact picker on phones).
  • Search across all sections. Results show where a match lives (for example Present Characters › Gwendolyn › mood) and its value. Tapping a result opens that section at that spot.
  • A JSON editor per section with line numbers and inline parse errors, so a typo is caught before saving.
  • Drafts: edits across several sections stay pending until saved. A footer shows how many sections changed, with Discard and Review changes.
  • Review changes shows a per-section diff and then saves. It reuses the existing UnifiedLineDiff (MariUnifiedDiff.tsx) that Prof Mari's edit review already uses.
  • It knows nothing about game state itself. It takes a source adapter: a list of sections (id, label, description, value), a save function, and optional per-section validation. Other data can plug in later without touching the component.

The first adapter: roleplay game state

  • Sections come from the existing AGENT_SUITE_TRACKER_SLICES (lib/agent-suite-tracker-slices.ts), which already define getValue and buildPatch with validation for each tracker. No new data shapes.
  • Saving follows the path Agent Suite already uses: flush queued HUD tracker edits, fetch a fresh snapshot, build the patches for the changed sections only, then send one PATCH /chats/:id/game-state with manual: true, aimed at the snapshot's messageId + swipeIndex. Because every swipe has its own snapshot, edits land on the turn being viewed, and swiping or regenerating keeps working as it does today.
  • It opens from the tracker panel header.
  • Client only. No server, schema or prompt changes in the first PR.

Planned slices. Each slice gets one or more commits, and the PR body lists the slices with their commit hashes:

  1. The component + the game-state adapter + the tracker panel entry point.
  2. Agent Suite's tracker tab uses the shared section editor instead of its own textarea.
  3. A chat-variables adapter (chat.metadata.macroVariables), useful for game-mode setups that keep state in variables rather than relying on the LLM.
  4. Game-mode adapters (world/engine state). These need a read/write route review first.
  5. Later, a friendlier form view for simple fields (text and numbers as inputs) on top of the same adapters.

Two PRs, so CI and review rounds stay reasonable:

  • PR 1: slices 1 to 3. Client only, low risk.
  • PR 2: slices 4 and 5. Game mode touches server routes and stored game data, so it gets its own review.

Alternatives considered

  • Keep improving Agent Suite's textarea in place. This helps one surface, and every other raw-JSON editor stays separate.
  • A generic JSON-tree library (react-json-view and similar). Adds a dependency and its own look, and still needs the adapter and save logic. A small in-house component matches the app better.
  • Editing the storage files directly. Doesn't persist (see above), and it skips the normalizers the PATCH route applies.

Additional context

  • Inspired by the state editor in Voyage, which added one after users reported the narrator and state models drifting with no way to fix it.
  • Saving goes through the same PATCH route and normalizers as the tracker panel and Agent Suite, so the existing validation and the Spatial Context location rule still apply.
  • Proof for the first PR: unit regressions for the patch folding and search, plus desktop and phone screenshots.

Feedback on the plan or the slice order is very welcome before slice 1 lands.

Template check

  • I DID NOT read this template and provide the requested details.

Ylli: okay, claude wrote that each slice would go as a small pr, but i was thinking of commits.. well, we'll see

Originally created by @ylli-selmani on GitHub (Oct 16, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7736 Originally assigned to: @ylli-selmani on GitHub. ## What problem does this solve? Roleplay chats carry a lot of state that the tracker agents maintain: the scene (date, time, location, weather), present characters, persona stats, custom tracker fields, the Inventory Tracker, and active quests. Agents read it back every turn as `<current_game_state>`. When an agent gets something wrong (a character who left is still "present", an item got duplicated, a quest is stuck), fixing it is awkward: - The tracker panel edits individual fields well, but it isn't built for bulk fixes, or for finding where a value lives across sections. - Agent Suite can edit the same data as raw JSON, but only one slice at a time, in a plain textarea, with no search and no preview of what is about to change. - Editing the files under `data/storage/tables` doesn't work while the server runs. Tables live in memory and get flushed back over the files, so hand edits are lost. The client also has several separate hand-rolled raw-JSON editors (Agent Suite tracker slices and memory keys, the agent-run field in the RP HUD actions menu, `GameJsonRepairModal`). Each one does its own parsing, validation and error display. ## Proposed solution A reusable **State Editor** component in Marinara's own visual language, plus a first use: editing the current roleplay game state. **The component** (`components/ui/state-editor/`): - A **sections list** (sidebar on desktop, a compact picker on phones). - **Search across all sections**. Results show where a match lives (for example `Present Characters › Gwendolyn › mood`) and its value. Tapping a result opens that section at that spot. - A **JSON editor per section** with line numbers and inline parse errors, so a typo is caught before saving. - **Drafts**: edits across several sections stay pending until saved. A footer shows how many sections changed, with **Discard** and **Review changes**. - **Review changes** shows a per-section diff and then saves. It reuses the existing `UnifiedLineDiff` (`MariUnifiedDiff.tsx`) that Prof Mari's edit review already uses. - It knows nothing about game state itself. It takes a **source adapter**: a list of sections (id, label, description, value), a save function, and optional per-section validation. Other data can plug in later without touching the component. **The first adapter: roleplay game state** - Sections come from the existing `AGENT_SUITE_TRACKER_SLICES` (`lib/agent-suite-tracker-slices.ts`), which already define `getValue` and `buildPatch` with validation for each tracker. No new data shapes. - Saving follows the path Agent Suite already uses: flush queued HUD tracker edits, fetch a fresh snapshot, build the patches for the changed sections only, then send one `PATCH /chats/:id/game-state` with `manual: true`, aimed at the snapshot's `messageId` + `swipeIndex`. Because every swipe has its own snapshot, edits land on the turn being viewed, and swiping or regenerating keeps working as it does today. - It opens from the tracker panel header. - **Client only.** No server, schema or prompt changes in the first PR. **Planned slices.** Each slice gets one or more commits, and the PR body lists the slices with their commit hashes: 1. The component + the game-state adapter + the tracker panel entry point. 2. Agent Suite's tracker tab uses the shared section editor instead of its own textarea. 3. A chat-variables adapter (`chat.metadata.macroVariables`), useful for game-mode setups that keep state in variables rather than relying on the LLM. 4. Game-mode adapters (world/engine state). These need a read/write route review first. 5. Later, a friendlier form view for simple fields (text and numbers as inputs) on top of the same adapters. **Two PRs**, so CI and review rounds stay reasonable: - **PR 1:** slices 1 to 3. Client only, low risk. - **PR 2:** slices 4 and 5. Game mode touches server routes and stored game data, so it gets its own review. ## Alternatives considered - **Keep improving Agent Suite's textarea in place.** This helps one surface, and every other raw-JSON editor stays separate. - **A generic JSON-tree library** (react-json-view and similar). Adds a dependency and its own look, and still needs the adapter and save logic. A small in-house component matches the app better. - **Editing the storage files directly.** Doesn't persist (see above), and it skips the normalizers the PATCH route applies. ## Additional context - Inspired by the state editor in Voyage, which added one after users reported the narrator and state models drifting with no way to fix it. - Saving goes through the same PATCH route and normalizers as the tracker panel and Agent Suite, so the existing validation and the Spatial Context location rule still apply. - Proof for the first PR: unit regressions for the patch folding and search, plus desktop and phone screenshots. Feedback on the plan or the slice order is very welcome before slice 1 lands. ## Template check - [ ] I DID NOT read this template and provide the requested details. --- Ylli: okay, claude wrote that each slice would go as a small pr, but i was thinking of commits.. well, we'll see
bsakaguchi 2026-10-21 06:13:53 +07:00
Author
Owner

@ylli-selmani commented on GitHub (Oct 16, 2026):

Closing as done for roleplay: #7737 shipped slices 1–3 (the editor, Agent Suite, chat variables) and #7739 shipped slice 5 (Fields view) plus docs.

Slice 4 (Game Mode) moves to its own issue, #7743, re-planned after kolacheee's review of what's safe to edit and how. Its prerequisite, checkpoints that also save the game's chat metadata, is #7742.


Generated by Claude Code

<!-- gh-comment-id:6222110840 --> @ylli-selmani commented on GitHub (Oct 16, 2026): Closing as done for roleplay: #7737 shipped slices 1–3 (the editor, Agent Suite, chat variables) and #7739 shipped slice 5 (Fields view) plus docs. Slice 4 (Game Mode) moves to its own issue, #7743, re-planned after kolacheee's review of what's safe to edit and how. Its prerequisite, checkpoints that also save the game's chat metadata, is #7742. --- _Generated by [Claude Code](https://claude.ai/code)_
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#4270
No description provided.