[PR #2593] [MERGED] feat(chat): card-CSS theming hooks (typing indicator + message grouping) #5678

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2593
Author: @kolacheee
Created: 6/16/2026
Status: ✅ Merged
Merged: 6/16/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/staging-cardcss-theming


📝 Commits (10+)

  • e6fe37a fix(chat): harden card CSS sanitizer against escape-sequence evasion
  • d74d73f feat(chat): apply character creator-notes CSS in chat (card theming)
  • cff5399 feat(chat): default card CSS mode to disabled (opt-in)
  • 0c75b45 feat(chat): card-CSS theming hooks for typing + grouped messages
  • 6d024ea docs: card CSS theming + authoring guide
  • 6690c15 Merge branch 'staging' into feat/staging-cardcss-theming
  • 10fd906 fix(chat): inject card CSS unlayered so it can override message styling
  • 0ea9148 docs: card CSS examples that actually apply (unlayered injection)
  • 52a1dd2 docs: rewrite card CSS guide against staging's real DOM + add showcase
  • 15421fc feat(chat): baseline card CSS support in game mode

📊 Changes

14 files changed (+1246 additions, -12 deletions)

View changed files

➕ docs/card-css-theming-guide.md (+343 -0)
📝 packages/client/src/components/chat/ChatArea.tsx (+21 -0)
📝 packages/client/src/components/chat/ChatMessage.tsx (+42 -6)
📝 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 (+2 -0)
📝 packages/client/src/components/chat/ConversationMessageGrouped.tsx (+2 -0)
📝 packages/client/src/components/chat/ConversationView.tsx (+15 -4)
➕ packages/client/src/components/chat/CreatorNotesCssInjector.tsx (+117 -0)
📝 packages/client/src/components/game/GameSurface.tsx (+1 -1)
➕ packages/client/src/lib/card-css.ts (+578 -0)
➕ packages/client/src/lib/creator-notes-css.ts (+23 -0)
📝 packages/client/src/styles/globals.css (+8 -0)
📝 packages/shared/src/types/chat.ts (+7 -0)

📄 Description

Linked issue

Closes #2580

Stacked on #2590 (creator-notes card-CSS injection) — these hooks are inert without it. Until #2590 merges, this PR's diff includes the #2586 + #2590 commits; it will be rebased onto staging as those land. The conversation avatar override also bundled into the source feature is split out to #2592.

Why this change

#2590 lets a character's creator-notes CSS style its messages, but two surfaces have no hooks for authors to target: the typing indicator and grouped (consecutive) messages. This adds the minimal markup hooks so card CSS can style those too — e.g. a custom "… is typing" treatment, or a distinct look for the first message in a run vs its continuations.

What changed

  • Typing indicator (ConversationView, classic mode): the row now carries .mari-typing-indicator / .mari-typing-dots / .mari-typing-text class hooks and data-typing-name (usable as content: attr(data-typing-name)). When a single character is typing, the row also gets data-card-css={characterId} so exclusive-mode CSS can target it via [data-card-css="<id>"] .mari-typing-*.
  • Message grouping: the standard message wrapper (ConversationMessage) and the grouped multi-speaker layout (ConversationMessageGrouped) carry data-grouped on continuation messages, so authors can target first-in-group with [data-card-css]:not([data-grouped]) and continuations with [data-grouped]. The grouped layout also gains the data-card-css scope it was previously missing.
  • Game-mode baseline — the game surface is scoped (.mari-card-css + data-chat-mode="game") and the injector mounts there, so Chat-mode card CSS reaches the game area and @chat-mode game targets it. Game uses its own layout, so the message hooks don't apply there; per-character (Exclusive) narration scoping is a noted follow-up.
  • Authoring guide — docs/card-css-theming-guide.md, written against staging's real chat DOM (every selector verified), with a smoking-gun test, the [data-card-css]-for-the-element vs class-for-children convention, @chat-mode targeting, the sanitizer limits, and a full "Eldritch Grimoire" showcase.
  • Cascade fix (carried from #2590): card CSS is injected unlayered, so its scoped selectors actually override the app's own message styling — a prior @layer card-css wrapper lost to the app's unlayered rules and silently neutered most theming.

The hook changes are additive markup (no default-render change); the cascade fix is what makes card CSS visibly take effect.

Out of scope (intentionally):

  • The multi-typer, exclusive-mode standalone typing-row split (each styled character gets an isolated row) — a niche refinement; the single-typer path above covers the common case.
  • The N-bubble grouping collapse into one seamless .mari-message-group — staging renders grouped messages flat, and collapsing would change default rendering.
  • The conversation avatar override (hide / emoji / sprite / gallery) — a large, independent feature split to #2592.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

Already run (automated): client typecheck (tsc -b) and client lint (eslint) pass. Full pnpm check and the in-app checks below still need a human.

Please manually verify in the app (conversation mode, with a card that has creator-notes CSS and Card Theming enabled):

  • Typing indicator — with <style>.mari-typing-text { color: hotpink; font-weight: bold; }</style> in a card's Creator Notes, send a message and confirm the "… is typing" row restyles while the reply streams. Confirm a normal chat's typing row is unchanged when no card CSS targets it.
  • Grouping — with <style>[data-grouped] { opacity: 0.6; }</style>, send two quick consecutive messages from the same character and confirm the continuation dims while the first stays full. Confirm [data-card-css]:not([data-grouped]) targets only first-in-group.
  • Confirm grouped multi-speaker messages (Name: text format / merged group chat) now pick up exclusive-mode card CSS (they were unscoped before).
  • Confirm default rendering (no card CSS) is visually identical to before, in both classic and bubble conversation styles.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

To be added: before/after of a card styling the typing indicator + grouped continuation messages.


🔄 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/2593 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 6/16/2026 **Status:** ✅ Merged **Merged:** 6/16/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/staging-cardcss-theming` --- ### 📝 Commits (10+) - [`e6fe37a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e6fe37a266b5e65ce1bcc835dda22183bb011b68) fix(chat): harden card CSS sanitizer against escape-sequence evasion - [`d74d73f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d74d73fa289c07b5ad2e4cfd00f6d78e219ec847) feat(chat): apply character creator-notes CSS in chat (card theming) - [`cff5399`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cff53994989b16b0b6ed9af9fe6a4329df861620) feat(chat): default card CSS mode to disabled (opt-in) - [`0c75b45`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0c75b45848bdb17b6f3638f307f233f27fc7f8d2) feat(chat): card-CSS theming hooks for typing + grouped messages - [`6d024ea`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6d024ea64e05b2e7fccbe17afd5a6aaf7a9596db) docs: card CSS theming + authoring guide - [`6690c15`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6690c156c2a33c9d80aa3a831d5864cacc74a52f) Merge branch 'staging' into feat/staging-cardcss-theming - [`10fd906`](https://github.com/Pasta-Devs/Marinara-Engine/commit/10fd906fd5b43275c68db11f1e0807fe298f35e1) fix(chat): inject card CSS unlayered so it can override message styling - [`0ea9148`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0ea914861daf46d82095582e67c9678f049c535b) docs: card CSS examples that actually apply (unlayered injection) - [`52a1dd2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/52a1dd275121e186fb75c939b0e4117272eec243) docs: rewrite card CSS guide against staging's real DOM + add showcase - [`15421fc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/15421fc8380d6dd54dbe5f3fbbb78c80947ed34b) feat(chat): baseline card CSS support in game mode ### 📊 Changes **14 files changed** (+1246 additions, -12 deletions) <details> <summary>View changed files</summary> ➕ `docs/card-css-theming-guide.md` (+343 -0) 📝 `packages/client/src/components/chat/ChatArea.tsx` (+21 -0) 📝 `packages/client/src/components/chat/ChatMessage.tsx` (+42 -6) 📝 `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` (+2 -0) 📝 `packages/client/src/components/chat/ConversationMessageGrouped.tsx` (+2 -0) 📝 `packages/client/src/components/chat/ConversationView.tsx` (+15 -4) ➕ `packages/client/src/components/chat/CreatorNotesCssInjector.tsx` (+117 -0) 📝 `packages/client/src/components/game/GameSurface.tsx` (+1 -1) ➕ `packages/client/src/lib/card-css.ts` (+578 -0) ➕ `packages/client/src/lib/creator-notes-css.ts` (+23 -0) 📝 `packages/client/src/styles/globals.css` (+8 -0) 📝 `packages/shared/src/types/chat.ts` (+7 -0) </details> ### 📄 Description ## Linked issue Closes #2580 > Stacked on #2590 (creator-notes card-CSS injection) — these hooks are inert without it. Until #2590 merges, this PR's diff includes the #2586 + #2590 commits; it will be rebased onto `staging` as those land. The conversation **avatar override** also bundled into the source feature is split out to #2592. ## Why this change #2590 lets a character's creator-notes CSS style its messages, but two surfaces have no hooks for authors to target: the **typing indicator** and **grouped (consecutive) messages**. This adds the minimal markup hooks so card CSS can style those too — e.g. a custom "… is typing" treatment, or a distinct look for the first message in a run vs its continuations. ## What changed - **Typing indicator** (`ConversationView`, classic mode): the row now carries `.mari-typing-indicator` / `.mari-typing-dots` / `.mari-typing-text` class hooks and `data-typing-name` (usable as `content: attr(data-typing-name)`). When a single character is typing, the row also gets `data-card-css={characterId}` so exclusive-mode CSS can target it via `[data-card-css="<id>"] .mari-typing-*`. - **Message grouping**: the standard message wrapper (`ConversationMessage`) and the grouped multi-speaker layout (`ConversationMessageGrouped`) carry `data-grouped` on continuation messages, so authors can target first-in-group with `[data-card-css]:not([data-grouped])` and continuations with `[data-grouped]`. The grouped layout also gains the `data-card-css` scope it was previously missing. - **Game-mode baseline** — the game surface is scoped (`.mari-card-css` + `data-chat-mode="game"`) and the injector mounts there, so **Chat**-mode card CSS reaches the game area and `@chat-mode game` targets it. Game uses its own layout, so the message hooks don't apply there; per-character (Exclusive) narration scoping is a noted follow-up. - **Authoring guide** — `docs/card-css-theming-guide.md`, written against staging's **real** chat DOM (every selector verified), with a smoking-gun test, the `[data-card-css]`-for-the-element vs class-for-children convention, `@chat-mode` targeting, the sanitizer limits, and a full "Eldritch Grimoire" showcase. - **Cascade fix** (carried from #2590): card CSS is injected **unlayered**, so its scoped selectors actually override the app's own message styling — a prior `@layer card-css` wrapper lost to the app's unlayered rules and silently neutered most theming. The hook changes are additive markup (no default-render change); the cascade fix is what makes card CSS visibly take effect. **Out of scope (intentionally):** - The multi-typer, exclusive-mode *standalone typing-row split* (each styled character gets an isolated row) — a niche refinement; the single-typer path above covers the common case. - The N-bubble *grouping collapse* into one seamless `.mari-message-group` — staging renders grouped messages flat, and collapsing would change default rendering. - The **conversation avatar override** (hide / emoji / sprite / gallery) — a large, independent feature split to #2592. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes Already run (automated): client typecheck (`tsc -b`) and client lint (`eslint`) pass. Full `pnpm check` and the in-app checks below still need a human. Please manually verify in the app (conversation mode, with a card that has creator-notes CSS and Card Theming enabled): - **Typing indicator** — with `<style>.mari-typing-text { color: hotpink; font-weight: bold; }</style>` in a card's Creator Notes, send a message and confirm the "… is typing" row restyles while the reply streams. Confirm a normal chat's typing row is unchanged when no card CSS targets it. - **Grouping** — with `<style>[data-grouped] { opacity: 0.6; }</style>`, send two quick consecutive messages from the same character and confirm the continuation dims while the first stays full. Confirm `[data-card-css]:not([data-grouped])` targets only first-in-group. - Confirm grouped multi-speaker messages (Name: text format / merged group chat) now pick up exclusive-mode card CSS (they were unscoped before). - Confirm default rendering (no card CSS) is visually identical to before, in both classic and bubble conversation styles. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) To be added: before/after of a card styling the typing indicator + grouped continuation messages. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:18:24 +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#5678
No description provided.