[PR #808] [MERGED] Fix JSONL chat file imports #4780

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/808
Author: @cha1latte
Created: 5/13/2026
Status: ✅ Merged
Merged: 5/13/2026
Merged by: @cha1latte

Base: main ← Head: fix/issue-800-jsonl-chat-import


📝 Commits (1)

  • b49aca4 Fix JSONL chat file imports

📊 Changes

3 files changed (+159 additions, -11 deletions)

View changed files

📝 packages/client/src/components/chat/ChatFilesDrawer.tsx (+1 -1)
📝 packages/server/src/routes/import.routes.ts (+28 -10)
➕ packages/server/test/st-chat-import-routes.test.ts (+130 -0)

📄 Description

Linked issue

Closes #800

Why this change

  • JSONL chat exports could hit the branch-import endpoint without the target chat id being available to the server, surfacing Import failed: Missing chatId instead of importing the transcript as a chat file.

What changed

  • Parse /api/import/st-chat-into-group multipart requests with req.parts() so the file and chatId field are collected regardless of multipart field order.
  • Send the target chatId before the file from the Manage Chat Files drawer.
  • Added a server route regression test that imports a Marinara-style JSONL transcript with both file-first and field-first multipart ordering and verifies imported messages persist.

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

Manual verification notes

  • Codex route proof: pnpm --filter @marinara-engine/server exec tsx --import ./test/setup-env.ts --test test/st-chat-import-routes.test.ts passed. The test covers JSONL branch import with file-first and field-first multipart bodies and verifies the imported message contents.
  • Codex baseline: pnpm check passed after the route regression test was added.
  • Codex scratch proof: pnpm --dir packages/server exec tsx ../../scratch/issue-800-jsonl-import-repro.ts --expect-fixed passed for file-first and field-first multipart branch imports.
  • Limitation: I could not replay the exact Termux UI session or the reporter's attached Princess Vivienne.jsonl file because the attachment binary is not available in this environment. The route-level behavior and Marinara-style JSONL payload are covered by the regression test.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

No docs or release metadata changes needed.

UI evidence (if applicable)

N/A. This is a route/import handling fix with regression coverage; no visible UI layout changed.

Summary by CodeRabbit

  • Bug Fixes

    • Improved multipart file upload handling for chat imports, ensuring uploads work correctly regardless of field order.
  • Tests

    • Added tests verifying chat file imports work consistently with different multipart field orderings.

Review Change Stack


🔄 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/808 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/13/2026 **Status:** ✅ Merged **Merged:** 5/13/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `main` ← **Head:** `fix/issue-800-jsonl-chat-import` --- ### 📝 Commits (1) - [`b49aca4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b49aca403afa85b7b96f1a28ace711db8e37b5fe) Fix JSONL chat file imports ### 📊 Changes **3 files changed** (+159 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/chat/ChatFilesDrawer.tsx` (+1 -1) 📝 `packages/server/src/routes/import.routes.ts` (+28 -10) ➕ `packages/server/test/st-chat-import-routes.test.ts` (+130 -0) </details> ### 📄 Description ## Linked issue <!-- Every PR should reference a feature request or issue report. If there isn't one yet, open one first to gather opinions: --> <!-- https://github.com/Pasta-Devs/Marinara-Engine/issues/new/choose --> Closes #800 ## Why this change <!-- What user problem, bug, or goal does this solve? --> - JSONL chat exports could hit the branch-import endpoint without the target chat id being available to the server, surfacing `Import failed: Missing chatId` instead of importing the transcript as a chat file. ## What changed <!-- List the key changes in this PR --> - Parse `/api/import/st-chat-into-group` multipart requests with `req.parts()` so the file and `chatId` field are collected regardless of multipart field order. - Send the target `chatId` before the file from the Manage Chat Files drawer. - Added a server route regression test that imports a Marinara-style JSONL transcript with both file-first and field-first multipart ordering and verifies imported messages persist. ## Validation <!-- Required: include commands run and/or manual checks performed --> - [ ] `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` ### Manual verification notes <!-- Describe exactly what you tested in a real browser/app, step by step. --> <!-- ⚠️ If an AI agent filled out or ticked these boxes for you, treat them --> <!-- as a TO-DO LIST, not as proof the work is done. Verify each item yourself --> <!-- before submitting. If you haven't verified it, untick the box. --> - Codex route proof: `pnpm --filter @marinara-engine/server exec tsx --import ./test/setup-env.ts --test test/st-chat-import-routes.test.ts` passed. The test covers JSONL branch import with file-first and field-first multipart bodies and verifies the imported message contents. - Codex baseline: `pnpm check` passed after the route regression test was added. - Codex scratch proof: `pnpm --dir packages/server exec tsx ../../scratch/issue-800-jsonl-import-repro.ts --expect-fixed` passed for file-first and field-first multipart branch imports. - Limitation: I could not replay the exact Termux UI session or the reporter's attached `Princess Vivienne.jsonl` file because the attachment binary is not available in this environment. The route-level behavior and Marinara-style JSONL payload are covered by the regression test. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) No docs or release metadata changes needed. ## UI evidence (if applicable) N/A. This is a route/import handling fix with regression coverage; no visible UI layout changed. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved multipart file upload handling for chat imports, ensuring uploads work correctly regardless of field order. * **Tests** * Added tests verifying chat file imports work consistently with different multipart field orderings. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/808) <!-- review_stack_entry_end --> <!-- 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:10:35 +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#4780
No description provided.