mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #1812] [MERGED] Card CSS theming: avatar override, typing indicator, message grouping #5282
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#5282
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/1812
Author: @kolacheee
Created: 6/1/2026
Status: ✅ Merged
Merged: 6/4/2026
Merged by: @cha1latte
Base:
refactor← Head:feat/card-css-content-fonts-grouping📝 Commits (1)
1539e0dAdd card CSS avatar and typing theming hooks📊 Changes
18 files changed (+1527 additions, -173 deletions)
View changed files
📝
docs/card-css-theming-guide.md(+92 -9)📝
src/engine/contracts/types/character.ts(+18 -0)📝
src/features/catalog/characters/components/CharacterColorsTab.tsx(+9 -0)📝
src/features/catalog/characters/components/CharacterEditorTabContent.tsx(+6 -1)📝
src/features/catalog/characters/components/CharacterMetadataTab.tsx(+35 -9)➕
src/features/catalog/characters/components/ConversationAvatarControl.tsx(+207 -0)📝
src/features/modes/conversation/components/ChatConversationSurface.tsx(+3 -0)📝
src/features/modes/conversation/components/ConversationMessage.tsx(+88 -21)📝
src/features/modes/conversation/components/ConversationModeRoute.tsx(+35 -2)📝
src/features/modes/conversation/components/ConversationView.tsx(+206 -59)➕
src/features/modes/conversation/hooks/use-conversation-avatar-overrides.ts(+87 -0)📝
src/features/modes/shared/chat-ui/components/ChatMessage.tsx(+2 -0)📝
src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.test.tsx(+38 -12)📝
src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.ts(+10 -1)📝
src/features/runtime/visuals/types.ts(+5 -0)📝
src/features/shell/discovery/discovery-entries.json(+11 -0)➕
src/shared/lib/chat-css.test.ts(+354 -0)📝
src/shared/lib/chat-css.ts(+321 -59)📄 Description
Linked issue
Closes #1967
Why this change
contenttext, embedded@font-facefonts) and mis-scoped chained[data-card-css]selectors in Exclusive mode.What changed
Card CSS sanitizer + scoping (
src/shared/lib/chat-css.ts)content: "text"after sanitization (strip<>, cap at 200 chars); allow CSS functions (attr(),counter(), quote keywords); unrecognized values still fall back to''.@font-faceblocks that reference onlydata:URIs (base64-embedded fonts); external-URL blocks are still stripped. Expanded theurl()data-allowlist to also coverdata:font/*anddata:application/font*.[data-card-css]selectors (e.g.[data-card-css]:not([data-grouped]),[data-card-css].mari-typing-indicator) so they chain onto the element in Exclusive mode and fall back to descendant in Chat mode.Message structure + grouping
data-groupedto conversation and roleplay message wrappers, so card CSS can target first-in-group ([data-card-css]:not([data-grouped])) vs. continuations ([data-grouped])..mari-message-bodyso card CSS styles one seamless container (continuous borders/corners/decorations); addedmari-message-group/data-card-css-grouphooks.Themeable typing indicator
.mari-typing-indicator/.mari-typing-dots/.mari-typing-text, scoped per character throughdata-card-css, with the character's name exposed asdata-typing-name(usable ascontent: attr(data-typing-name)for custom labels).Per-character Conversation avatar override (new user-facing feature)
extensions.conversationAvatar({ mode: default | hide | emoji | sprite | gallery, value? }) with aConversationAvatarOverridecontract type.ConversationAvatarControl) to choose the mode and pick an emoji / sprite / gallery image.use-chat-surface-data(a single batched query, gated so it only fetches when an override is actually set) and rendered inConversationMessagefor both the single and grouped-speaker avatar paths. Conversation-mode only ? other modes ignore the field.Other
docs/card-css-theming-guide.mdwith the new selector hooks, the typing-indicator section, the avatar control, edit-mode/grouping behavior, new tips, and a refreshed AI-prompt template.Refactor impact
Primary owner: chat mode (conversation) + shared chat-ui
Impact areas reviewed:
src/shared/lib/chat-css.ts? sanitizer + selector scopingsrc/features/modes/conversation/components/ConversationView.tsx,ConversationMessage.tsx? conversation rendering, grouping, avatar override, typing indicatorsrc/features/modes/shared/chat-ui/hooks/use-chat-surface-data.ts? shared CharacterMap builder (used by all chat modes); added a conversation-only avatar field + sprite/gallery resolutionsrc/features/modes/shared/chat-ui/components/ChatMessage.tsx? roleplaydata-groupedsrc/features/catalog/characters/components/*? character-editor Colors tab wiring + newConversationAvatarControlsrc/engine/contracts/types/character.ts,src/features/runtime/visuals/types.ts? new optional typesBoundary notes:
character.tsgains an optionalconversationAvatarextension field ? backward-compatible, no migration, ignored by older readers.use-chat-surface-datais shared across conversation/roleplay/game. The addedconversationAvatar/conversationAvatarSrcmap fields and the resolution query are gated (only fetch when a sprite/gallery override exists) and are ignored by the roleplay/game renderers, so those surfaces are unchanged.Pressure points touched:
use-chat-surface-data.ts(CharacterMap construction) andChatMessage.tsx(RP wrapper). Not touched: ModeSurface, GameSurface,src-tauri/src/lib.rscommand registration, import modules.Validation
pnpm typecheck,pnpm build,pnpm check:architecture,pnpm check:docs, or fullpnpm checkwhen warranted)pnpm checkpasses before PR push/handoffManual verification notes
Run locally on the merged branch (now up to date with
refactor):pnpm typecheck(tsc -b) ? passpnpm build(tsc -b + vite) ? passpnpm lint:eslint? passpnpm check:architecture(depcruise + rust-structure) ? passpnpm check:unused(knip) ? passpnpm check:docs? passpnpm check:discovery? pass (38 entries; the newconversation-avatarentry validates)pnpm check:line-endings? fails only on pre-existingcustom_components/marinara_engine/*.py(CRLF in a local Windows working tree); those files aren't touched by this PR and the check passes on an LF checkout such as CI.pnpm check:rust(cargo) ? not run locally; this PR makes no Rust changes (the Rust deltas here come from the mergedrefactorbase and are validated upstream).Feature Discoverability
Check exactly one:
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.Reason:
conversation-avatar, Library category) for the per-character Conversation Avatar control insrc/features/shell/discovery/discovery-entries.json; its action opens the Characters panel. The card-CSS theming hooks themselves are documented indocs/card-css-theming-guide.md.Docs and release impact
docs/card-css-theming-guide.mdProof
Core claim:
content, or leak embedded fonts app-wide; and the avatar-resolution query stays gated and bounded so it can't regress chat into lag.Verification run:
refactor-merge head:pnpm typecheck(clean),pnpm test(23 files / 97 passed),pnpm build(clean),pnpm lint:eslint,pnpm check:architecture,pnpm check:unused,pnpm check:docs,pnpm check:discovery? all pass locally. (check:line-endingsflags only pre-existing CRLF incustom_components/**/*.py, unrelated to this PR; no Rust changes.)Evidence:
pnpm testcoverschat-css): theurl()/@import/@font-face/:has()/position:fixed/ theme-token /contentguards; the@font-facedata-font-only contract (external,image/*, non-font,local(), and source-less blocks all rejected);@keyframes+@font-facefamily namespacing with a per-card salt; and escaped-function-name canonicalization (\75rl(?url(,lo\63al(?local().use-chat-surface-datasuite): resolution is gated (no fetch without an override or outside Conversation mode), resolves once with no per-render refetch, and revalidates exactly once on remount.cssTargetsTypingIndicatorcovered for styled / unstyled / comment-only inputs and@chat-modesurface filtering.Risk coverage:
@font-faceis kept; benign card CSS (escaped selectors,contentstrings) is preserved.url()?url(about:invalid);image/*/ non-font /local()/ source-less / escaped@font-facestripped; theme-token and!importantoverrides stripped;:has()removed; the avatar query stays disabled with no override and in Roleplay/Game.Manual verification requested:
UI evidence
Conversation Avatar selector

Convo mode example (Chat-scoped)

Convo mode examples (Character-scoped)



RP mode example (Chat-scoped)

RP mode example (Character-scoped)

GM mode example (Chat-scoped)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.