[PR #7799] [MERGED] feat(onboarding): Chat Settings persona and question paths, and drop a removed card's variables #7929

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

📋 Pull Request Information

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

Base: staging ← Head: feat/onboarding-followups


📝 Commits (8)

  • 5b32735 fix(onboarding): drop a removed card's chat variables (#7795)
  • 2adcfaa feat(onboarding): create a persona from the Chat Settings picker (#7796)
  • 0465bf1 feat(onboarding): answer one card's character questions from Chat Settings (#7797)
  • 0797d85 fix(onboarding): open the questions window on the chat's saved answers (#7797)
  • 387d531 docs(onboarding): a shared name is one value, even after setup (#7797)
  • 4dc545f fix(onboarding): keep the questions window on a failed save, and re-check the roster before dropping
  • 835b7c8 fix(onboarding): keep a re-added card's answers when the removal cleanup runs
  • a9d63d3 test(onboarding): pin the wizard's shared parse instead of its old private one

📊 Changes

10 files changed (+771 additions, -54 deletions)

View changed files

📝 docs/characters/choosing-your-persona.md (+3 -1)
📝 docs/characters/interactive-onboarding.md (+7 -1)
📝 packages/client/src/components/characters/CharacterOnboardingModal.tsx (+30 -1)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+247 -0)
📝 packages/client/src/components/chat/ChatSetupWizard.tsx (+8 -37)
📝 packages/client/src/localization/locales/en.json (+1 -0)
📝 packages/server/src/routes/chats.routes.ts (+83 -13)
📝 packages/shared/src/utils/onboarding.ts (+174 -0)
➕ scripts/regressions/onboarding-followups.regression.ts (+206 -0)
📝 scripts/regressions/onboarding-s1.regression.ts (+12 -1)

📄 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

Closes #7795
Closes #7796
Closes #7797

Why this change

  • The variables outlived the card. Selecting an onboarding-enabled character in the setup wizard immediately seeded its character-question defaults into the chat's variables (that seeding protects chats started without the wizard). Removing the character again left every one of those names behind — visible clutter in Chat Variables, with no card left to read them.
  • A running chat could not build a persona. A card's Create your persona row existed only in the setup wizard. Skip the wizard, change your mind later, or join a chat that already exists, and there was no path to a persona from the card's questions.
  • The answers were only editable during setup. Character-question answers had no second entrance either: delete one, pick the wrong option, or want a different answer, and the only fix was hand-editing Chat Variables.

What changed

  • Removing a character now removes the answers it owned. PATCH /chats/:id drops the chat variables that the leaving card's enabled character questions declare, unless another character still in the chat declares the same name (a shared name keeps its value, because the remaining card reads it). A card whose onboarding is switched off owns nothing; a remaining card's declaration protects a name even if that block is switched off, since its card fields can still read it. This is the requested cleanup: a removed card's answers no longer survive by accident.
  • Create your persona from Chat Settings. The Persona picker in a Roleplay chat lists Create your persona · Answer X's questions for every character in the chat whose card can build one — the same rows, under the same canBuildPersona rule, as the wizard. Picking one opens the existing questions window with persona questions only, so it can never replace character-question answers with first-option defaults. Create persona saves the persona and sets it on this chat.
  • Answer one card's character questions from Chat Settings. The onboarding marker in Characters is now an action: it opens that card's questions alone (no other cards, no persona section), starting from the answers the chat already holds — edit one and the others keep their values. Saving again also restores a deleted answer; other cards' variables are untouched. The Add Character picker also shows the wizard's passive marker, so a card with interactive onboarding is recognisable before it is added.
  • One card parse for every surface. readCardOnboarding (shared) now reads a card's onboarding block, unique ids and the five card fields for the server seeding, the server removal, the wizard and the drawer, so the four surfaces cannot drift. The route returns the patched row, because the client caches the response.
  • Reopening shows what was saved. answersFromStoredValues (shared) rebuilds a card's answers from the chat's variables — a choice by option value, or by its label when the value is blank, free text as typed, a multi-select split by its separator — so the window opens on them instead of on every question's first option. A stored value the current options cannot express renders unselected and is not written, so an untouched save cannot replace it; the route merges chat variables per name (null deletes), so nothing else on the chat is lost either.
  • Docs: both onboarding guides describe the post-setup persona and question paths, and that a card that leaves a chat takes its answers with it.
  • Regression: scripts/regressions/onboarding-followups.regression.ts pins the card parse (both storage shapes, unique ids, unreadable data) and the removal rule (shared name kept, disabled leaver owns nothing, disabled stayer still protects, duplicates, unstorable names).

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

Run on this branch's own worktree (dev stack on port 6993; UI reached through the Vite dev server). The boxes above are still a to-do list for a human.

  • pnpm check — exit 0 (impeccable, localization 14,788 keys, format, lint, type checks, full build).
  • node ./scripts/run-regressions.mjs --filter onboarding-followups — 1/1 passed.
  • Browser/API proof on the worktree's data with two demo cards (bond + rank, and a second card declaring only rank):
    • Adding both seeded rank = scout and bond = an old friend before any question was saved — the reported starting point.
    • Removing Onboarding Demo dropped bond and kept rank (the remaining card declares it). Re-adding seeded bond again. Removing every declarer left macroVariables = {}.
    • The same removal through the drawer (Ylli) left No variables yet in Chat Settings.
  • Create your persona (Ylli): the two template rows appeared above None; picking Onboarding Demo opened the name/role questions; Create persona saved a persona named Lollipop Man and the chat's personaId points at it. Its description and personality match the template exactly (Name: Lollipop Man, Role: ranger, A ranger of the guild.).
  • Character questions (Ylli): the person-with-plus marker on Onboarding Demo opened A few questions for that card alone; saving wrote the answers to Chat Variables, and Rank Sharer's answers were not touched.
  • Needs a click after the review fix: reopen Onboarding Demo's questions and confirm the answers already saved come up preselected; save without editing anything and confirm Chat Variables is unchanged.
  • Not covered: light theme, mobile viewport and the tablet layout. The rows and the marker reuse the existing picker/row classes (h-5 w-5, same hover treatment), but nobody clicked them on a phone.

Review rounds

Local CodeRabbit (CLI 0.8.2), two runs inside the free hourly quota:

  1. Whole branch (--committed --base origin/staging) — 1 major: the questions window started every question on its first option, and mergeCardVariables writes every name the window asked, so saving one edited answer rewrote the ones nobody touched. Verified real; fixed in 0797d8594 (answersFromStoredValues, plus the "open, save, nothing changed" round trip in the regression).
  2. Fix delta (--committed --base 0465bf1d1) — 1 major, 1 minor:
    • major, not a defect: it asked to merge outgoing keys in case useUpdateChatMetadata / PATCH /chats/:id/metadata replaces macroVariables. The route merges per name ({ ...saved, ...changedValues }, null removes one name) and returns the patched row, so other cards' variables and any value this window did not write are retained. No change made.
    • minor, taken: the post-setup paragraph should say a name two cards share is one value. Fixed in 387d531e7.

GitHub CodeRabbit on the first push (2 actionable comments, both verified and fixed in 4dc545fbc):

  1. minor — the questions window closed before the metadata write, so a failed PATCH discarded the answers the player had just typed. The write now happens first; on failure the toast shows and the window stays open with its edits for a retry. Nothing is created on that path, so a retry is safe (unlike the persona path, which closes first on purpose).
  2. major — the removal cleanup decided which names to delete from the roster the route had already written, so a concurrent PATCH could add a card declaring one of them in between and lose that card's answer. The decision now happens inside the chat's metadata queue, from the roster read there; a card added after that read is still safe because its own seeding patch is queued behind the cleanup. The rule itself is unchanged and remains pinned by the regression — this is about when it runs, and the guarantee is the per-chat serialization chats.storage.ts documents.

Second GitHub round, on that fix (1 actionable comment, fixed in 835b7c81c):

  1. major — the new cleanup filtered the live roster against the ids this request removed, so a card removed here and re-added by a concurrent PATCH was skipped and its saved answers deleted. The live roster already is the remaining set, so the filter is gone; a re-added card protects the names it declares, and in the ordinary case the removed card is not in that roster anyway.

Third GitHub round, on 835b7c81c: no actionable comments (its two replies on the earlier threads only acknowledge the fixes). A fourth, on the regression-pin commit, also reported none.

CI caught one stale proof: complete-node-regressions failed on onboarding-s1, whose last assertion matched the wizard calling withUniqueOnboardingIds(parsed.data…) itself — exactly the private parse this PR replaced with shared readCardOnboarding. 920/921 passed with that as the only failure; the pin now follows the shared parse (a9d63d3d0), and the uniqueness half stays pinned where the parse lives.

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)

Extended the open [docs-i18n] issue #7781 with every doc change from this PR (no new issue).

UI evidence (if applicable)

  • Persona picker: Create your persona · Answer Onboarding Demo's questions sits above None, with the card's avatar and the wizard's person-with-plus glyph.
  • Characters list: Onboarding Demo and Rank Sharer show the glyph; Raven (persona-only onboarding) correctly does not, because it has no character questions to re-answer.
  • Questions window: titled A few questions, one card section, Save answers.

🔄 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/7799 **Author:** [@ylli-selmani](https://github.com/ylli-selmani) **Created:** 10/19/2026 **Status:** ✅ Merged **Merged:** 10/19/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/onboarding-followups` --- ### 📝 Commits (8) - [`5b32735`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5b32735f9418cbadfc2ca2654e755f2427efc0f0) fix(onboarding): drop a removed card's chat variables (#7795) - [`2adcfaa`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2adcfaa143fcb1947522ec1b4b195f411c475381) feat(onboarding): create a persona from the Chat Settings picker (#7796) - [`0465bf1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0465bf1d101e10ba0eb7df72f323a96a311d6baf) feat(onboarding): answer one card's character questions from Chat Settings (#7797) - [`0797d85`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0797d859457cb1603c93a955cfa2cdb44ef23e34) fix(onboarding): open the questions window on the chat's saved answers (#7797) - [`387d531`](https://github.com/Pasta-Devs/Marinara-Engine/commit/387d531e7408935d89791af0327b172309a64030) docs(onboarding): a shared name is one value, even after setup (#7797) - [`4dc545f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4dc545fbcb91d37b07e2a529ffd3ee1d5afbfd72) fix(onboarding): keep the questions window on a failed save, and re-check the roster before dropping - [`835b7c8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/835b7c81c9d726f61b0f21b73f3f794eaf8ff299) fix(onboarding): keep a re-added card's answers when the removal cleanup runs - [`a9d63d3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a9d63d3d09b9c46a924bcb984ebd2313e8ca08ec) test(onboarding): pin the wizard's shared parse instead of its old private one ### 📊 Changes **10 files changed** (+771 additions, -54 deletions) <details> <summary>View changed files</summary> 📝 `docs/characters/choosing-your-persona.md` (+3 -1) 📝 `docs/characters/interactive-onboarding.md` (+7 -1) 📝 `packages/client/src/components/characters/CharacterOnboardingModal.tsx` (+30 -1) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+247 -0) 📝 `packages/client/src/components/chat/ChatSetupWizard.tsx` (+8 -37) 📝 `packages/client/src/localization/locales/en.json` (+1 -0) 📝 `packages/server/src/routes/chats.routes.ts` (+83 -13) 📝 `packages/shared/src/utils/onboarding.ts` (+174 -0) ➕ `scripts/regressions/onboarding-followups.regression.ts` (+206 -0) 📝 `scripts/regressions/onboarding-s1.regression.ts` (+12 -1) </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 Closes #7795 Closes #7796 Closes #7797 ## Why this change - **The variables outlived the card.** Selecting an onboarding-enabled character in the setup wizard immediately seeded its character-question defaults into the chat's variables (that seeding protects chats started without the wizard). Removing the character again left every one of those names behind — visible clutter in **Chat Variables**, with no card left to read them. - **A running chat could not build a persona.** A card's **Create your persona** row existed only in the setup wizard. Skip the wizard, change your mind later, or join a chat that already exists, and there was no path to a persona from the card's questions. - **The answers were only editable during setup.** Character-question answers had no second entrance either: delete one, pick the wrong option, or want a different answer, and the only fix was hand-editing Chat Variables. ## What changed - **Removing a character now removes the answers it owned.** `PATCH /chats/:id` drops the chat variables that the leaving card's enabled character questions declare, **unless another character still in the chat declares the same name** (a shared name keeps its value, because the remaining card reads it). A card whose onboarding is switched off owns nothing; a remaining card's declaration protects a name even if that block is switched off, since its card fields can still read it. This is the requested cleanup: a removed card's answers no longer survive by accident. - **Create your persona from Chat Settings.** The **Persona** picker in a Roleplay chat lists **Create your persona · Answer X's questions** for every character in the chat whose card can build one — the same rows, under the same `canBuildPersona` rule, as the wizard. Picking one opens the existing questions window with **persona questions only**, so it can never replace character-question answers with first-option defaults. **Create persona** saves the persona and sets it on this chat. - **Answer one card's character questions from Chat Settings.** The onboarding marker in **Characters** is now an action: it opens that card's questions alone (no other cards, no persona section), **starting from the answers the chat already holds** — edit one and the others keep their values. Saving again also restores a deleted answer; other cards' variables are untouched. The **Add Character** picker also shows the wizard's passive marker, so a card with interactive onboarding is recognisable before it is added. - **One card parse for every surface.** `readCardOnboarding` (shared) now reads a card's onboarding block, unique ids and the five card fields for the server seeding, the server removal, the wizard and the drawer, so the four surfaces cannot drift. The route returns the patched row, because the client caches the response. - **Reopening shows what was saved.** `answersFromStoredValues` (shared) rebuilds a card's answers from the chat's variables — a choice by option value, or by its label when the value is blank, free text as typed, a multi-select split by its separator — so the window opens on them instead of on every question's first option. A stored value the current options cannot express renders unselected and is **not written**, so an untouched save cannot replace it; the route merges chat variables per name (null deletes), so nothing else on the chat is lost either. - **Docs:** both onboarding guides describe the post-setup persona and question paths, and that a card that leaves a chat takes its answers with it. - **Regression:** `scripts/regressions/onboarding-followups.regression.ts` pins the card parse (both storage shapes, unique ids, unreadable data) and the removal rule (shared name kept, disabled leaver owns nothing, disabled stayer still protects, duplicates, unstorable names). ## 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 Run on this branch's own worktree (dev stack on port 6993; UI reached through the Vite dev server). The boxes above are still a to-do list for a human. - `pnpm check` — exit 0 (impeccable, localization 14,788 keys, format, lint, type checks, full build). - `node ./scripts/run-regressions.mjs --filter onboarding-followups` — 1/1 passed. - Browser/API proof on the worktree's data with two demo cards (`bond` + `rank`, and a second card declaring only `rank`): - Adding both seeded `rank = scout` and `bond = an old friend` before any question was saved — the reported starting point. - Removing **Onboarding Demo** dropped `bond` and kept `rank` (the remaining card declares it). Re-adding seeded `bond` again. Removing every declarer left `macroVariables = {}`. - The same removal through the drawer (Ylli) left **No variables yet** in Chat Settings. - **Create your persona** (Ylli): the two template rows appeared above **None**; picking Onboarding Demo opened the name/role questions; **Create persona** saved a persona named **Lollipop Man** and the chat's `personaId` points at it. Its description and personality match the template exactly (`Name: Lollipop Man`, `Role: ranger`, `A ranger of the guild.`). - **Character questions** (Ylli): the person-with-plus marker on Onboarding Demo opened **A few questions** for that card alone; saving wrote the answers to Chat Variables, and Rank Sharer's answers were not touched. - **Needs a click after the review fix:** reopen Onboarding Demo's questions and confirm the answers already saved come up preselected; save without editing anything and confirm Chat Variables is unchanged. - Not covered: light theme, mobile viewport and the tablet layout. The rows and the marker reuse the existing picker/row classes (`h-5 w-5`, same hover treatment), but nobody clicked them on a phone. ## Review rounds Local CodeRabbit (CLI 0.8.2), two runs inside the free hourly quota: 1. **Whole branch** (`--committed --base origin/staging`) — **1 major**: the questions window started every question on its first option, and `mergeCardVariables` writes every name the window asked, so saving one edited answer rewrote the ones nobody touched. Verified real; fixed in `0797d8594` (`answersFromStoredValues`, plus the "open, save, nothing changed" round trip in the regression). 2. **Fix delta** (`--committed --base 0465bf1d1`) — **1 major, 1 minor**: - major, **not a defect**: it asked to merge outgoing keys in case `useUpdateChatMetadata` / `PATCH /chats/:id/metadata` replaces `macroVariables`. The route merges per name (`{ ...saved, ...changedValues }`, `null` removes one name) and returns the patched row, so other cards' variables and any value this window did not write are retained. No change made. - minor, **taken**: the post-setup paragraph should say a name two cards share is one value. Fixed in `387d531e7`. GitHub CodeRabbit on the first push (2 actionable comments, both verified and fixed in `4dc545fbc`): 1. **minor** — the questions window closed before the metadata write, so a failed `PATCH` discarded the answers the player had just typed. The write now happens first; on failure the toast shows and the window stays open with its edits for a retry. Nothing is created on that path, so a retry is safe (unlike the persona path, which closes first on purpose). 2. **major** — the removal cleanup decided which names to delete from the roster the route had already written, so a concurrent `PATCH` could add a card declaring one of them in between and lose that card's answer. The decision now happens inside the chat's metadata queue, from the roster read there; a card added after that read is still safe because its own seeding patch is queued behind the cleanup. The rule itself is unchanged and remains pinned by the regression — this is about *when* it runs, and the guarantee is the per-chat serialization `chats.storage.ts` documents. Second GitHub round, on that fix (1 actionable comment, fixed in `835b7c81c`): 3. **major** — the new cleanup filtered the live roster against the ids *this* request removed, so a card removed here and re-added by a concurrent `PATCH` was skipped and its saved answers deleted. The live roster already is the remaining set, so the filter is gone; a re-added card protects the names it declares, and in the ordinary case the removed card is not in that roster anyway. Third GitHub round, on `835b7c81c`: **no actionable comments** (its two replies on the earlier threads only acknowledge the fixes). A fourth, on the regression-pin commit, also reported none. CI caught one stale proof: `complete-node-regressions` failed on `onboarding-s1`, whose last assertion matched the wizard calling `withUniqueOnboardingIds(parsed.data…)` itself — exactly the private parse this PR replaced with shared `readCardOnboarding`. 920/921 passed with that as the only failure; the pin now follows the shared parse (`a9d63d3d0`), and the uniqueness half stays pinned where the parse lives. ## Docs and release impact - [ ] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README) as needed - [x] 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) Extended the open `[docs-i18n]` issue **#7781** with every doc change from this PR (no new issue). ## UI evidence (if applicable) - Persona picker: **Create your persona · Answer Onboarding Demo's questions** sits above **None**, with the card's avatar and the wizard's person-with-plus glyph. - Characters list: Onboarding Demo and Rank Sharer show the glyph; Raven (persona-only onboarding) correctly does not, because it has no character questions to re-answer. - Questions window: titled **A few questions**, one card section, **Save answers**. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:08:55 +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#7929
No description provided.