[PR #8664] [MERGED] feat(chat): scenario step in the chat setup wizard (scenario setup 2/5) #8731

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8664
Author: @Gunterlie
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @Gunterlie

Base: scenarios-for-hoes ← Head: scenarios/02-wizard-step


📝 Commits (4)

  • ed05dbc feat(chat): scenario step in the chat setup wizard
  • 15946ca fix(generate): use the chat scenario override in conversation prompts
  • fdc52d6 fix(chat): scenario step review fixes
  • 086804e fix(chat): lock the scenario opening after it reaches the chat

📊 Changes

6 files changed (+531 additions, -34 deletions)

View changed files

📝 packages/client/src/components/chat/ChatSetupWizard.tsx (+428 -33)
📝 packages/client/src/hooks/use-scene.ts (+11 -1)
📝 packages/client/src/localization/locales/en.json (+24 -0)
📝 packages/server/src/routes/generate.routes.ts (+2 -0)
📝 packages/server/src/services/generation/character-prompt-context.ts (+18 -0)
➕ scripts/regressions/conversation-scenario-override.regression.ts (+48 -0)

📄 Description

Why

Part 1 (#8660) added a server route that drafts a premise and an opening. This part gives users the feature: an optional last step in the chat setup wizard where they describe what they are in the mood for, preview and edit the result, and start the chat with exactly that.

This is part 2 of 5 of the scenario setup feature; it merges into the feature branch scenarios-for-hoes. Planned work, no linked issue.

What changed

Wizard step "Set up a scenario" (roleplay and conversation; not game, not multiplayer)

  • Idea box with "Give me ideas" (empty idea) and "Generate"; loading line with Stop (aborts the request); route errors shown, idea kept.
  • Preview: editable premise and "Opening from {name}". Each part can be regenerated with an optional note; the other part keeps the user's edits.
  • "Skip and start" = today's flow, unchanged. "Start with this scenario" writes the opening as the first message from that character, then saves the premise to groupScenarioText together with the setup-complete flag. No model call on start; no stock greeting.
  • Failure safety: opener re-checked before writing; double submit guarded. If the message write fails, nothing is saved. If the message is written but the metadata write fails, the opening is locked (read-only, "This opening is already in the chat."), skip/back/new opening/profile are hidden, and retry only saves the premise.
  • Hint under the premise: "Replaces the character's own scenario for this chat."
  • Focus moves to the right field after each view change; loading uses a persistent role="status" region.
  • New hook useScenarioDraft(); new chat.wizard.scenario.* keys in en.json only.

Server fix: conversation chats ignored the scenario override

  • Conversation mode does not run the preset assembler; card fields come from injectIdentityFallbackMessages, which always used each card's own scenario. So both the new premise and the existing chat-settings scenario override had no effect in conversation chats.
  • The helper now mirrors the preset character marker (marker-expander.ts): when groupScenarioText is set, it drops each card's scenario and adds the override once. Gated to conversation mode; roleplay/game prompts are unchanged.
  • Regression scripts/regressions/conversation-scenario-override.regression.ts (fails without the fix).

Validation

  • pnpm check passed; client and server tsc passed; the 3 related regressions pass.
  • Live POST /api/generate debug-prompt proof on a throwaway server (dummy connection, no model reply): conversation with override → premise 1 / card scenario 0; without → 0 / 1; roleplay unchanged (1 / 0 and 0 / 1).
  • Browser proof with the draft route mocked: Start writes exactly the previewed text, one message on double click, no stock greetings, premise saved; forced 500 on the message write and on the metadata write both recover correctly. Screenshots at 390/768/1440, light and dark.
  • Opus review: no blockers; findings fixed (failed-start half state, focus/live region, premise hint). Local CodeRabbit: multiplayer stale draft and post-write metadata failure fixed; a request to extend the regression to roleplay/group modes was rejected because the server change is gated to conversation mode and the live test showed roleplay unchanged.

Manual verification

  • Start a roleplay chat with a scenario against a real model; check the opening is exactly the previewed text and the reply follows the premise.
  • Same for a conversation chat; check the reply follows the premise.
  • Open an existing conversation chat that already had a scenario override in chat settings; check the override now affects replies (behaviour change from the server fix).
  • Skip the step; check the chat starts exactly as before (stock greeting).
  • Check the step on a phone (390 px) in light theme.

Known gaps (later work)

  • The "Use a Profile" quick start skips the scenario step.
  • In group chats the first character sends the opening; there is no speaker picker yet.
  • The generate dry-run route does not add the identity fallback in conversation mode, so it does not match the live prompt.
  • The conversation wizard got typecheck coverage only; the browser proofs ran in the roleplay wizard.

🔄 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/8664 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `scenarios-for-hoes` ← **Head:** `scenarios/02-wizard-step` --- ### 📝 Commits (4) - [`ed05dbc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ed05dbc3d03db1a59d07dc55fcd40e2b184a579e) feat(chat): scenario step in the chat setup wizard - [`15946ca`](https://github.com/Pasta-Devs/Marinara-Engine/commit/15946caa9042e254ecdf572e3c4a9327d3bdb358) fix(generate): use the chat scenario override in conversation prompts - [`fdc52d6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fdc52d68520b682478ee1ce0cebe6a6e81fe985a) fix(chat): scenario step review fixes - [`086804e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/086804ea14815612d197d1ddec8e078908e2c66a) fix(chat): lock the scenario opening after it reaches the chat ### 📊 Changes **6 files changed** (+531 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/chat/ChatSetupWizard.tsx` (+428 -33) 📝 `packages/client/src/hooks/use-scene.ts` (+11 -1) 📝 `packages/client/src/localization/locales/en.json` (+24 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+2 -0) 📝 `packages/server/src/services/generation/character-prompt-context.ts` (+18 -0) ➕ `scripts/regressions/conversation-scenario-override.regression.ts` (+48 -0) </details> ### 📄 Description ## Why Part 1 (#8660) added a server route that drafts a premise and an opening. This part gives users the feature: an optional last step in the chat setup wizard where they describe what they are in the mood for, preview and edit the result, and start the chat with exactly that. This is **part 2 of 5** of the scenario setup feature; it merges into the feature branch `scenarios-for-hoes`. Planned work, no linked issue. ## What changed **Wizard step "Set up a scenario"** (roleplay and conversation; not game, not multiplayer) - Idea box with "Give me ideas" (empty idea) and "Generate"; loading line with Stop (aborts the request); route errors shown, idea kept. - Preview: editable premise and "Opening from {name}". Each part can be regenerated with an optional note; the other part keeps the user's edits. - "Skip and start" = today's flow, unchanged. "Start with this scenario" writes the opening as the first message from that character, then saves the premise to `groupScenarioText` together with the setup-complete flag. No model call on start; no stock greeting. - Failure safety: opener re-checked before writing; double submit guarded. If the message write fails, nothing is saved. If the message is written but the metadata write fails, the opening is locked (read-only, "This opening is already in the chat."), skip/back/new opening/profile are hidden, and retry only saves the premise. - Hint under the premise: "Replaces the character's own scenario for this chat." - Focus moves to the right field after each view change; loading uses a persistent `role="status"` region. - New hook `useScenarioDraft()`; new `chat.wizard.scenario.*` keys in `en.json` only. **Server fix: conversation chats ignored the scenario override** - Conversation mode does not run the preset assembler; card fields come from `injectIdentityFallbackMessages`, which always used each card's own `scenario`. So both the new premise and the existing chat-settings scenario override had no effect in conversation chats. - The helper now mirrors the preset character marker (`marker-expander.ts`): when `groupScenarioText` is set, it drops each card's scenario and adds the override once. Gated to conversation mode; roleplay/game prompts are unchanged. - Regression `scripts/regressions/conversation-scenario-override.regression.ts` (fails without the fix). ## Validation - `pnpm check` passed; client and server `tsc` passed; the 3 related regressions pass. - Live `POST /api/generate` debug-prompt proof on a throwaway server (dummy connection, no model reply): conversation with override → premise 1 / card scenario 0; without → 0 / 1; roleplay unchanged (1 / 0 and 0 / 1). - Browser proof with the draft route mocked: Start writes exactly the previewed text, one message on double click, no stock greetings, premise saved; forced 500 on the message write and on the metadata write both recover correctly. Screenshots at 390/768/1440, light and dark. - Opus review: no blockers; findings fixed (failed-start half state, focus/live region, premise hint). Local CodeRabbit: multiplayer stale draft and post-write metadata failure fixed; a request to extend the regression to roleplay/group modes was rejected because the server change is gated to conversation mode and the live test showed roleplay unchanged. ## Manual verification - [ ] Start a roleplay chat with a scenario against a real model; check the opening is exactly the previewed text and the reply follows the premise. - [ ] Same for a conversation chat; check the reply follows the premise. - [ ] Open an existing conversation chat that already had a scenario override in chat settings; check the override now affects replies (behaviour change from the server fix). - [ ] Skip the step; check the chat starts exactly as before (stock greeting). - [ ] Check the step on a phone (390 px) in light theme. ## Known gaps (later work) - The "Use a Profile" quick start skips the scenario step. - In group chats the first character sends the opening; there is no speaker picker yet. - The generate dry-run route does not add the identity fallback in conversation mode, so it does not match the live prompt. - The conversation wizard got typecheck coverage only; the browser proofs ran in the roleplay wizard. --- <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:19 +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#8731
No description provided.