[PR #5226] [MERGED] Add Lorebook Update order and custom result previews #6680

Closed
opened 2026-10-23 04:12:40 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5226
Author: @SpicyMarinara
Created: 8/18/2026
Status: ✅ Merged
Merged: 8/18/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/5225-lorebook-update-order


📝 Commits (4)

  • 416992d Add Lorebook Update entry order
  • f7ba618 Accept explicitly signed lorebook orders
  • c7b827e Preview custom agent result formats
  • 528ec7e Strengthen custom result preview regression

📊 Changes

9 files changed (+352 additions, -26 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 e2e/core-flows.e2e.ts (+25 -0)
📝 packages/client/src/components/agents/AgentEditor.tsx (+12 -25)
➕ packages/client/src/lib/custom-agent-result-examples.ts (+179 -0)
📝 packages/client/src/localization/locales/en.json (+2 -0)
📝 packages/server/src/routes/generate/agent-write-approval.ts (+14 -1)
📝 packages/server/src/routes/generate/lorebook-keeper-utils.ts (+9 -0)
📝 packages/shared/src/types/agent.ts (+2 -0)
📝 scripts/regressions/open-issues.regression.ts (+108 -0)

📄 Description

Linked issue

Closes #5225

Related package work: Pasta-Devs/Marinara-Agents#425

Why this change

Lorebook Update agents currently lose any requested entry injection order before persistence. New entries therefore use the storage default and existing entries cannot be moved, forcing users who group lore entries at a shared order such as 200 to batch-edit Agent output after every run.

The approval-gated path also reconstructs updates from editable proposal text, so merely forwarding order in the automatic path would still silently drop it when Review Agent Outputs is enabled.

Custom-agent creators also only see a short description of the selected result type. Without opening a built-in agent as a reference, they cannot see the complete JSON response shape or its optional fields while writing their prompt.

What changed

  • Accept an optional safe integer order from top-level or nested Lorebook Update entry data.
  • Apply it when creating or updating entries while preserving existing/default order when omitted or malformed.
  • Include valid order values in Lorebook approval text and parse them back on commit.
  • Show a complete response example in the empty custom-agent prompt editor for every selectable result type.
  • Update that preview immediately when the selected result type changes, including optional fields such as Lorebook order.
  • Document the optional field in the shared Lorebook Update type and add an Unreleased changelog entry.
  • Add regression and focused browser coverage for both behaviors.

Validation

  • pnpm build:shared
  • node ./scripts/run-regressions.mjs --filter scripts/regressions/open-issues.regression.ts
  • pnpm check
  • Focused Playwright test on desktop Chromium
  • Focused Playwright test on mobile Chromium
  • Verify a Lorebook Update creates an entry with order: 200
  • Verify a Lorebook Update changes an existing entry to order: 200
  • Verify omitted or malformed order preserves the existing/default behavior
  • Verify approval-gated editing and commit preserve the optional order
  • Manually verify each custom-agent result type shows its matching response example
  • Read and followed CONTRIBUTING.md

Verification notes

  • Focused regression proof passed for custom-result example completeness, valid create/update order, approval text round-trip, omission, numeric strings, fractions, and unsafe integers.
  • The focused custom-agent preview browser test passed on desktop and mobile Chromium.
  • The broad smoke run was inconclusive because its shared local test server degraded into unrelated timeouts; the new focused assertions passed independently on both target projects.

Docs and release impact

  • No user guide changes needed; the inline authoring guidance, shared contract, and CHANGELOG.md are updated in this PR.
  • No version/release files changed.

UI evidence

The Prompt Template textarea uses the selected result type response example as its empty-state preview. Existing prompts are unchanged, and built-in agent placeholders retain their previous behavior.

Summary by CodeRabbit

  • New Features

    • Added optional injection-order support for Lorebook Keeper updates.
    • Valid order values are preserved during approval reviews and applied when entries are created or updated.
    • Approval details now display the configured order when available.
    • Custom Agent prompt editors now preview format-specific JSON or plain-text response examples.
  • Bug Fixes

    • Invalid order values are safely ignored.
  • Tests

    • Added coverage for order validation, approval handling, automatic updates, and prompt previews.

🔄 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/5226 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 8/18/2026 **Status:** ✅ Merged **Merged:** 8/18/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/5225-lorebook-update-order` --- ### 📝 Commits (4) - [`416992d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/416992d6731eeecdc3a23f59e43b9e30911fb5de) Add Lorebook Update entry order - [`f7ba618`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f7ba618b9cfa35b2dc7605b09d0f7b371df825fe) Accept explicitly signed lorebook orders - [`c7b827e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c7b827e4f860552f5afc6533de71bd8972febb5f) Preview custom agent result formats - [`528ec7e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/528ec7efc82939c046ee31500789c091027de6b9) Strengthen custom result preview regression ### 📊 Changes **9 files changed** (+352 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `e2e/core-flows.e2e.ts` (+25 -0) 📝 `packages/client/src/components/agents/AgentEditor.tsx` (+12 -25) ➕ `packages/client/src/lib/custom-agent-result-examples.ts` (+179 -0) 📝 `packages/client/src/localization/locales/en.json` (+2 -0) 📝 `packages/server/src/routes/generate/agent-write-approval.ts` (+14 -1) 📝 `packages/server/src/routes/generate/lorebook-keeper-utils.ts` (+9 -0) 📝 `packages/shared/src/types/agent.ts` (+2 -0) 📝 `scripts/regressions/open-issues.regression.ts` (+108 -0) </details> ### 📄 Description ## Linked issue Closes #5225 Related package work: Pasta-Devs/Marinara-Agents#425 ## Why this change Lorebook Update agents currently lose any requested entry injection order before persistence. New entries therefore use the storage default and existing entries cannot be moved, forcing users who group lore entries at a shared order such as 200 to batch-edit Agent output after every run. The approval-gated path also reconstructs updates from editable proposal text, so merely forwarding `order` in the automatic path would still silently drop it when **Review Agent Outputs** is enabled. Custom-agent creators also only see a short description of the selected result type. Without opening a built-in agent as a reference, they cannot see the complete JSON response shape or its optional fields while writing their prompt. ## What changed - Accept an optional safe integer `order` from top-level or nested Lorebook Update entry data. - Apply it when creating or updating entries while preserving existing/default order when omitted or malformed. - Include valid order values in Lorebook approval text and parse them back on commit. - Show a complete response example in the empty custom-agent prompt editor for every selectable result type. - Update that preview immediately when the selected result type changes, including optional fields such as Lorebook `order`. - Document the optional field in the shared Lorebook Update type and add an Unreleased changelog entry. - Add regression and focused browser coverage for both behaviors. ## Validation - [ ] `pnpm build:shared` - [ ] `node ./scripts/run-regressions.mjs --filter scripts/regressions/open-issues.regression.ts` - [ ] `pnpm check` - [ ] Focused Playwright test on desktop Chromium - [ ] Focused Playwright test on mobile Chromium - [ ] Verify a Lorebook Update creates an entry with `order: 200` - [ ] Verify a Lorebook Update changes an existing entry to `order: 200` - [ ] Verify omitted or malformed order preserves the existing/default behavior - [ ] Verify approval-gated editing and commit preserve the optional order - [ ] Manually verify each custom-agent result type shows its matching response example - [ ] Read and followed `CONTRIBUTING.md` ### Verification notes - Focused regression proof passed for custom-result example completeness, valid create/update order, approval text round-trip, omission, numeric strings, fractions, and unsafe integers. - The focused custom-agent preview browser test passed on desktop and mobile Chromium. - The broad smoke run was inconclusive because its shared local test server degraded into unrelated timeouts; the new focused assertions passed independently on both target projects. ## Docs and release impact - [ ] No user guide changes needed; the inline authoring guidance, shared contract, and `CHANGELOG.md` are updated in this PR. - [ ] No version/release files changed. ## UI evidence The Prompt Template textarea uses the selected result type response example as its empty-state preview. Existing prompts are unchanged, and built-in agent placeholders retain their previous behavior. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added optional injection-order support for Lorebook Keeper updates. * Valid order values are preserved during approval reviews and applied when entries are created or updated. * Approval details now display the configured order when available. * Custom Agent prompt editors now preview format-specific JSON or plain-text response examples. * **Bug Fixes** * Invalid order values are safely ignored. * **Tests** * Added coverage for order validation, approval handling, automatic updates, and prompt previews. <!-- 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-23 04:12:40 +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#6680
No description provided.