[PR #4043] [MERGED] fix(cards): non-destructive version restore, correct timestamps, wrapping diffs (#4040) #6216

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

📋 Pull Request Information

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

Base: staging ← Head: fix/4040-card-version-history


📝 Commits (3)

  • 4c502f0 fix(cards): preserve versions on restore, keep timestamps, wrap long diffs
  • a9b6b46 fix: address CodeRabbit review on card version history
  • 18a864e Merge branch 'staging' into fix/4040-card-version-history

📊 Changes

4 files changed (+108 additions, -49 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/client/src/components/characters/CharacterEditor.tsx (+3 -3)
📝 packages/client/src/components/personas/PersonaEditor.tsx (+3 -3)
📝 packages/server/src/services/storage/characters.storage.ts (+101 -43)

📄 Description

Why

From #4040. The reporter raised three things about character-card version history; two the maintainer endorsed, and the reporter's EDIT narrowed the third to a concrete bug:

  1. Restoring an older version permanently loses the newer one. restoreVersion overwrote the current card without snapshotting it, so the newer state was gone forever.
  2. A saved version shows the wrong timestamp. When you save v2, the snapshot of v1 was stamped with the v2 save time (now()), not with when v1 was actually saved — so v1 appeared to have been created at the moment you replaced it.
  3. The comparison view doesn't wrap long text. The side-by-side panes used whitespace-pre-wrap, which wraps on spaces but not on long unbroken tokens — creator notes full of HTML and links overflowed the modal horizontally.

(The full inline word-level diff the reporter also mentioned is already covered by the existing per-field side-by-side view; the maintainer had deprioritized a fancier diff UI, so this PR keeps that view and just makes it wrap.)

What changed

Server — characters.storage.ts (both characters and personas):

  • restoreVersion / restorePersonaVersion snapshot the current card to history before overwriting it (source "restore"), skipped when the current card already equals the target version. Restoring is now non-destructive.
  • update / updatePersona stamp the pre-save snapshot with the replaced card's own updatedAt instead of the new save time, so each version keeps its real date.

Client:

  • CharacterEditor.tsx / PersonaEditor.tsx — the compare panes now use min-w-0 break-words [overflow-wrap:anywhere], so long URLs/HTML wrap instead of overflowing; the restore confirmation now says the current card is saved to history first.

Test plan

  • Save a card as v2, then restore v1; confirm v2 now appears in version history (not lost) and the card is v1.
  • Confirm a version's history timestamp reflects when that content was saved, not when it was replaced.
  • Open the compare modal on a version whose creator notes contain a very long URL / unbroken HTML; confirm it wraps within the pane and the modal doesn't scroll sideways.
  • Repeat the restore + wrap checks for a persona card.
  • Confirm restoring a version identical to the current card does not create a redundant snapshot.
  • pnpm check passes. (Passed in the authoring session; re-verify locally.)

Fixes #4040.

Summary by CodeRabbit

  • Bug Fixes
    • Restoring an older character or persona card version now saves the current version to history first, preventing newer edits from being lost.
    • Version history entries now retain the correct edit timestamps.
    • Improved version comparison displays so long text, URLs, and HTML wrap correctly within creator notes.
    • Updated restore confirmation messages to clarify that the current card is preserved in version history before restoration.

🔄 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/4043 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 7/24/2026 **Status:** ✅ Merged **Merged:** 7/24/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/4040-card-version-history` --- ### 📝 Commits (3) - [`4c502f0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4c502f0a0e73681dded3a2c1253cffb9b9ae212f) fix(cards): preserve versions on restore, keep timestamps, wrap long diffs - [`a9b6b46`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a9b6b4692dcfa05993cf01d14da235d686911ae3) fix: address CodeRabbit review on card version history - [`18a864e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/18a864e2f4cd05e170efeda9f75f9692c73e3602) Merge branch 'staging' into fix/4040-card-version-history ### 📊 Changes **4 files changed** (+108 additions, -49 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/client/src/components/characters/CharacterEditor.tsx` (+3 -3) 📝 `packages/client/src/components/personas/PersonaEditor.tsx` (+3 -3) 📝 `packages/server/src/services/storage/characters.storage.ts` (+101 -43) </details> ### 📄 Description ## Why From #4040. The reporter raised three things about character-card version history; two the maintainer endorsed, and the reporter's EDIT narrowed the third to a concrete bug: 1. **Restoring an older version permanently loses the newer one.** `restoreVersion` overwrote the current card without snapshotting it, so the newer state was gone forever. 2. **A saved version shows the wrong timestamp.** When you save v2, the snapshot of v1 was stamped with the v2 save time (`now()`), not with when v1 was actually saved — so v1 appeared to have been created at the moment you replaced it. 3. **The comparison view doesn't wrap long text.** The side-by-side panes used `whitespace-pre-wrap`, which wraps on spaces but not on long unbroken tokens — creator notes full of HTML and links overflowed the modal horizontally. (The full inline word-level diff the reporter also mentioned is already covered by the existing per-field side-by-side view; the maintainer had deprioritized a fancier diff UI, so this PR keeps that view and just makes it wrap.) ## What changed Server — `characters.storage.ts` (both characters and personas): - **`restoreVersion` / `restorePersonaVersion`** snapshot the current card to history *before* overwriting it (source `"restore"`), skipped when the current card already equals the target version. Restoring is now non-destructive. - **`update` / `updatePersona`** stamp the pre-save snapshot with the replaced card's own `updatedAt` instead of the new save time, so each version keeps its real date. Client: - **`CharacterEditor.tsx` / `PersonaEditor.tsx`** — the compare panes now use `min-w-0 break-words [overflow-wrap:anywhere]`, so long URLs/HTML wrap instead of overflowing; the restore confirmation now says the current card is saved to history first. ## Test plan - [ ] Save a card as v2, then restore v1; confirm v2 now appears in version history (not lost) and the card is v1. - [ ] Confirm a version's history timestamp reflects when that content was saved, not when it was replaced. - [ ] Open the compare modal on a version whose creator notes contain a very long URL / unbroken HTML; confirm it wraps within the pane and the modal doesn't scroll sideways. - [ ] Repeat the restore + wrap checks for a persona card. - [ ] Confirm restoring a version identical to the current card does not create a redundant snapshot. - [ ] `pnpm check` passes. (Passed in the authoring session; re-verify locally.) Fixes #4040. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Restoring an older character or persona card version now saves the current version to history first, preventing newer edits from being lost. * Version history entries now retain the correct edit timestamps. * Improved version comparison displays so long text, URLs, and HTML wrap correctly within creator notes. * Updated restore confirmation messages to clarify that the current card is preserved in version history before restoration. <!-- 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:08:16 +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#6216
No description provided.