[PR #1058] [CLOSED] feat: creator notes CSS injection with tri-state mode #4905

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1058
Author: @kolacheee
Created: 5/21/2026
Status: ❌ Closed

Base: staging ← Head: feature/creator-notes-css


📝 Commits (7)

  • 32363d0 feat: render creator notes CSS from character cards
  • 46fae49 feat: add per-character card theming toggle in Chat Settings
  • b9b2387 feat: replace per-character card CSS toggles with tri-state mode selector
  • b178932 fix: add mari-card-css scope to GameSurface and data-card-css to active narration
  • 097ee0c fix: move data-card-css from narration box to inner content divs
  • fda0946 feat: harden card CSS scoping and add data-chat-mode attributes
  • e97f109 fix: strip CSS comments before scoping to prevent selector corruption

📊 Changes

12 files changed (+479 additions, -52 deletions)

View changed files

📝 packages/client/src/components/chat/ChatArea.tsx (+24 -0)
📝 packages/client/src/components/chat/ChatMessage.tsx (+4 -47)
📝 packages/client/src/components/chat/ChatRoleplaySurface.tsx (+1 -1)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+125 -0)
📝 packages/client/src/components/chat/ConversationMessage.tsx (+2 -0)
📝 packages/client/src/components/chat/ConversationView.tsx (+1 -1)
➕ packages/client/src/components/chat/CreatorNotesCssInjector.tsx (+87 -0)
📝 packages/client/src/components/game/GameNarration.tsx (+13 -2)
📝 packages/client/src/components/game/GameSurface.tsx (+1 -1)
➕ packages/client/src/lib/chat-css.ts (+197 -0)
📝 packages/shared/src/index.ts (+1 -0)
➕ packages/shared/src/utils/creator-notes-css.ts (+23 -0)

📄 Description

Summary

  • Extracts <style> blocks from character creator notes and injects them as scoped CSS into the chat area
  • Adds a tri-state mode selector (Disabled / Exclusive / Chat) in Chat Settings → Card Theming:
    • Disabled: no card CSS is applied — characters' embedded styles are ignored
    • Exclusive: each character's CSS only affects their own messages (scoped via data-card-css attribute)
    • Chat: all card CSS affects the entire chat area, including UI elements (default)
  • CSS is sanitized (sanitizeChatCss) and scoped (scopeChatCss) before injection
  • data-card-css attributes added to message wrappers in all surface modes (roleplay, conversation, game narration)
  • Chat metadata key: cardCssMode (replaces earlier disabledCardCssCharIds approach)

Files changed

  • CreatorNotesCssInjector.tsx — new component: extracts, sanitizes, scopes, and injects card CSS per mode
  • ChatArea.tsx — reads cardCssMode from chat metadata, passes mode to injector in all 3 surface modes
  • ChatMessage.tsx — adds data-card-css to narrator, roleplay, and iMessage wrapper elements
  • ConversationMessage.tsx — adds data-card-css to grouped and regular message wrappers
  • GameNarration.tsx — adds data-card-css to stacked and regular log entries
  • ChatSettingsDrawer.tsx — replaces per-character on/off toggles with CardCssModeSelector tri-state UI

Test plan

  • Import a character card with <style> blocks in creator notes
  • Verify Chat mode applies CSS to the entire chat area (including UI coloring)
  • Verify Exclusive mode scopes CSS to only the character's own messages
  • Verify Disabled mode removes all card CSS from the page
  • Test with multiple characters that have CSS — verify exclusive mode isolates each
  • Verify mode persists across page reloads (stored in chat metadata)
  • Test in all surface modes: roleplay, conversation, and game narration
  • Verify no CSS leaks outside the .mari-card-css scope in Chat and Exclusive modes

🤖 Generated with Claude Code


🔄 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/1058 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 5/21/2026 **Status:** ❌ Closed **Base:** `staging` ← **Head:** `feature/creator-notes-css` --- ### 📝 Commits (7) - [`32363d0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/32363d03af9ad3f1995e46c4abd2b4472959620d) feat: render creator notes CSS from character cards - [`46fae49`](https://github.com/Pasta-Devs/Marinara-Engine/commit/46fae49b7364cbeda773f02aadc3579691eafacc) feat: add per-character card theming toggle in Chat Settings - [`b9b2387`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b9b2387b9fda9f05fb94832c4213f4e17499c6ec) feat: replace per-character card CSS toggles with tri-state mode selector - [`b178932`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b1789324669c17bd31225be2967cd3c1bf89a134) fix: add mari-card-css scope to GameSurface and data-card-css to active narration - [`097ee0c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/097ee0ccf1f2a78f0316f6ade17180099379f554) fix: move data-card-css from narration box to inner content divs - [`fda0946`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fda0946e1f351eb3762f06e53cd0a6983e08f62d) feat: harden card CSS scoping and add data-chat-mode attributes - [`e97f109`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e97f10953a9afbaa78a5c98347424f3e6db793c5) fix: strip CSS comments before scoping to prevent selector corruption ### 📊 Changes **12 files changed** (+479 additions, -52 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/chat/ChatArea.tsx` (+24 -0) 📝 `packages/client/src/components/chat/ChatMessage.tsx` (+4 -47) 📝 `packages/client/src/components/chat/ChatRoleplaySurface.tsx` (+1 -1) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+125 -0) 📝 `packages/client/src/components/chat/ConversationMessage.tsx` (+2 -0) 📝 `packages/client/src/components/chat/ConversationView.tsx` (+1 -1) ➕ `packages/client/src/components/chat/CreatorNotesCssInjector.tsx` (+87 -0) 📝 `packages/client/src/components/game/GameNarration.tsx` (+13 -2) 📝 `packages/client/src/components/game/GameSurface.tsx` (+1 -1) ➕ `packages/client/src/lib/chat-css.ts` (+197 -0) 📝 `packages/shared/src/index.ts` (+1 -0) ➕ `packages/shared/src/utils/creator-notes-css.ts` (+23 -0) </details> ### 📄 Description ## Summary - Extracts `<style>` blocks from character creator notes and injects them as scoped CSS into the chat area - Adds a **tri-state mode selector** (Disabled / Exclusive / Chat) in Chat Settings → Card Theming: - **Disabled**: no card CSS is applied — characters' embedded styles are ignored - **Exclusive**: each character's CSS only affects their own messages (scoped via `data-card-css` attribute) - **Chat**: all card CSS affects the entire chat area, including UI elements (default) - CSS is sanitized (`sanitizeChatCss`) and scoped (`scopeChatCss`) before injection - `data-card-css` attributes added to message wrappers in all surface modes (roleplay, conversation, game narration) - Chat metadata key: `cardCssMode` (replaces earlier `disabledCardCssCharIds` approach) ## Files changed - `CreatorNotesCssInjector.tsx` — new component: extracts, sanitizes, scopes, and injects card CSS per mode - `ChatArea.tsx` — reads `cardCssMode` from chat metadata, passes mode to injector in all 3 surface modes - `ChatMessage.tsx` — adds `data-card-css` to narrator, roleplay, and iMessage wrapper elements - `ConversationMessage.tsx` — adds `data-card-css` to grouped and regular message wrappers - `GameNarration.tsx` — adds `data-card-css` to stacked and regular log entries - `ChatSettingsDrawer.tsx` — replaces per-character on/off toggles with `CardCssModeSelector` tri-state UI ## Test plan - [ ] Import a character card with `<style>` blocks in creator notes - [ ] Verify **Chat** mode applies CSS to the entire chat area (including UI coloring) - [ ] Verify **Exclusive** mode scopes CSS to only the character's own messages - [ ] Verify **Disabled** mode removes all card CSS from the page - [ ] Test with multiple characters that have CSS — verify exclusive mode isolates each - [ ] Verify mode persists across page reloads (stored in chat metadata) - [ ] Test in all surface modes: roleplay, conversation, and game narration - [ ] Verify no CSS leaks outside the `.mari-card-css` scope in Chat and Exclusive modes 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:11:36 +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#4905
No description provided.