[GH-ISSUE #1784] [Issue]: Prompt and chat settings preset parity regressions in refactor #867

Closed
opened 2026-10-21 05:22:37 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Xelvanis on GitHub (Jun 1, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1784

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Static parity audit found several preset regressions in the refactor branch versus the legacy package implementation. The highest-risk items are shallow prompt preset duplicate/delete behavior, changed runtime prompt preset precedence, and broken chat-settings preset import/export envelope handling.

Expected behavior

Prompt presets should preserve legacy-compatible workflows:

  • Duplicating a prompt preset should copy its prompt groups, prompt sections, preset variables, and remap section/group order to the new child IDs.
  • Deleting a prompt preset should remove its owned prompt groups, prompt sections, and preset variables.
  • Runtime prompt preset selection should honor explicit request/connection overrides before falling back to the chat preset, matching legacy behavior unless there is a documented product decision.
  • Chat-settings preset import/export should round-trip a marinara_chat_preset envelope and sanitize/import it through the preset contract.
  • Default chat-settings presets should remain protected from delete/update paths, with active preset fallback handled in storage logic.

Actual behavior

Refactor evidence from static inspection:

  • src/features/catalog/presets/hooks/use-presets.ts calls generic storageCommandsApi.duplicate("prompts", id) for prompt preset duplication.
  • src-tauri/src/commands/storage/shared.rs generic duplicate_record only copies the root record and does not copy/remap prompt child records.
  • src-tauri/src/commands/storage/commands/entities.rs generic delete only has special child cleanup for lorebooks, not prompt presets.
  • src/engine/generation/prompt-preset-selection.ts currently orders candidates as impersonate, chat, request, connection, and only allows connection overrides for roleplay.
  • Legacy packages/server/src/routes/generate/prompt-preset-selection.ts ordered candidates as impersonate, request, connection, chat, and allowed roleplay plus visual_novel.
  • src/features/modes/shared/chat-ui/components/ChatSettingsDrawer.tsx exports the raw selected chat preset JSON instead of a marinara_chat_preset envelope.
  • src/features/catalog/chat-presets/hooks/use-chat-presets.ts imports chat presets with raw storageApi.create("chat-presets", envelope), while legacy parsed and sanitized the envelope through the chat preset route/storage contract.

Steps to reproduce

  1. In refactor, duplicate a prompt preset that contains groups, sections, and preset variables.
  2. Open the duplicated preset.
  3. Observe that only the root prompt preset record is copied; child prompt groups/sections/variables are not remapped/copied.
  4. Delete a prompt preset with owned children.
  5. Inspect prompt-groups, prompt-sections, and prompt-variables for rows still pointing at the deleted presetId.
  6. Compare generation candidate selection with an explicit request preset or connection preset and a chat-level preset present.
  7. Export a chat-settings preset and try to import the resulting file through the same chat-settings preset import path.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: refactor lineage, inspected from a branch based on origin/refactor
  • Run mode: not run; static parity audit only
  • OS + version: not collected
  • Node + pnpm versions: not collected
  • Rust version, if relevant: not collected
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: not relevant

Logs, screenshots, or video

No runtime logs or screenshots. Evidence is static code comparison against the legacy package implementation.

Regression notes

Legacy reference points:

  • packages/server/src/services/storage/prompts.storage.ts had prompt-aware duplicate, remove, setDefault, child reorder, and child copy/remap logic.
  • packages/server/src/routes/generate/prompt-preset-selection.ts used request and connection prompt preset overrides before chat fallback.
  • packages/server/src/routes/chat-presets.routes.ts exported/imported marinara_chat_preset envelopes.
  • packages/server/src/services/storage/chat-presets.storage.ts protected default chat presets and handled active fallback after deletion.

Additional context

Suggested repair order:

  1. Add prompt-specific duplicate/delete commands in Tauri storage: copy/remap groups, sections, variables, and cascade children on delete.
  2. Restore or explicitly decide prompt preset candidate precedence: impersonate, request, connection, chat.
  3. Add chat-settings preset import/export wrappers that use marinara_chat_preset envelopes.
  4. Add focused storage/runtime proof for duplicate/delete and candidate ordering.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Xelvanis on GitHub (Jun 1, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1784 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Static parity audit found several preset regressions in the refactor branch versus the legacy package implementation. The highest-risk items are shallow prompt preset duplicate/delete behavior, changed runtime prompt preset precedence, and broken chat-settings preset import/export envelope handling. ## Expected behavior Prompt presets should preserve legacy-compatible workflows: - Duplicating a prompt preset should copy its prompt groups, prompt sections, preset variables, and remap section/group order to the new child IDs. - Deleting a prompt preset should remove its owned prompt groups, prompt sections, and preset variables. - Runtime prompt preset selection should honor explicit request/connection overrides before falling back to the chat preset, matching legacy behavior unless there is a documented product decision. - Chat-settings preset import/export should round-trip a `marinara_chat_preset` envelope and sanitize/import it through the preset contract. - Default chat-settings presets should remain protected from delete/update paths, with active preset fallback handled in storage logic. ## Actual behavior Refactor evidence from static inspection: - `src/features/catalog/presets/hooks/use-presets.ts` calls generic `storageCommandsApi.duplicate("prompts", id)` for prompt preset duplication. - `src-tauri/src/commands/storage/shared.rs` generic `duplicate_record` only copies the root record and does not copy/remap prompt child records. - `src-tauri/src/commands/storage/commands/entities.rs` generic delete only has special child cleanup for lorebooks, not prompt presets. - `src/engine/generation/prompt-preset-selection.ts` currently orders candidates as impersonate, chat, request, connection, and only allows connection overrides for `roleplay`. - Legacy `packages/server/src/routes/generate/prompt-preset-selection.ts` ordered candidates as impersonate, request, connection, chat, and allowed `roleplay` plus `visual_novel`. - `src/features/modes/shared/chat-ui/components/ChatSettingsDrawer.tsx` exports the raw selected chat preset JSON instead of a `marinara_chat_preset` envelope. - `src/features/catalog/chat-presets/hooks/use-chat-presets.ts` imports chat presets with raw `storageApi.create("chat-presets", envelope)`, while legacy parsed and sanitized the envelope through the chat preset route/storage contract. ## Steps to reproduce 1. In refactor, duplicate a prompt preset that contains groups, sections, and preset variables. 2. Open the duplicated preset. 3. Observe that only the root prompt preset record is copied; child prompt groups/sections/variables are not remapped/copied. 4. Delete a prompt preset with owned children. 5. Inspect `prompt-groups`, `prompt-sections`, and `prompt-variables` for rows still pointing at the deleted `presetId`. 6. Compare generation candidate selection with an explicit request preset or connection preset and a chat-level preset present. 7. Export a chat-settings preset and try to import the resulting file through the same chat-settings preset import path. ## Impact area - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [ ] Chat mode - [ ] Roleplay mode - [ ] Game mode - [ ] Shared mode UI - [ ] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [ ] React-free engine behavior, contracts, agents, or capability ports - [ ] Shared API wrapper or remote runtime routing - [ ] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: `refactor` lineage, inspected from a branch based on `origin/refactor` - Run mode: not run; static parity audit only - OS + version: not collected - Node + pnpm versions: not collected - Rust version, if relevant: not collected - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: not relevant ## Logs, screenshots, or video No runtime logs or screenshots. Evidence is static code comparison against the legacy package implementation. ## Regression notes Legacy reference points: - `packages/server/src/services/storage/prompts.storage.ts` had prompt-aware `duplicate`, `remove`, `setDefault`, child reorder, and child copy/remap logic. - `packages/server/src/routes/generate/prompt-preset-selection.ts` used request and connection prompt preset overrides before chat fallback. - `packages/server/src/routes/chat-presets.routes.ts` exported/imported `marinara_chat_preset` envelopes. - `packages/server/src/services/storage/chat-presets.storage.ts` protected default chat presets and handled active fallback after deletion. ## Additional context Suggested repair order: 1. Add prompt-specific duplicate/delete commands in Tauri storage: copy/remap groups, sections, variables, and cascade children on delete. 2. Restore or explicitly decide prompt preset candidate precedence: impersonate, request, connection, chat. 3. Add chat-settings preset import/export wrappers that use `marinara_chat_preset` envelopes. 4. Add focused storage/runtime proof for duplicate/delete and candidate ordering. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:22:37 +07:00
Author
Owner

@Xelvanis commented on GitHub (Jun 1, 2026):

Additional chat-settings preset parity findings

A focused chat-presets pass found a few issues not fully captured above:

Confirmed regressions

  • Save As can clone default/active flags. Refactor duplicate path calls generic storage_duplicate; src-tauri/src/commands/storage/shared.rs duplicate_record only removes id and preserves isDefault / isActive / aliases. Legacy packages/server/src/services/storage/chat-presets.storage.ts always inserted duplicates with isDefault: "false" and isActive: "false".
  • Applying a preset merges instead of replacing preset-owned state. Refactor src/features/catalog/chat-presets/hooks/use-chat-presets.ts builds a chat patch from current metadata plus preset metadata and only changes connectionId / promptPresetId when those keys exist. This means applying the Default preset {} cannot reset old connection, prompt preset, tools, agents, translation, memory, or advanced flags. Legacy packages/server/src/services/storage/chat-presets.storage.ts rebuilt metadata from base defaults + preset metadata + preserved chat-owned fields, so preset-owned settings were cleared/reset.
  • Raw chat-preset import can replace existing rows. Refactor useImportChatPreset calls storageApi.create("chat-presets", envelope) and export writes the raw selected row from ChatSettingsDrawer.tsx. FileStorage.create preserves a supplied id and replaces any existing same-ID row. Legacy import expected a marinara_chat_preset envelope and created a new inactive, non-default preset.

Likely parity gap

  • Legacy profile import may keep chat preset settings as a JSON string. Refactor maps legacy chat_presets to chat-presets, but typed normalization only parses parameters for that collection, not settings. Client sanitizer expects object settings. Legacy storage parsed row settings before returning a preset.

Suggested split/repair order

  1. Add a focused chat-preset storage/API path instead of using generic create/update/delete/duplicate directly.
  2. Export/import only marinara_chat_preset envelopes and always mint a new inactive non-default row.
  3. Make apply replace preset-owned settings while preserving only chat-owned metadata keys.
  4. Normalize legacy/imported settings objects and protect default chat presets below the UI layer.

Evidence is static code comparison only; no runtime reproduction was run.

<!-- gh-comment-id:4590885857 --> @Xelvanis commented on GitHub (Jun 1, 2026): ## Additional chat-settings preset parity findings A focused chat-presets pass found a few issues not fully captured above: ### Confirmed regressions - Save As can clone default/active flags. Refactor duplicate path calls generic `storage_duplicate`; `src-tauri/src/commands/storage/shared.rs` `duplicate_record` only removes `id` and preserves `isDefault` / `isActive` / aliases. Legacy `packages/server/src/services/storage/chat-presets.storage.ts` always inserted duplicates with `isDefault: "false"` and `isActive: "false"`. - Applying a preset merges instead of replacing preset-owned state. Refactor `src/features/catalog/chat-presets/hooks/use-chat-presets.ts` builds a chat patch from current metadata plus preset metadata and only changes `connectionId` / `promptPresetId` when those keys exist. This means applying the Default preset `{}` cannot reset old connection, prompt preset, tools, agents, translation, memory, or advanced flags. Legacy `packages/server/src/services/storage/chat-presets.storage.ts` rebuilt metadata from base defaults + preset metadata + preserved chat-owned fields, so preset-owned settings were cleared/reset. - Raw chat-preset import can replace existing rows. Refactor `useImportChatPreset` calls `storageApi.create("chat-presets", envelope)` and export writes the raw selected row from `ChatSettingsDrawer.tsx`. `FileStorage.create` preserves a supplied `id` and replaces any existing same-ID row. Legacy import expected a `marinara_chat_preset` envelope and created a new inactive, non-default preset. ### Likely parity gap - Legacy profile import may keep chat preset `settings` as a JSON string. Refactor maps legacy `chat_presets` to `chat-presets`, but typed normalization only parses `parameters` for that collection, not `settings`. Client sanitizer expects object settings. Legacy storage parsed row `settings` before returning a preset. ### Suggested split/repair order 1. Add a focused chat-preset storage/API path instead of using generic create/update/delete/duplicate directly. 2. Export/import only `marinara_chat_preset` envelopes and always mint a new inactive non-default row. 3. Make apply replace preset-owned settings while preserving only chat-owned metadata keys. 4. Normalize legacy/imported `settings` objects and protect default chat presets below the UI layer. Evidence is static code comparison only; no runtime reproduction was run.
Author
Owner

@SpicyMarinara commented on GitHub (Jun 1, 2026):

Fixed on refactor in 37bb88aa.\n\nWhat changed:\n- Prompt preset runtime precedence now matches legacy: impersonate, request, connection for roleplay/visual novel, then chat.\n- Prompt preset duplicate/delete now deep-copies/remaps groups, sections, variables, and cascades children on delete.\n- Chat preset export/import now uses the marinara_chat_preset envelope and sanitizes imported settings.\n- Chat preset apply now replaces preset-owned state with defaults + preset metadata while preserving chat-owned scene/runtime fields.\n- Default chat presets are protected from delete/update, and active deletion falls back to the mode default.\n- Legacy JSON-string settings are normalized for chat presets.\n\nVerification:\n- pnpm typecheck\n- pnpm check:architecture\n- cargo check --manifest-path src-tauri/Cargo.toml\n- git diff --check HEAD~1..HEAD

<!-- gh-comment-id:4591883548 --> @SpicyMarinara commented on GitHub (Jun 1, 2026): Fixed on refactor in 37bb88aa.\n\nWhat changed:\n- Prompt preset runtime precedence now matches legacy: impersonate, request, connection for roleplay/visual novel, then chat.\n- Prompt preset duplicate/delete now deep-copies/remaps groups, sections, variables, and cascades children on delete.\n- Chat preset export/import now uses the marinara_chat_preset envelope and sanitizes imported settings.\n- Chat preset apply now replaces preset-owned state with defaults + preset metadata while preserving chat-owned scene/runtime fields.\n- Default chat presets are protected from delete/update, and active deletion falls back to the mode default.\n- Legacy JSON-string settings are normalized for chat presets.\n\nVerification:\n- pnpm typecheck\n- pnpm check:architecture\n- cargo check --manifest-path src-tauri/Cargo.toml\n- git diff --check HEAD~1..HEAD
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#867
No description provided.