[PR #8401] [MERGED] fix(characters): merge refetched edits into an unsaved Character editor form #8577

Closed
opened 2026-11-07 16:45:44 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8401
Author: @Gunterlie
Created: 10/28/2026
Status: ✅ Merged
Merged: 10/28/2026
Merged by: @Gunterlie

Base: feat/mari-companion ← Head: fix/mari-character-form-rebase


📝 Commits (2)

  • 78c64eb fix(characters): merge refetched edits into an unsaved Character editor form
  • 998bb7e fix(characters): keep the merge base until the save lands; guard the conflict action

📊 Changes

5 files changed (+107 additions, -2 deletions)

View changed files

📝 packages/client/src/components/characters/CharacterEditor.tsx (+38 -2)
➕ packages/client/src/lib/form-rebase.ts (+30 -0)
📝 packages/client/src/localization/locales/en.json (+2 -0)
➕ scripts/regressions/character-form-rebase.regression.ts (+36 -0)
📝 scripts/regressions/tsconfig.client-lanes.json (+1 -0)

📄 Description

Linked issue

No issue: this is planned work, slice 1 of the Professor Mari companion feature (Prof. Mari floats next to real editors and live-edits them). Slices are PRed into the integration branch feat/mari-companion, which goes to staging when the feature is ready.

Why this change

When the Character editor had unsaved edits, it ignored every refetch of the character. So when the user approved a Professor Mari change (Mari's chat invalidates the character query), the open editor silently dropped her change, and the next Save wrote the old values back over it. The same happened to a version restore made while the form was dirty.

The companion feature needs Mari's approved changes to land in an editor the user is still typing in, so this has to work first.

What changed

  • New packages/client/src/lib/form-rebase.ts: a three-way merge (base = card as last loaded, mine = unsaved form, server = refetch). Server-only changes land, the user's unsaved edits stay; a field both sides changed differently keeps the user's value and is reported.
  • CharacterEditor.tsx: keeps the loaded card as the merge base and merges a refetch into a dirty form instead of ignoring it. On a conflict, a warning toast offers "Use the new version" (swapped merge; marks the form dirty, does nothing after a character switch, 12 s).
  • Two English strings in en.json.
  • Regression scripts/regressions/character-form-rebase.regression.ts (also added to the client-lanes typecheck).

Not merged on a dirty refetch, same as before: the character comment and the avatar preview.

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

Agent-run (not manual): full pnpm check exit 0 (one pre-existing warning in HomeProfessorMariChat.tsx:380, file not touched here); node ./scripts/run-regressions.mjs --filter scripts/regressions/character-form-rebase.regression.ts passed; an Opus read-only review found 4 issues (refetch during save could drop edits; conflict action after a character switch; action not marking dirty; toast too short), all fixed in the second commit.

To verify manually:

  1. Open a character, edit Description without saving. Ask Professor Mari to change Personality and approve it. Personality updates in the editor, your Description edit stays. Save; both persist after reload.
  2. Edit Description without saving, then approve a Mari change to Description. A warning toast says your version was kept; "Use the new version" switches the field to Mari's text and keeps the form unsaved.
  3. Trigger the toast, switch to another character, click "Use the new version": nothing changes in the other character.
  4. Edit a field, click Save, and approve a Mari change while the save is still running: no edit is lost.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) 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 new UI apart from the conflict toast (sonner warning with one action).


🔄 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/8401 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/28/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `feat/mari-companion` ← **Head:** `fix/mari-character-form-rebase` --- ### 📝 Commits (2) - [`78c64eb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/78c64ebc89249cf4383ad6b480a1fbb9f247f9b1) fix(characters): merge refetched edits into an unsaved Character editor form - [`998bb7e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/998bb7e2e8145abc3905545519ef89245e0aa8d2) fix(characters): keep the merge base until the save lands; guard the conflict action ### 📊 Changes **5 files changed** (+107 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/characters/CharacterEditor.tsx` (+38 -2) ➕ `packages/client/src/lib/form-rebase.ts` (+30 -0) 📝 `packages/client/src/localization/locales/en.json` (+2 -0) ➕ `scripts/regressions/character-form-rebase.regression.ts` (+36 -0) 📝 `scripts/regressions/tsconfig.client-lanes.json` (+1 -0) </details> ### 📄 Description ## Linked issue No issue: this is planned work, slice 1 of the Professor Mari companion feature (Prof. Mari floats next to real editors and live-edits them). Slices are PRed into the integration branch `feat/mari-companion`, which goes to `staging` when the feature is ready. ## Why this change When the Character editor had unsaved edits, it ignored every refetch of the character. So when the user approved a Professor Mari change (Mari's chat invalidates the character query), the open editor silently dropped her change, and the next Save wrote the old values back over it. The same happened to a version restore made while the form was dirty. The companion feature needs Mari's approved changes to land in an editor the user is still typing in, so this has to work first. ## What changed - New `packages/client/src/lib/form-rebase.ts`: a three-way merge (base = card as last loaded, mine = unsaved form, server = refetch). Server-only changes land, the user's unsaved edits stay; a field both sides changed differently keeps the user's value and is reported. - `CharacterEditor.tsx`: keeps the loaded card as the merge base and merges a refetch into a dirty form instead of ignoring it. On a conflict, a warning toast offers "Use the new version" (swapped merge; marks the form dirty, does nothing after a character switch, 12 s). - Two English strings in `en.json`. - Regression `scripts/regressions/character-form-rebase.regression.ts` (also added to the client-lanes typecheck). Not merged on a dirty refetch, same as before: the character comment and the avatar preview. ## 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 Agent-run (not manual): full `pnpm check` exit 0 (one pre-existing warning in `HomeProfessorMariChat.tsx:380`, file not touched here); `node ./scripts/run-regressions.mjs --filter scripts/regressions/character-form-rebase.regression.ts` passed; an Opus read-only review found 4 issues (refetch during save could drop edits; conflict action after a character switch; action not marking dirty; toast too short), all fixed in the second commit. To verify manually: 1. Open a character, edit Description without saving. Ask Professor Mari to change Personality and approve it. Personality updates in the editor, your Description edit stays. Save; both persist after reload. 2. Edit Description without saving, then approve a Mari change to Description. A warning toast says your version was kept; "Use the new version" switches the field to Mari's text and keeps the form unsaved. 3. Trigger the toast, switch to another character, click "Use the new version": nothing changes in the other character. 4. Edit a field, click Save, and approve a Mari change while the save is still running: no edit is lost. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) 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 new UI apart from the conflict toast (sonner warning with one action). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:45:44 +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#8577
No description provided.