[PR #1635] [MERGED] Preserve JSONL message roles and character ids #5168

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1635
Author: @Promansis
Created: 5/30/2026
Status: ✅ Merged
Merged: 5/30/2026
Merged by: @Promansis

Base: refactor ← Head: fix/issue-1524-jsonl-avatar-context


📝 Commits (2)

  • 1da2497 Preserve JSONL message character ids
  • d8fd5b8 Preserve JSONL message roles

📊 Changes

1 file changed (+204 additions, -8 deletions)

View changed files

📝 src-tauri/src/commands/storage/imports/bulk_imports.rs (+204 -8)

📄 Description

Linked issue

Closes #1524

Why this change

Marinara JSONL chat export writes stored message rows as-is, including each row's role and characterId, but the JSONL/ST importer discarded that local context. Imported Marinara JSONL user rows could become assistant messages because the importer only looked at ST's is_user flag, and imported messages always lost characterId.

What changed

  • The JSONL/ST chat importer now preserves supported explicit Marinara JSONL roles: user, assistant, system, and narrator.
  • ST-style rows without an explicit role still use the existing is_user fallback and default assistant behavior.
  • Unknown role strings are not persisted verbatim; they fall back to assistant.
  • Non-empty row-level characterId strings are preserved on imported messages.
  • Imported chats collect those explicit row-level character IDs into characterIds, preserving existing inherited chat links when present.
  • Plain SillyTavern character_name rows remain transcript-only and are not guessed into local character links.
  • Added importer tests for Marinara JSONL roles, unknown role fallback, character IDs, and the ST character_name negative control.

Refactor impact

Primary owner:

  • Rust storage imports.

Impact areas reviewed:

  • ST/JSONL chat import behavior.
  • Marinara JSONL export shape, which already serializes message rows with role and characterId.
  • Chat/message persistence fields used by chat and roleplay message rendering and avatar resolution.

Boundary notes:

  • Rust import capability only; no React feature imports, engine coupling, shared API routing, or remote-runtime allowlist changes.
  • The fix avoids name-based matching because character_name is not a stable local character identity.

Pressure points touched:

  • src-tauri/src/commands/storage/imports/bulk_imports.rs

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

Manual verification notes

  • cargo check --manifest-path src-tauri/Cargo.toml
  • cargo test --manifest-path src-tauri/Cargo.toml import_st_chat_text
  • cargo fmt --manifest-path src-tauri/Cargo.toml --check was attempted, but the repository currently has unrelated rustfmt drift in other files. The touched importer hunks were manually aligned and git diff --check passes.

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

UI evidence

Not applicable; this is Rust import behavior.


🔄 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/1635 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 5/30/2026 **Status:** ✅ Merged **Merged:** 5/30/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `refactor` ← **Head:** `fix/issue-1524-jsonl-avatar-context` --- ### 📝 Commits (2) - [`1da2497`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1da2497a64e43fb919dd6ad144bacb550545990c) Preserve JSONL message character ids - [`d8fd5b8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d8fd5b829de6c3edb72cc529536350fd39a95afe) Preserve JSONL message roles ### 📊 Changes **1 file changed** (+204 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/imports/bulk_imports.rs` (+204 -8) </details> ### 📄 Description ## Linked issue Closes #1524 ## Why this change Marinara JSONL chat export writes stored message rows as-is, including each row's `role` and `characterId`, but the JSONL/ST importer discarded that local context. Imported Marinara JSONL user rows could become assistant messages because the importer only looked at ST's `is_user` flag, and imported messages always lost `characterId`. ## What changed - The JSONL/ST chat importer now preserves supported explicit Marinara JSONL roles: `user`, `assistant`, `system`, and `narrator`. - ST-style rows without an explicit role still use the existing `is_user` fallback and default assistant behavior. - Unknown role strings are not persisted verbatim; they fall back to assistant. - Non-empty row-level `characterId` strings are preserved on imported messages. - Imported chats collect those explicit row-level character IDs into `characterIds`, preserving existing inherited chat links when present. - Plain SillyTavern `character_name` rows remain transcript-only and are not guessed into local character links. - Added importer tests for Marinara JSONL roles, unknown role fallback, character IDs, and the ST `character_name` negative control. ## Refactor impact Primary owner: - Rust storage imports. Impact areas reviewed: - ST/JSONL chat import behavior. - Marinara JSONL export shape, which already serializes message rows with `role` and `characterId`. - Chat/message persistence fields used by chat and roleplay message rendering and avatar resolution. Boundary notes: - Rust import capability only; no React feature imports, engine coupling, shared API routing, or remote-runtime allowlist changes. - The fix avoids name-based matching because `character_name` is not a stable local character identity. Pressure points touched: - `src-tauri/src/commands/storage/imports/bulk_imports.rs` ## Validation - [ ] `pnpm check` passes locally - [ ] `pnpm typecheck` passes locally - [ ] `pnpm build` passes locally - [ ] `pnpm check:architecture` passes locally - [ ] `pnpm check:docs` passes locally - [x] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [x] 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 ### Manual verification notes - `cargo check --manifest-path src-tauri/Cargo.toml` - `cargo test --manifest-path src-tauri/Cargo.toml import_st_chat_text` - `cargo fmt --manifest-path src-tauri/Cargo.toml --check` was attempted, but the repository currently has unrelated rustfmt drift in other files. The touched importer hunks were manually aligned and `git diff --check` passes. ## Docs and release impact - [x] 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 ## UI evidence Not applicable; this is Rust import behavior. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:13:53 +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#5168
No description provided.