[GH-ISSUE #1502] Roleplay CYOA and context-injection outputs are not persisted to message extra #752

Closed
opened 2026-10-20 17:32:54 +07:00 by bsakaguchi · 1 comment
Owner

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

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Roleplay CYOA choices and cached writer/context injections appear to be client-only or agent-run-only after generation, even though the Roleplay UI hydrates them from assistant message.extra after reload/chat switch.

This came out of the Roleplay smoke/audit work for #1486.

Evidence

  • src/features/modes/roleplay/components/CyoaChoices.tsx hydrates choices from the last assistant message's extra.cyoaChoices and saves edits back to that same message extra.
  • src/features/modes/roleplay/components/ContextInjectionPanel.tsx reads cached injections from the last assistant message's extra.contextInjections and saves edits back there.
  • src/features/runtime/generation/hooks/use-generate.ts applies live CYOA agent results only to useAgentStore via setCyoaChoices(choices, chatId).
  • src/engine/generation/start-generation.ts persists agent results to agent-runs, but saveAssistantMessage, saveRegeneratedMessage, and the generation extra patch only write replay/snapshot/thinking/sprite/summary fields. They do not write cyoaChoices or contextInjections to assistant message extra.
  • src/features/catalog/chats/hooks/use-chats.ts treats cyoaChoices and contextInjections as swipe-scoped message extra fields, which reinforces that these are intended to live on the message/swipe record.

Expected

After a Roleplay generation with CYOA or context-injection agents:

  • generated CYOA choices persist on the assistant message/swipe and survive reload/chat switch,
  • cached context injections persist on the assistant message/swipe and remain editable/rerunnable from the Roleplay agents panel,
  • regenerate/swipe behavior keeps those fields scoped to the correct assistant swipe.

Actual

The live client can show CYOA choices from useAgentStore, and agent-runs are persisted, but the message extra fields that the Roleplay UI hydrates from are not populated by generation. After reload or switching away/back, the UI cannot recover those choices/injections from the message record unless the user manually edited/saved them first.

Suggested Fix

Choose one source of truth and wire it end to end. The current UI suggests message/swipe extra is the intended source, so likely fix generation persistence to include:

  • cyoaChoices from successful CYOA agent results,
  • contextInjections from successful pre-generation injection results,
  • swipe-scoped handling for regenerate/add-swipe paths.

If agent-runs should be the source instead, update the Roleplay components to hydrate from agent-runs and remove the stale message-extra assumption.

  • #1486
  • #1501 tracks the separate Writer Agent Review pause/resume contract issue.
  • #1497 tracks the separate raw invokeTauri Roleplay panel architecture issue.
Originally created by @Xelvanis on GitHub (May 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1502 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Roleplay CYOA choices and cached writer/context injections appear to be client-only or agent-run-only after generation, even though the Roleplay UI hydrates them from assistant `message.extra` after reload/chat switch. This came out of the Roleplay smoke/audit work for #1486. ## Evidence - `src/features/modes/roleplay/components/CyoaChoices.tsx` hydrates choices from the last assistant message's `extra.cyoaChoices` and saves edits back to that same message extra. - `src/features/modes/roleplay/components/ContextInjectionPanel.tsx` reads cached injections from the last assistant message's `extra.contextInjections` and saves edits back there. - `src/features/runtime/generation/hooks/use-generate.ts` applies live CYOA agent results only to `useAgentStore` via `setCyoaChoices(choices, chatId)`. - `src/engine/generation/start-generation.ts` persists agent results to `agent-runs`, but `saveAssistantMessage`, `saveRegeneratedMessage`, and the generation extra patch only write replay/snapshot/thinking/sprite/summary fields. They do not write `cyoaChoices` or `contextInjections` to assistant message extra. - `src/features/catalog/chats/hooks/use-chats.ts` treats `cyoaChoices` and `contextInjections` as swipe-scoped message extra fields, which reinforces that these are intended to live on the message/swipe record. ## Expected After a Roleplay generation with CYOA or context-injection agents: - generated CYOA choices persist on the assistant message/swipe and survive reload/chat switch, - cached context injections persist on the assistant message/swipe and remain editable/rerunnable from the Roleplay agents panel, - regenerate/swipe behavior keeps those fields scoped to the correct assistant swipe. ## Actual The live client can show CYOA choices from `useAgentStore`, and `agent-runs` are persisted, but the message extra fields that the Roleplay UI hydrates from are not populated by generation. After reload or switching away/back, the UI cannot recover those choices/injections from the message record unless the user manually edited/saved them first. ## Suggested Fix Choose one source of truth and wire it end to end. The current UI suggests message/swipe extra is the intended source, so likely fix generation persistence to include: - `cyoaChoices` from successful CYOA agent results, - `contextInjections` from successful pre-generation injection results, - swipe-scoped handling for regenerate/add-swipe paths. If `agent-runs` should be the source instead, update the Roleplay components to hydrate from `agent-runs` and remove the stale message-extra assumption. ## Related - #1486 - #1501 tracks the separate Writer Agent Review pause/resume contract issue. - #1497 tracks the separate raw `invokeTauri` Roleplay panel architecture issue.
Author
Owner

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

Resolved on refactor in 3e85cfca. CYOA choices and pre-generation context injections now persist to assistant message/swipe extra during normal generation, regeneration, and targeted agent retries.

<!-- gh-comment-id:4571930546 --> @SpicyMarinara commented on GitHub (May 29, 2026): Resolved on refactor in 3e85cfca. CYOA choices and pre-generation context injections now persist to assistant message/swipe extra during normal generation, regeneration, and targeted agent retries.
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#752
No description provided.