[PR #1727] [MERGED] [codex] Extract active lorebook scope reasons #5236

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

📋 Pull Request Information

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

Base: refactor ← Head: codex/lorebooks-scope-reasons


📝 Commits (2)

  • e8db10a Extract active lorebook scope reasons
  • 1e69008 Address lorebook scope review notes

📊 Changes

5 files changed (+387 additions, -170 deletions)

View changed files

➕ src/engine/generation-core/lorebooks/active-lorebook-scope.test.ts (+131 -0)
➕ src/engine/generation-core/lorebooks/active-lorebook-scope.ts (+208 -0)
📝 src/engine/generation/active-lorebook-scanner.ts (+12 -62)
📝 src/features/catalog/lorebooks/components/LorebooksPanel.tsx (+14 -28)
📝 src/features/modes/shared/chat-ui/components/ChatSettingsDrawer.tsx (+22 -80)

📄 Description

Linked issue

None.

Why this change

  • Lorebook active-scope behavior was duplicated between engine prompt activation, the Lorebooks panel Active filter, and Chat Settings.
  • The duplicate UI logic could drift from engine rules, especially around Game Lorebook Keeper exclusions.

What changed

  • Added an engine-owned active lorebook scope/reason helper in src/engine/generation-core/lorebooks/active-lorebook-scope.ts.
  • Routed prompt assembly scanner scope checks through the shared helper without changing prompt order.
  • Updated the Lorebooks panel Active filter and Chat Settings active lorebook/marker-warning logic to consume the shared helper.
  • Added focused tests covering reason ordering, label folding, and disabled Game Lorebook Keeper exclusions.

Refactor impact

Primary owner:

  • Engine generation-core lorebook scope contract.

Impact areas reviewed:

  • Prompt-time lorebook activation scanner.
  • Lorebooks panel Active filter.
  • Chat Settings active lorebook list and prompt-marker warning.
  • Game Lorebook Keeper exclusion behavior.

Boundary notes:

  • Product scope behavior stays in src/engine/generation-core.
  • React feature code imports deterministic engine helper only; no engine import from React/shared APIs/Tauri.
  • No shared API, Rust, Tauri command, or remote runtime changes.

Pressure points touched:

  • Shared mode UI: ChatSettingsDrawer.tsx now delegates active lorebook scope math to the engine helper.

Validation

  • pnpm check passes locally
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Playwright, screenshot, or recording evidence added for UI changes
  • Remote runtime smoke checked when relevant

Commands run:

  • pnpm vitest run src/engine/generation-core/lorebooks/active-lorebook-scope.test.ts src/engine/generation/prompt-assembly.test.ts src/engine/generation-core/lorebooks/keyword-scanner.test.ts passed: 3 files, 69 tests.
  • pnpm check passed.
  • pnpm build passed; Vite reported existing large chunk warnings plus an existing CSS minify warning about file not being a known CSS property.

Manual verification notes

  • Native Tauri UI pass was not run for the Lorebooks panel Active filter or Chat Settings active lorebook list.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

Notes:

  • No docs/changelog update made; this is an internal refactor with unchanged user-facing copy and no public workflow change.

UI evidence

  • Not captured; no visual layout change intended.

Summary by CodeRabbit

  • New Features

    • Enhanced lorebook scope reasoning with clear categorization: global, character, persona, chat, and selected contexts.
  • Tests

    • Added comprehensive test suite for lorebook scope resolution to ensure accurate scope matching and consistent behavior.
  • Refactor

    • Consolidated duplicate scope-resolution logic across multiple components into a centralized utility for improved maintainability and consistency.

🔄 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/1727 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/31/2026 **Status:** ✅ Merged **Merged:** 5/31/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `codex/lorebooks-scope-reasons` --- ### 📝 Commits (2) - [`e8db10a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e8db10a983e68455dccce9850123af9f9d20c1fe) Extract active lorebook scope reasons - [`1e69008`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1e690089344292d615e3c8e62ee3049f49b3c6ff) Address lorebook scope review notes ### 📊 Changes **5 files changed** (+387 additions, -170 deletions) <details> <summary>View changed files</summary> ➕ `src/engine/generation-core/lorebooks/active-lorebook-scope.test.ts` (+131 -0) ➕ `src/engine/generation-core/lorebooks/active-lorebook-scope.ts` (+208 -0) 📝 `src/engine/generation/active-lorebook-scanner.ts` (+12 -62) 📝 `src/features/catalog/lorebooks/components/LorebooksPanel.tsx` (+14 -28) 📝 `src/features/modes/shared/chat-ui/components/ChatSettingsDrawer.tsx` (+22 -80) </details> ### 📄 Description ## Linked issue None. ## Why this change - Lorebook active-scope behavior was duplicated between engine prompt activation, the Lorebooks panel Active filter, and Chat Settings. - The duplicate UI logic could drift from engine rules, especially around Game Lorebook Keeper exclusions. ## What changed - Added an engine-owned active lorebook scope/reason helper in `src/engine/generation-core/lorebooks/active-lorebook-scope.ts`. - Routed prompt assembly scanner scope checks through the shared helper without changing prompt order. - Updated the Lorebooks panel Active filter and Chat Settings active lorebook/marker-warning logic to consume the shared helper. - Added focused tests covering reason ordering, label folding, and disabled Game Lorebook Keeper exclusions. ## Refactor impact Primary owner: - Engine generation-core lorebook scope contract. Impact areas reviewed: - Prompt-time lorebook activation scanner. - Lorebooks panel Active filter. - Chat Settings active lorebook list and prompt-marker warning. - Game Lorebook Keeper exclusion behavior. Boundary notes: - Product scope behavior stays in `src/engine/generation-core`. - React feature code imports deterministic engine helper only; no engine import from React/shared APIs/Tauri. - No shared API, Rust, Tauri command, or remote runtime changes. Pressure points touched: - Shared mode UI: `ChatSettingsDrawer.tsx` now delegates active lorebook scope math to the engine helper. ## Validation <!-- Checkboxes intentionally left unchecked for human verification per template. Commands below were run locally by Codex. --> - [x] `pnpm check` passes locally - [x] `pnpm typecheck` passes locally - [x] `pnpm build` passes locally - [ ] `pnpm check:architecture` passes locally - [ ] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Playwright, screenshot, or recording evidence added for UI changes - [ ] Remote runtime smoke checked when relevant Commands run: - `pnpm vitest run src/engine/generation-core/lorebooks/active-lorebook-scope.test.ts src/engine/generation/prompt-assembly.test.ts src/engine/generation-core/lorebooks/keyword-scanner.test.ts` passed: 3 files, 69 tests. - `pnpm check` passed. - `pnpm build` passed; Vite reported existing large chunk warnings plus an existing CSS minify warning about `file` not being a known CSS property. ### Manual verification notes - Native Tauri UI pass was not run for the Lorebooks panel Active filter or Chat Settings active lorebook list. ## Docs and release impact - [x] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [x] Confirmed this PR does not restore old staging/package-workspace/release claims Notes: - No docs/changelog update made; this is an internal refactor with unchanged user-facing copy and no public workflow change. ## UI evidence - Not captured; no visual layout change intended. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Enhanced lorebook scope reasoning with clear categorization: global, character, persona, chat, and selected contexts. * **Tests** * Added comprehensive test suite for lorebook scope resolution to ensure accurate scope matching and consistent behavior. * **Refactor** * Consolidated duplicate scope-resolution logic across multiple components into a centralized utility for improved maintainability and consistency. <!-- 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:14:30 +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#5236
No description provided.