[GH-ISSUE #2957] [Issue]: Editing an assistant message in classic conversation view silently deletes its saved name/timestamp prefix #1533

Closed
opened 2026-10-21 05:38:22 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Jun 28, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2957

Originally assigned to: @SpicyMarinara on GitHub.

What's wrong

In classic conversation style, the edit box is pre-filled with the displayed version of an assistant message — which already has the leading CharacterName: prefix (or a [12:30] timestamp) stripped out. If you make any real edit and save, that stripped text is written back to the database, permanently destroying the stored prefix/timestamp. You never see the prefix in the edit box, so there's no way to know you're dropping it.

How to reproduce (try it yourself)

  1. Use a chat in classic conversation style (conversationMessageStyle === "classic") with an assistant message whose stored content starts with a name prefix — e.g. Aria:\nHello there. (common in group/individual mode), or a leading [12:30] timestamp. It displays as just Hello there..
  2. Open edit on it — the textarea is pre-filled with Hello there. (the prefix is already gone, with no indication it existed).
  3. Make any change, e.g. Hello!.
  4. Save (Ctrl/Cmd+Enter or the check button).

You'll see: the stored content (and the active swipe row) becomes Hello! — the Aria:\n prefix (or [12:30]) is permanently gone from the DB.
Expected: the edit box should seed with the raw stored content (prefix/timestamp intact) so an edit doesn't silently drop it.

(A pure no-op save does not corrupt — the change guard short-circuits. It requires an actual edit, which is the common case. The roleplay surface is not affected — it seeds the editor from raw message.content.)

Where it is

packages/client/src/components/chat/ConversationView.tsx builds the render item from the strip-applied displayMsg (lines 590-603) and doesn't carry the raw content onto the item. By render time msg is already the stripped version, so originalContent at line 991 (displayMsg.content !== msg.content ? msg.content : undefined) is undefined in the normal (non-regenerating) case. That flows into packages/client/src/components/chat/ConversationMessage.tsx: editSourceContent = originalContent ?? message.content (426) → startEditing seeds the textarea from it (437) → handleSaveEdit persists it via onEdit → updateMessageContent (overwrites messages.content and the active swipe row). Contrast ChatMessage.tsx (roleplay), which seeds initialContent={message.content} (1739) from raw content and is fine.

What's happening

The raw DB content is discarded at the item-build layer — the item only carries the display-stripped displayMsg — so the editor can only ever see stripped text, and there's no raw fallback for editSourceContent to recover. Saving writes the stripped text verbatim. Anything that relied on the prefix (speaker attribution, export, branching) now has wrong content.

Suggested fix

Carry the raw DB content onto the conversation item (e.g. item.rawContent = msg.content before stripping) and compute originalContent against the raw content, so editSourceContent falls back to raw. Alternatively pass a dedicated editSource prop holding the raw content, independent of the display transforms.


AI-investigated against v2.0.6; both the item-build and render layers traced and confirmed. Please verify before fixing.

Originally created by @kolacheee on GitHub (Jun 28, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2957 Originally assigned to: @SpicyMarinara on GitHub. **What's wrong** In classic conversation style, the edit box is pre-filled with the **displayed** version of an assistant message — which already has the leading `CharacterName:` prefix (or a `[12:30]` timestamp) stripped out. If you make any real edit and save, that stripped text is written back to the database, permanently destroying the stored prefix/timestamp. You never see the prefix in the edit box, so there's no way to know you're dropping it. **How to reproduce (try it yourself)** 1. Use a chat in classic conversation style (`conversationMessageStyle === "classic"`) with an assistant message whose **stored** content starts with a name prefix — e.g. `Aria:\nHello there.` (common in group/individual mode), or a leading `[12:30]` timestamp. It displays as just `Hello there.`. 2. Open edit on it — the textarea is pre-filled with `Hello there.` (the prefix is already gone, with no indication it existed). 3. Make any change, e.g. `Hello!`. 4. Save (Ctrl/Cmd+Enter or the check button). **You'll see:** the stored content (and the active swipe row) becomes `Hello!` — the `Aria:\n` prefix (or `[12:30]`) is permanently gone from the DB. **Expected:** the edit box should seed with the **raw** stored content (prefix/timestamp intact) so an edit doesn't silently drop it. (A pure no-op save does *not* corrupt — the change guard short-circuits. It requires an actual edit, which is the common case. The roleplay surface is **not** affected — it seeds the editor from raw `message.content`.) **Where it is** `packages/client/src/components/chat/ConversationView.tsx` builds the render item from the strip-applied `displayMsg` (lines 590-603) and doesn't carry the raw content onto the item. By render time `msg` is already the stripped version, so `originalContent` at line 991 (`displayMsg.content !== msg.content ? msg.content : undefined`) is `undefined` in the normal (non-regenerating) case. That flows into `packages/client/src/components/chat/ConversationMessage.tsx`: `editSourceContent = originalContent ?? message.content` (426) → `startEditing` seeds the textarea from it (437) → `handleSaveEdit` persists it via `onEdit` → `updateMessageContent` (overwrites `messages.content` **and** the active swipe row). Contrast `ChatMessage.tsx` (roleplay), which seeds `initialContent={message.content}` (1739) from raw content and is fine. **What's happening** The raw DB content is discarded at the item-build layer — the item only carries the display-stripped `displayMsg` — so the editor can only ever see stripped text, and there's no raw fallback for `editSourceContent` to recover. Saving writes the stripped text verbatim. Anything that relied on the prefix (speaker attribution, export, branching) now has wrong content. **Suggested fix** Carry the raw DB content onto the conversation item (e.g. `item.rawContent = msg.content` before stripping) and compute `originalContent` against the **raw** content, so `editSourceContent` falls back to raw. Alternatively pass a dedicated `editSource` prop holding the raw content, independent of the display transforms. --- *AI-investigated against v2.0.6; both the item-build and render layers traced and confirmed. Please verify before fixing.*
Author
Owner

@SpicyMarinara commented on GitHub (Jun 29, 2026):

Fixed in staging: classic Conversation editing now keeps the raw stored message as the edit source even when the visible row strips timestamps/name prefixes for display. Validated with pnpm check and pnpm regression:prompt.

<!-- gh-comment-id:4830955428 --> @SpicyMarinara commented on GitHub (Jun 29, 2026): Fixed in staging: classic Conversation editing now keeps the raw stored message as the edit source even when the visible row strips timestamps/name prefixes for display. Validated with pnpm check and pnpm regression:prompt.
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#1533
No description provided.