Applying a CC preset deferred the actual settings update behind an
unawaitable event continuation, so /preset resolved before the preset
was applied. A connection profile switch runs /api, /preset, /api in
sequence, and the preset's stored chat_completion_source would land
after the final /api check, reverting the source to the previous
provider. Requests then silently went to the wrong endpoint.
The preset application chain is now captured in a promise that
selectPreset awaits, so /preset resolves only when the preset is fully
applied and follow-up commands sequence correctly. The UI dropdown
path is unchanged, and callers that do not await selectPreset keep
the exact previous behavior.
Fixes#5926Fixes#5147
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* feature: support Claude Opus 4.8 model
* feature: support OpenAI GPT 5.6 models
* fix: replace deprecated Gemini preview model with stable gemini-3.1-flash-lite
* Fix GPT-5.6 Chat Completions effort mapping
- Map Maximum reasoning effort to xhigh because max is Responses-only
- Clarify model-specific OpenAI and adaptive Claude effort guidance
- Cover stable Gemini 3.1 Flash-Lite thinking-level routing
Tests:
- npm run test:unit -- --runInBand
- ESLint on all changed JavaScript files
* Fix: migrate Gemini image models to stable IDs
- Replace shut-down Gemini image preview selectors for Google AI and Vertex AI
- Migrate saved chat and caption model settings to the stable replacements
- Enable image generation for the stable model IDs
- Correct the Gemini 3.1 Flash Image context fallback to 128K
- Add regression coverage for stable Gemini 3 image thinking levels
Tests:
- npm run test:unit -- --runInBand
- ESLint on all changed JavaScript files
---------
Co-authored-by: Wolfsblvt <wolfsblvt@gmail.com>
* Optimize World Info entry sorting to avoid O(n^2) lookups
The comparator in checkWorldInfo called sortedEntries.indexOf() twice per
comparison, making the sort O(n^2 log n). Build an index Map once and use
it for lookups instead. Sort order is unchanged.
* Address review: build index map before sort, use -1 for unknown entries
Move sortedEntriesIndex creation to immediately before the activatedNow
sort so indices match the current sortedEntries array. Use ?? -1 so
externally force-activated (cloned) entries behave like indexOf(-1).
* Skip index map when at most one entry needs sorting
Build sortedEntriesIndex only when activatedNow.size > 1, since the
comparator is not used for zero or one activated entries.
---------
Co-authored-by: ransxd <ransxd@users.noreply.github.com>
* Update TTS model from Gemini 2.5 to 3.1 in TTS Extension
Added New versions and new Default model
* Add glm-5.2 option to model selection dropdown
Co-authored-by: Samueras <Samueras@jackoedv.de>
* Split Pollinations into two separate API providers: (Key) and (No Key)
- Replaces the single "Pollinations" source with two distinct entries:
- "Pollinations (Key)": uses gen.pollinations.ai/v1 with Bearer token auth,
supports BYOP OAuth flow with app key pk_Gu8Ta8q6QhS67hSg and manual key entry
- "Pollinations (No Key)": uses text.pollinations.ai/v1, no authentication required
- Renames CHAT_COMPLETION_SOURCES.POLLINATIONS to POLLINATIONS_KEY/POLLINATIONS_NOKEY
throughout the codebase (constants, endpoints, frontend scripts)
- Adds BYOP authorize button and OAuth callback handler for key-based source
- Updates all data-source attributes, secret key mappings, model selectors,
tool-calling, reasoning, slash-commands, caption, and SD extension references
https://claude.ai/code/session_01T57Cm84cv2GiSL4DPCccBj
* Fix POLLINATIONS_NOKEY: exempt from API key check, fix placeholder text
- Add POLLINATIONS_NOKEY to the keyless providers exemption in the
/generate endpoint's API key guard (was hitting the 400 check)
- Remove 'pk_...' from the key input placeholder since pk_ is the
app key used in the BYOP auth link, not the user's secret key
https://claude.ai/code/session_01T57Cm84cv2GiSL4DPCccBj
* Add Pollinations anonymous/authenticated endpoint selector
Implements reviewer feedback to use a single Pollinations provider with
an endpoint dropdown (similar to Z.AI) rather than two separate sources.
- Add POLLINATIONS_ENDPOINT enum (anonymous / authenticated)
- Anonymous uses text.pollinations.ai/v1, no API key required
- Authenticated uses gen.pollinations.ai/v1, requires sk_... key with BYOP OAuth support
- Key input and BYOP button are hidden when anonymous endpoint is selected
- Backend skips key guard for anonymous requests
- Reasoning effort and JSON schema only sent for authenticated mode
- Connection status check passes for anonymous without a saved key
https://claude.ai/code/session_01T57Cm84cv2GiSL4DPCccBj
* Fix broken Pollinations references after resolving merge conflicts
- Replace POLLINATIONS_KEY/NOKEY in CHAT_COMPLETION_SOURCES with POLLINATIONS
- Fix SECRET_KEYS.POLLINATIONS → SECRET_KEYS.POLLINATIONS_KEY in backend
- Update all chat_completion_sources references in openai.js to use unified POLLINATIONS
- Consolidate duplicate model select/change handlers into single pollinations_model
- Keep backward compat in caption-image handler for pollinations_key/nokey multimodal API
- Fix openai.js inline handler to route pollinations to correct endpoint based on endpoint field
https://claude.ai/code/session_01T57Cm84cv2GiSL4DPCccBj
* Complete Pollinations unification: remove all pollinations_key/nokey splits
- Fix committed merge conflict in openai.js (Wolfsblvt review)
- Replace POLLINATIONS_KEY/NOKEY in chat_completion_source dropdown with single POLLINATIONS option
- Replace pollinations_key,pollinations_nokey in all data-source attributes with pollinations
- Merge duplicate /pollinations_key and /pollinations_nokey multimodal routes into single /pollinations
- Update caption extension: single "Pollinations" option using pollinations_endpoint from oai_settings
- Update slash-commands.js model selector to single pollinations entry
- Clean up caption-image handler (openai.js) to use only 'pollinations' api type
- Pass pollinations_endpoint in caption request body (shared.js)
- Add settings migration: pollinations_key → pollinations, pollinations_nokey → pollinations (anonymous)
https://claude.ai/code/session_01T57Cm84cv2GiSL4DPCccBj
* Address Cohee review: named constants, mock key, revert POLLINATIONS_KEY rename, default to authenticated
- Use POLLINATIONS_ENDPOINT named constants throughout (no magic 'anonymous' strings)
- Use mock key pattern (set key to POLLINATIONS_ENDPOINT.ANONYMOUS value) so no guard exception needed
- Revert POLLINATIONS_KEY rename back to POLLINATIONS in secrets.js files
- Default pollinations_endpoint to AUTHENTICATED so saved keys aren't bypassed
- Remove redundant isPollinationsAnon check from getReasoningEffort() (backend handles it)
- Unify tool-calling.js, caption, shared, stable-diffusion to single POLLINATIONS source
https://claude.ai/code/session_01T57Cm84cv2GiSL4DPCccBj
* Fix ESLint padded-blocks error in BYOP OAuth callback
https://claude.ai/code/session_01T57Cm84cv2GiSL4DPCccBj
* fix: regression in caption API validation
* fix: remove unneeded migration
* fix: remove duplicate keyless check in apiSourceConfig
* fix: regression in extractReasoningFromData
* refactor: simplify UI unhide logic
* fix: remove BYOP flow due to security concerns
* fix: use a string instead of a constant reference for placeholder key
* fix: reconnect when switching endpoints
* feat: support pollinations in /api-url command
* fix: remove endpoint check from image generation (it always uses authenticated)
* fix: default to authenticated
* fix: use a named constant in auto-connect logic
* fix: filter by modality in anon models list
* fix: remove bespoke model loading logic for anon endpoint
---------
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
* feat(core): add MessageFormatter pipeline for extension message hooks
Introduces a new MessageFormatter singleton class (public/scripts/message-formatter.js)
that allows extensions to transform message text at well-defined stages of the
messageFormatting() pipeline, before the result reaches the DOM.
The pipeline exposes three hook stages (all before DOMPurify sanitization):
- BEFORE_REGEX -- raw Markdown, before custom regex rules
- AFTER_REGEX -- plain Markdown, after regex, before showdown conversion
- AFTER_MARKDOWN -- rendered HTML, after showdown, before sanitization (default)
There is intentionally no post-sanitize stage to prevent XSS vectors.
Extensions register hooks via getContext().messageFormatter.addHook(fn, { stage, order }).
Stage and order enums (formatting_stage, hook_order) are re-exported on the
singleton instance itself so extensions need no additional imports beyond getContext().
The formatter also exposes a .format() shim over messageFormatting() for
convenience. messageFormatting() itself gains full JSDoc documentation.
* feat(core): add pipeline documentation to MessageFormatter.format()
Adds detailed JSDoc documentation to the MessageFormatter.format() method
describing the complete 11-step message formatting pipeline, from prompt-bias
stripping through DOMPurify sanitization. Clarifies that all extension hooks
(beforeRegex, afterRegex, afterMarkdown) run before sanitization to ensure
their output is always sanitised.
* feat(core): add async detection and non-string return guards to MessageFormatter
Adds runtime and registration-time safety checks to the MessageFormatter hook system:
- Throws TypeError at registration if an async function is passed to addHook()
- Emits console warning and ignores return value if a hook returns non-string at runtime
- Detects Promise returns and includes helpful hint that hook may be async
- Updates JSDoc to clarify synchronous string return requirement and error conditions
* test(frontend): add comprehensive e2e tests for MessageFormatter
Adds full test coverage for the MessageFormatter singleton class including:
- Module exports validation (formatting_stage, hook_order enums)
- Singleton instance constant re-exports
- Registration validation (rejects non-functions, async functions, unknown stages)
- Hook execution pipeline (stage isolation, order sorting, context freezing)
- Error handling (continues on throw, warns on non-string/Promise returns)
- Stage injection
* refactor(core): rename ch_name parameter to characterName in MessageFormatter
Renames the `ch_name` parameter to `characterName` throughout MessageFormatter for improved code clarity and consistency with modern naming conventions. Updates JSDoc typedef and method signatures.
* fix: handle scoped comment macro closing tag tokenization edge case
The lexer greedily tokenizes '//' before '/', causing {{///}} to parse as {{// /}} instead of {{/ //}}. Added special case detection in MacroCstWalker to check if the comment macro's first argument starts with '/' and treat it as a closing block. Removed list/strictArgs flags from comment macro definition and added comprehensive e2e tests for scoped comment blocks.
* refactor: DRY, remove unneccessarily duplicated private extractMacroInfo
* feat: enhance world info sorting with ascending/descending modes and animation
- Add autoFocus property to popup inputs with autofocus attribute and tabIndex
- Add slide animation to setInfoBlock/clearInfoBlock with configurable animate option
- Replace simple input prompt with detailed popup for applying current sorting
- Add ascending/descending order toggle for world info entry sorting
- Add configurable step value between order assignments
- Add real-time warning when starting value is below
* fix: improve world info sorting warning to account for step value
- Update warning calculation to consider step size when detecting order collisions
- Add step input parameter to updateWarning function
- Attach input listener to step field for real-time warning updates
- Display more detailed warning message showing the calculated final order value
Temporarily commented out Filter.Pipe and Filter.EscapedPipe token handling in MacroLexer to fix issue where pipe characters in argument values (e.g., {{setvar::foo::|bar}}) were incorrectly parsed as filter operators. Added regression tests for pipe handling in argument values and skipped existing output modifier tests until filter flag (>) logic is properly implemented.
Resolves: #5618
When a textarea is removed from the DOM before the autocomplete
clone-positioning logic runs, parentElement is null and
MutationObserver.observe throws. This can happen when extensions
abort generation early (via generate_interceptor) and the textarea
is torn down before autocomplete finishes setup.
Add a null check so the observer is only attached when the parent
still exists.
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
* fix mislabelled popup for "Replace existing Quick Reply Set"
it currently provides a popup asking for confirmation "Replace existing World Info" when user tries to create a new QR Set with an existing name.
Checked that it does not conflict/reuse anything from the actual world info screen.
* capitalisation
* update: improve fetching of selected default expression
It includes the fallback values #emoji and #none.
* update: allow expression-list to filter custom expressions
It can allow, filter out, or only include custom expressions in the result.
* update: separate getLastExpression from the slash command to use on macros
* feat: register defaultExpression macro
It will fetch the label of the currently selected global fallback expression.
* feat: register lastExpression macro
It will return the last expression used by the selected character.
* feat: register availableExpressions macro
Returns a list of all expressions provided by the Classifier API.
* update: fix macros labels
* update: normalize return label for defaultExpression macro
* Fix - Typos
* Update - Add compatibility with old macro engine
* Fix - Remove redundant structuredClone
* Update - Consider sprite folders to fetch the last expression used
* Update - Improve last message handling when name is provided
* Fix - Update description of getLastCharacterMessage
* Update - Bring back using active character as fallback for groups
Just weighted that if no name is provided, doing fallback to the active character generating prompt is more useful for groups than grabbing the expression used by another character, after randomly removing that prev commit.
* Fix personal lore stale update on rename (#5628)
* Add test for rename persona lore
Co-authored-by: Copilot <copilot@github.com>
* Fix stale update on personal lore rename
Co-authored-by: Copilot <copilot@github.com>
Given the recent work to fix#5610, this is a continuation to fix a
similiar bug in the persona lore.
* Add newline for linter check
---------
Co-authored-by: Copilot <copilot@github.com>
* feat: update links for other personas
---------
Co-authored-by: Unnatural Developer <40277404+unnaturaldeveloper@users.noreply.github.com>
Co-authored-by: Copilot <copilot@github.com>
* Add test to reproduce chat lore bug
Co-authored-by: Copilot <copilot@github.com>
Given that I wanted to reliably reproduce the bug, I created a playwright Docker container as part of this commit, along with the applicable unit test. The included docker-compose includes an environment variable that is passed for use by the frontend test harness, default to the host that the playwright and the ST instance containers are running on.
* Fix stale chat bound lore name after rename
Co-authored-by: Copilot <copilot@github.com>
Given the function renameWorldInfo and the resulting call to updateWorldInfoLinks, this fix ensures that if the world_info key in the chat_metadata is still set to the old name, it will be updated to the name
Resolves: #5608
* Start to separate test runner from branch
Given the bug fix for #5608 should be separate from the test runner
compose file, this commit removes the file from the branch associated
with the bug fix.
* Fix frontend test setup to check for login page
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
* Make change to eslint configuration
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
Given the updates to the setup of frontend-utils, configure eslint to
recognize browser and jquery specific globals
---------
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
* feat: add allowBaseName option to getUniqueName utility function
* feat: simplify getUniqueName by removing allowBaseName option and changing default startIndex to 0
* Update - Turn expression-set-fallback into expression-fallback
Make the extension a getter and setter instead of a setter only.
* Update - Rewrite the help string and add usage examples
* Fix - Remove the alias
* Feat - Add expression-set-fallback slash command
* Fix ESLint
* Fix - Use proper name convention for slash command method
* Fix - Change misleading expression-set-fallback help string label
* Fix - Use normal description for expression label argument
* Update - Make expression-set-fallback case unsensitive
Also fixed array creation by removing the spread syntax and added warning.
* feat: enhance asset management with extension categories
Co-authored-by: Copilot <copilot@github.com>
* fix: enhance extension name validation in server endpoints
* feat: display extension author in the extensions list
* fix: unify server error response format
Co-authored-by: Copilot <copilot@github.com>
* feat: add splash on installing third-party for the first time
* fix: add URL format validation, unify validation error messages
Co-authored-by: Copilot <copilot@github.com>
* fix: apply object freeze to EMPTY_AUTHOR value
Co-authored-by: Copilot <copilot@github.com>
* fix: typecheck extensionName in API requests
Co-authored-by: Copilot <copilot@github.com>
* feat: add feature flag guard to extensions endpoints
Co-authored-by: Copilot <copilot@github.com>
* fix: parse URL before checking
Co-authored-by: Copilot <copilot@github.com>
* fix: use case insensitive regex check
* fix: make debug log more useful
Co-authored-by: Copilot <copilot@github.com>
* fix: add pre-validation of URL format and protocol
Co-authored-by: Copilot <copilot@github.com>
* fix: leaner installation success toast
* fix: settings data loss when extensions are disabled
* fix: don't try to auto-focus elements that don't exist
Co-authored-by: Copilot <copilot@github.com>
* fix: set Popup.defaultResult to negative
Co-authored-by: Copilot <copilot@github.com>
* revert: restore undefined default result
---------
Co-authored-by: Copilot <copilot@github.com>
* Improve NanoGPT Model List
* Update token multiplier condition to !== 1 to support showing discounts
* Add Model Sorting
* rework sorting to be more compact
* feat: combine CC model sorting/grouping settings
Co-authored-by: Copilot <copilot@github.com>
* fix: adjust migration logic
Co-authored-by: Copilot <copilot@github.com>
* feat: implement grouping for Chutes
* fix: apply review suggestions
* fix: call reconnect instead of direct status check
---------
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
Co-authored-by: Copilot <copilot@github.com>
* feat: add gemma 4 for AI studio
* fix: update max context return value for gemma-3n-e4b-it model
* refactor: iterate array of [regex, number]
* gemma4: enable tool calling and sysprompt
Co-authored-by: Copilot <copilot@github.com>
---------
Co-authored-by: Copilot <copilot@github.com>
* added macro processing to caption ext
added
`prompt = substituteParamsExtended(prompt);`
to the captionmultimodal function
(so it can use macros and stuff)
* caption ext updated from old substituteparams
* removed comment
This fixes the following bug in Firefox Mobile on Android:
**Steps to reproduce:**
1. Swipe a word into the chat input edit field in Firefox Mobile on Android, for examples "Test".
2. In GBoard (default Android keyboard), tap on a different suggestion, for examples "Rest".
**Expected behavior:** The word "Test" is replaced with "Rest".
**Actual behavior:** The word becomes "TestRest".
I confirmed with bisecting that the commit f897a4ab1a introduced the issue.
This change fixes the issue by disabling the layout hack while editing text.
Disabling the layout hack is limited to Firefox Mobile because
* I could not reproduce the bug in Chrome on Android
* This way, if it causes a new bug, only Firefox Mobile users are affected
* feat: add MiniMax as a chat completion provider
Add MiniMax (https://www.minimax.io) as a first-class chat completion
provider. MiniMax already has TTS integration in SillyTavern; this
extends support to LLM chat completions via their OpenAI-compatible API.
Supported models:
- MiniMax-M2.5 (default) — 204K context
- MiniMax-M2.5-highspeed — same capability, faster inference
Key implementation details:
- Reuses existing SECRET_KEYS.MINIMAX (shared with TTS)
- API endpoint: https://api.minimax.io/v1
- Temperature clamped to (0.0, 1.0] as required by MiniMax API
- Returns hardcoded model list since MiniMax doesn't expose /v1/models
- Full UI integration: model selector, sampler parameters, streaming
Co-Authored-By: octo-patch <octo-patch@users.noreply.github.com>
* feat: upgrade MiniMax default model to M2.7
- Add MiniMax-M2.7 and MiniMax-M2.7-highspeed to model list
- Set MiniMax-M2.7 as default model
- Keep all previous models as alternatives
* feat: independent request function, vision support, temp clamping for MiniMax
- Extract sendMinimaxRequest() following Chutes pattern (PR #4844)
with function calling and JSON Schema structured output support
- Clamp temperature to (0.01, 1.0] on backend; limit frontend UI max to 1.0
- Enable image inlining for MiniMax M2.7 model
- Add MiniMax to slash-commands model selector and tokenizer mapping
- Add minimax_model to default preset
* feat: add VLM-based vision support for MiniMax M2.7
M2.7 does not natively accept image input. When images are detected
in messages, pre-process them via the MiniMax VLM endpoint
(/v1/coding_plan/vlm) to convert images to text descriptions before
sending to the chat completions API. Uses the same API key.
* feat: add M2-her model to MiniMax provider
M2-her is MiniMax's dialogue/roleplay-optimized model with 64K context
and 2048 max completion tokens. Text-only (no vision).
* feat: add MiniMax China endpoint (minimaxi.com) support
Add endpoint selector (Global/China) for MiniMax, mirroring the
SiliconFlow pattern. Users can now choose between api.minimax.io
(international) and api.minimaxi.com (China domestic).
* fix: merge consecutive same-role messages for MiniMax
MiniMax API rejects consecutive messages with the same role with
error 'invalid chat setting (2013)'. Merge them before sending.
* review: address PR feedback on MiniMax provider
Backend (src/endpoints/backends/chat-completions.js):
- Drop the entire MiniMax VLM image-preprocessing path; vision is no
longer advertised for this provider, so M2.7 messages now go straight
to /chat/completions without a separate VLM round-trip.
- Drop the json_schema -> response_format mapping (MiniMax does not
document structured-output support; relying on it was speculative).
- Drop the backend temperature clamp; the same clamp now lives in the
frontend so the wire payload matches what the user sees.
- Drop the MINIMAX branch in /status that returned a hard-coded model
list; the frontend hardcodes the same list and bypasses /status via
noValidateSources, so the round-trip was wasted.
- Add a streaming Transform + non-streaming helper that move
<think>...</think> blocks from delta.content / message.content to
reasoning_content. MiniMax M2.x emit chain-of-thought inline in
content; without this transform the raw <think> tags leak into the
rendered chat. Includes a state machine that holds back partial
marker bytes so a marker split across SSE chunks is still detected.
Frontend:
- public/scripts/openai.js: add MINIMAX to noValidateSources so the key
is accepted without a /models call; remove the dead saveModelList
branch; clamp temperature to (0.0, 1.0] in createGenerationParameters.
- public/scripts/reasoning.js: add MINIMAX to the non-streaming
reasoning_content extraction case (the backend transform now produces
this field for MiniMax responses).
- public/scripts/slash-commands.js: add MINIMAX to the /api enum and
add a MiniMax case to /api-url so users can switch endpoint by
command.
- public/scripts/custom-request.js: pass minimax_endpoint through the
override-payload merge alongside the other per-source endpoint fields.
- public/scripts/tokenizers.js: stop returning openai_model (which was
always a MiniMax model id and thus an unknown tokenizer); fall back
to gpt-3.5-turbo for a coarse but functional estimate.
- public/scripts/tool-calling.js: add MINIMAX to supportedSources so
function-calling settings are exposed.
- public/index.html: drop the "-- Connect to the API --" placeholder
option from the model select (the model list is hardcoded and always
populated); remove minimax from the vision data-source attributes
on the inline-media controls.
- public/img/minimax.svg: replace the multicolor brand SVG with a
single-color currentColor version that matches the other provider
icons in the connect panel.
* review: drop backend <think> parsing, defer to frontend
Per reviewer feedback: SillyTavern's reasoningHandler / reasoning_auto_parse
setting already extracts <think>...</think> blocks on the client side, so the
backend doesn't need to rewrite MiniMax responses. Removes the SSE Transform,
the non-streaming helper, and the corresponding case in reasoning.js.
* fix: remove isImageInliningSupported declaration for MINIMAX
* fix: remove MINIMAX from stream reasoning parsing
* fix: add to autoconnect logic
* fix: add missing MINIMAX models from docs
* fix: freq. and pres. pen aren't supported for MINIMAX
* fix: use clamp function for adjusting temperature
* fix: pass minimax_endpoint from connection profile to ChatCompletionService
* fix: update supported APIs in slash command documentation
* fix: replace bespoke merge with standard MERGE_TOOLS processing
* fix: add data-i18n attributes for headers
---------
Co-authored-by: octo-patch <octo-patch@users.noreply.github.com>
Co-authored-by: octo-patch <octo-patch@github.com>
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>