[PR #4729] [MERGED] fix: clear stale conversationCommandContent when message content is edited #6482

Closed
opened 2026-10-23 04:10:50 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4729
Author: @NeoKazuya
Created: 8/7/2026
Status: ✅ Merged
Merged: 8/7/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/conversation-edit-command-content


📝 Commits (2)

  • 48f8aa6 fix: clear stale conversationCommandContent when message content is edited
  • 1fea4c4 fix: gate the active-swipe clear on the swipe's own extra

📊 Changes

2 files changed (+34 additions, -2 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/services/storage/chats.storage.ts (+33 -2)

📄 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 #4728

Why this change

  • Conversation-mode prompt history prefers extra.conversationCommandContent (the raw reply before command stripping) over content for assistant messages, and editing a message never cleared that field. Once a reply carried a command, edits to it never reached the model: the UI, database, and exports showed the edit while every later prompt kept sending the original wording.

What changed

  • Clear conversationCommandContent in updateMessageContent when the visible content changes, mirrored onto the active swipe row the same way content already is.
  • Keep the field on no-op saves and on hidden commandOnly anchor messages, whose content is empty by design and whose only text is this field.
  • Apply the clear with direct db.update writes inside the existing patch-queue section, since withPatchQueue is not re-entrant and a nested updateMessageExtra call would deadlock.
  • Preserve per-swipe extras and untouched swipes' raw text. Continue, regeneration, and game-mode paths are unaffected.
  • Prose-guardian rewrites, which apply through the same function, now reach prompt history too.
  • Edited messages lose their command markers in the model-visible transcript. The commands themselves already executed at generation time.
  • Add the user-facing fix to the Unreleased changelog.

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

  • Edited a Conversation reply carrying a [schedule_update] raw copy through the chat UI on a local test build. The edit persisted to content, its conversationCommandContent was cleared, and an untouched command reply in the same chat kept its raw copy.
  • Drove the patched storage layer and prompt formatter directly: an edit to a command reply returns the edited text in Conversation prompt history, a no-op save keeps the raw copy, commandOnly anchors keep theirs, swipe-then-edit follows the edit while swiping back restores the untouched swipe's raw text, and Roleplay behavior is unchanged.
  • pnpm check, regression:regeneration-context, regression:prompt, and regression:conversation-summary pass locally.
  • Peek Prompt on a reply generated after an edit no longer contains the deleted wording.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) 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)

No UI changes.

Summary by CodeRabbit

  • Bug Fixes
    • Edited conversation replies containing character commands now send the updated wording to the model.
    • Updated message content no longer retains stale command data, keeping active conversation variations synchronized.
  • Documentation
    • Added an Unreleased changelog entry describing the conversation reply behavior improvement.

🔄 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/4729 **Author:** [@NeoKazuya](https://github.com/NeoKazuya) **Created:** 8/7/2026 **Status:** ✅ Merged **Merged:** 8/7/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/conversation-edit-command-content` --- ### 📝 Commits (2) - [`48f8aa6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/48f8aa6885b471f41cf40decf4af16d387c0e3cc) fix: clear stale conversationCommandContent when message content is edited - [`1fea4c4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1fea4c4801be0a712ba1eb348eeedfcd06ac8c24) fix: gate the active-swipe clear on the swipe's own extra ### 📊 Changes **2 files changed** (+34 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/services/storage/chats.storage.ts` (+33 -2) </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 #4728 ## Why this change - Conversation-mode prompt history prefers `extra.conversationCommandContent` (the raw reply before command stripping) over `content` for assistant messages, and editing a message never cleared that field. Once a reply carried a command, edits to it never reached the model: the UI, database, and exports showed the edit while every later prompt kept sending the original wording. ## What changed - Clear `conversationCommandContent` in `updateMessageContent` when the visible content changes, mirrored onto the active swipe row the same way `content` already is. - Keep the field on no-op saves and on hidden `commandOnly` anchor messages, whose `content` is empty by design and whose only text is this field. - Apply the clear with direct `db.update` writes inside the existing patch-queue section, since `withPatchQueue` is not re-entrant and a nested `updateMessageExtra` call would deadlock. - Preserve per-swipe extras and untouched swipes' raw text. Continue, regeneration, and game-mode paths are unaffected. - Prose-guardian rewrites, which apply through the same function, now reach prompt history too. - Edited messages lose their command markers in the model-visible transcript. The commands themselves already executed at generation time. - Add the user-facing fix to the Unreleased changelog. ## Validation <!-- Required: include commands run and/or manual checks performed --> - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] 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` ### Manual verification notes <!-- Describe exactly what you tested in a real browser/app, step by step. --> <!-- ⚠️ If an AI agent filled out or ticked these boxes for you, treat them --> <!-- as a TO-DO LIST, not as proof the work is done. Verify each item yourself --> <!-- before submitting. If you haven't verified it, untick the box. --> - Edited a Conversation reply carrying a `[schedule_update]` raw copy through the chat UI on a local test build. The edit persisted to `content`, its `conversationCommandContent` was cleared, and an untouched command reply in the same chat kept its raw copy. - Drove the patched storage layer and prompt formatter directly: an edit to a command reply returns the edited text in Conversation prompt history, a no-op save keeps the raw copy, `commandOnly` anchors keep theirs, swipe-then-edit follows the edit while swiping back restores the untouched swipe's raw text, and Roleplay behavior is unchanged. - `pnpm check`, `regression:regeneration-context`, `regression:prompt`, and `regression:conversation-summary` pass locally. - Peek Prompt on a reply generated after an edit no longer contains the deleted wording. ## Docs and release impact - [ ] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) 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) <!-- Add before/after screenshots or recordings for UI changes --> No UI changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Edited conversation replies containing character commands now send the updated wording to the model. * Updated message content no longer retains stale command data, keeping active conversation variations synchronized. * **Documentation** * Added an Unreleased changelog entry describing the conversation reply behavior improvement. <!-- 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-23 04:10:50 +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#6482
No description provided.