[GH-ISSUE #3025] [Issue]: Duplicating a preset drops defaultChoices, so the copy uses wrong choice-variable defaults #1594

Closed
opened 2026-10-21 05:40:22 +07:00 by bsakaguchi · 1 comment
Owner

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

Originally assigned to: @SpicyMarinara on GitHub.

What's wrong
Duplicating a preset (POST /api/prompts/:id/duplicate) copies its prompts, sections, groups, and choice blocks but not the source preset's defaultChoices. The copy is created with the DB default "{}", so when it is used as an override preset (or when its choice-selection modal pre-fills), choice variables fall back to each block's FIRST option, producing a different assembled prompt than the original whenever a saved default was not the first option.

How to reproduce (try it yourself)

  1. With the bundled "Marinara's Universal Preset" (populated defaultChoices), call POST /api/prompts/:id/duplicate.
  2. Inspect the copy's defaultChoices (it is "{}").
  3. Use the copy as an override preset on a chat (a different preset than the chat's own) and generate, or open its Choice Selection modal.

You'll see: choice macros resolve to first options instead of the original saved defaults, changing the prompt sent to the model.
Expected: the duplicate carries the source preset's defaultChoices.

(Note: plain generation with the copy as the chat's ACTIVE preset and no per-chat choices does NOT reproduce — that path reads per-chat presetChoices, not the preset's defaultChoices. The bug surfaces via the preset-override path and the modal pre-fill.)

Where it is
packages/server/src/services/storage/prompts.storage.ts — duplicate() (128-211): the create() call (131-141) omits defaultChoices, and the final update() at line 208 passes only sectionOrder/groupOrder. update() already supports the key at lines 111-112. Impact paths: generate.routes.ts:1816-1822, dry-run-route.ts:829-837, assembler fallback assembler.ts:276-279, client ChoiceSelectionModal.tsx:142-146,187.

What's happening
duplicate() never reads or writes the source's defaultChoices. create() doesn't accept it, and the trailing update() only carries the order arrays, so the source's saved defaults are never propagated.

Suggested fix
Carry defaultChoices into the copy in the final update() at packages/server/src/services/storage/prompts.storage.ts:208:

await this.update(newPreset.id, {
  sectionOrder: newSectionOrder,
  groupOrder: newGroupOrder,
  defaultChoices: JSON.parse((preset.defaultChoices as string) || "{}"),
});

create() cannot accept defaultChoices, so this trailing update() is the only place to propagate it. The column is notNull().default("{}"), so preset.defaultChoices is always a string and the parse is safe; update() re-stringifies it once (lines 111-112).

Related: a sibling issue covers the same defaultChoices-dropped bug on the preset IMPORT path (marinara.importer.ts importPreset()) — same root-cause shape.


AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.

Originally created by @kolacheee on GitHub (Jun 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3025 Originally assigned to: @SpicyMarinara on GitHub. **What's wrong** Duplicating a preset (`POST /api/prompts/:id/duplicate`) copies its prompts, sections, groups, and choice blocks but not the source preset's `defaultChoices`. The copy is created with the DB default `"{}"`, so when it is used as an override preset (or when its choice-selection modal pre-fills), choice variables fall back to each block's FIRST option, producing a different assembled prompt than the original whenever a saved default was not the first option. **How to reproduce (try it yourself)** 1. With the bundled "Marinara's Universal Preset" (populated `defaultChoices`), call `POST /api/prompts/:id/duplicate`. 2. Inspect the copy's `defaultChoices` (it is `"{}"`). 3. Use the copy as an override preset on a chat (a different preset than the chat's own) and generate, or open its Choice Selection modal. You'll see: choice macros resolve to first options instead of the original saved defaults, changing the prompt sent to the model. Expected: the duplicate carries the source preset's `defaultChoices`. (Note: plain generation with the copy as the chat's ACTIVE preset and no per-chat choices does NOT reproduce — that path reads per-chat `presetChoices`, not the preset's `defaultChoices`. The bug surfaces via the preset-override path and the modal pre-fill.) **Where it is** `packages/server/src/services/storage/prompts.storage.ts` — `duplicate()` (128-211): the `create()` call (131-141) omits `defaultChoices`, and the final `update()` at line 208 passes only `sectionOrder`/`groupOrder`. `update()` already supports the key at lines 111-112. Impact paths: `generate.routes.ts:1816-1822`, `dry-run-route.ts:829-837`, assembler fallback `assembler.ts:276-279`, client `ChoiceSelectionModal.tsx:142-146,187`. **What's happening** `duplicate()` never reads or writes the source's `defaultChoices`. `create()` doesn't accept it, and the trailing `update()` only carries the order arrays, so the source's saved defaults are never propagated. **Suggested fix** Carry `defaultChoices` into the copy in the final `update()` at `packages/server/src/services/storage/prompts.storage.ts:208`: ```ts await this.update(newPreset.id, { sectionOrder: newSectionOrder, groupOrder: newGroupOrder, defaultChoices: JSON.parse((preset.defaultChoices as string) || "{}"), }); ``` `create()` cannot accept `defaultChoices`, so this trailing `update()` is the only place to propagate it. The column is `notNull().default("{}")`, so `preset.defaultChoices` is always a string and the parse is safe; `update()` re-stringifies it once (lines 111-112). *Related: a sibling issue covers the same `defaultChoices`-dropped bug on the preset IMPORT path (`marinara.importer.ts` `importPreset()`) — same root-cause shape.* --- *AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.*
Author
Owner

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

Fixed on staging in PR #3031 (merged as f542e282). Closing manually because GitHub auto-close keywords only close issues when merged into the default branch (main), not staging.

<!-- gh-comment-id:4834696786 --> @SpicyMarinara commented on GitHub (Jun 29, 2026): Fixed on staging in PR #3031 (merged as f542e282). Closing manually because GitHub auto-close keywords only close issues when merged into the default branch (main), not staging.
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#1594
No description provided.