mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #1749] [MERGED] feat: character-scoped regex scripts with tri-state mode #5259
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#5259
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/1749
Author: @kolacheee
Created: 5/31/2026
Status: ✅ Merged
Merged: 6/1/2026
Merged by: @cha1latte
Base:
refactor← Head:feat/character-scoped-regex📝 Commits (7)
7ad3f50feat: character-scoped regex scripts with tri-state mode79b9a01fix: match scoped regex mode button order to card theming57743b7security: harden CSS sanitizer and regex import against malicious cardse04cb7afix: resolve architecture violations and unused exports40e5a95Fix scoped regex PR regressionsd4e63ddMerge upstream refactor into scoped regex PR329d036Address review feedback: scoped regex imports📊 Changes
16 files changed (+784 additions, -35 deletions)
View changed files
📝
src/engine/contracts/schemas/regex.schema.ts(+1 -0)📝
src/engine/contracts/types/chat.ts(+3 -0)📝
src/engine/contracts/types/regex.ts(+1 -0)📝
src/features/catalog/agents/hooks/use-regex-scripts.ts(+12 -3)📝
src/features/catalog/agents/index.ts(+1 -0)📝
src/features/catalog/agents/regex-application.test.tsx(+75 -4)📝
src/features/catalog/agents/regex-application.ts(+40 -6)📝
src/features/catalog/characters/hooks/use-character-import-flow.ts(+37 -1)📝
src/features/modes/conversation/components/ConversationInput.tsx(+12 -8)📝
src/features/modes/game/components/GameNarration.tsx(+24 -4)📝
src/features/modes/shared/chat-ui/components/ChatInput.tsx(+7 -6)📝
src/features/modes/shared/chat-ui/components/ChatMessage.tsx(+18 -2)📝
src/features/modes/shared/chat-ui/components/ChatSettingsDrawer.tsx(+164 -1)📝
src/features/shell/bot-browser/components/BotBrowserView.tsx(+17 -0)➕
src/shared/lib/regex-script-import.test.tsx(+220 -0)➕
src/shared/lib/regex-script-import.ts(+152 -0)📄 Description
Linked issue
Closes #1758
Why this change
SillyTavern character cards can embed regex find-and-replace scripts in
extensions.regex_scriptsthat transform AI output (e.g., replacing<coras_comm>tags with styled HTML). In the old engine these were imported as character-scoped scripts (PR #1059) but the feature was never completed. This is a clean rewrite for the refactored Tauri architecture, adding character scoping to the existing global-only regex system, wiring extraction into the import pipeline, and providing per-chat mode controls.What changed
characterId: string | nulltoRegexScriptinterface andcreateRegexScriptSchemascopedRegexModefield (disabled/exclusive/chat)use-regex-scriptshook: accepts optionalcharacterIdsparameter for client-side filtering (falsy checks for null/undefined compatibility with JSON storage), addeduseBatchCreateRegexScriptsanduseDeleteRegexScriptsByCharactermutationsregex-application.ts: exportedScopedRegexModetype, addedfilterForMode()function, updateduseApplyRegex(characterIds?)to filter scripts by scoped mode before applicationchatCharacterIdstouseApplyRegex, readsscopedRegexModefrom chat store, passesscopedMode+characterIdtoapplyToAIOutputchatCharacterIdsfrom props, pass touseApplyRegex, addscopedModeto allapplyToUserInputcallsactiveCharacterIdstouseApplyRegex, readsscopedRegexModefrom store, passes context toapplyToAIOutputsrc/shared/lib/regex-script-import.ts— extracts embedded regex scripts from ST cardextensions.regex_scripts, converts ST format (numeric placements,/pattern/flags,disabled→enabled), validates withisPatternSafe()ReDoS check, batch-creates viastorageApiuse-character-import-flow.tscallsimportRegexScriptsForCharacterafter successful ST batch import;BotBrowserView.tsxcalls it after bothimportStCharacterpathsRefactor impact
Primary owner: catalog (agents/regex), shared mode UI, imports
Impact areas reviewed:
src/engine/contracts/— type + schema additions (one nullable field)src/features/catalog/agents/— hooks + application logic updatedsrc/features/modes/shared/chat-ui/— ChatMessage, ChatInput, ChatSettingsDrawer modifiedsrc/features/modes/conversation/— ConversationInput modifiedsrc/features/modes/game/— GameNarration modifiedsrc/features/catalog/characters/hooks/— import flow hook modifiedsrc/features/shell/bot-browser/— BotBrowserView modifiedBoundary notes:
regex-scriptscollection, character filtering is client-sideregex-application.tsinfeatures/catalog/agents/is the display-time hook, not the prompt-assembly pipelinePressure points touched:
Validation
pnpm typecheck,pnpm build,pnpm check:architecture,pnpm check:docs, or fullpnpm checkwhen warranted)pnpm checkpasses locally before PR push/handoff, including the unused-code checkpnpm typecheckpasses locallypnpm buildpasses locallypnpm check:architecturepasses locallypnpm check:docspasses locallyManual verification notes
Docs and release impact
UI evidence
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.