mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #726] [MERGED] feat(chat): import JSONL into existing chat as a new branch #4748
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#4748
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/726
Author: @LukaTheHero
Created: 5/12/2026
Status: ✅ Merged
Merged: 5/12/2026
Merged by: @LukaTheHero
Base:
main← Head:feat/import-chat-into-group📝 Commits (1)
03fa729feat(chat): import JSONL into existing chat as a new branch📊 Changes
3 files changed (+202 additions, -6 deletions)
View changed files
📝
packages/client/src/components/chat/ChatFilesDrawer.tsx(+92 -1)📝
packages/server/src/routes/import.routes.ts(+91 -0)📝
packages/server/src/services/import/st-chat.importer.ts(+19 -5)📄 Description
Summary
Adds an Import Chat button to the Manage Chat Files drawer so a JSONL exported from one chat can be brought back as a sibling branch of another chat — instead of dropping into Settings → Import Chat, which spawns a brand-new character entry at the top of the chat list.
Why
Right now, the only "Import Chat" UI lives in Settings, and it always creates a new top-level chat (and, when no character match is found, it can effectively orphan the transcript away from the character you actually want it on). The drawer for an individual chat only offers Export Chat, which is asymmetric — there's no way to round-trip a JSONL back into the same conversation as a new chat file. This PR makes Manage Chat Files symmetric: you can export a branch and import a branch from the same place, and the imported one lands alongside the others as a chat file.
Changes
packages/server/src/services/import/st-chat.importer.ts—ImportSTChatOptionsnow acceptscharacterIds,personaId,connectionId, andpromptPresetIdso callers can fully inherit an existing chat's settings (previously these were always nulled).packages/server/src/routes/import.routes.ts— newPOST /api/import/st-chat-into-groupendpoint. Looks up the target chat, auto-assigns agroupIdif it doesn't have one (same trick the existingPOST /chats/:id/branchendpoint uses atchats.routes.ts:1579), inherits the target chat's character roster / persona / connection / prompt preset, and for multi-character chats builds aname → characterIdspeaker map from the target roster so per-message attribution survives the import. No new character is created in any path.packages/client/src/components/chat/ChatFilesDrawer.tsx— adds an Import Chat section under Export Chat in both the grouped and ungrouped drawer states. Posts the file + the current chat id to the new endpoint, invalidates list/detail/group caches (the target chat may have just been freshly assigned a groupId), refetches the branch list, and switches the active chat to the newly imported branch.Notes for reviewer
character_nameto match or create characters — it only uses the target chat's existing roster. Speakers in the JSONL whose name doesn't match anyone in that roster fall back to the first inherited character (existingimportSTChatfallback behavior).POST /chats/:id/branch, so importing into a chat that's never been branched will quietly give it agroupIdand the imported file becomes its first branch.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.