mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #2590] [MERGED] feat(chat): apply character creator-notes CSS in chat (card theming) #5677
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#5677
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/2590
Author: @kolacheee
Created: 6/16/2026
Status: ✅ Merged
Merged: 6/16/2026
Merged by: @SpicyMarinara
Base:
staging← Head:feat/staging-cardcss-injection📝 Commits (5)
e6fe37afix(chat): harden card CSS sanitizer against escape-sequence evasiond74d73ffeat(chat): apply character creator-notes CSS in chat (card theming)cff5399feat(chat): default card CSS mode to disabled (opt-in)423017aMerge branch 'staging' into feat/staging-cardcss-injection95161f2fix(chat): inject card CSS unlayered so it can override message styling📊 Changes
10 files changed (+870 additions, -3 deletions)
View changed files
📝
packages/client/src/components/chat/ChatArea.tsx(+20 -0)📝
packages/client/src/components/chat/ChatMessage.tsx(+32 -1)📝
packages/client/src/components/chat/ChatRoleplaySurface.tsx(+5 -1)📝
packages/client/src/components/chat/ChatSettingsDrawer.tsx(+82 -0)📝
packages/client/src/components/chat/ConversationMessage.tsx(+1 -0)📝
packages/client/src/components/chat/ConversationView.tsx(+5 -1)➕
packages/client/src/components/chat/CreatorNotesCssInjector.tsx(+117 -0)➕
packages/client/src/lib/card-css.ts(+578 -0)➕
packages/client/src/lib/creator-notes-css.ts(+23 -0)📝
packages/shared/src/types/chat.ts(+7 -0)📄 Description
Linked issue
Closes #2579
Why this change
Character cards can ship custom CSS in their
creator_notes(a long-standing card convention), but staging has no way to apply it — so imported cards that rely on creator-notes styling render plain. This ports the creator-notes card-CSS feature (source: #1748) so a card's embedded styling actually shows in chat, with a per-chat control over how aggressively it applies and a hardened sanitizer so untrusted card CSS can't exfiltrate data, escape its scope, or override the app theme.What changed
lib/card-css.ts— sanitizes + scopes untrusted card CSS: strips network/script vectors, removes:has()/position: fixed/ history-probing, blocks theme-token overrides and!important, namespaces@keyframesand@font-face(anti-collision salted), recurses into@media, canonicalizes CSS escape sequences so the literal-text guards can't be evaded, and rewrites every selector under a per-card scope. PlusfilterCssByModefor@chat-modesurface targeting.lib/creator-notes-css.ts— lifts<style>blocks out ofcreator_notes.CreatorNotesCssInjector— for the chat's active characters, extracts → filters → scopes → injects one<style id="marinara-card-css">into<head>, unlayered so its scoped selectors override the app's own message styling (the app sets some message styles with unlayered rules that beat any@layer— wrapping card CSS in a layer silently neutered most theming; the sanitizer + per-card scope still contain it). Mounted inChatAreafor the roleplay + conversation surfaces.ChatMetadata.cardCssMode— new per-chat tri-state:disabled(default — card styling is opt-in per chat) /exclusive(each character's CSS only styles their own messages) /chat(whole area)..mari-card-css+data-chat-modeon the roleplay + conversation surface containers;data-card-css={characterId}on the message wrappers.Game mode is intentionally out of scope here (its surface and narration log have a distinct structure and stacking); a follow-up can extend the same markers to it.
Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Already run (automated): client typecheck (
tsc -b), client lint (eslint), and server typecheck all pass. Fullpnpm checkand the in-app checks below still need a human.Please manually verify in the app:
<style>…</style>block to a character's Creator Notes (e.g.<style>.mari-message-bubble { border: 2px solid hotpink; }</style>), open a chat with that character, and confirm the Card Theming section appears in chat settings and the styling shows.url(http://…)background (no outbound request), a--primary: redoverride (app theme unchanged), aposition: fixedoverlay, a:has()probe, and an escaped evasion such aspo\73ition: fixed.Docs and release impact
UI evidence (if applicable)
To be added: screenshots of the Card Theming control and a card's CSS applied in chat (disabled / exclusive / chat).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.