[PR #2377] [MERGED] Auto-detect entry tags and lorebook category on SillyTavern import #5566

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/st-lorebook-tag-category


📝 Commits (2)

  • 0c08713 Auto-detect entry tags and lorebook category on SillyTavern import
  • fc36106 Move lorebook signal detection into its own module

📊 Changes

4 files changed (+206 additions, -3 deletions)

View changed files

➕ src-tauri/src/commands/storage/imports/lorebook_signals.rs (+140 -0)
📝 src-tauri/src/commands/storage/imports/normalization.rs (+4 -3)
📝 src-tauri/src/commands/storage/imports/service.rs (+2 -0)
📝 src-tauri/src/commands/storage/imports/service_tests.rs (+60 -0)

📄 Description

Linked issue

Closes #2298

Why this change

The Rust importer hardcoded every imported entry's tag to "" and the lorebook category to "uncategorized", dropping the tag and category auto-detection the upstream main web importer applies. Imported SillyTavern lorebooks therefore lost their entry tags and landed uncategorized — a regression vs main.

What changed

  • Port detectEntryTag and detectCategory / CATEGORY_SIGNALS from main's st-lorebook.importer.ts into normalization.rs as pure signal-scoring helpers.
  • Use ordered signal tables (not hash maps) to preserve main's deterministic tie-breaking (earlier tag/category wins; category defaults to world).

Refactor impact

Primary owner: Rust imports (src-tauri/src/commands/storage/imports/normalization.rs)

Impact areas reviewed:

  • Entry path (normalize_lorebook_entry) and lorebook path (normalize_lorebook). The ST-import wrapper copies source keys but ST entries carry no tag, so the computed tag is preserved.

Boundary notes:

  • none — pure functions, no I/O.

Pressure points touched:

  • import modules (normalization.rs)

Validation

  • Matching validation command passes locally
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • cargo clippy --workspace --all-targets -- -D warnings — clean
  • cargo test --workspace — green, including 4 new tests (tag detection, category detection, empty-tag default, world-category default).

Feature Discoverability

  • N/A because this PR is a compatibility/regression bugfix and does not add a new thing users need to find.

Reason:

  • Restores parity with the web importer.

Docs and release impact

  • No docs changes needed

🔄 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/2377 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 6/5/2026 **Status:** ✅ Merged **Merged:** 6/6/2026 **Merged by:** [@Romuromylus](https://github.com/Romuromylus) **Base:** `refactor` ← **Head:** `fix/st-lorebook-tag-category` --- ### 📝 Commits (2) - [`0c08713`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0c08713bb61e6cb755d509dca88cd59e15ff86d7) Auto-detect entry tags and lorebook category on SillyTavern import - [`fc36106`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fc36106c1922c27c86c9b9fa7e7635bd69425b69) Move lorebook signal detection into its own module ### 📊 Changes **4 files changed** (+206 additions, -3 deletions) <details> <summary>View changed files</summary> ➕ `src-tauri/src/commands/storage/imports/lorebook_signals.rs` (+140 -0) 📝 `src-tauri/src/commands/storage/imports/normalization.rs` (+4 -3) 📝 `src-tauri/src/commands/storage/imports/service.rs` (+2 -0) 📝 `src-tauri/src/commands/storage/imports/service_tests.rs` (+60 -0) </details> ### 📄 Description ## Linked issue Closes #2298 ## Why this change The Rust importer hardcoded every imported entry's `tag` to `""` and the lorebook `category` to `"uncategorized"`, dropping the tag and category auto-detection the upstream `main` web importer applies. Imported SillyTavern lorebooks therefore lost their entry tags and landed uncategorized — a regression vs `main`. ## What changed - Port `detectEntryTag` and `detectCategory` / `CATEGORY_SIGNALS` from `main`'s `st-lorebook.importer.ts` into `normalization.rs` as pure signal-scoring helpers. - Use **ordered** signal tables (not hash maps) to preserve `main`'s deterministic tie-breaking (earlier tag/category wins; category defaults to `world`). ## Refactor impact Primary owner: Rust imports (`src-tauri/src/commands/storage/imports/normalization.rs`) Impact areas reviewed: - Entry path (`normalize_lorebook_entry`) and lorebook path (`normalize_lorebook`). The ST-import wrapper copies source keys but ST entries carry no `tag`, so the computed tag is preserved. Boundary notes: - none — pure functions, no I/O. Pressure points touched: - import modules (`normalization.rs`) ## Validation - [ ] Matching validation command passes locally - [ ] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - `cargo clippy --workspace --all-targets -- -D warnings` — clean - `cargo test --workspace` — green, including 4 new tests (tag detection, category detection, empty-tag default, world-category default). ## Feature Discoverability - [x] N/A because this PR is a compatibility/regression bugfix and does not add a new thing users need to find. Reason: - Restores parity with the web importer. ## Docs and release impact - [x] No docs changes needed --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:17:26 +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#5566
No description provided.