[GH-ISSUE #1149] [Issue]: Refactor game segment edits leave JSON fragments from unknown tags #568

Closed
opened 2026-10-20 17:30:17 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @cha1latte on GitHub (May 24, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1149

Originally assigned to: @cha1latte on GitHub.

Summary

Game-mode segment edits on the refactor branch can leave dangling JSON fragments in the message history when a GM message contains an unknown bracket command with nested brackets.

Expected behavior

When segment edit persistence strips processed/unknown GM command tags, it should remove the entire balanced unknown tag body so the edited history only contains readable narration/dialogue.

Actual behavior

src/engine/modes/game/state/segment-edits.ts strips unknown [tag: ...] commands with a first-] regex. A tag such as [debug: {"items":["torch"]}] leaves }] behind after stripping. If the player edits/deletes a game narration segment, that malformed residue can be saved into the prompt/history used for later game turns.

Steps to reproduce

  1. On the refactor branch, run the segment edit stripping path against game narration containing an unknown tag with nested brackets, for example: The room shifts. [debug: {"items":["torch"]}] Continue forward.
  2. Apply any persisted segment edit/delete overlay for that assistant message so stripGmCommandTags runs.
  3. Inspect the edited content that is sent forward into game history.

Environment

  • Marinara Engine version: refactor branch (60050abe)
  • Install type: source
  • OS + version: Windows 11
  • Browser or app shell: Not browser-specific; engine segment-edit logic

Logs, screenshots, or video

Not specified.

Additional context

The client-side game tag parser already has a quote-aware balanced unknown-tag stripper. The refactor engine copy did not get the same handling, so UI-visible parsing and prompt/history rewriting disagree.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @cha1latte on GitHub (May 24, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1149 Originally assigned to: @cha1latte on GitHub. ## Summary Game-mode segment edits on the refactor branch can leave dangling JSON fragments in the message history when a GM message contains an unknown bracket command with nested brackets. ## Expected behavior When segment edit persistence strips processed/unknown GM command tags, it should remove the entire balanced unknown tag body so the edited history only contains readable narration/dialogue. ## Actual behavior `src/engine/modes/game/state/segment-edits.ts` strips unknown `[tag: ...]` commands with a first-`]` regex. A tag such as `[debug: {"items":["torch"]}]` leaves `}]` behind after stripping. If the player edits/deletes a game narration segment, that malformed residue can be saved into the prompt/history used for later game turns. ## Steps to reproduce 1. On the `refactor` branch, run the segment edit stripping path against game narration containing an unknown tag with nested brackets, for example: `The room shifts. [debug: {"items":["torch"]}] Continue forward.` 2. Apply any persisted segment edit/delete overlay for that assistant message so `stripGmCommandTags` runs. 3. Inspect the edited content that is sent forward into game history. ## Environment - Marinara Engine version: refactor branch (`60050abe`) - Install type: source - OS + version: Windows 11 - Browser or app shell: Not browser-specific; engine segment-edit logic ## Logs, screenshots, or video Not specified. ## Additional context The client-side game tag parser already has a quote-aware balanced unknown-tag stripper. The refactor engine copy did not get the same handling, so UI-visible parsing and prompt/history rewriting disagree. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:30:17 +07:00
  • closed this issue
  • added the
    bug
    label
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#568
No description provided.