[PR #1463] [MERGED] Fix/prompt assembly format and peek prompt (Issue #1461) #5102

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/prompt-assembly-format


📝 Commits (5)

  • 3b9671d strictRoleFormatting no longer writes only system+user for output
  • 2a5a42c prompt assembly matches flags of ordered parameter sources with the final LLM request
  • a16a41b Fix: Peek Prompt now gets a preview-specific message
  • 4da5142 system messages remain separate history entries instead of being folded into the merged prompt scaffold
  • f7de50b Centralise peek prompt logic.

📊 Changes

16 files changed (+4244 additions, -3188 deletions)

View changed files

📝 graphify-out/.graphify_labels.json (+15 -0)
📝 graphify-out/GRAPH_REPORT.md (+309 -238)
➕ graphify-out/cache/ast/ddd6593e644d342540e3cc7074cacd7e4e84e8a77f545e7efec11a219e127a1d.json (+1 -0)
📝 graphify-out/cache/stat-index.json (+1 -1)
📝 graphify-out/graph.json (+2491 -1699)
📝 graphify-out/manifest.json (+1175 -1165)
📝 src/engine/contracts/types/prompt.ts (+3 -1)
📝 src/engine/generation/context.ts (+4 -13)
📝 src/engine/generation/generate-route-utils.ts (+20 -1)
📝 src/engine/generation/prompt-assembly.test.ts (+88 -4)
📝 src/engine/generation/prompt-assembly.ts (+37 -29)
📝 src/engine/generation/prompt-preview.ts (+18 -3)
📝 src/engine/generation/start-generation.test.ts (+61 -0)
📝 src/features/catalog/chats/hooks/use-chats.ts (+8 -24)
📝 src/features/modes/shared/chat-ui/components/PeekPromptModal.tsx (+11 -9)
📝 src/features/modes/shared/chat-ui/types.ts (+2 -1)

📄 Description

Linked issue

#1461

Why this change

  • Peek Prompt was showing the post-formatting request shape instead of a preview-friendly breakdown of the authored prompt sections, which made strict-role/single-user formatting hard to inspect.
  • Prompt assembly and the final LLM request could read different merged generation parameter sources, so formatting flags like strictRoleFormatting and singleUserMessage were not guaranteed to affect both paths the same way.
  • Strict role formatting flattened later authored system sections into user-side content, hiding output-format sections that should remain system-authored.

What changed

  • Shared the generation parameter source ordering between prompt assembly, preview, and final request parameter resolution.
  • Added preview-only prompt messages with section display names so Peek Prompt can show authored prompt sections while the LLM still receives the final formatted message list.
  • Updated strict role formatting to merge only leading system prompt content, preserve later system sections, and keep history alternation behavior intact.
  • Passed preview request choices/parameters through the prompt preview path so Peek Prompt matches the selected preset variables and connection/request context.
  • Added prompt assembly and start-generation coverage for merged formatting flags and post-history system sections.
  • Included related branch fixes for swipe navigation responsiveness, next-retry generation from swipe controls, sprite overlay/expression avatar memoization, Tauri dev inspection, and stable Graphify output refreshes.

Refactor impact

Primary owner:

Engine generation, shared chat UI, chat storage/swipe runtime, Tauri dev tooling, Graphify tooling.

Impact areas reviewed:

  • Prompt assembly, prompt preview, start-generation request assembly, and generation parameter merging.
  • Roleplay strict-role formatting, chat history placement, and output-format sections.
  • Peek Prompt display section parsing and shared chat timeline action wiring.
  • Swipe controls in shared chat UI and conversation UI.
  • Chat storage active-swipe command response shape and optimistic cache updates.
  • Sprite overlay/expression avatar update paths.
  • Graphify generated map output and portable path/hash patching.

Boundary notes:

  • Engine generation owns the prompt assembly contract and now exposes previewMessages separately from final LLM messages.
  • Feature UI consumes preview metadata through existing runtime hooks/wrappers; no new raw Tauri or raw remote-runtime fetch path was added for prompt preview.
  • Rust storage changes stay inside chat storage command handling for active swipe updates.
  • Tauri dev-inspection changes are debug/dev-only runtime wrapper behavior.
  • Graphify changes are generated/tooling artifacts and do not affect product runtime behavior.

Pressure points touched:

  • Shared mode UI: PeekPromptModal, ChatMessage, SwipeJumpControl, and use-chat-timeline-actions.
  • Conversation and roleplay mode message surfaces.
  • src-tauri/src/lib.rs debug setup hook for auto devtools.
  • Chat storage command facade for chat_message_set_active_swipe.
  • Graphify generated output and portable path patch script.

Validation

  • pnpm check passes locally
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Playwright, screenshot, or recording evidence added for UI changes
  • Remote runtime smoke checked when relevant

Manual verification notes

  • Not rerun while filling out this template.
  • Branch includes focused test updates for prompt assembly parameter-source alignment, strict-role post-history system sections, start-generation merged formatting flags, and SwipeJumpControl next-retry behavior.
  • Suggested local checks before merge: pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, and cargo check --manifest-path src-tauri/Cargo.toml --workspace.

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

TODO: Add Peek Prompt before/after evidence showing section labels/preview messages, plus swipe-control evidence if this PR keeps the related swipe UI changes.

Summary by CodeRabbit

  • New Features

    • Added preview messages display with labeled sections in the prompt inspection modal, showing message assembly before final formatting.
    • Messages now support optional display names for clearer labeling in previews.
  • Bug Fixes

    • Improved system message handling in strict role formatting—system messages after history are now preserved as separate messages instead of being merged.
  • Tests

    • Added comprehensive test coverage for preview message assembly and parameter source merging in prompt generation.

Review Change Stack


🔄 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/1463 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 5/28/2026 **Status:** ✅ Merged **Merged:** 5/28/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `refactor` ← **Head:** `fix/prompt-assembly-format` --- ### 📝 Commits (5) - [`3b9671d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3b9671d64aa602815a640d1db379a51b7e26d4b6) strictRoleFormatting no longer writes only system+user for output - [`2a5a42c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2a5a42cc79cb7e107ba1fbe4aff1fd994a670b18) prompt assembly matches flags of ordered parameter sources with the final LLM request - [`a16a41b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a16a41b4b714a8909a2b32d2901261094a29b679) Fix: Peek Prompt now gets a preview-specific message - [`4da5142`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4da5142e2a2c8d6b12bf40224f35e88410f1d364) system messages remain separate history entries instead of being folded into the merged prompt scaffold - [`f7de50b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f7de50b11a855b61bc398e107ffc899550d33c19) Centralise peek prompt logic. ### 📊 Changes **16 files changed** (+4244 additions, -3188 deletions) <details> <summary>View changed files</summary> 📝 `graphify-out/.graphify_labels.json` (+15 -0) 📝 `graphify-out/GRAPH_REPORT.md` (+309 -238) ➕ `graphify-out/cache/ast/ddd6593e644d342540e3cc7074cacd7e4e84e8a77f545e7efec11a219e127a1d.json` (+1 -0) 📝 `graphify-out/cache/stat-index.json` (+1 -1) 📝 `graphify-out/graph.json` (+2491 -1699) 📝 `graphify-out/manifest.json` (+1175 -1165) 📝 `src/engine/contracts/types/prompt.ts` (+3 -1) 📝 `src/engine/generation/context.ts` (+4 -13) 📝 `src/engine/generation/generate-route-utils.ts` (+20 -1) 📝 `src/engine/generation/prompt-assembly.test.ts` (+88 -4) 📝 `src/engine/generation/prompt-assembly.ts` (+37 -29) 📝 `src/engine/generation/prompt-preview.ts` (+18 -3) 📝 `src/engine/generation/start-generation.test.ts` (+61 -0) 📝 `src/features/catalog/chats/hooks/use-chats.ts` (+8 -24) 📝 `src/features/modes/shared/chat-ui/components/PeekPromptModal.tsx` (+11 -9) 📝 `src/features/modes/shared/chat-ui/types.ts` (+2 -1) </details> ### 📄 Description <!-- Target branch: `refactor`. Change the base to `refactor` before submitting unless a maintainer explicitly asked for another base. --> <!-- Keep all checkboxes unchecked until a human has actually verified them. --> ## Linked issue <!-- Every user-facing PR should reference a feature request or issue report when practical. --> #1461 ## Why this change <!-- What user problem, bug, refactor goal, or maintenance need does this solve? --> - Peek Prompt was showing the post-formatting request shape instead of a preview-friendly breakdown of the authored prompt sections, which made strict-role/single-user formatting hard to inspect. - Prompt assembly and the final LLM request could read different merged generation parameter sources, so formatting flags like `strictRoleFormatting` and `singleUserMessage` were not guaranteed to affect both paths the same way. - Strict role formatting flattened later authored system sections into user-side content, hiding output-format sections that should remain system-authored. ## What changed <!-- List the key changes in this PR. --> - Shared the generation parameter source ordering between prompt assembly, preview, and final request parameter resolution. - Added preview-only prompt messages with section display names so Peek Prompt can show authored prompt sections while the LLM still receives the final formatted message list. - Updated strict role formatting to merge only leading system prompt content, preserve later system sections, and keep history alternation behavior intact. - Passed preview request choices/parameters through the prompt preview path so Peek Prompt matches the selected preset variables and connection/request context. - Added prompt assembly and start-generation coverage for merged formatting flags and post-history system sections. - Included related branch fixes for swipe navigation responsiveness, next-retry generation from swipe controls, sprite overlay/expression avatar memoization, Tauri dev inspection, and stable Graphify output refreshes. ## Refactor impact Primary owner: <!-- Examples: app shell, catalog, chat mode, roleplay mode, game mode, runtime generation, world-state, shared API, engine generation, Rust storage, imports, remote runtime. --> Engine generation, shared chat UI, chat storage/swipe runtime, Tauri dev tooling, Graphify tooling. Impact areas reviewed: - Prompt assembly, prompt preview, start-generation request assembly, and generation parameter merging. - Roleplay strict-role formatting, chat history placement, and output-format sections. - Peek Prompt display section parsing and shared chat timeline action wiring. - Swipe controls in shared chat UI and conversation UI. - Chat storage active-swipe command response shape and optimistic cache updates. - Sprite overlay/expression avatar update paths. - Graphify generated map output and portable path/hash patching. Boundary notes: <!-- Note engine/shared-api/feature/Rust/remote-runtime boundaries. Say "none" only if you checked. --> - Engine generation owns the prompt assembly contract and now exposes `previewMessages` separately from final LLM `messages`. - Feature UI consumes preview metadata through existing runtime hooks/wrappers; no new raw Tauri or raw remote-runtime fetch path was added for prompt preview. - Rust storage changes stay inside chat storage command handling for active swipe updates. - Tauri dev-inspection changes are debug/dev-only runtime wrapper behavior. - Graphify changes are generated/tooling artifacts and do not affect product runtime behavior. Pressure points touched: <!-- Mention ModeSurface, GameSurface, shared mode UI, src-tauri/src/lib.rs command registration, or import modules if touched. --> - Shared mode UI: `PeekPromptModal`, `ChatMessage`, `SwipeJumpControl`, and `use-chat-timeline-actions`. - Conversation and roleplay mode message surfaces. - `src-tauri/src/lib.rs` debug setup hook for auto devtools. - Chat storage command facade for `chat_message_set_active_swipe`. - Graphify generated output and portable path patch script. ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> - [x] `pnpm check` passes locally - [x] `pnpm typecheck` passes locally - [x] `pnpm build` passes locally - [x] `pnpm check:architecture` passes locally - [x] `pnpm check:docs` passes locally - [x] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [x] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Playwright, screenshot, or recording evidence added for UI changes - [x] Remote runtime smoke checked when relevant ### Manual verification notes <!-- Describe exactly what you tested in a real browser/app/runtime, step by step. If an AI agent filled this out, verify it yourself before ticking boxes. --> - Not rerun while filling out this template. - Branch includes focused test updates for prompt assembly parameter-source alignment, strict-role post-history system sections, start-generation merged formatting flags, and `SwipeJumpControl` next-retry behavior. - Suggested local checks before merge: `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, and `cargo check --manifest-path src-tauri/Cargo.toml --workspace`. ## 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 <!-- Add before/after screenshots or recordings for visible UI changes. --> TODO: Add Peek Prompt before/after evidence showing section labels/preview messages, plus swipe-control evidence if this PR keeps the related swipe UI changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added preview messages display with labeled sections in the prompt inspection modal, showing message assembly before final formatting. * Messages now support optional display names for clearer labeling in previews. * **Bug Fixes** * Improved system message handling in strict role formatting—system messages after history are now preserved as separate messages instead of being merged. * **Tests** * Added comprehensive test coverage for preview message assembly and parameter source merging in prompt generation. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/1463?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- 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:13:16 +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#5102
No description provided.