mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #363] [MERGED] fix(chats): preserve folder categorization across branch create/delete #4579
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#4579
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/363
Author: @LukaTheHero
Created: 5/3/2026
Status: ✅ Merged
Merged: 5/3/2026
Merged by: @LukaTheHero
Base:
main← Head:fix/branch-ops-preserve-folder-categorization📝 Commits (1)
68547b8fix(chats): preserve folder categorization across branch create/delete📊 Changes
3 files changed (+35 additions, -3 deletions)
View changed files
📝
packages/server/src/routes/chat-folders.routes.ts(+8 -2)📝
packages/server/src/routes/chats.routes.ts(+4 -1)📝
packages/server/src/services/storage/chats.storage.ts(+23 -0)📄 Description
Closes #340
Why this change
When a user moves an RP into a folder, only the currently visible representative branch gets
folderIdset. The sidebar collapses every chat sharing agroupIdinto a single row and readsfolderIdfrom whichever branch is currently the most-recently-updated representative (packages/client/src/components/layout/ChatSidebar.tsxdisplayChats+folderChatsMap).That coupling produced two failure modes that always dropped the tree back into Uncategorized:
POST /:id/branchcallsstorage.create(...), which does not acceptfolderId, so the new branch lands withfolderId = null. The post-createstorage.update(newChat.id, {})bumpsupdatedAtto now, making the new branch the most-recently-updated row in its group — so the sidebar readsfolderId = nullfrom it and the whole tree appears uncategorized.folderIdwas never set (because the move-to-folder mutation only ever wrote the field on one branch). The replacement representative hasfolderId = null→ tree falls out of its folder.What changed
chats.storage.ts— newsetFolderForChat(chatId, folderId)helper. When the chat has agroupId, it writesfolderIdto every branch in the group without touching siblings'updatedAt(so categorizing doesn't silently reorder branch history), then bumpsupdatedAton just the targeted chat to preserve the existing "moved chat goes to top" behavior. Falls back to a single-chat update when there's nogroupId.chats.routes.ts— branch creation passesfolderId: sourceChat.folderId ?? nullinto the existing post-createstorage.updatecall so the new branch inherits the source's folder. Combined withsetFolderForChatpropagation at move time, every branch in a group now always carries the samefolderId.chat-folders.routes.ts—/move-chatand/reorder-chatsroute throughsetFolderForChatso any folder change applies to the whole group, not just the visible representative.Compatibility
groupId) take the unchanged single-row path.folderIdheal on the next move-to-folder action.Summary by CodeRabbit
Bug Fixes
Improvements
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.