[PR #2464] [MERGED] Fix user-message regeneration source prompt #5620

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/user-message-regeneration-source-prompt


📝 Commits (5)

  • 050e59e Fix user-message regeneration source prompt
  • 12fa5e5 Harden user regeneration source loading
  • 27ca449 Harden regeneration attachment source blocks
  • e8c193f Gate user rewrite command side effects
  • c883f2b Fence user rewrites from agent residue

📊 Changes

4 files changed (+991 additions, -132 deletions)

View changed files

📝 src/engine/generation/generate-route-utils.ts (+53 -0)
📝 src/engine/generation/prompt-assembly.ts (+72 -15)
➕ src/engine/generation/start-generation.bunny.test.ts (+611 -0)
📝 src/engine/generation/start-generation.ts (+255 -117)

📄 Description

Linked issue

Closes #2450

Why this change

  • Regenerating a user message removed the target user turn from prompt history without preserving the original source/rewrite path, so providers could continue as the assistant while the result was saved as a user swipe.

What changed

  • Added user-message regeneration source helpers that preserve original user content, readable text attachments, and image payloads without duplicating stored readable attachment blocks.
  • Fed the transformed source through prompt-only regex, latest-user macros, and lorebook scanning without replaying the target as visible chat history.
  • Appended the user-message rewrite instruction for provider-normal user-role prompts and saved/emitted regenerated user swipes as user messages.

Refactor impact

Primary owner:

  • Engine generation / runtime generation

Impact areas reviewed:

  • Prompt assembly regex, macros, lorebook scan, and semantic latest-input behavior.
  • Main and direct generation request messages plus prompt preview snapshots.
  • Regenerated swipe save/event routing for user vs assistant targets.

Boundary notes:

  • Engine-only TypeScript change; no React feature, shared API, Rust, Tauri command, or remote-runtime boundary changes.

Pressure points touched:

  • Prompt assembly and startGeneration request/save setup only; no ModeSurface, GameSurface, shared mode UI, src-tauri command registration, or import modules touched.

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

  • pnpm check
  • Focused Vitest proof was run during development before the base branch removed tracked TypeScript test files; final rebased branch validation used the current repo gate above.

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:

  • Internal generation prompt/runtime bugfix; no new user-discoverable surface.

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: engine-only prompt/runtime bugfix; no visible UI changes.


🔄 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/2464 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 6/6/2026 **Status:** ✅ Merged **Merged:** 6/6/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `fix/user-message-regeneration-source-prompt` --- ### 📝 Commits (5) - [`050e59e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/050e59e1351453e0bcafcd0895d9dcae633eb137) Fix user-message regeneration source prompt - [`12fa5e5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/12fa5e57a329703f7c61f76f0478d97ba452a3ad) Harden user regeneration source loading - [`27ca449`](https://github.com/Pasta-Devs/Marinara-Engine/commit/27ca449f1068362f14d54a2478e11242bae3e81a) Harden regeneration attachment source blocks - [`e8c193f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e8c193f6a66881a2fa170a6b25e6a2b51610af14) Gate user rewrite command side effects - [`c883f2b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c883f2b9505482b83626939c9c616c74f82a9d80) Fence user rewrites from agent residue ### 📊 Changes **4 files changed** (+991 additions, -132 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/generation/generate-route-utils.ts` (+53 -0) 📝 `src/engine/generation/prompt-assembly.ts` (+72 -15) ➕ `src/engine/generation/start-generation.bunny.test.ts` (+611 -0) 📝 `src/engine/generation/start-generation.ts` (+255 -117) </details> ### 📄 Description ## Linked issue Closes #2450 ## Why this change - Regenerating a user message removed the target user turn from prompt history without preserving the original source/rewrite path, so providers could continue as the assistant while the result was saved as a user swipe. ## What changed - Added user-message regeneration source helpers that preserve original user content, readable text attachments, and image payloads without duplicating stored readable attachment blocks. - Fed the transformed source through prompt-only regex, latest-user macros, and lorebook scanning without replaying the target as visible chat history. - Appended the user-message rewrite instruction for provider-normal user-role prompts and saved/emitted regenerated user swipes as user messages. ## Refactor impact Primary owner: - Engine generation / runtime generation Impact areas reviewed: - Prompt assembly regex, macros, lorebook scan, and semantic latest-input behavior. - Main and direct generation request messages plus prompt preview snapshots. - Regenerated swipe save/event routing for user vs assistant targets. Boundary notes: - Engine-only TypeScript change; no React feature, shared API, Rust, Tauri command, or remote-runtime boundary changes. Pressure points touched: - Prompt assembly and startGeneration request/save setup only; no ModeSurface, GameSurface, shared mode UI, src-tauri command registration, or import modules touched. ## Validation - [x] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [x] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - `pnpm check` - Focused Vitest proof was run during development before the base branch removed tracked TypeScript test files; final rebased branch validation used the current repo gate above. ## 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. - [x] 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: - Internal generation prompt/runtime bugfix; no new user-discoverable surface. ## Docs and release impact - [x] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [x] Confirmed this PR does not restore old staging/package-workspace/release claims ## UI evidence N/A: engine-only prompt/runtime bugfix; no visible UI changes. --- <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:52 +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#5620
No description provided.