[PR #2038] [MERGED] Fix native prompt preset import order remap #5401

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2038
Author: @cha1latte
Created: 6/3/2026
Status: ✅ Merged
Merged: 6/3/2026
Merged by: @cha1latte

Base: refactor ← Head: fix/issue-2000-preset-import-order


📝 Commits (1)

  • c08ba79 Fix native preset import order remap

📊 Changes

3 files changed (+185 additions, -9 deletions)

View changed files

📝 src-tauri/src/commands/storage/imports/marinara.rs (+65 -6)
📝 src-tauri/src/commands/storage/imports/marinara_rollback.rs (+3 -3)
📝 src-tauri/src/commands/storage/imports/marinara_tests.rs (+117 -0)

📄 Description

Linked issue

Closes #2000

Why this change

  • Native marinara_preset imports recreated prompt groups, sections, and variables with new IDs, but left the preset root groupOrder, sectionOrder, and variableOrder arrays pointing at exported child IDs.
  • The preset editor trusts those root order arrays, so imported prompt sections could disappear from the ordered editor view even though the child rows were created.

What changed

  • Preserve created child order from native parented-record imports so fallback order is deterministic.
  • Track old-to-new section and variable IDs during native prompt preset import.
  • Patch the created preset root with remapped groupOrder, sectionOrder, and variableOrder before flushing import writes.
  • Add a regression test covering remapped IDs, duplicate exported IDs, missing exported IDs, and fallback append order.

Refactor impact

Primary owner:

  • Rust storage/imports

Impact areas reviewed:

  • Native Marinara prompt preset import
  • Prompt group, section, and variable persistence
  • Import rollback behavior for created preset children
  • Preset editor consumer expectation that root order arrays contain persisted child IDs

Boundary notes:

  • No React/UI changes. The fix is in the producer path that saves imported preset data.
  • No shared API or remote runtime routing changes.

Pressure points touched:

  • src-tauri/src/commands/storage/imports/marinara.rs
  • src-tauri/src/commands/storage/imports/marinara_rollback.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

  • Codex reproduced the stale-order bug before the fix with:
    • cargo test --manifest-path src-tauri/Cargo.toml marinara_preset_import_remaps_root_child_order_arrays
  • Codex verified the fix with:
    • cargo test --manifest-path src-tauri/Cargo.toml marinara_preset_import_remaps_root_child_order_arrays
    • cargo test --manifest-path src-tauri/Cargo.toml marinara_preset_import
    • cargo check --manifest-path src-tauri/Cargo.toml
    • pnpm check
  • node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json passed locally.
  • Bunny review passed locally on the current diff.

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:

  • Bugfix only. It restores existing native preset import behavior and does not add a new discoverable feature.

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

N/A. This is a Rust storage/import fix; the focused test reads the saved prompt preset and child records directly.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed ordering preservation in Marinara lorebook and preset imports to ensure folder, group, section, and variable ordering is correctly maintained when mapping to newly created record IDs during import operations.
  • Tests

    • Added test coverage to verify Marinara preset imports properly remap all ordering arrays to match newly created records.

🔄 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/2038 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/3/2026 **Status:** ✅ Merged **Merged:** 6/3/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-2000-preset-import-order` --- ### 📝 Commits (1) - [`c08ba79`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c08ba79fe9ff0ec4b458e5dcfb0fbe436c81b949) Fix native preset import order remap ### 📊 Changes **3 files changed** (+185 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/imports/marinara.rs` (+65 -6) 📝 `src-tauri/src/commands/storage/imports/marinara_rollback.rs` (+3 -3) 📝 `src-tauri/src/commands/storage/imports/marinara_tests.rs` (+117 -0) </details> ### 📄 Description ## Linked issue Closes #2000 ## Why this change - Native `marinara_preset` imports recreated prompt groups, sections, and variables with new IDs, but left the preset root `groupOrder`, `sectionOrder`, and `variableOrder` arrays pointing at exported child IDs. - The preset editor trusts those root order arrays, so imported prompt sections could disappear from the ordered editor view even though the child rows were created. ## What changed - Preserve created child order from native parented-record imports so fallback order is deterministic. - Track old-to-new section and variable IDs during native prompt preset import. - Patch the created preset root with remapped `groupOrder`, `sectionOrder`, and `variableOrder` before flushing import writes. - Add a regression test covering remapped IDs, duplicate exported IDs, missing exported IDs, and fallback append order. ## Refactor impact Primary owner: - Rust storage/imports Impact areas reviewed: - Native Marinara prompt preset import - Prompt group, section, and variable persistence - Import rollback behavior for created preset children - Preset editor consumer expectation that root order arrays contain persisted child IDs Boundary notes: - No React/UI changes. The fix is in the producer path that saves imported preset data. - No shared API or remote runtime routing changes. Pressure points touched: - `src-tauri/src/commands/storage/imports/marinara.rs` - `src-tauri/src/commands/storage/imports/marinara_rollback.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 - Codex reproduced the stale-order bug before the fix with: - `cargo test --manifest-path src-tauri/Cargo.toml marinara_preset_import_remaps_root_child_order_arrays` - Codex verified the fix with: - `cargo test --manifest-path src-tauri/Cargo.toml marinara_preset_import_remaps_root_child_order_arrays` - `cargo test --manifest-path src-tauri/Cargo.toml marinara_preset_import` - `cargo check --manifest-path src-tauri/Cargo.toml` - `pnpm check` - `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json` passed locally. - Bunny review passed locally on the current diff. ## 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: - Bugfix only. It restores existing native preset import behavior and does not add a new discoverable feature. ## 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 N/A. This is a Rust storage/import fix; the focused test reads the saved prompt preset and child records directly. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed ordering preservation in Marinara lorebook and preset imports to ensure folder, group, section, and variable ordering is correctly maintained when mapping to newly created record IDs during import operations. * **Tests** * Added test coverage to verify Marinara preset imports properly remap all ordering arrays to match newly created records. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:15:59 +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#5401
No description provided.