[PR #8107] [MERGED] fix(chat): render system messages as readable message blocks #8105

Closed
opened 2026-10-24 04:10:25 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8107
Author: @SpicyMarinara
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/8101-system-messages


📝 Commits (4)

  • 2184a53 test(chat): reproduce unformatted system messages
  • be4832e Merge remote-tracking branch 'origin/staging' into fix/8101-system-messages
  • 56dc746 fix(chat): format system messages and protect literal code
  • c9da953 fix(chat): protect creator-note code and honor system font size

📊 Changes

10 files changed (+541 additions, -72 deletions)

View changed files

📝 e2e/core-flows.e2e.ts (+12 -0)
📝 e2e/markdown-blocks.e2e.ts (+5 -2)
➕ e2e/system-messages.e2e.ts (+218 -0)
📝 packages/client/src/components/bot-browser/BotBrowserView.tsx (+7 -9)
📝 packages/client/src/components/chat/ChatMessage.tsx (+34 -32)
📝 packages/client/src/components/chat/ConversationMessage.tsx (+38 -28)
➕ packages/client/src/components/chat/SystemMessage.tsx (+124 -0)
📝 packages/client/src/lib/chat-html.ts (+2 -1)
➕ packages/client/src/lib/markdown-code.ts (+53 -0)
➕ scripts/regressions/markdown-code.regression.ts (+48 -0)

📄 Description

Linked issue

Closes #8101

Why this change

System messages bypassed the formatted message renderer and action controls. Long content was squeezed into a pill, newlines and Markdown/HTML were displayed as plain text, and users could not edit or branch from those messages. Separately, literal HTML inside backticks could reach the HTML parser and change the formatting of later text.

What changed

  • Render system messages as readable blocks constrained to the transcript width in Conversation and Roleplay, with supported Markdown, sanitized HTML, authored newlines the configured chat font size and the existing macro-resolved display text.
  • Reuse existing copy, edit, bookmark/pin/private-note, branch, AI visibility and delete actions. Keep the dedicated Conversation call-event cards.
  • Protect inline and fenced code before quote formatting, HTML detection, image conversion and sanitization. Restore escaped code after formatting so literal font/style/image tags remain text and cannot recolor later prose or load code images.
  • Apply the same code protection to Bot Browser creator notes before HTML decoding, style extraction and sanitization. Valid HTML attributes remain intact; stray prose angle brackets cannot swallow a code span or fence.
  • Keep actual newline characters in fenced code on the mixed-HTML path. The existing regression now checks exact multiline code text while retaining its original checks for authored HTML PRE/BR markup.

The maintainer confirmed that the issue's message-processing request is already covered by Advanced Parameters → Post-Processing Messages. Preset-specific custom tags still require compatible regex/preset setup. Fenced wrapping at every width is already on staging through #8104.

Validation

  • pnpm install --frozen-lockfile and pnpm check: passed, including localization, formatting, types and production builds. The existing HomeProfessorMariChat hook-dependency warning remains; no errors.
  • Focused markdown-code, chat-html-newlines and open-issues Node regressions: 3/3 files passed.
  • pnpm regression:ui e2e/system-messages.e2e.ts e2e/markdown-blocks.e2e.ts e2e/code-block-wrapping.e2e.ts --project=desktop-chromium --project=mobile-chromium --project=mobile-webkit --workers=2: 21/21 passed, plus 1/1 desktop Bot Browser import/creator-notes case.
  • Browser coverage includes both themes, actual newline geometry, viewport containment, a 24px chat font setting, the localized System label, displayed macros with their raw edit source preserved, persisted edits, bookmarks, branching with the system row preserved, literal code/text equality, author-selected color reset and blocked script/event/iframe content.
  • pnpm smoke:ui: 7/7 passed, including Game narration.
  • Fresh local CodeRabbit: 10 files reviewed, one non-blocking optimization note suggesting a no-backtick detection fast path. The shared protection behavior is retained; that optional optimization is deferred. Earlier valid macro-display findings and both hosted code-protection defects are repaired.
  • Before-fix system-message control failed on the missing rendered heading. Disabling only the new literal-code protection reproduced the reported empty inline code instead of literal <font color="#HEX">; the protection was restored and the final suite passed. The hosted-review regressions also failed before repair: Bot Browser produced no literal code spans, the angle-bracket case retained its backticks unprotected, and system text rendered at 17px despite a 24px setting. All now pass. Failure logs, screenshots and traces were preserved.

Browser runs used disposable data, ports 7860–7863 and at most two workers. Screenshots were visually inspected. These are automated browser checks, including mobile emulation.

Manual verification still needed

  • Manually verify the reported Windows/Firefox installation; local desktop coverage used Chromium on macOS.
  • Manually verify on physical Android/iOS devices.
  • Manually verify selecting/copying indented code and using the system-message controls in your usual theme and layout.

Docs and release impact

Existing localized labels are reused. No new user documentation or release metadata is needed.

UI evidence

Before/after browser screenshots are embedded in a self-contained HTML file; download it to view the original PNGs. All four published images were verified byte-for-byte. The fixture includes a deliberately invalid image for its HTML security probe.


🔄 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/8107 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/8101-system-messages` --- ### 📝 Commits (4) - [`2184a53`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2184a539e4c22b26a8f01d95c4494a78689cefa8) test(chat): reproduce unformatted system messages - [`be4832e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/be4832ee78986ae0d9bbf5202ac6294c1e7ad414) Merge remote-tracking branch 'origin/staging' into fix/8101-system-messages - [`56dc746`](https://github.com/Pasta-Devs/Marinara-Engine/commit/56dc746d034941d6f4b05ca0ee488a67e73aac8e) fix(chat): format system messages and protect literal code - [`c9da953`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c9da953d9b9d90b9475393d262acb5782d5b662f) fix(chat): protect creator-note code and honor system font size ### 📊 Changes **10 files changed** (+541 additions, -72 deletions) <details> <summary>View changed files</summary> 📝 `e2e/core-flows.e2e.ts` (+12 -0) 📝 `e2e/markdown-blocks.e2e.ts` (+5 -2) ➕ `e2e/system-messages.e2e.ts` (+218 -0) 📝 `packages/client/src/components/bot-browser/BotBrowserView.tsx` (+7 -9) 📝 `packages/client/src/components/chat/ChatMessage.tsx` (+34 -32) 📝 `packages/client/src/components/chat/ConversationMessage.tsx` (+38 -28) ➕ `packages/client/src/components/chat/SystemMessage.tsx` (+124 -0) 📝 `packages/client/src/lib/chat-html.ts` (+2 -1) ➕ `packages/client/src/lib/markdown-code.ts` (+53 -0) ➕ `scripts/regressions/markdown-code.regression.ts` (+48 -0) </details> ### 📄 Description ## Linked issue Closes #8101 ## Why this change System messages bypassed the formatted message renderer and action controls. Long content was squeezed into a pill, newlines and Markdown/HTML were displayed as plain text, and users could not edit or branch from those messages. Separately, literal HTML inside backticks could reach the HTML parser and change the formatting of later text. ## What changed - Render system messages as readable blocks constrained to the transcript width in Conversation and Roleplay, with supported Markdown, sanitized HTML, authored newlines the configured chat font size and the existing macro-resolved display text. - Reuse existing copy, edit, bookmark/pin/private-note, branch, AI visibility and delete actions. Keep the dedicated Conversation call-event cards. - Protect inline and fenced code before quote formatting, HTML detection, image conversion and sanitization. Restore escaped code after formatting so literal font/style/image tags remain text and cannot recolor later prose or load code images. - Apply the same code protection to Bot Browser creator notes before HTML decoding, style extraction and sanitization. Valid HTML attributes remain intact; stray prose angle brackets cannot swallow a code span or fence. - Keep actual newline characters in fenced code on the mixed-HTML path. The existing regression now checks exact multiline code text while retaining its original checks for authored HTML PRE/BR markup. The maintainer confirmed that the issue's message-processing request is already covered by Advanced Parameters → Post-Processing Messages. Preset-specific custom tags still require compatible regex/preset setup. Fenced wrapping at every width is already on staging through #8104. ## Validation - `pnpm install --frozen-lockfile` and `pnpm check`: passed, including localization, formatting, types and production builds. The existing HomeProfessorMariChat hook-dependency warning remains; no errors. - Focused `markdown-code`, `chat-html-newlines` and `open-issues` Node regressions: **3/3 files passed**. - `pnpm regression:ui e2e/system-messages.e2e.ts e2e/markdown-blocks.e2e.ts e2e/code-block-wrapping.e2e.ts --project=desktop-chromium --project=mobile-chromium --project=mobile-webkit --workers=2`: **21/21 passed**, plus **1/1** desktop Bot Browser import/creator-notes case. - Browser coverage includes both themes, actual newline geometry, viewport containment, a 24px chat font setting, the localized System label, displayed macros with their raw edit source preserved, persisted edits, bookmarks, branching with the system row preserved, literal code/text equality, author-selected color reset and blocked script/event/iframe content. - `pnpm smoke:ui`: **7/7 passed**, including Game narration. - Fresh local CodeRabbit: **10 files reviewed, one non-blocking optimization note** suggesting a no-backtick detection fast path. The shared protection behavior is retained; that optional optimization is deferred. Earlier valid macro-display findings and both hosted code-protection defects are repaired. - Before-fix system-message control failed on the missing rendered heading. Disabling only the new literal-code protection reproduced the reported empty inline code instead of literal `<font color="#HEX">`; the protection was restored and the final suite passed. The hosted-review regressions also failed before repair: Bot Browser produced no literal code spans, the angle-bracket case retained its backticks unprotected, and system text rendered at 17px despite a 24px setting. All now pass. Failure logs, screenshots and traces were preserved. Browser runs used disposable data, ports 7860–7863 and at most two workers. Screenshots were visually inspected. These are automated browser checks, including mobile emulation. ### Manual verification still needed - [ ] Manually verify the reported Windows/Firefox installation; local desktop coverage used Chromium on macOS. - [ ] Manually verify on physical Android/iOS devices. - [ ] Manually verify selecting/copying indented code and using the system-message controls in your usual theme and layout. ## Docs and release impact Existing localized labels are reused. No new user documentation or release metadata is needed. ## UI evidence [Before/after browser screenshots](https://gist.github.com/SpicyMarinara/634066f157b464e9c3296a335b168eba) are embedded in a self-contained HTML file; download it to view the original PNGs. All four published images were verified byte-for-byte. The fixture includes a deliberately invalid image for its HTML security probe. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#8105
No description provided.