mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #1406] [MERGED] Inherit folder assignment when creating derived chats #5073
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#5073
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/1406
Author: @Romuromylus
Created: 5/27/2026
Status: ✅ Merged
Merged: 5/27/2026
Merged by: @Romuromylus
Base:
refactor← Head:fix/refactor-issue-1344-folder-inheritance📝 Commits (5)
4b08599Inherit folder assignment when creating derived chats588b244Add test coverage for the three uncovered fix sites3edd771Merge branch 'refactor' into fix/refactor-issue-1344-folder-inheritancec91d75fMerge branch 'refactor' into fix/refactor-issue-1344-folder-inheritancec2d149cMerge branch 'refactor' into fix/refactor-issue-1344-folder-inheritance📊 Changes
5 files changed (+445 additions, -0 deletions)
View changed files
📝
src-tauri/src/commands/storage/profile/legacy.rs(+56 -0)➕
src/engine/modes/roleplay/scene/scene-service.test.ts(+239 -0)📝
src/engine/modes/roleplay/scene/scene-service.ts(+2 -0)➕
src/features/modes/game/api/game-api.test.ts(+145 -0)📝
src/features/modes/game/api/game-api.ts(+3 -0)📄 Description
Why this change
Issue #1344 asked for chat-folder parity verification against v1.6.0/v1.6.1. The audit (see issue comment) found four call sites where a derived chat is built from an explicit object literal that omits
folderId. Result: a chat in folder X spawns a derived chat at root instead of staying in the same folder.Affected paths:
createRoleplayScene) from a chat inside a folder.forkRoleplayScene) from a scene chat inside a folder, both clone and convert modes.gameApi.createGame) when the UI does not reuse an existing chat id.gameApi.startSession) carrying over from the previous session in a folder.Storage-layer paths (native and v1.6.x legacy profile import,
branch_chatin Rust) already preservefolderIdcorrectly, those need no change. This PR is scoped to the four engine and feature paths where the create payload was the bug.What changed
src/engine/modes/roleplay/scene/scene-service.ts:150—createRoleplayScenenow passesfolderId: originChat.folderId ?? nullinto the new chat's create payload.src/engine/modes/roleplay/scene/scene-service.ts:240—forkRoleplayScenepropagatesfolderId: sceneChat.folderId ?? nullfor both clone and convert modes.src/features/modes/game/api/game-api.ts:778, 799—gameApi.createGamegains an optionalfolderIdinput and the new-chat branch passesfolderId: data.folderId ?? nullthrough. The existing-chat-id branch was already correct via partial patch and is unchanged.src/features/modes/game/api/game-api.ts:958—gameApi.startSessioncarriesfolderId: previousChat?.folderId ?? nullforward.src/engine/modes/roleplay/scene/scene-service.test.ts— vitest covering scene create, fork-clone, and fork-convert folder inheritance (4 cases, including a null-origin sanity check).src/features/modes/game/api/game-api.test.ts— new vitest coveringcreateGamenew-chat folderId propagation,createGamenull-default behavior, andstartSessionpreviousChat folderId carryover (3 cases).src-tauri/src/commands/storage/profile/legacy.rs— newlegacy_chat_import_preserves_folder_assignmenttest asserts a v1.6.x profile import preserves the chat's folder assignment across the legacy table roundtrip.The
?? nullnormalization is for legacy chats predating the field; engineChat.folderIdisstring | nullbut rows from older user data can surface the field asundefined.Verification
pnpm checkclean locally (architecture + tsc -b + cargo check + docs).cargo clippy --workspace --all-targets -- -D warningsclean (CI parity for the test-arg signature check).scene-service.test.tscases pass, all 3 newgame-api.test.tscases pass. Full vitest suite stays green.cargo test --workspacepasses apart from one pre-existing environmental flake (crates/assetssymlink test requires admin on Windows; unrelated to this PR).createRoleplayScenethrough the livepnpm tauri devwindow via Playwright over WebView2 CDP (port 9223). Seeded a chat folder + a roleplay chat in that folder via realstorage_createinvokes, calledcreateRoleplaySceneagainst the dynamically-imported engine module from the page context, then asserted the new scene chat'sfolderIdmatched the seeded folder id viastorage_get. PASS. Confirms the fix line atscene-service.ts:150round-trips correctly through the real Rust storage layer.Follow-ups (deferred, not blocking this PR)
gameApi.createGamenow accepts an optionalfolderId, but no caller passes it yet. Adding the field at the input boundary keeps the API ready without a churnful follow-up.folderId). Needs a separate Tier 1c runtime check to confirm, will file independently if reproduced.useCreateChat(the generic chat hook) does not acceptfolderIdfor "new chat into current folder" either. That is a deliberate design decision, not in scope here.create_chatslash command inconnected-commands.tsalso writes withoutfolderId. Plausibly correct (the agent has no folder context), but worth a deliberate call from upstream.Linked issue
Refs #1344
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.