mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7737] [MERGED] feat(state-editor): add reusable State Editor for roleplay game state #7904
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#7904
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7737
Author: @ylli-selmani
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @ylli-selmani
Base:
staging← Head:feat/state-editor📝 Commits (8)
cbf5cf8feat(state-editor): add a reusable State Editor and open it on roleplay game state1f81d18feat(state-editor): share the JSON field with Agent Suite and link it to the State Editore0a2d17feat(state-editor): open chat variables in the State Editor67f443ffix(state-editor): use the same plain label on the tracker toolbar buttondda4023feat(state-editor): show which message and swipe the game state belongs to068c7b4fix(state-editor): keep warnings steady and fill the snapshot label as messages load1f7203efix(state-editor): localize the invalid-JSON and unknown-section messages46c765ffix(state-editor): refuse to save a section the tracker changed meanwhile📊 Changes
16 files changed (+1857 additions, -21 deletions)
View changed files
📝
packages/client/src/components/chat/AgentSuiteModal.tsx(+64 -19)📝
packages/client/src/components/layout/ModalRenderer.tsx(+12 -0)➕
packages/client/src/components/modals/ChatVariablesEditorModal.tsx(+157 -0)➕
packages/client/src/components/modals/GameStateEditorModal.tsx(+309 -0)➕
packages/client/src/components/ui/state-editor/StateEditor.tsx(+494 -0)➕
packages/client/src/components/ui/state-editor/StateJsonField.tsx(+95 -0)📝
packages/client/src/features/chat-settings/sections/ChatVariablesSection.tsx(+8 -0)📝
packages/client/src/features/tracker-panel/components/TrackerDataSidebar.tsx(+5 -0)📝
packages/client/src/features/tracker-panel/components/TrackerSidebarHeader.tsx(+27 -1)➕
packages/client/src/lib/state-editor/chat-variables-editor-source.ts(+92 -0)➕
packages/client/src/lib/state-editor/game-state-editor-source.ts(+75 -0)➕
packages/client/src/lib/state-editor/state-editor-json.ts(+205 -0)➕
packages/client/src/lib/state-editor/state-editor.types.ts(+22 -0)📝
packages/client/src/localization/locales/en.json(+82 -0)➕
scripts/regressions/state-editor.regression.ts(+208 -0)📝
scripts/regressions/tsconfig.client-lanes.json(+2 -1)📄 Description
Linked issue
Part of #7736 (this PR covers slices 1 to 3; slices 4 and 5 come in a second PR).
Why this change
What changed
Slices
cbf5cf8, label fix67f443f, snapshot labeldda4023, review fixes068c7b4,1f7203eand46c765f). A new{ }button ("Open in State Editor") in the tracker panel's settings toolbar opens a State Editor on the current turn's game state: a sections list (chip row on phones), search across every key and value (a result jumps to its line), a JSON editor per section with inline parse errors, and a per-section diff under Review changes before saving. Changed sections are saved in one game-state PATCH aimed at the turn being viewed. A line under the search says which snapshot is open: message #N (the number the chat shows), swipe X of Y, a Latest badge and a one-line excerpt; the raw message id is in its tooltip.1f81d18). Agent Suite's JSON tracker blocks get the State Editor's line-numbered field, show parse errors while typing and keep Save disabled until the JSON parses. The Tracker data header gets an Open in State Editor link. Text blocks keep their plain textarea.e0a2d17). Chat Settings → Chat Variables gets a Search and edit all in the State Editor link that opens the chat's{{name}}variables as one JSON map with search, review and save. Saving sends only the names that changed (null for removed ones) through the same metadata save queue as the section, so a{{setvar}}saved meanwhile under another name survives. New names follow the Chat Variables naming rules; names{{setvar}}stored with dots or dashes stay editable. The section list hides when a source has a single section, and the review subtitle only mentions "the turn you're viewing" for game state.How: the editor (
components/ui/state-editor/StateEditor.tsx) only knows sections and a save function. The game-state source reusesAGENT_SUITE_TRACKER_SLICES, so validation and patch building stay shared with Agent Suite; several slices rewrite all ofplayerStats, so their patches are folded one onto the other instead of built from the same snapshot. Before saving, queued tracker-panel edits are flushed and a fresh snapshot is fetched; if the turn moved on (new reply or swipe), the save is refused with a Reload option instead of overwriting the new turn. On the same turn, a changed section that the tracker also updated after the editor opened is refused the same way, because sections save whole and would undo that update; the opened snapshot stays the baseline (no refetch on focus or reconnect). The snapshot label reads the message from the chat's already-loaded pages (no extra request) and follows those caches as they fill; its #N is the chat's message count minus the loaded messages after it. The JSON field with its line-number gutter (StateJsonField.tsx) is shared by the State Editor and Agent Suite. The chat-variables source (lib/state-editor/chat-variables-editor-source.ts) diffs the draft against the map the editor opened with and checks names, value length and the 500-variable cap before sending. Warnings use the static app accent, and the invalid-JSON lead and unknown-section message are localized (the parser's own detail follows the lead).Known limits, on purpose:
messageIdandswipeIndexthe editor opened, so the edit lands on that snapshot and never on the new turn. A server-enforced precondition would close the gap fully; it touches the server route, so it's noted for the second PR instead of growing this client-only one.open-issues.regression.ts, so turning them into localized error codes is tracked in #7738.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
mood, jumped to Gwendolyn's mood, edited it plus a quest objective, broke and reverted a section's JSON, reviewed the diff, saved, and confirmed the new values viaGET /api/chats/:id/game-state. In Agent Suite, broke a tracker block's JSON and saw the inline error with Save disabled.gull, changed one value, removed one and added one, reviewed and saved, and confirmed the map viaGET /api/chats/:id. Addinguseris refused at save with "belongs to a built-in macro".pnpm checkpassed in the cloud copy and on Windows (0 errors). Regressionsstate-editor,open-issuesandtoken-estimatorpass.coderabbit review --committed --base origin/staging): one trivial finding (the toolbar button said "Edit raw game state"), fixed in67f443f.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)Docs are deliberately deferred: the user docs for the State Editor land with the second PR for #7736 (slices 4 and 5), once all entry points exist, and that PR opens the
[docs-i18n]follow-up issue for the translated docs. This PR changes no docs.UI evidence (if applicable)
Which snapshot is open
Review changes (desktop)
Phone: open, search, jump to the match
Phone: invalid JSON, review, saved
Agent Suite: shared JSON field, then a live parse error (slice 2)
Chat variables: the new link, and the review before saving (slice 3)
🤖 Generated with Claude Code
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.