fix(regex): let a script tick both display-only and prompt-only - #388
Merged
Conversation
SillyTavern treats "Only Format Display" (markdownOnly) and "Only Format Prompt" (promptOnly) as two independent opt-ins and ORs them; Glaze required both at once, so a script with both flags never ran — no caller passes isMarkdown and isPrompt together. An imported pair such as "Use Figure Spaces" / "Return Normal Spaces" therefore swapped spaces for U+2007 in the prompt but never swapped them back for display. - applyRegexes now runs a script when either opt-in matches the current pass, while the storage (run-on-edit) pass still skips both kinds so a display rewrite is never baked into the stored message - displayRegexesProvider stops dropping a promptOnly script that also ticks markdownOnly - tests cover both passes plus the storage pass for the both-flags case and the prompt-only half of the pair Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PeAHpjepbusNwo4X5DQDsp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SillyTavern treats "Only Format Display" (
markdownOnly) and "Only Format Prompt" (promptOnly) as two independent opt-ins and ORs them —getRegexedStringinpublic/scripts/extensions/regex/engine.js:Glaze required both at once (
&&-of-negatives), and no caller ever passesisMarkdownandisPrompttogether —ChatMessageMapper.toMappasses onlyisMarkdown: true,applyPromptRegexesonlyisPrompt: true. A script with both flags was therefore dead in every pass. An imported pair such as "Use Figure Spaces" / "Return Normal Spaces" swapped spaces for U+2007 in the outgoing prompt but never swapped them back for display.Changes
applyRegexes(lib/core/llm/regex_service.dart) now runs a script when either opt-in matches the current pass, mirroring ST. The storage pass (run-on-edit, neither flag set) still skips both kinds, so a display rewrite is never baked into the stored message.displayRegexesProvider(lib/core/state/active_regex_provider.dart) stops dropping apromptOnlyscript that also ticksmarkdownOnly— that second gate kept such a script out of the display list even with the engine fixed.Verification
test/regex_service_test.dartcases: amarkdownOnly + promptOnlyscript fires in the display pass and in the prompt pass but not in the storage pass, and thepromptOnlyhalf of the pair rewrites spaces only in the prompt.engine.jsgetRegexedString, plus theisMarkdown: true/isPrompt: truecall sites inpublic/script.js).flutter analyzeandflutter testwere not run — no Flutter SDK in the agent environment; relying on CI for both.🤖 Generated with Claude Code
https://claude.ai/code/session_01PeAHpjepbusNwo4X5DQDsp
Generated by Claude Code