[GH-ISSUE #3050] [Issue]: Persona version restore silently drops savedStatusOptions (not captured in snapshots, not restored), and a savedStatusOptions-only edit creates no version #1619

Closed
opened 2026-10-21 05:40:53 +07:00 by bsakaguchi · 2 comments
Owner

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

Originally assigned to: @SpicyMarinara on GitHub.

What's wrong
The persona version payload (PersonaCardSnapshot) has no savedStatusOptions field, buildPersonaSnapshot() never captures it, and restorePersonaVersion()'s UPDATE set clause omits it. So saved persona versions never record savedStatusOptions, and restoring an older version leaves savedStatusOptions stuck at its CURRENT value instead of reverting it. A user rolling a persona back via version history gets every field reverted except their Conversation-mode saved status text options. As a secondary effect, because the snapshot omits the field, a PATCH that changes ONLY savedStatusOptions produces an identical before/after snapshot, so personaSnapshotChanged returns false and no version is created — that change is unversioned.

How to reproduce (try it yourself)

  1. Create a persona, set savedStatusOptions to ['Working'], and save in a way that creates version V1 (via another tracked field change).
  2. Edit the persona, change savedStatusOptions to ['Sleeping'] AND a tracked field, save (V2).
  3. POST /api/characters/personas/:id/versions//restore.
  4. GET /api/characters/personas/:id.

You'll see: name/description/etc. revert to V1, but savedStatusOptions is still ['Sleeping'].
Expected: savedStatusOptions reverts to ['Working'] along with the rest of the version.

Where it is

  • packages/server/src/services/storage/characters.storage.ts:71-90 (buildPersonaSnapshot, no savedStatusOptions), 100-119 (normalizePersonaSnapshot), 504-521 (updatePersona nextData merge — secondary effect), 565-588 (restorePersonaVersion set clause).
  • Type: packages/shared/src/types/character.ts:146-163 (PersonaCardSnapshot).
  • Column: packages/server/src/db/schema/characters.ts:69 (savedStatusOptions: text("saved_status_options").notNull().default("[]")).

What's happening
savedStatusOptions was added as a persona column and handled by create/duplicate/update, but was never added to the version snapshot contract or the restore path, so it's excluded from both capture and restore. The change-detection compares PersonaCardSnapshot objects that don't contain the key, so a savedStatusOptions-only edit looks like a no-op.

Suggested fix
Make version capture and restore lossless for savedStatusOptions, and update the CLIENT snapshot builder so pnpm check stays green:

  1. packages/shared/src/types/character.ts — add savedStatusOptions: string; to PersonaCardSnapshot (after tags).
  2. characters.storage.ts buildPersonaSnapshot() — savedStatusOptions: persona.savedStatusOptions ?? "[]",.
  3. characters.storage.ts normalizePersonaSnapshot() — savedStatusOptions: data.savedStatusOptions ?? "[]",.
  4. characters.storage.ts updatePersona() nextData merge — ...(updates.savedStatusOptions !== undefined && { savedStatusOptions: updates.savedStatusOptions }), (required so a savedStatusOptions-only edit actually produces a snapshot — capturing it in buildPersonaSnapshot is necessary but not sufficient).
  5. characters.storage.ts restorePersonaVersion() set clause — savedStatusOptions: data.savedStatusOptions, (data is normalized, so old snapshots default to "[]").
  6. packages/client/src/components/personas/PersonaEditor.tsx buildCurrentPersonaSnapshot() literal — savedStatusOptions: formData.savedStatusOptions,.

Regression note (important): PersonaCardSnapshot is a SHARED type also built by the client in buildCurrentPersonaSnapshot(). Adding it as a REQUIRED field WITHOUT step 6 breaks the client typecheck (Property 'savedStatusOptions' is missing), failing pnpm check (the repo's only validation gate). PersonaFormData already carries savedStatusOptions, so the value is available. The ?? "[]" defaulting matches the existing tags treatment and the column default, and restoring old snapshots (no key) is safe because normalizePersonaSnapshot defaults it. Run pnpm check to confirm both client and server typecheck.


AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.

Originally created by @kolacheee on GitHub (Jun 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3050 Originally assigned to: @SpicyMarinara on GitHub. **What's wrong** The persona version payload (`PersonaCardSnapshot`) has no `savedStatusOptions` field, `buildPersonaSnapshot()` never captures it, and `restorePersonaVersion()`'s UPDATE set clause omits it. So saved persona versions never record `savedStatusOptions`, and restoring an older version leaves `savedStatusOptions` stuck at its CURRENT value instead of reverting it. A user rolling a persona back via version history gets every field reverted except their Conversation-mode saved status text options. As a secondary effect, because the snapshot omits the field, a PATCH that changes ONLY `savedStatusOptions` produces an identical before/after snapshot, so `personaSnapshotChanged` returns false and no version is created — that change is unversioned. **How to reproduce (try it yourself)** 1. Create a persona, set `savedStatusOptions` to ['Working'], and save in a way that creates version V1 (via another tracked field change). 2. Edit the persona, change `savedStatusOptions` to ['Sleeping'] AND a tracked field, save (V2). 3. POST /api/characters/personas/:id/versions/<V1>/restore. 4. GET /api/characters/personas/:id. You'll see: name/description/etc. revert to V1, but `savedStatusOptions` is still ['Sleeping']. Expected: `savedStatusOptions` reverts to ['Working'] along with the rest of the version. **Where it is** - `packages/server/src/services/storage/characters.storage.ts:71-90` (`buildPersonaSnapshot`, no savedStatusOptions), `100-119` (`normalizePersonaSnapshot`), `504-521` (`updatePersona` nextData merge — secondary effect), `565-588` (`restorePersonaVersion` set clause). - Type: `packages/shared/src/types/character.ts:146-163` (`PersonaCardSnapshot`). - Column: `packages/server/src/db/schema/characters.ts:69` (`savedStatusOptions: text("saved_status_options").notNull().default("[]")`). **What's happening** `savedStatusOptions` was added as a persona column and handled by create/duplicate/update, but was never added to the version snapshot contract or the restore path, so it's excluded from both capture and restore. The change-detection compares `PersonaCardSnapshot` objects that don't contain the key, so a savedStatusOptions-only edit looks like a no-op. **Suggested fix** Make version capture and restore lossless for `savedStatusOptions`, and update the CLIENT snapshot builder so `pnpm check` stays green: 1. `packages/shared/src/types/character.ts` — add `savedStatusOptions: string;` to `PersonaCardSnapshot` (after `tags`). 2. `characters.storage.ts` `buildPersonaSnapshot()` — `savedStatusOptions: persona.savedStatusOptions ?? "[]",`. 3. `characters.storage.ts` `normalizePersonaSnapshot()` — `savedStatusOptions: data.savedStatusOptions ?? "[]",`. 4. `characters.storage.ts` `updatePersona()` nextData merge — `...(updates.savedStatusOptions !== undefined && { savedStatusOptions: updates.savedStatusOptions }),` (required so a savedStatusOptions-only edit actually produces a snapshot — capturing it in buildPersonaSnapshot is necessary but not sufficient). 5. `characters.storage.ts` `restorePersonaVersion()` set clause — `savedStatusOptions: data.savedStatusOptions,` (data is normalized, so old snapshots default to "[]"). 6. `packages/client/src/components/personas/PersonaEditor.tsx` `buildCurrentPersonaSnapshot()` literal — `savedStatusOptions: formData.savedStatusOptions,`. Regression note (important): `PersonaCardSnapshot` is a SHARED type also built by the client in `buildCurrentPersonaSnapshot()`. Adding it as a REQUIRED field WITHOUT step 6 breaks the client typecheck (`Property 'savedStatusOptions' is missing`), failing `pnpm check` (the repo's only validation gate). `PersonaFormData` already carries `savedStatusOptions`, so the value is available. The `?? "[]"` defaulting matches the existing `tags` treatment and the column default, and restoring old snapshots (no key) is safe because `normalizePersonaSnapshot` defaults it. Run `pnpm check` to confirm both client and server typecheck. --- *AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.*
Author
Owner

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

Claiming this for the current staging sweep in draft PR #3053 (branch codex/issue-sweep-3033-3052).

<!-- gh-comment-id:4834990888 --> @SpicyMarinara commented on GitHub (Jun 29, 2026): Claiming this for the current staging sweep in draft PR #3053 (branch `codex/issue-sweep-3033-3052`).
Author
Owner

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

Fixed in PR #3053 on branch codex/issue-sweep-3033-3052 (commit bfb1bc76). Closing this issue as addressed; the PR remains open for staging review/merge.

<!-- gh-comment-id:4835091120 --> @SpicyMarinara commented on GitHub (Jun 29, 2026): Fixed in PR #3053 on branch `codex/issue-sweep-3033-3052` (commit bfb1bc76). Closing this issue as addressed; the PR remains open for staging review/merge.
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#1619
No description provided.