mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #8587] [MERGED] feat(roleplay): add an [html] artifact command with narrator memory #8688
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#8688
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8587
Author: @ylli-selmani
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ylli-selmani
Base:
staging← Head:feat/html-artifact-command📝 Commits (10+)
05fe6b0feat(roleplay): add the [html: …] command, advertised only with Immersive HTML5240ee0feat(roleplay): run Immersive HTML on demand, guided and aloneef24c0ddocs(roleplay): document the [html] command, /html, and Only when asked4561ec2fix(roleplay): address review findings on the on-demand HTML path522e0b2fix(roleplay): keep an [html] request on the reply that made it069675cfix(roleplay): run earlier responders' guided rewrites in turn order02a11cffeat(roleplay): make [html] artifacts a command result with narrator memoryf9bd611fix(roleplay): tidy the html artifact call after review7dfb365fix(roleplay): html artifacts can draw, know the scene and run in parallelad24ee9fix(roleplay): keep messages hidden from the speaker out of an artifact's scene📊 Changes
21 files changed (+859 additions, -18 deletions)
View changed files
📝
docs/chats/slash-commands.md(+3 -0)📝
docs/roleplay/getting-started.md(+10 -0)📝
packages/client/src/components/chat/ChatArea.tsx(+16 -0)📝
packages/client/src/components/chat/ChatInput.tsx(+4 -0)📝
packages/client/src/components/chat/ChatMessage.tsx(+17 -0)📝
packages/client/src/components/chat/ChatRoleplaySurface.tsx(+3 -0)📝
packages/client/src/components/chat/RoleplayCommandResults.tsx(+40 -9)📝
packages/client/src/hooks/use-generate.ts(+4 -0)📝
packages/client/src/hooks/use-roleplay-commands.ts(+27 -1)➕
packages/client/src/lib/artifact-svg.ts(+90 -0)📝
packages/client/src/lib/chat-html.ts(+20 -3)📝
packages/client/src/lib/slash-commands.ts(+19 -0)📝
packages/client/src/localization/locales/en.json(+4 -0)📝
packages/server/src/routes/chats.routes.ts(+49 -0)📝
packages/server/src/routes/generate.routes.ts(+49 -4)📝
packages/server/src/routes/generate/conversation-prompt-formatting.ts(+7 -1)➕
packages/server/src/services/generation/html-artifact.ts(+320 -0)📝
packages/server/src/services/generation/roleplay-commands.ts(+8 -0)📝
packages/server/src/services/storage/chats.storage.ts(+25 -0)📝
packages/shared/src/types/roleplay-command.ts(+16 -0)...and 1 more files
📄 Description
Linked issue
Part of #8586
Why this change
Roleplay can put in-world HTML on screen in two ways, and both sit at an extreme. The Documents command is free and instant, but it renders one of six fixed styles, so "a spellbook page" arrives as a letter-styled card. The Immersive HTML agent makes bespoke HTML, but it runs after every reply, costs a model call per message, and picks the visual itself. There is no way to say "this moment needs exactly this artifact".
This adds the middle ground: the narrator asks for one artifact, the way it already asks for an image with
[illustrate: subject="…"], and one model call makes it.An artifact is a command result, not message text. Live testing of the first version showed why: its markup was saved into the message and sent back to the narrator on every later turn, and nothing showed that the command had been used.
What changed
[html: prompt="…"]Roleplay command. It has its own HTML Artifacts toggle under Roleplay Commands, starts off, and needs no agent in the chat. The request is capped at 2,000 characters. A reply can make 3; further commands show a limit error on their marker instead of costing a call. The narrator's command does not run in multiplayer rooms, and a card's defined intro is left as written.<artifact>and<memory>: the artifact's readable text word for word, plus one line on how it looks. The narrator seesArtifact: <memory>in later turns and never the markup. This follows how the Documents command stays in history, so agents' history does not see it either.renderContent. It is at most 28rem wide and centered, and the prompt asks for a compact piece. It appears as a marker only in Visual Novel.sanitizeChatHtmlgains an option that keeps a small set: shapes, text, groups, gradients and clip paths (lib/artifact-svg.ts).use,image,foreignObject, filters, animation and links stay out. Ids get a per-artifact prefix, and anyurl()orhrefthat points outside the artifact is removed. Messages never set the option and keep the full ban./html <prompt>. The manual twin, throughPOST /chats/:chatId/roleplay-html. It adds one artifact at the end of the latest reply, works with the toggle off, and is refused during a generation. Command markers wait while it runs, so an edit cannot erase its new entry from a stale copy.scripts/regressions/roleplay-commands.regression.tscovers parsing, gating, the model output parser, the prompt, the memory seam, and the limit.UI precedents: the inline placement follows inline
[illustrate], the marker and its Edit and Delete follow the other Roleplay command results inRoleplayCommandResults.tsx, and the rendering followsrenderContentinChatMessage.tsx.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Artifact:line and no HTML./html a terminal readoutworks with the toggle off, and is refused during a generation./htmlruns and work again afterwards.node scripts/run-regressions.mjs --filter roleplay-commands.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue openeddocs/roleplay/getting-started.mdanddocs/chats/slash-commands.mdare updated on this branch. The[docs-i18n]follow-up is #8603.UI evidence (if applicable)
Pending: screenshots from live testing. The sanitizer was run in a browser against a drawn artifact and against markup with script,
onload, remoteimage/use,foreignObject,javascript:links and escapedurl(): the drawing survived and all of those were removed. Two saved artifacts then rendered correctly in a real chat, and new artifacts were generated in live testing. The 28rem cap was measured on a saved artifact; the compact prompt line has not been tried on a new one yet.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.