[PR #2418] [MERGED] Normalize chat-bulk import entity defaults and message roles #5596

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/chat-bulk-import-normalize


📝 Commits (1)

  • f1819d1 Normalize chat-bulk import entity defaults and message roles

📊 Changes

2 files changed (+7 additions, -2 deletions)

View changed files

📝 src-tauri/src/commands/storage/imports/bulk_imports.rs (+1 -1)
📝 src-tauri/src/commands/storage/imports/marinara_chat_bulk.rs (+6 -1)

📄 Description

Linked issue

Closes #2368

Why this change

  • The native marinara-chat-bulk importer created chat records via raw storage.create and persisted messages without role validation, unlike every sibling import path. Stringified typed fields (e.g. characterIds) stayed strings, and arbitrary message roles persisted unchecked.

What changed

  • src-tauri/src/commands/storage/imports/marinara_chat_bulk.rs: chat creation now routes through the shared with_entity_defaults("chats", ...) (seeds CHAT_DEFAULTS + normalizes CHAT_FIELDS typed JSON), mirroring marinara.rs. Each message role is run through the existing imported_jsonl_message_role allowlist before insert.
  • src-tauri/src/commands/storage/imports/bulk_imports.rs: widened imported_jsonl_message_role to pub(crate) so the sibling importer can reuse it.
  • The allowlist permits narrator; only truly-unknown roles coerce to assistant, so valid roles pass through unchanged.

Refactor impact

Primary owner: Rust storage (imports)

Impact areas reviewed:

  • src-tauri/src/commands/storage/imports/marinara_chat_bulk.rs (chat + message creation)
  • src-tauri/src/commands/storage/imports/bulk_imports.rs (helper visibility)

Boundary notes:

  • None. Confined to the import layer; one helper widened pub(crate), no engine/features/shared crossing, no mode branching. On already-real arrays with_entity_defaults is a no-op, so clean exports round-trip unchanged.

Pressure points touched:

  • Import modules.

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 test --manifest-path src-tauri/Cargo.toml -p marinara-engine imports:: — 62 passed (no regression). A local-only test confirmed a stringified characterIds/metadata chat normalizes to a real array/object and that narrator is preserved while an unknown role (banana) coerces to assistant.
  • cargo clippy --manifest-path src-tauri/Cargo.toml --workspace --all-targets -- -D warnings — clean.

Feature Discoverability

  • Updated src/features/shell/discovery/
  • N/A because this PR is an import-correctness bugfix.

Reason:

  • No new discoverable surface.

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/2418 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 6/6/2026 **Status:** ✅ Merged **Merged:** 6/6/2026 **Merged by:** [@Romuromylus](https://github.com/Romuromylus) **Base:** `refactor` ← **Head:** `fix/chat-bulk-import-normalize` --- ### 📝 Commits (1) - [`f1819d1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f1819d112f979270b9e5e12aed276a845e1539ef) Normalize chat-bulk import entity defaults and message roles ### 📊 Changes **2 files changed** (+7 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/imports/bulk_imports.rs` (+1 -1) 📝 `src-tauri/src/commands/storage/imports/marinara_chat_bulk.rs` (+6 -1) </details> ### 📄 Description ## Linked issue Closes #2368 ## Why this change - The native `marinara-chat-bulk` importer created chat records via raw `storage.create` and persisted messages without role validation, unlike every sibling import path. Stringified typed fields (e.g. `characterIds`) stayed strings, and arbitrary message roles persisted unchecked. ## What changed - `src-tauri/src/commands/storage/imports/marinara_chat_bulk.rs`: chat creation now routes through the shared `with_entity_defaults("chats", ...)` (seeds CHAT_DEFAULTS + normalizes CHAT_FIELDS typed JSON), mirroring `marinara.rs`. Each message role is run through the existing `imported_jsonl_message_role` allowlist before insert. - `src-tauri/src/commands/storage/imports/bulk_imports.rs`: widened `imported_jsonl_message_role` to `pub(crate)` so the sibling importer can reuse it. - The allowlist permits `narrator`; only truly-unknown roles coerce to `assistant`, so valid roles pass through unchanged. ## Refactor impact Primary owner: Rust storage (imports) Impact areas reviewed: - `src-tauri/src/commands/storage/imports/marinara_chat_bulk.rs` (chat + message creation) - `src-tauri/src/commands/storage/imports/bulk_imports.rs` (helper visibility) Boundary notes: - None. Confined to the import layer; one helper widened `pub(crate)`, no engine/features/shared crossing, no mode branching. On already-real arrays `with_entity_defaults` is a no-op, so clean exports round-trip unchanged. Pressure points touched: - Import modules. ## Validation - [x] 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 test --manifest-path src-tauri/Cargo.toml -p marinara-engine imports::` — 62 passed (no regression). A local-only test confirmed a stringified `characterIds`/`metadata` chat normalizes to a real array/object and that `narrator` is preserved while an unknown role (`banana`) coerces to `assistant`. - `cargo clippy --manifest-path src-tauri/Cargo.toml --workspace --all-targets -- -D warnings` — clean. ## Feature Discoverability - [ ] Updated `src/features/shell/discovery/` - [x] N/A because this PR is an import-correctness bugfix. Reason: - No new discoverable surface. ## 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:42 +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#5596
No description provided.