[PR #2310] [MERGED] Fix chat folder storage semantics #5530

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2310
Author: @Promansis
Created: 6/5/2026
Status: ✅ Merged
Merged: 6/5/2026
Merged by: @Promansis

Base: refactor ← Head: fix/issue-2271-chat-folder-storage-semantics


📝 Commits (1)

  • eeeaf8c Fix chat folder storage semantics

📊 Changes

3 files changed (+1138 additions, -6 deletions)

View changed files

📝 src-tauri/src/commands/storage/commands/entities.rs (+1126 -3)
📝 src-tauri/src/commands/storage/contracts.rs (+7 -3)
📝 src-tauri/src/commands/storage/shared.rs (+5 -0)

📄 Description

Linked issue

Closes #2271

Why this change

Chat folder storage paths could create invalid durable state: folder order writes were split from folder creation, chat-folder assignments only checked existence, mode aliases could persist non-canonically, folder mode updates could bypass compatibility, and folder deletion cleaned child chats after parent removal.

What changed

  • Adds chat-folder defaults for name, mode, collapsed state, and top insertion order.
  • Creates chat folders through one atomic collection update that shifts existing folder order and inserts the new folder together.
  • Validates chat folderId assignments against the target folder's canonical mode on create and update, including folder-only patches and simultaneous mode/folderId patches.
  • Allows explicit chat unfiling without requiring legacy malformed chats to have a valid mode.
  • Canonicalizes accepted legacy chat and chat-folder mode aliases before they persist.
  • Trims accepted chat folderId values before persisting create and patch bodies.
  • Applies chat-folder name trim/nonempty validation on patch as well as create.
  • Validates chat-folder mode patches and rejects changes while incompatible filed chats remain in the folder.
  • Deletes chat folders and unfiles child chats in one atomic storage transition.

Refactor impact

Primary owner:

Rust storage

Impact areas reviewed:

  • Generic storage create/update/delete commands for chats and chat-folders
  • Chat folder order fields: sortOrder and order
  • Chat folder referential cleanup for child chats
  • Existing connection-folder and lorebook-folder storage cleanup patterns

Boundary notes:

  • Rust-only storage contract repair in src-tauri; no React, engine, shared API, or remote-runtime boundary changes.

Pressure points touched:

  • Generic Tauri storage commands in src-tauri/src/commands/storage/commands/entities.rs
  • Storage collection contracts in src-tauri/src/commands/storage/contracts.rs
  • Storage defaults in src-tauri/src/commands/storage/shared.rs

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • cargo test --manifest-path src-tauri/Cargo.toml chat_folder
  • cargo test --manifest-path src-tauri/Cargo.toml chat_folder_id_create_and_patch_persist_trimmed_reference
  • cargo test --manifest-path src-tauri/Cargo.toml chat_folder_name_patch_trims_and_rejects_blank_names
  • cargo test --manifest-path src-tauri/Cargo.toml legacy_no_mode
  • cargo test --manifest-path src-tauri/Cargo.toml filed_chat_alias_mode_create_and_patch_persist_canonical_mode
  • cargo test --manifest-path src-tauri/Cargo.toml moving_chat
  • cargo test --manifest-path src-tauri/Cargo.toml creating_chat_rejects_folder_from_another_mode
  • cargo test --manifest-path src-tauri/Cargo.toml updating_chat_mode_and_folder_validates_post_patch_pair
  • cargo check --manifest-path src-tauri/Cargo.toml
  • pnpm check

Feature Discoverability

Check exactly one:

  • Updated src/features/shell/discovery/ because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.
  • N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find.

Reason:

Storage contract repair only; no new user-discoverable feature or workflow.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

UI evidence

No visible UI changes; storage command behavior only.


🔄 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/2310 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 6/5/2026 **Status:** ✅ Merged **Merged:** 6/5/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `refactor` ← **Head:** `fix/issue-2271-chat-folder-storage-semantics` --- ### 📝 Commits (1) - [`eeeaf8c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/eeeaf8c06fc5f3c194e4a931c06202a0a4419829) Fix chat folder storage semantics ### 📊 Changes **3 files changed** (+1138 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/commands/entities.rs` (+1126 -3) 📝 `src-tauri/src/commands/storage/contracts.rs` (+7 -3) 📝 `src-tauri/src/commands/storage/shared.rs` (+5 -0) </details> ### 📄 Description ## Linked issue Closes #2271 ## Why this change Chat folder storage paths could create invalid durable state: folder order writes were split from folder creation, chat-folder assignments only checked existence, mode aliases could persist non-canonically, folder mode updates could bypass compatibility, and folder deletion cleaned child chats after parent removal. ## What changed - Adds chat-folder defaults for name, mode, collapsed state, and top insertion order. - Creates chat folders through one atomic collection update that shifts existing folder order and inserts the new folder together. - Validates chat `folderId` assignments against the target folder's canonical mode on create and update, including folder-only patches and simultaneous `mode`/`folderId` patches. - Allows explicit chat unfiling without requiring legacy malformed chats to have a valid mode. - Canonicalizes accepted legacy chat and chat-folder mode aliases before they persist. - Trims accepted chat `folderId` values before persisting create and patch bodies. - Applies chat-folder name trim/nonempty validation on patch as well as create. - Validates chat-folder mode patches and rejects changes while incompatible filed chats remain in the folder. - Deletes chat folders and unfiles child chats in one atomic storage transition. ## Refactor impact Primary owner: Rust storage Impact areas reviewed: - Generic storage create/update/delete commands for `chats` and `chat-folders` - Chat folder order fields: `sortOrder` and `order` - Chat folder referential cleanup for child chats - Existing connection-folder and lorebook-folder storage cleanup patterns Boundary notes: - Rust-only storage contract repair in `src-tauri`; no React, engine, shared API, or remote-runtime boundary changes. Pressure points touched: - Generic Tauri storage commands in `src-tauri/src/commands/storage/commands/entities.rs` - Storage collection contracts in `src-tauri/src/commands/storage/contracts.rs` - Storage defaults in `src-tauri/src/commands/storage/shared.rs` ## Validation - [ ] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [ ] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - `cargo test --manifest-path src-tauri/Cargo.toml chat_folder` - `cargo test --manifest-path src-tauri/Cargo.toml chat_folder_id_create_and_patch_persist_trimmed_reference` - `cargo test --manifest-path src-tauri/Cargo.toml chat_folder_name_patch_trims_and_rejects_blank_names` - `cargo test --manifest-path src-tauri/Cargo.toml legacy_no_mode` - `cargo test --manifest-path src-tauri/Cargo.toml filed_chat_alias_mode_create_and_patch_persist_canonical_mode` - `cargo test --manifest-path src-tauri/Cargo.toml moving_chat` - `cargo test --manifest-path src-tauri/Cargo.toml creating_chat_rejects_folder_from_another_mode` - `cargo test --manifest-path src-tauri/Cargo.toml updating_chat_mode_and_folder_validates_post_patch_pair` - `cargo check --manifest-path src-tauri/Cargo.toml` - `pnpm check` ## Feature Discoverability Check exactly one: - [ ] Updated `src/features/shell/discovery/` because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool. - [ ] N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find. Reason: Storage contract repair only; no new user-discoverable feature or workflow. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [ ] Confirmed this PR does not restore old staging/package-workspace/release claims ## UI evidence No visible UI changes; storage command behavior only. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:17:06 +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#5530
No description provided.