[PR #6778] [MERGED] feat: add lorebook authoring and diagnostic tools #7328

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6778
Author: @SirAdoni
Created: 9/27/2026
Status: ✅ Merged
Merged: 9/28/2026
Merged by: @SpicyMarinara

Base: staging ← Head: contrib/6698-lorebook-tools


📝 Commits (10+)

  • 13cb507 feat: add lorebook authoring and diagnostic tools
  • 53da51a test: verify lorebook tools on desktop and mobile
  • 4f2ffc4 Merge staging and fix lorebook export regex complexity
  • f409151 fix: record lorebook activations after reply persistence
  • 408f1d3 Merge staging inventory update into lorebook contribution
  • 8950c3e Merge commit '3355c32277' into contrib/6698-lorebook-tools
  • e5a206e fix: harden lorebook imports and diagnostic checks
  • 22991f7 test: capture Windows readiness timeout diagnostics
  • d01afb7 Merge remote-tracking branch 'pr-review/6778' into codex/assigned-6778
  • 9707476 Merge latest staging into reviewed lorebook tools

📊 Changes

39 files changed (+4764 additions, -49 deletions)

View changed files

📝 CHANGELOG.md (+13 -1)
➕ e2e/lorebook-tools.e2e.ts (+113 -0)
➕ packages/client/src/components/lorebooks/LorebookBulkEditPanel.tsx (+278 -0)
📝 packages/client/src/components/lorebooks/LorebookEditor.tsx (+208 -33)
📝 packages/client/src/components/lorebooks/LorebookEntryRow.tsx (+26 -3)
➕ packages/client/src/components/lorebooks/LorebookLintPanel.tsx (+185 -0)
➕ packages/client/src/components/lorebooks/LorebookScanTest.tsx (+196 -0)
➕ packages/client/src/components/lorebooks/LorebookTextImportDialog.tsx (+323 -0)
📝 packages/client/src/components/panels/LorebooksPanel.tsx (+4 -2)
➕ packages/client/src/components/panels/library/LorebookSelectionEnableActions.tsx (+88 -0)
📝 packages/client/src/components/panels/settings/FeatureSwitchesSettings.tsx (+5 -1)
📝 packages/client/src/components/ui/ExportFormatDialog.tsx (+18 -2)
📝 packages/client/src/hooks/use-lorebooks.ts (+95 -1)
📝 packages/client/src/localization/locales/en.json (+143 -0)
📝 packages/server/src/app.ts (+2 -0)
📝 packages/server/src/db/file-backed-store.ts (+3 -0)
📝 packages/server/src/db/schema/index.ts (+1 -0)
➕ packages/server/src/db/schema/lorebook-activation-stats.ts (+14 -0)
📝 packages/server/src/routes/generate.routes.ts (+8 -0)
➕ packages/server/src/routes/lorebook-text.routes.ts (+93 -0)

...and 19 more files

📄 Description

Linked issue

Closes #6806. Partial implementation of #6698; the umbrella issue remains open.

Why this change

Lorebook authors need import/export, bulk editing and diagnostics that preserve data and matching semantics.

What changed

  • Add lorebook authoring and diagnostic tools within existing panels and storage.
  • Make imports atomic with existing transactions, preserve case/regex semantics in diagnostics, and repair Windows fixture handling while retaining the contributor diagnostics.

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

pnpm check; prompt regressions; 15 lorebook regressions; three desktop/mobile Chromium/WebKit browser cases; seven shell smoke cases passed. The final Windows fixture combination still requires Windows CI.

Valid findings were traced and fixed. See the current maintainer verification below for review and validation evidence.

Manual verification

Manually verify bulk edits, failed import rollback, exports and case-sensitive/regular-expression diagnostics using a representative lorebook.

Automated browser evidence does not claim physical-device or manual container verification. Human checklist states are preserved.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened
  • Version/release files updated (only if this PR includes a version bump)

Added an Unreleased changelog entry. No release metadata or user-facing docs changed.

UI evidence

Browser evidence (download the HTML to view the embedded screenshots). Captions distinguish before/after captures from current feature screenshots.

Summary by CodeRabbit

  • New Features
    • Added bulk lorebook management, including selecting, enabling or disabling books, editing multiple entries, and navigating selection ranges.
    • Added lorebook lint checks and scan testing, with entry-level results and activation statistics.
    • Added Markdown and CSV lorebook import and export, with duplicate-handling options and previews.
  • Improvements
    • Added filters and sorting for lorebook activation history, plus clearer context-limit explanations in chat previews.
    • Improved CSV export safety and import handling for large text files.

Maintainer verification

Published a6dc8578c resolves all four latest hosted findings. CSV/Markdown downloads now reuse the existing ASCII fallback plus UTF-8 filename* pattern, preserving spaces and non-English names with safe header encoding. Browser setup requests fail immediately on HTTP errors. The activation regression now exercises actual generation and Continue, directly checks that unknown entry IDs are not stored, and proves shutdown flushes a queued activation before storage closes and persists it after reopening.

Exact-head pnpm check, export/import and real activation regressions, feature browsers 3/3, and smoke 7/7 pass. The combined integration c5410d2c2 passes pnpm check, four focused regressions, and all nine affected browser cases across desktop Chromium, mobile Chromium and mobile WebKit. The final combined local CodeRabbit delta completed with zero findings across nine files. Earlier CSV ambiguity, rollback and lint fixes remain covered.

Latest follow-up 5adb4b438 fixes selected lorebooks disappearing from bulk Enable/Disable after filtering. The component submits every selected ID to the existing endpoint; Undo still uses only server-confirmed changedIds. Removed the obsolete client planner and its implementation-only test. The retained actual browser fixture reproduces the old disabled-button failure and now verifies hidden selections, exact mutation contents, unchanged IDs, and precise Undo.

For this six-file delta: pnpm check passes, the targeted browser matrix passes 3/3, and shell smoke passes 7/7. Independent source review has no substantive findings. Local CodeRabbit completed with zero findings across all six changed files. No user-facing copy or styling changed.

Current-head hosted CodeRabbit and GitHub checks remain merge gates. Human validation checkboxes are unchanged.

Local build and container verification

Tested commit: 5adb4b4389. Full local pnpm check passed. The full Docker image built successfully and ran with synthetic data; HTTP readiness and embedded build commit were verified. These results do not claim completion of the remaining manual and UI edge-case checklist.

Interactive browser walkthroughs of the feature were completed against the running production container using synthetic fixtures, supported by focused automated browser checks. This was agent-operated browser interaction, not physical-device testing. The broader theme, empty-state and error-path checklist remains separate.

Completed UI verification

At 5adb4b4389, functional browser checks passed 3/3 across desktop Chromium, mobile Chromium and mobile WebKit. Coverage included lint warnings, scan preview, import, bulk enable/disable and undo. Two supplemental empty-lorebook views passed and were visually inspected: light desktop (1440px) and dark narrow (390px), with visible search, completed loading and no horizontal document overflow. The production-container walkthrough also verified actions on selected lorebooks hidden by filtering. These were agent-operated synthetic browser checks; no physical-device or real-provider testing is claimed.


🔄 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/6778 **Author:** [@SirAdoni](https://github.com/SirAdoni) **Created:** 9/27/2026 **Status:** ✅ Merged **Merged:** 9/28/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `contrib/6698-lorebook-tools` --- ### 📝 Commits (10+) - [`13cb507`](https://github.com/Pasta-Devs/Marinara-Engine/commit/13cb507d323db44841331eede753ea1ff7b639a5) feat: add lorebook authoring and diagnostic tools - [`53da51a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/53da51ab5cbca761c9a5df1b9c8b6474996d6cfa) test: verify lorebook tools on desktop and mobile - [`4f2ffc4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4f2ffc44167040de09965db5f9f06d0ccc227828) Merge staging and fix lorebook export regex complexity - [`f409151`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f4091519b3d3aeef34f0911d3a00e9fa09561baa) fix: record lorebook activations after reply persistence - [`408f1d3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/408f1d36a2853b1f73fe15b4771debe1d410286c) Merge staging inventory update into lorebook contribution - [`8950c3e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8950c3e3a595b9eee1e394db5ee9f4f86d18b276) Merge commit '3355c32277f71d2d4aa2e4f84d4901c098047dec' into contrib/6698-lorebook-tools - [`e5a206e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e5a206edcb3117a18392e85886f381c223d69a81) fix: harden lorebook imports and diagnostic checks - [`22991f7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/22991f7a05af4e0237ab782127e4adc7f2b78286) test: capture Windows readiness timeout diagnostics - [`d01afb7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d01afb7c54d118624c74e74a8e98da15f37fea93) Merge remote-tracking branch 'pr-review/6778' into codex/assigned-6778 - [`9707476`](https://github.com/Pasta-Devs/Marinara-Engine/commit/970747651eac80b7a7031de57f2e5ca497806cb9) Merge latest staging into reviewed lorebook tools ### 📊 Changes **39 files changed** (+4764 additions, -49 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+13 -1) ➕ `e2e/lorebook-tools.e2e.ts` (+113 -0) ➕ `packages/client/src/components/lorebooks/LorebookBulkEditPanel.tsx` (+278 -0) 📝 `packages/client/src/components/lorebooks/LorebookEditor.tsx` (+208 -33) 📝 `packages/client/src/components/lorebooks/LorebookEntryRow.tsx` (+26 -3) ➕ `packages/client/src/components/lorebooks/LorebookLintPanel.tsx` (+185 -0) ➕ `packages/client/src/components/lorebooks/LorebookScanTest.tsx` (+196 -0) ➕ `packages/client/src/components/lorebooks/LorebookTextImportDialog.tsx` (+323 -0) 📝 `packages/client/src/components/panels/LorebooksPanel.tsx` (+4 -2) ➕ `packages/client/src/components/panels/library/LorebookSelectionEnableActions.tsx` (+88 -0) 📝 `packages/client/src/components/panels/settings/FeatureSwitchesSettings.tsx` (+5 -1) 📝 `packages/client/src/components/ui/ExportFormatDialog.tsx` (+18 -2) 📝 `packages/client/src/hooks/use-lorebooks.ts` (+95 -1) 📝 `packages/client/src/localization/locales/en.json` (+143 -0) 📝 `packages/server/src/app.ts` (+2 -0) 📝 `packages/server/src/db/file-backed-store.ts` (+3 -0) 📝 `packages/server/src/db/schema/index.ts` (+1 -0) ➕ `packages/server/src/db/schema/lorebook-activation-stats.ts` (+14 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+8 -0) ➕ `packages/server/src/routes/lorebook-text.routes.ts` (+93 -0) _...and 19 more files_ </details> ### 📄 Description ## Linked issue Closes #6806. Partial implementation of #6698; the umbrella issue remains open. ## Why this change Lorebook authors need import/export, bulk editing and diagnostics that preserve data and matching semantics. ## What changed - Add lorebook authoring and diagnostic tools within existing panels and storage. - Make imports atomic with existing transactions, preserve case/regex semantics in diagnostics, and repair Windows fixture handling while retaining the contributor diagnostics. ## Validation - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` pnpm check; prompt regressions; 15 lorebook regressions; three desktop/mobile Chromium/WebKit browser cases; seven shell smoke cases passed. The final Windows fixture combination still requires Windows CI. Valid findings were traced and fixed. See the current maintainer verification below for review and validation evidence. ### Manual verification Manually verify bulk edits, failed import rollback, exports and case-sensitive/regular-expression diagnostics using a representative lorebook. Automated browser evidence does not claim physical-device or manual container verification. Human checklist states are preserved. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened - [ ] Version/release files updated (only if this PR includes a version bump) Added an Unreleased changelog entry. No release metadata or user-facing docs changed. ## UI evidence [Browser evidence](https://gist.github.com/SpicyMarinara/5b3875c9d20a039e732572465ba401e2) (download the HTML to view the embedded screenshots). Captions distinguish before/after captures from current feature screenshots. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added bulk lorebook management, including selecting, enabling or disabling books, editing multiple entries, and navigating selection ranges. * Added lorebook lint checks and scan testing, with entry-level results and activation statistics. * Added Markdown and CSV lorebook import and export, with duplicate-handling options and previews. * **Improvements** * Added filters and sorting for lorebook activation history, plus clearer context-limit explanations in chat previews. * Improved CSV export safety and import handling for large text files. <!-- end of auto-generated comment: release notes by coderabbit.ai --> <!-- maintainer-final-review --> ### Maintainer verification Published a6dc8578c resolves all four latest hosted findings. CSV/Markdown downloads now reuse the existing ASCII fallback plus UTF-8 filename* pattern, preserving spaces and non-English names with safe header encoding. Browser setup requests fail immediately on HTTP errors. The activation regression now exercises actual generation and Continue, directly checks that unknown entry IDs are not stored, and proves shutdown flushes a queued activation before storage closes and persists it after reopening. Exact-head pnpm check, export/import and real activation regressions, feature browsers 3/3, and smoke 7/7 pass. The combined integration c5410d2c2 passes pnpm check, four focused regressions, and all nine affected browser cases across desktop Chromium, mobile Chromium and mobile WebKit. The final combined local CodeRabbit delta completed with zero findings across nine files. Earlier CSV ambiguity, rollback and lint fixes remain covered. Latest follow-up `5adb4b438` fixes selected lorebooks disappearing from bulk Enable/Disable after filtering. The component submits every selected ID to the existing endpoint; Undo still uses only server-confirmed `changedIds`. Removed the obsolete client planner and its implementation-only test. The retained actual browser fixture reproduces the old disabled-button failure and now verifies hidden selections, exact mutation contents, unchanged IDs, and precise Undo. For this six-file delta: `pnpm check` passes, the targeted browser matrix passes 3/3, and shell smoke passes 7/7. Independent source review has no substantive findings. Local CodeRabbit completed with zero findings across all six changed files. No user-facing copy or styling changed. Current-head hosted CodeRabbit and GitHub checks remain merge gates. Human validation checkboxes are unchanged. <!-- /maintainer-final-review --> <!-- local-validation-20260928 --> ### Local build and container verification Tested commit: 5adb4b4389d5f097241c603db7037c9f5d97fa5a. Full local pnpm check passed. The full Docker image built successfully and ran with synthetic data; HTTP readiness and embedded build commit were verified. These results do not claim completion of the remaining manual and UI edge-case checklist. <!-- /local-validation-20260928 --> <!-- interactive-validation-20260928 --> Interactive browser walkthroughs of the feature were completed against the running production container using synthetic fixtures, supported by focused automated browser checks. This was agent-operated browser interaction, not physical-device testing. The broader theme, empty-state and error-path checklist remains separate. <!-- /interactive-validation-20260928 --> ### Completed UI verification At 5adb4b4389d5f097241c603db7037c9f5d97fa5a, functional browser checks passed 3/3 across desktop Chromium, mobile Chromium and mobile WebKit. Coverage included lint warnings, scan preview, import, bulk enable/disable and undo. Two supplemental empty-lorebook views passed and were visually inspected: light desktop (1440px) and dark narrow (390px), with visible search, completed loading and no horizontal document overflow. The production-container walkthrough also verified actions on selected lorebooks hidden by filtering. These were agent-operated synthetic browser checks; no physical-device or real-provider testing is claimed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:18:41 +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#7328
No description provided.