[PR #8689] [MERGED] feat(cards): share one card editor between characters and personas #8750

Closed
opened 2026-11-07 17:39:25 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8689
Author: @ylli-selmani
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/shared-cards-a


📝 Commits (8)

  • 0a04a22 test: pin persona patch omission and clear semantics
  • 3f5e517 Share authored card mapping across character and persona copies
  • a067a0c Share one card editor between characters and personas
  • 1226300 Keep shared card drafts to the card fields
  • df4bafd Treat a character save as the merge base for its own refetch
  • 5fece1c Preserve persona defaults and wait for character saves before Mari edits
  • fc9d81a Type the optional browser test result before it is registered
  • 498b3e3 Merge branch 'staging' into feat/shared-cards-a

📊 Changes

20 files changed (+2573 additions, -2117 deletions)

View changed files

➕ e2e/shared-card-editor.e2e.ts (+117 -0)
➕ packages/client/src/components/cards/CardColors.tsx (+209 -0)
➕ packages/client/src/components/cards/CardEditor.tsx (+235 -0)
➕ packages/client/src/components/cards/CardFieldsTab.tsx (+225 -0)
➕ packages/client/src/components/cards/CardIdentityFields.tsx (+92 -0)
➕ packages/client/src/components/cards/CardProse.tsx (+178 -0)
➕ packages/client/src/components/cards/CardRpgFields.tsx (+255 -0)
➕ packages/client/src/components/cards/use-card-gallery-selection.ts (+52 -0)
📝 packages/client/src/components/characters/CharacterEditor.tsx (+475 -1134)
📝 packages/client/src/components/personas/PersonaEditor.tsx (+320 -967)
➕ packages/client/src/hooks/use-card-editor-draft.ts (+13 -0)
➕ packages/client/src/hooks/use-card-editor-save.ts (+46 -0)
📝 packages/client/src/localization/locales/en.json (+4 -0)
📝 packages/shared/src/index.ts (+1 -0)
➕ packages/shared/src/utils/authored-card.ts (+141 -0)
➕ scripts/regressions/authored-card.regression.ts (+127 -0)
📝 scripts/regressions/open-issues.regression.ts (+14 -9)
📝 scripts/regressions/persona-api-normalization.regression.ts (+43 -0)
📝 scripts/regressions/persona-client-contract.regression.ts (+12 -4)
📝 scripts/regressions/prompt-token-counters.regression.ts (+14 -3)

📄 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

Part of #8688. This is PR A of 3; the issue stays open for B (unified storage and migration) and C (chat roles and alias parity).

Why this change

  • The Character Editor and Persona Editor are two separate implementations of mostly the same card. Every shared field has to be built, bound and saved twice, so personas keep missing features characters already have, for example name aliases that color a nickname in chat.
  • This PR makes both editors open one shared editor implementation, with no storage or API change. A shared field added later is bound once and saved through one path, and both libraries get it.
  • It is also the base for #8688's later steps: one card store (B) and using the same card as player in one chat and as cast in another (C).

What changed

Shared card model (packages/shared)

  • utils/authored-card.ts: one typed adapter between the character payload and the flat persona shape (personaFromCard, cardFromPersona, independentCardFields). The "add as persona / add as character" copy actions in both editors now use it instead of two hand-written key lists. Role-specific fields (greetings, persona status bars, RPG settings, crop, tags, conversation profile) round-trip losslessly.

Shared editor (packages/client/src/components/cards/)

  • CardEditor, CardIdentityFields, CardColors, CardRpgFields, CardProse, use-card-gallery-selection: the editor shell, metadata/identity fields, colors tab, RPG fields, prose textareas (with the shared token counter) and gallery selection, used by both editors.
  • CardFieldsTab: one binding for each Card-tab field, including the Prof. Mari wand and alternatives. CharacterCardTab and PersonaCardTab only pass their copy, section order and role-only parts (character summary, greetings and onboarding dialogue, variable chips).
  • hooks/use-card-editor-draft.ts and use-card-editor-save.ts: async save and upload handlers always read the latest keystroke, so typing during an in-flight save is never lost or overwritten.
  • CharacterEditor.tsx fix (also on staging today): typing in a field while a save of that field is in flight no longer raises a false "This character changed while you were editing" warning. The save now becomes the merge base, so its own refetch isn't mistaken for an edit made elsewhere. On desktop that warning also covered the Save button.
  • CharacterEditor.tsx and PersonaEditor.tsx shrink to their entry points (about 1,300 lines smaller together; the shared components above hold that code once). Layout, tabs, the word "Persona" and both libraries are unchanged.

Tests

  • e2e/shared-card-editor.e2e.ts (new): for both kinds, opens the editor and the Card tab, edits the title and description while a save is held in flight, then verifies both persist, no false conflict warning appears, and both survive a reopen.
  • scripts/regressions/authored-card.regression.ts (new): both legacy shapes round-trip, independent copies, the tags default.
  • The persona PATCH regression pins omitted vs. explicitly cleared fields.
  • open-issues, persona-client-contract and prompt-token-counters now assert on the shared files instead of the old per-editor markup.

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

Agent-run checks on the rebased branch (origin/staging + 5 commits):

  • pnpm check green (0 errors, the 12 existing lint warnings).
  • Focused regressions passed: authored-card, persona-client-contract, persona-api-normalization, prompt-token-counters, open-issues, character-form-rebase. Before the rebase, also: assigned-issue-sweep, avatar-crop-contract, capability-package-chat-controls, character-bulk-tags, onboarding-s1, persona-api-decoded-reads, chat-persona-macros, game-ruleset-sheets-storage, card-field-alternatives-import.
  • e2e/shared-card-editor.e2e.ts passed on desktop-chromium, mobile-chromium and mobile-webkit.
  • A local CodeRabbit pass over the whole branch found two regressions from the extraction (the persona generation draft carried the whole form; a lost tags ?? []), fixed with regressions in the last commit.

Manual verification notes

  • Manually verify in the browser that the Character Editor and Persona Editor look and tab exactly as before, on desktop and a mobile viewport.
  • Manually verify that editing a field on each tab (Metadata, Card, Colors, Stats) in both editors saves, and survives closing and reopening the card.
  • Manually verify that typing in a field right after clicking Save keeps the new text, that Save becomes active again, and that no "changed while you were editing" warning appears.
  • Manually verify that the Prof. Mari wand and "Add Alternative Field" work on a persona's Card tab and a character's Card tab.
  • Manually verify that variable chips still appear under a character's Card fields when the character has onboarding questions.
  • Manually verify that "add as persona" from a character, and "add as character" from a persona, create independent copies with the prose, colors and stats intact.

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 intended visual change. Both editors render the same tabs and fields through shared components.

🤖 Generated with Claude Code


🔄 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/8689 **Author:** [@ylli-selmani](https://github.com/ylli-selmani) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/shared-cards-a` --- ### 📝 Commits (8) - [`0a04a22`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0a04a22db3a90ec897a5f54fad5db71c38805fdf) test: pin persona patch omission and clear semantics - [`3f5e517`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3f5e517da5183f7753c9ed9fd7af4952ee637767) Share authored card mapping across character and persona copies - [`a067a0c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a067a0cb8c5c27f2158a0e7a16c0c638a2bb8d7a) Share one card editor between characters and personas - [`1226300`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1226300edd2b5313dcd3a834663b697ef090930c) Keep shared card drafts to the card fields - [`df4bafd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/df4bafdd52c4de517e56367b8615e800744b6781) Treat a character save as the merge base for its own refetch - [`5fece1c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5fece1c3439ff5ec58ebd4f41f1cd888a434bda0) Preserve persona defaults and wait for character saves before Mari edits - [`fc9d81a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fc9d81a9e611579b5af5e774170ccb2a32b46ad9) Type the optional browser test result before it is registered - [`498b3e3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/498b3e311c60d876b1d84be2edd0674ba318d758) Merge branch 'staging' into feat/shared-cards-a ### 📊 Changes **20 files changed** (+2573 additions, -2117 deletions) <details> <summary>View changed files</summary> ➕ `e2e/shared-card-editor.e2e.ts` (+117 -0) ➕ `packages/client/src/components/cards/CardColors.tsx` (+209 -0) ➕ `packages/client/src/components/cards/CardEditor.tsx` (+235 -0) ➕ `packages/client/src/components/cards/CardFieldsTab.tsx` (+225 -0) ➕ `packages/client/src/components/cards/CardIdentityFields.tsx` (+92 -0) ➕ `packages/client/src/components/cards/CardProse.tsx` (+178 -0) ➕ `packages/client/src/components/cards/CardRpgFields.tsx` (+255 -0) ➕ `packages/client/src/components/cards/use-card-gallery-selection.ts` (+52 -0) 📝 `packages/client/src/components/characters/CharacterEditor.tsx` (+475 -1134) 📝 `packages/client/src/components/personas/PersonaEditor.tsx` (+320 -967) ➕ `packages/client/src/hooks/use-card-editor-draft.ts` (+13 -0) ➕ `packages/client/src/hooks/use-card-editor-save.ts` (+46 -0) 📝 `packages/client/src/localization/locales/en.json` (+4 -0) 📝 `packages/shared/src/index.ts` (+1 -0) ➕ `packages/shared/src/utils/authored-card.ts` (+141 -0) ➕ `scripts/regressions/authored-card.regression.ts` (+127 -0) 📝 `scripts/regressions/open-issues.regression.ts` (+14 -9) 📝 `scripts/regressions/persona-api-normalization.regression.ts` (+43 -0) 📝 `scripts/regressions/persona-client-contract.regression.ts` (+12 -4) 📝 `scripts/regressions/prompt-token-counters.regression.ts` (+14 -3) </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 Part of #8688. This is PR A of 3; the issue stays open for B (unified storage and migration) and C (chat roles and alias parity). ## Why this change - The Character Editor and Persona Editor are two separate implementations of mostly the same card. Every shared field has to be built, bound and saved twice, so personas keep missing features characters already have, for example name aliases that color a nickname in chat. - This PR makes both editors open **one shared editor implementation**, with no storage or API change. A shared field added later is bound once and saved through one path, and both libraries get it. - It is also the base for #8688's later steps: one card store (B) and using the same card as player in one chat and as cast in another (C). ## What changed **Shared card model (`packages/shared`)** - `utils/authored-card.ts`: one typed adapter between the character payload and the flat persona shape (`personaFromCard`, `cardFromPersona`, `independentCardFields`). The "add as persona / add as character" copy actions in both editors now use it instead of two hand-written key lists. Role-specific fields (greetings, persona status bars, RPG settings, crop, tags, conversation profile) round-trip losslessly. **Shared editor (`packages/client/src/components/cards/`)** - `CardEditor`, `CardIdentityFields`, `CardColors`, `CardRpgFields`, `CardProse`, `use-card-gallery-selection`: the editor shell, metadata/identity fields, colors tab, RPG fields, prose textareas (with the shared token counter) and gallery selection, used by both editors. - `CardFieldsTab`: one binding for each Card-tab field, including the Prof. Mari wand and alternatives. `CharacterCardTab` and `PersonaCardTab` only pass their copy, section order and role-only parts (character summary, greetings and onboarding dialogue, variable chips). - `hooks/use-card-editor-draft.ts` and `use-card-editor-save.ts`: async save and upload handlers always read the latest keystroke, so typing during an in-flight save is never lost or overwritten. - `CharacterEditor.tsx` fix (also on `staging` today): typing in a field while a save of that field is in flight no longer raises a false "This character changed while you were editing" warning. The save now becomes the merge base, so its own refetch isn't mistaken for an edit made elsewhere. On desktop that warning also covered the Save button. - `CharacterEditor.tsx` and `PersonaEditor.tsx` shrink to their entry points (about 1,300 lines smaller together; the shared components above hold that code once). Layout, tabs, the word "Persona" and both libraries are unchanged. **Tests** - `e2e/shared-card-editor.e2e.ts` (new): for both kinds, opens the editor and the Card tab, edits the title and description while a save is held in flight, then verifies both persist, no false conflict warning appears, and both survive a reopen. - `scripts/regressions/authored-card.regression.ts` (new): both legacy shapes round-trip, independent copies, the tags default. - The persona PATCH regression pins omitted vs. explicitly cleared fields. - `open-issues`, `persona-client-contract` and `prompt-token-counters` now assert on the shared files instead of the old per-editor markup. ## 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` Agent-run checks on the rebased branch (`origin/staging` + 5 commits): - `pnpm check` green (0 errors, the 12 existing lint warnings). - Focused regressions passed: authored-card, persona-client-contract, persona-api-normalization, prompt-token-counters, open-issues, character-form-rebase. Before the rebase, also: assigned-issue-sweep, avatar-crop-contract, capability-package-chat-controls, character-bulk-tags, onboarding-s1, persona-api-decoded-reads, chat-persona-macros, game-ruleset-sheets-storage, card-field-alternatives-import. - `e2e/shared-card-editor.e2e.ts` passed on desktop-chromium, mobile-chromium and mobile-webkit. - A local CodeRabbit pass over the whole branch found two regressions from the extraction (the persona generation draft carried the whole form; a lost `tags ?? []`), fixed with regressions in the last commit. ### Manual verification notes - Manually verify in the browser that the Character Editor and Persona Editor look and tab exactly as before, on desktop and a mobile viewport. - Manually verify that editing a field on each tab (Metadata, Card, Colors, Stats) in both editors saves, and survives closing and reopening the card. - Manually verify that typing in a field right after clicking Save keeps the new text, that Save becomes active again, and that no "changed while you were editing" warning appears. - Manually verify that the Prof. Mari wand and "Add Alternative Field" work on a persona's Card tab and a character's Card tab. - Manually verify that variable chips still appear under a character's Card fields when the character has onboarding questions. - Manually verify that "add as persona" from a character, and "add as character" from a persona, create independent copies with the prose, colors and stats intact. ## 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 intended visual change. Both editors render the same tabs and fields through shared components. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:39:25 +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#8750
No description provided.