[PR #458] [MERGED] feat(agents): add editable injections and secret plot controls #4628

Closed
opened 2026-10-22 04:09:17 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/458
Author: @Xelvanis
Created: 5/6/2026
Status: ✅ Merged
Merged: 5/6/2026
Merged by: @Xelvanis

Base: main ← Head: feat/editable-agent-injections-secret-plot


📝 Commits (1)

  • 2f8da57 feat(agents): add editable injections and secret plot controls

📊 Changes

20 files changed (+2509 additions, -418 deletions)

View changed files

📝 docs/FAQ.md (+19 -0)
📝 docs/FRONTEND.md (+15 -5)
📝 docs/ROLEPLAY.md (+47 -0)
➕ packages/client/src/components/agents/ContextInjectionPanel.tsx (+474 -0)
➕ packages/client/src/components/agents/SecretPlotPanel.tsx (+543 -0)
📝 packages/client/src/components/chat/ChatRoleplaySurface.tsx (+2 -0)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+205 -29)
📝 packages/client/src/components/chat/RoleplayHUD.tsx (+51 -2)
📝 packages/client/src/components/chat/RoleplayHUDActionsMenu.tsx (+407 -165)
📝 packages/client/src/components/chat/RoleplayHUDPanels.tsx (+1 -0)
📝 packages/client/src/components/ui/HelpTooltip.tsx (+15 -2)
📝 packages/client/src/hooks/use-agents.ts (+11 -0)
📝 packages/client/src/hooks/use-generate.ts (+11 -1)
📝 packages/server/src/db/file-backed-store.ts (+22 -1)
📝 packages/server/src/routes/agents.routes.ts (+175 -1)
📝 packages/server/src/routes/generate.routes.ts (+26 -25)
➕ packages/server/src/routes/generate/agent-normalizers.ts (+45 -0)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+387 -187)
📝 packages/server/src/services/storage/agents.storage.ts (+44 -0)
📝 packages/shared/src/types/chat.ts (+9 -0)

📄 Description

Linked issue

No linked issue, but this feature would be useful for users to troubleshoot their writing agents, quickly test output of different models with re-run, and tweaking their prompts.

Closes #

Why this change

  • Writer-agent guidance could affect a reply without giving users a clear way to inspect, edit, or re-run the specific guidance that caused it.
  • Secret Plot Driver memory needed a safer, opt-in UI so users can refresh turn guidance without accidentally wiping or replacing the long-running hidden arc.
  • Users can use this to troubleshoot issues, such as Narrative Director continuing roleplay instead of generating guidance, or test the output of different models quickly.

What changed

  • Added opt-in Roleplay HUD tabs for cached prompt injections and Secret Plot Driver state.
  • Added editable cached context injections on assistant messages, including save controls, scoped re-runs, and Narrative Director cadence status.
  • Added a Secret Plot panel for scene directions, arc memory, fulfilled/momentum state, and full vs turn-only re-runs.
  • Added agent memory and cadence API routes, plus retry-agent support for explicit agent lists, historical message anchors, and secret plot rerun modes.
  • Updated generation/regeneration so cached injections can be reused or refreshed for the same assistant message.
  • Updated shared chat metadata/types and docs in docs/FAQ.md, docs/FRONTEND.md, and docs/ROLEPLAY.md.

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

AI-run notes:

  • CI=true pnpm install --frozen-lockfile passed.
  • pnpm check passed.
  • Docker/container build was not run.
  • Browser screenshots were captured from a temporary seeded demo app, not real user data.

Manual verification notes

  • Confirm pnpm check passes locally.
  • Build and run the app locally.
  • Open a roleplay chat with agents enabled.
  • In Chat Settings -> Agents -> Writer Agents, add/enable Prose Guardian, Narrative Director, and Secret Plot Driver.
  • Toggle the Injections tab on and confirm it appears in the Roleplay HUD Agents menu.
  • Toggle the Secret Plot tab on and confirm it appears in the Roleplay HUD Agents menu when Secret Plot Driver is active.
  • Generate a roleplay reply with writer agents enabled.
  • Open Roleplay HUD -> Agents -> Injections and confirm cached prompt injections appear for the latest assistant message.
  • Edit one cached injection, save it, refresh/reopen the menu, and confirm the edit persists.
  • Re-run one eligible cached injection and confirm only that injection is refreshed.
  • With Narrative Director active, confirm its cadence/countdown appears and the interval stepper saves.
  • Open Roleplay HUD -> Agents -> Secret plot and confirm scene directions and arc memory load.
  • Edit a scene direction, save it, refresh/reopen the menu, and confirm the edit persists.
  • Try “re-run scene directions” and confirm it refreshes turn guidance without replacing the long-term arc.
  • Try “re-run full secret plot state” and confirm it asks before replacing arc memory.
  • Remove Secret Plot Driver from the chat and confirm the destructive warning appears before hidden plot memory is cleared.
  • Check the new UI in dark mode and light mode.
  • Check the new UI in a narrow/mobile viewport.
  • Check empty states: no assistant message yet, no cached injections yet, and no Secret Plot memory yet.
  • Check error paths if possible: failed memory load/save or failed agent retry shows a sensible failure state.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

Docs updated in this branch:

  • docs/FAQ.md
  • docs/FRONTEND.md
  • docs/ROLEPLAY.md

No version/release files appear to be changed.

UI evidence (if applicable)

Screenshot 2026-05-06 185839 Screenshot 2026-05-06 190714 hud-injections-tab hud-secret-plot-arc-fields mobile-secret-plot-tab

WIP

Summary by CodeRabbit

  • New Features

    • Roleplay Agents menu with Activity / Injections / Secret tabs; editable cached injections panel and Secret Plot memory editor with save, rerun, and reroll (full or turn-only).
    • Message-scoped agent retry that replays cached injections and supports secret-plot reroll modes.
    • HUD and settings: show Secret Plot panel on add; per-chat toggles for Injections/Secret panels; wider help tooltips.
  • Documentation

    • FAQ, frontend API, and Roleplay docs updated for retry behavior, plot-steering overlaps, new agent endpoints, and memory tooling.

🔄 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/458 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/6/2026 **Status:** ✅ Merged **Merged:** 5/6/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `main` ← **Head:** `feat/editable-agent-injections-secret-plot` --- ### 📝 Commits (1) - [`2f8da57`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2f8da57b38434da0c92e952866c0fdc112e1543f) feat(agents): add editable injections and secret plot controls ### 📊 Changes **20 files changed** (+2509 additions, -418 deletions) <details> <summary>View changed files</summary> 📝 `docs/FAQ.md` (+19 -0) 📝 `docs/FRONTEND.md` (+15 -5) 📝 `docs/ROLEPLAY.md` (+47 -0) ➕ `packages/client/src/components/agents/ContextInjectionPanel.tsx` (+474 -0) ➕ `packages/client/src/components/agents/SecretPlotPanel.tsx` (+543 -0) 📝 `packages/client/src/components/chat/ChatRoleplaySurface.tsx` (+2 -0) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+205 -29) 📝 `packages/client/src/components/chat/RoleplayHUD.tsx` (+51 -2) 📝 `packages/client/src/components/chat/RoleplayHUDActionsMenu.tsx` (+407 -165) 📝 `packages/client/src/components/chat/RoleplayHUDPanels.tsx` (+1 -0) 📝 `packages/client/src/components/ui/HelpTooltip.tsx` (+15 -2) 📝 `packages/client/src/hooks/use-agents.ts` (+11 -0) 📝 `packages/client/src/hooks/use-generate.ts` (+11 -1) 📝 `packages/server/src/db/file-backed-store.ts` (+22 -1) 📝 `packages/server/src/routes/agents.routes.ts` (+175 -1) 📝 `packages/server/src/routes/generate.routes.ts` (+26 -25) ➕ `packages/server/src/routes/generate/agent-normalizers.ts` (+45 -0) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+387 -187) 📝 `packages/server/src/services/storage/agents.storage.ts` (+44 -0) 📝 `packages/shared/src/types/chat.ts` (+9 -0) </details> ### 📄 Description ## Linked issue <!-- Every PR should reference a feature request or issue report. If there isn't one yet, open one first to gather opinions: --> <!-- https://github.com/Pasta-Devs/Marinara-Engine/issues/new/choose --> No linked issue, but this feature would be useful for users to troubleshoot their writing agents, quickly test output of different models with re-run, and tweaking their prompts. Closes # ## Why this change - Writer-agent guidance could affect a reply without giving users a clear way to inspect, edit, or re-run the specific guidance that caused it. - Secret Plot Driver memory needed a safer, opt-in UI so users can refresh turn guidance without accidentally wiping or replacing the long-running hidden arc. - Users can use this to troubleshoot issues, such as Narrative Director continuing roleplay instead of generating guidance, or test the output of different models quickly. ## What changed - Added opt-in Roleplay HUD tabs for cached prompt injections and Secret Plot Driver state. - Added editable cached context injections on assistant messages, including save controls, scoped re-runs, and Narrative Director cadence status. - Added a Secret Plot panel for scene directions, arc memory, fulfilled/momentum state, and full vs turn-only re-runs. - Added agent memory and cadence API routes, plus retry-agent support for explicit agent lists, historical message anchors, and secret plot rerun modes. - Updated generation/regeneration so cached injections can be reused or refreshed for the same assistant message. - Updated shared chat metadata/types and docs in `docs/FAQ.md`, `docs/FRONTEND.md`, and `docs/ROLEPLAY.md`. ## Validation - [X] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [X] 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) - [X] Read and followed `CONTRIBUTING.md` AI-run notes: - `CI=true pnpm install --frozen-lockfile` passed. - `pnpm check` passed. - Docker/container build was not run. - Browser screenshots were captured from a temporary seeded demo app, not real user data. ### Manual verification notes - [X] Confirm `pnpm check` passes locally. - [X] Build and run the app locally. - [X] Open a roleplay chat with agents enabled. - [X] In Chat Settings -> Agents -> Writer Agents, add/enable Prose Guardian, Narrative Director, and Secret Plot Driver. - [X] Toggle the Injections tab on and confirm it appears in the Roleplay HUD Agents menu. - [X] Toggle the Secret Plot tab on and confirm it appears in the Roleplay HUD Agents menu when Secret Plot Driver is active. - [X] Generate a roleplay reply with writer agents enabled. - [X] Open Roleplay HUD -> Agents -> Injections and confirm cached prompt injections appear for the latest assistant message. - [x] Edit one cached injection, save it, refresh/reopen the menu, and confirm the edit persists. - [x] Re-run one eligible cached injection and confirm only that injection is refreshed. - [x] With Narrative Director active, confirm its cadence/countdown appears and the interval stepper saves. - [X] Open Roleplay HUD -> Agents -> Secret plot and confirm scene directions and arc memory load. - [x] Edit a scene direction, save it, refresh/reopen the menu, and confirm the edit persists. - [x] Try “re-run scene directions” and confirm it refreshes turn guidance without replacing the long-term arc. - [x] Try “re-run full secret plot state” and confirm it asks before replacing arc memory. - [x] Remove Secret Plot Driver from the chat and confirm the destructive warning appears before hidden plot memory is cleared. - [X] Check the new UI in dark mode and light mode. - [x] Check the new UI in a narrow/mobile viewport. - [x] Check empty states: no assistant message yet, no cached injections yet, and no Secret Plot memory yet. - [ ] Check error paths if possible: failed memory load/save or failed agent retry shows a sensible failure state. ## Docs and release impact - [ ] No docs changes needed - [X] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) Docs updated in this branch: - `docs/FAQ.md` - `docs/FRONTEND.md` - `docs/ROLEPLAY.md` No version/release files appear to be changed. ## UI evidence (if applicable) <img width="282" height="451" alt="Screenshot 2026-05-06 185839" src="https://github.com/user-attachments/assets/3d6b3adc-5b8a-401f-8d8c-ac050af1c2ea" /> <img width="331" height="231" alt="Screenshot 2026-05-06 190714" src="https://github.com/user-attachments/assets/af2dc4eb-6b57-4031-9c74-3d82eb69a853" /> <img width="326" height="360" alt="hud-injections-tab" src="https://github.com/user-attachments/assets/12103f03-0dae-44ae-8486-84672140770e" /> <img width="326" height="360" alt="hud-secret-plot-arc-fields" src="https://github.com/user-attachments/assets/6d603902-a407-4196-85eb-418bf5b5e2fa" /> <img width="390" height="456" alt="mobile-secret-plot-tab" src="https://github.com/user-attachments/assets/8009d757-68ab-40ab-a891-51475cfcecd6" /> WIP <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Roleplay Agents menu with Activity / Injections / Secret tabs; editable cached injections panel and Secret Plot memory editor with save, rerun, and reroll (full or turn-only). * Message-scoped agent retry that replays cached injections and supports secret-plot reroll modes. * HUD and settings: show Secret Plot panel on add; per-chat toggles for Injections/Secret panels; wider help tooltips. * **Documentation** * FAQ, frontend API, and Roleplay docs updated for retry behavior, plot-steering overlaps, new agent endpoints, and memory tooling. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:09:17 +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#4628
No description provided.