mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #1344] [Issue]: Refactor chat folders need branch/folder storage parity verification #666
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#666
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?
Originally created by @cha1latte on GitHub (May 26, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1344
Originally assigned to: @Romuromylus on GitHub.
Summary
Chat folders appear mostly present in refactor, but full backend/storage parity with v1.6.0/v1.6.1 still needs verification.
Expected behavior
Chat folders should preserve v1.6.0/v1.6.1 branch/folder inheritance, storage, profile migration, import, and export behavior.
Actual behavior
Folder UI/hooks exist, but branch/folder inheritance and profile migration parity have not been verified.
Steps to reproduce
@cha1latte commented on GitHub (May 26, 2026):
Audit follow-up: this is chat storage/migration parity. Suggested proof should cover chat folders, branch/folder inheritance, reload, profile export/import, and legacy/default paths that could drop folder assignment.
@Romuromylus commented on GitHub (May 27, 2026):
Audit results against
refactorate6c033de(current HEAD):Verified preserved (no parity gap)
branch_chat(Rust) atsrc-tauri/src/commands/storage/chats.rs:474-498clones the full source chat row and only mutatesid,name,groupIdbefore callingstate.storage.create("chats", chat).folderIdcarries through. This is the equivalent of the v1.6.x fix in #363.src-tauri/src/commands/storage/profile.rs:19-54lists both"chats"and"chat-folders"inPROFILE_COLLECTIONS. Rows are exported verbatim with no field stripping.src-tauri/src/commands/storage/profile.rs:167-194reads each collection's rows as-is and callsnormalize_profile_json_fields.normalize_typed_json_fieldsfor"chats"(shared.rs:160-172) only validates the shape ofcharacterIds,activeLorebookIds,activeAgentIds,activeToolIds,memories,metadata,gameState.folderIdis not listed, so it passes through unchanged.src-tauri/src/commands/storage/profile/legacy.rs:19-53maps("chat_folders", "chat-folders")and("chats", "chats").add_legacy_chat_memoriesonly injects amemoriesarray;normalize_legacy_profile_json_fieldsreuses the same non-stripping path.folderIdsurvives roundtrip.useMoveChat,useReorderChats,useUpdateChat(use-chats / use-chat-folders hooks) all use partialstorageApi.updatecalls, which preserve untouched fields.Verified parity gaps
Each of these creates a new chat row with an explicit object literal that omits
folderId. The source chat had a folder; the derived chat starts unfiled.createRoleplaySceneatsrc/engine/modes/roleplay/scene/scene-service.ts:145-156. Scene chat created from a roleplay chat in folder X ends up at root.forkRoleplaySceneatsrc/engine/modes/roleplay/scene/scene-service.ts:234-243. Cloning or converting a scene drops the folder from the source.gameApi.createGamenew-chat path atsrc/features/modes/game/api/game-api.ts:793-806. Only thechatId-reuse branch (line 782) preserves the folder via partial patch. The fresh-chat branch does not.gameApi.startNextSessionatsrc/features/modes/game/api/game-api.ts:950-968. Starting session N+1 in a campaign creates a new chat row and does not carry the previous session'sfolderId.create_chatcommand atsrc/engine/generation/connected-commands.ts:606-615. Lower severity: an agent creating a sibling chat plausibly has no folder context. Worth a deliberate decision either way.Storage layer notes (not bugs, but adjacent risks)
storage_list / create / update / deleteagainstFileStorage.with_entity_defaultsinsrc-tauri/src/commands/storage/shared.rs:328-501has no"chat-folders"branch, so folder rows write whatever shape the client sends. The client'suseCreateFolder(use-chat-folders.ts:22-29) only passesname,mode,color.sortOrderandcollapsedend up undefined on first write.useDeleteFolderonly invalidates the chats list query; nothing nullsfolderIdon chats pointing at the deleted folder. After delete, those chats reference a dangling id. UI behavior depends on whether the sidebar treats missing folder lookups as "unfiled" or as "lost". Worth a runtime check.useCreateChat(use-chats.ts:379-395) does not acceptfolderIdat all. Every chat-creation entry point starts at root; folder assignment is exclusively post-creation via drag-to-folder. If the design intent is "create in current folder when one is selected", that wiring is missing on the new-chat sidebar button and the new-from-character path.Type drift worth flagging
src/features/catalog/chats/types.tsre-declares a slimmerChatandChatFolder(missingpersonaId,promptPresetId,connectionId,connectedChatId,sortOrder,createdAt;ChatFoldermissescreatedAt/updatedAt). The canonical types insrc/engine/contracts/types/chat.tsare richer. This local copy lets a spread or copy through these hooks silently drop fields without TypeScript flagging it. Worth collapsing onto the engine types in a follow-up.Test coverage
No vitest or marinara_tests.rs case currently covers chat-folder roundtrip:
branch_chatpreservesfolderId.marinara_tests.rsdoes cover lorebook entry folder remapping (marinara_lorebook_import_remaps_nested_folders) but no chat-folder analogue.Suggested follow-ups
If the verdict is "scene and game-new-chat should inherit folder from origin", a single small PR can wire
folderId: originChat.folderId ?? nullinto the four explicit-create call sites listed above, plus add one roundtrip test inmarinara_tests.rsand one scene-creation vitest. I can pick that up as a separate issue if you want it tracked.The cascade-delete behavior on folder removal is the other path worth a runtime confirmation. If it is in fact dangling rather than reassigning to null, that is a bug independent of this audit. Happy to file separately.