Commit Graph

11572 Commits

Author SHA1 Message Date
Robert de Forest ef25a03650 Expose character update APIs for extensions (#5062)
* Expose character update APIs for extensions

Add getCharacterSource, importFromExternalUrl, and importTags to the
extension context (SillyTavern.getContext()). This allows extensions to:

- Get the source URL for a character (Chub, etc.)
- Import/update a character from an external URL
- Import tags from a character's embedded tag data

These functions already exist and are used internally but were not
exposed to extensions. This enables extension developers to build
features like bulk character update checking and tag synchronization.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix review comments

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-01-26 20:38:23 +02:00
Cohee 5a7875ba28 Update Pollinations API (#5060)
* Upgrade Pollinations API
Done: text, caption
To do: TTS, image
Fixes #5020

* Update Pollinations TTS to new API

* Update Pollinations API for images
2026-01-26 20:31:13 +02:00
Cohee ffa01d80a6 Add macros autocomplete to alternate greetings 2026-01-23 23:51:06 +02:00
Wolfsblvt 9ff9d59672 Macros 2.0 (v0.7.1) - Macro Autocomplete everywhere (#5019)
* Add macro autocomplete for free text inputs

Implements macro autocomplete (`{{`) for textareas and input fields marked with `data-macros` attribute. Extracts shared autocomplete logic into MacroAutoCompleteHelper.js for consistency between slash command and free text contexts. Includes MutationObserver for dynamic element initialization and supports variable shorthands, operators, flags, and scoped macro closing tags.

* fix annoying circular dependency again

* Add `data-macros` attribute to enable macro autocomplete on text inputs

Enables macro autocomplete (`{{`) for various textareas and input fields throughout the UI by adding the `data-macros` attribute. Includes context template fields, instruct mode sequences, character/persona descriptions, world info content, and other prompt-related inputs. Also ensures the attribute is preserved when expanding editors and creating world info entries.

* Allow macro autocomplete in editing messages

Enables macro autocomplete (`{{`) when editing messages by adding the `data-macros` attribute to the dynamically created edit textarea element.

* Add autocomplete visibility setting support for macro autocomplete

Respects the global STScript autocomplete visibility setting (`power_user.stscript.autocomplete.state`) for macro autocomplete in free text inputs. When set to "Input length > 1", macro autocomplete only activates after typing `{{` plus at least 2 characters. Also adds a tooltip to the visibility setting explaining it applies to both slash commands and macros.

* Fix unclosed div tag in STScript autocomplete visibility setting

Closes the `<div>` tag that was incorrectly left open in the autocomplete visibility setting markup.

* Add setting to control macro autocomplete visibility in non-expanded fields

Introduces a new `showInAllMacroFields` setting that controls whether macro autocomplete appears in all macro-enabled fields or only in expanded editors and when pressing Ctrl+Space. Also adds `data-macros-autocomplete` attribute support with `always` and `hide` modes for per-field override. When the setting is off, autocomplete only shows in expanded editors (which now get `data-macros-autocomplete="always"`) and the completion

* Add `data-macros-autocomplete-style` attribute to control macro autocomplete popup size

Introduces a new `data-macros-autocomplete-style` attribute with `small` (33vw, max 700px) and `expanded` (default chat width) modes to control macro autocomplete popup dimensions. The `small` style is now the default for inline fields, while `expanded` is used for expanded editors and prompt manager. Also refactors `getAutocompleteMode` to return `DEFAULT` instead of `null` and adds corresponding `getAutocompleteStyle` helper

* Fix autocomplete details panel alignment when list is constrained by viewport edge

Adjusts the details panel position to align with the actual autocomplete list position when the list is constrained by the right edge of the viewport. Previously, the panel would position based on cursor location even when the list was pushed left, causing misalignment. Now checks if the list's actual position differs from the calculated position (with 5px tolerance) and uses the list's position instead.

* Guard autocomplete details panel alignment check with `isReplaceable` condition

Prevents attempting to read the autocomplete list's bounding rect when the list is not visible. The alignment adjustment for viewport-constrained lists now only runs when `isReplaceable` is true, avoiding potential errors when the list DOM is not rendered.

* Fix macro autocomplete cursor detection to handle nested macros correctly

Updates `findMacroAtCursor` to track nesting depth when searching for opening `{{` and closing `}}` braces. Previously would incorrectly stop at the first brace pair encountered in either direction, breaking autocomplete when cursor was inside nested macros like `{{getvar::{{getvar::name}}}}`. Now properly skips over nested macro boundaries by incrementing/decrementing depth counters until finding the matching braces at depth

* gief me my comments back (and fixes, that were missed)

- Added detailed JSDoc comments to all exported functions explaining parameters, return types, and behavior
- Added inline comments throughout functions explaining logic flow, edge cases, and implementation details
- Documented parser-based vs regex-based unclosed scope detection approaches
- Clarified variable shorthand autocomplete logic including operator filtering, context display, and priority

* refactor(macros): freeze MACRO_AUTOCOMPLETE_MODE and MACRO_AUTOCOMPLETE_STYLE enums

* feat(macros): explicitly set `makeSelectable` flag for non-insertable autocomplete options

- Set `makeSelectable = true` for variable shorthand options in {{if}} conditions (already insertable)
- Set `makeSelectable = false` for already-typed operators in variable shorthand autocomplete
- Set `makeSelectable = false` for already-typed flags in macro autocomplete
- Set `makeSelectable = false` for non-selectable closing block flags when no unclosed scopes exist
- Set `makeSelectable = false` for sc

* refactor(macros): consolidate typedef imports in MacroAutoCompleteHelper

- Fixed typo in MacroDefinition typedef import (removed extra `/` from JSDoc comment)
- Replaced long-form typedef imports with short-form aliases for MacroAutoCompleteContext and MacroDefinition
- Improved code consistency by using imported typedefs throughout function signatures

* refactor(autocomplete): select first selectable item as default instead of always first item

- Extracted default item selection logic into `selectDefaultItem()` method
- Changed default selection to prioritize first selectable item over first item in list
- Falls back to last item when no selectable items exist (preserves context for info-only options)
- Added JSDoc documentation explaining selection behavior

* feat(macros): make already-typed variable names non-selectable in autocomplete

- Set `makeSelectable = false` for variable name options that match the currently typed name
- Set empty `valueProvider` for matched variables to prevent re-insertion
- Prevents redundant selection of variables that are already fully typed in the input

* feat(macros): add value context autocomplete option for variable shorthand operators

- Created `VariableValueContextAutoCompleteOption` class to display context about expected values
- Shows operator name, symbol, and description when typing variable shorthand values
- Displays currently typed value and completion hint
- Non-selectable option (context only) with priority 4
- Added to variable shorthand autocomplete when operator is typed and value is being entered

* fix lint

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-01-23 23:46:47 +02:00
Wolfsblvt ca60ba148c chore(macros): Allow registration of aliases for existing macros (#5053)
- Added `registerMacroAlias()` public method to register aliases for existing macros
- Extracted shared registration logic into private `#registerMacroEntry()` helper
- Refactored `registerMacro()` to use `#registerMacroEntry()` for both primary macros and aliases
- Alias registration validates name format, prevents self-aliasing, and resolves alias chains to primary definition
- Aliases inherit handler and metadata from target but has source of the registration caller
2026-01-23 23:19:07 +02:00
Cohee bf7efbf7e1 Merge branch 'release' into staging 2026-01-23 22:52:57 +02:00
Cohee 7a497421bb Add getOneCharacter to getContext 2026-01-23 22:52:17 +02:00
Wolfsblvt 42155ecebf Macros 2.0 (v0.7.3) - Variable Shorthand: Comparison Operators & Autocomplete Improvements (#5050)
* feat: Add numeric comparison operators (>, >=, <, <=) to variable shorthand syntax

- Added four new comparison operators for local and global variables
- Implemented greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual operations in MacroCstWalker
- Updated lexer to recognize >=, >, <=, < operators (longer patterns before shorter to avoid conflicts)
- Simplified parser by consolidating operator alternatives into single OR block
- Enhanced autocomplete with operator definitions, examples, and usage

* Improve autocomplete for variable shorthand operators with cursor-aware filtering

- Track `variableNameEnd` and `variableOperatorEnd` positions in parsed macro context for accurate cursor position checks
- Add `isShortOperatorPrefix()` helper to detect operators that could be prefixes of longer ones (e.g., `>` → `>=`)
- Fix operator autocomplete to show longer variants when typing short operators (typing `>` now shows both `>` and `>=`)
- Show operator suggestions immediately when variable
2026-01-23 01:05:00 +02:00
Wolfsblvt 6f5032f20e Allow reasoning edit to substitute macros on saving the reasoning (#5052)
* Apply macro substitution when editing reasoning content

- Added `substituteParams()` call to process macros in edited reasoning text
- Changed `newReasoning` from const to let to allow reassignment

* chore: Remove unnecessary double macro substitution from message edit

- Removed `substituteParams()` call for first message (index 0) in `messageEditDone()`
- Macro substitution is now handled consistently by `updateMessage()` for all messages
2026-01-23 00:45:26 +02:00
Cohee 042dd44408 Add APP_INITIALIZED to event auto-fire list 2026-01-23 00:32:43 +02:00
DeclineThyself cc12ace48d Clarified contribution guidelines for large PRs. (#5032)
* Added guidelines for splitting large PRs.

* Added links, formatting and mentioned dot property access.

* Fixed and corrected:
https://github.com/SillyTavern/SillyTavern/pull/5032#discussion_r2707433279
https://github.com/SillyTavern/SillyTavern/pull/5032#discussion_r2707445447
https://github.com/SillyTavern/SillyTavern/pull/5032#discussion_r2707449255
https://github.com/SillyTavern/SillyTavern/pull/5032#discussion_r2707455801
https://github.com/SillyTavern/SillyTavern/pull/5032#discussion_r2707458468

* Removed and altered: https://github.com/SillyTavern/SillyTavern/pull/5032#discussion_r2710152562 https://github.com/SillyTavern/SillyTavern/pull/5032#discussion_r2710125321 https://github.com/SillyTavern/SillyTavern/pull/5032#discussion_r2710129926 https://github.com/SillyTavern/SillyTavern/pull/5032#discussion_r2707430359

* Get rid of nested lists

---------

Co-authored-by: user <user@exmaple.com>
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-01-23 00:24:38 +02:00
DeclineThyself a09c1a7a84 Added 'dot-notation': ['error'] to .eslint.cjs (#5042)
* Added 'dot-notation': ['error'], to `.eslint.cjs`

* Ran `eslint --fix` to correct `dot-notation` errors.

* Added `eslint-disable dot-notation` anywhere errors were caused.

* Allowed dot-notation for uppercase properties: 'allowPattern': '[A-Z]\\w*$'

* Check if `rule instanceof CSSStyleRule`
https://github.com/SillyTavern/SillyTavern/pull/5042#discussion_r2711827148

* Fixed `await result.json();` types.

* refactor: update dot-notation usage in CoquiTtsProvider and PresetManager

---------

Co-authored-by: user <user@exmaple.com>
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-01-23 00:11:03 +02:00
Cohee 03f671ca72 Merge branch 'release' into staging 2026-01-22 23:59:08 +02:00
Cohee d6a20ba546 Fix npm audit 2026-01-22 23:58:57 +02:00
Wolfsblvt 26d495f457 Add /reroll-pick command to reset {{pick}} macro (#5049)
* feat(macros): Add `/reroll-pick` command to reset `{{pick}}` macro choices

- Added `/reroll-pick` slash command to change the seed for all `{{pick}}` macros in current chat
- Command accepts optional numeric seed value, otherwise increments current seed by 1
- Updated `{{pick}}` macro to use `pick_reroll_seed` from chat metadata in seed calculation
- Updated `{{pick}}` macro description to mention reroll capability
- Added comprehensive help text with examples for `/reroll-pick` command
- Updated tests

* lint fix

* fix(macros): exclude null reroll seed from {{pick}} hash calculation

- Changed reroll seed default from 0 to null when not set
- Filter out null values from combined seed string to avoid including "-0" suffix
- Updated both core macro implementation and tests to match new behavior

* Use strict null comparison

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-01-22 23:52:59 +02:00
Wolfsblvt f3c886fd12 Add APP_INITIALIZED event before hideLoader in initialization sequence, before APP_READY fires (#5051)
* Add APP_INIT event before hideLoader in initialization sequence

* refactor(events): rename APP_INIT to APP_INITIALIZED

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-01-22 23:40:48 +02:00
Forkoz b5eacfa014 Add tabby for adaptive_P (#5044) 2026-01-22 12:39:03 +02:00
san-tian 865114fb1c Replace error with warn when failing to write config.yaml
* try to modify config.yaml at start instead of modify it

* replace error with warn when failing to write config.yaml

---------

Co-authored-by: ccss <ccss>
2026-01-21 14:56:23 +02:00
Cohee ff78290fd0 glm-4.7-flash 2026-01-20 23:22:29 +02:00
Cohee 2c09d32b5b feat(docker): add robust healthcheck script (#5028)
* feat(docker): add robust healthcheck script

- Added `docker/healthcheck.cjs`: A standalone, dependency-free Node.js script for verifying server status.
- Updated `Dockerfile`: Added HEALTHCHECK instruction and script copy step.
- Features: Auto-detects port from env/config, handles IPv4/IPv6 fallback, auto-retries HTTPS on socket hangup, and sets custom User-Agent.

* feat(docker): new healthcheck with /api/health endpoint

- Added `GET /api/health` endpoint to `server.js` (unauthenticated) for lightweight status checks.
- Update `docker/healthcheck.cjs`: Rewrite
- Updated Error handle for `HEALTHCHECK`

* feat(docker): switch to heartbeat file healthcheck mechanism

- Replaced network-based check with a file-based heartbeat approach.
- Updated `src/command-line.js`: Added `heartbeatInterval` argument with explicit ENV override (`SILLYTAVERN_HEARTBEAT_INTERVAL`).
- Updated `src/server-main.js`: Added logic to write `heartbeat.json` to data directory at set intervals.
- Rewrote `docker/healthcheck.cjs`: Script now monitors the heartbeat file timestamp (zero dependencies, no config parsing required).
- Updated `Dockerfile`: Sets default heartbeat interval to 30s and ensures script availability.
- Updated `config.yaml`: Added `heartbeatInterval` defaulting to 0 (disabled) for non-Docker users.

* Fix variable names

* Convert to ESM, use serverDirectory variable

* Move file to /src

* fix: update heartbeat path to use global DATA_ROOT variable

* Pretty colors

* Move healthcheck to docker-compose.yml

* Comment fixed

* Even cleaner diff!

---------

Co-authored-by: Pavdig <101715456+Pavdig@users.noreply.github.com>
2026-01-18 16:36:37 +02:00
Cohee 1ff98e76f8 Recent Chats: Add pin functionality (#5030)
* feat: Implement pinned chat functionality in welcome screen

* Highlight pinned / unpinned blocks

* Reduce flash duration
2026-01-18 15:50:23 +02:00
Mooki a50fecee25 feat(sd): Add generation status indicator and improve abort handling (#5015)
* feat(sd): Add generation status indicator and improve abort handling

- Add persistent toast notification showing "Generating image..." during generation
- Toast displays spinner, supports multiple concurrent generations with count
- Click toast to dismiss (generation continues in background)
- Improve abort handling: show friendly "Image generation stopped" info message
  instead of error when user clicks stop button
- Handle abort in both generatePicture() and sendGenerationRequest() catch blocks

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Scope abort controllers for each individual button

* Use native element reference for caching button abort controller

* Update toast in paintbrush button handler

* refactor: Update abort message for image generation in sdMessageButton

* feat: Enhance generation indicator with active generation count in toast

* Move tracking after prompt generation, add toast for LLM prompt gen progress

* Add type annotation for generation toastr

* Simplify generation abort checks

* Remove unnecessary blank line in addSDGenButtons function

---------

Co-authored-by: mschienbein <mschienbein@users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-01-18 15:03:56 +02:00
Pavdig 78651bdf56 Docker: Build Optimization and Enhanced Non-Root/Volumeless Support (#5024)
* docker: optimize build layers and enhance permission handling

- Pre-created hardcoded dirs in Dockerfile to support volumeless non-root runs.
- Enhanced slightly docker-entrypoint.sh with robust volume detection and safer chown logic.
- Included legacy 'backups' directory... again.
- Added dos2unix to install list.
- Updated .dockerignore
- Updated comments
- Smaller fixes

* fix(docker): removed unnecessary comment, and the... *sighs* backups dir, again

* Exclude DS_Store everywhere

* Exclude tests and all jsconfigs from docker images

* Exclude local plugins from docker builds

* fix(docker): backups are back... yay xD

* feat(docker): add robust healthcheck script

- Added `docker/healthcheck.cjs`: A standalone, dependency-free Node.js script for verifying server status.
- Updated `Dockerfile`: Added HEALTHCHECK instruction and script copy step.
- Features: Auto-detects port from env/config, handles IPv4/IPv6 fallback, auto-retries HTTPS on socket hangup, and sets custom User-Agent.

* Fix .dockerignore permission

* Revert "feat(docker): add robust healthcheck script"

This reverts commit fa634fb08884cdef9245a12271cb9a13b487365f.

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-01-17 22:51:50 +02:00
Cohee 06691e8b9d Gemini: Add config.yaml setting for thought signatures (#5025) 2026-01-16 23:23:39 +02:00
Cohee 9d36b19ef9 Update validation for query messages and max entries 2026-01-16 23:11:07 +02:00
adventchilde / aethel 8926cdc5ce Adding Slash Commands for Vector Storage Extension (#5008)
* Add vector slash commands

* Updated vector-threshold command per feedback. Want to validate it is correct before fixing other commands.

* Added slash commands for several vector storage settings.

* Added slash commands for vector storage, updated w/dev feedback

* Fix min value of entries

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-01-16 22:59:24 +02:00
Beinsezii 76f70ec3c2 Add Adaptive P sampler ordering (#5022) 2026-01-16 12:41:06 +02:00
Jeff Sandberg b418ec5c37 Add taxon filter controls to Group Chat member list (#5006)
* Add taxon controls to top of group member list

* Refactor/cleanup getGroupCharacters

* Fix favorites, refactor and cleanup code

* Fix clearing filters, only show relevant filters in groups

* Fix issues and add persistence

- Fix group member tag listing requiring character list to be init to display
- Fix character tag updates to actually show up in group member contexts
- Persist filter changes for group member tag controls

* Apply suggestions from code review

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>

* Avoid sibling selectors

* Err on invalid tag type

* avoid hardcoded ids

* cleanup: don't use `group_member`, use `group_candidates_list`

* Support both selectors and jquery instances in getFilterHelper

* Sanitize missing tag filters before rendering

* Unscrew jsdoc formatting

* Show all tags, mark absents specially

* Improve JSDoc

* Fix tag indicator for group contexts

* Don't use deprecated fields

* Add a comment on potentially undefined group id

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-01-16 02:27:59 +02:00
Cohee e77c1d33a6 Fix logit bias with best match tokenizer
Fixes #5017
2026-01-15 21:43:31 +02:00
Beinsezii ede7efe52c Adaptive-P for llama.cpp llama-server (#4959)
* Enable Adaptive-P UI on llama.cpp

* Add Adaptive P sampler ordering

* Revert "Add Adaptive P sampler ordering"

This reverts commit 22d85a0e89954dfaf58264059ab0fec61a038c40.
2026-01-15 21:28:30 +02:00
Wolfsblvt 9b0f0dcc9a Fix legacy name prefix removal using wrong variable in bookmarks
Fixes leftover bug from #4993.
In both `getBookmarkName` and `createBranch`, the second regex replacement was incorrectly using the original `name` variable instead of the already-cleaned `cleanName` variable, causing the legacy prefix removal to fail.
2026-01-15 11:01:52 +01:00
Wolfsblvt 0b529290aa Macros 2.0 expose runtime warn log function 2026-01-15 00:32:27 +01:00
DeclineThyself 7d99540829 Improved printMessages performance on large chats by reducing DOM updates. (#4947)
* Improved printMessages performance by reducing DOM updates.
Refactored part of addOneMessage into createMessageElement.

Before: Rendered 1000 messages in 25.529199999809265 seconds.
After:  Rendered 1000 messages in 5.088 seconds.

* Fixed mistakes: https://github.com/SillyTavern/SillyTavern/pull/4947#pullrequestreview-3624592007

* Formatting fix

* Fixed scroll and last_mes order..

* Refactored printMessages logic into redisplayChat.

* Passed `fade`.

* Cleanup.

* WIP.
Removed getMessageFromTemplate
Refactored addOneMessage and updateMessageElement.

* Minor changes to better match https://github.com/SillyTavern/SillyTavern/pull/4985

* If insert is false, `newMessage` may not be new, so I renamed `newMessage` to `messageElement` and `newMessageId` to `messageId`.

I also rearranged some constants to improve readability.

* Accept 0 as valid insertAfter/insertBefore targets

* Renamed forceId to messageId for clarity.

* Change forceId to undefined by default.

* Swapped `forceId` to `messageId` in addOneMessage.

* Added adjustMediaScroll to updateMessageElement.

* Revert "Change forceId to undefined by default."

This reverts commit cbda7eb3fe0a2aa46e0988e82260910c62bc5034.

---------

Co-authored-by: user <user@exmaple.com>
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-01-15 00:30:40 +02:00
Mooki bce1372ed4 feat(sd): Add Z.AI GLM-Image model support (#5012)
* feat(sd): Add Z.AI GLM-Image model support

Add the new GLM-Image model to the Z.AI image generation source:
- Add 'glm-image' to the model dropdown with friendly display name
- Handle GLM-Image's requirement for dimensions in multiples of 32
  (vs CogView's multiples of 16)
- Show quality dropdown for GLM-Image (supports standard/hd)

The GLM-Image model uses the same API endpoint as CogView
but has different dimension constraints.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(sd): Enhance Z.AI GLM-Image support

- Use regex for GLM-Image model detection (futureproofing)
- Skip 2^21 pixel limit for GLM-Image (CogView-specific)
- Add Z.AI recommended resolutions (1280x1280, 1568x1056, etc.)
- Add "Use Coding API" toggle for GLM Coding Plan users
- Add better error logging for image fetch debugging

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor(sd): Address PR review feedback for Z.AI GLM-Image

- Remove custom zai_coding_api setting, use existing oai_settings.zai_endpoint
- Always use Common API for image generation (avoids rate limits)
- Keep ZAI_ENDPOINT import for consistency with other extensions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: always use Common API for Z.AI image generation

Removes conditional endpoint selection since we decided to always use
Common API for image generation (Coding API has stricter rate limits).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* It's not only cogview anymore

* Remove unused param from request payload

* Remove redundant debug logs

* Loosen the check on image quality data attribute

* Bring back coding API notice

---------

Co-authored-by: mschienbein <mschienbein@users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-01-14 23:58:53 +02:00
Cohee b89ffdfece Suppress error messages when Firefox unloads the tab (#5013)
* Fix error messages when Firefox tab reopened after unload
#4989

* Export settingsReady flag
2026-01-14 23:40:52 +02:00
Cohee 206540a072 Revert "Add <svg> to list of Showdown block tags (#4998)"
This reverts commit f79ee5a1b1.
2026-01-14 03:25:54 +02:00
Cohee 26af6b10c3 Increase wait delay in chat-jump 2026-01-14 02:32:53 +02:00
Cohee 7e410b4aa8 Retry API tokenization on reconnecting to backend
Fixes #5004
2026-01-14 02:16:56 +02:00
Cohee cd3bed87c1 Merge pull request #4954 from SillyTavern/fix/docker-readonly
Update Dockerfile
2026-01-14 01:46:14 +02:00
Cohee f79ee5a1b1 Add <svg> to list of Showdown block tags (#4998)
Fixes #4898
2026-01-14 00:49:42 +02:00
DeclineThyself 3e40ac1c27 refactor/perf-printMessages #4: Renamed newMessage to messageElement and newMessageId to messageId. (#4985)
* If insert is false, `newMessage` may not be new, so I renamed `newMessage` to `messageElement` and `newMessageId` to `messageId`.

I also rearranged some constants to improve readability.

* Accept 0 as valid insertAfter/insertBefore targets

* Yeah whatever

---------

Co-authored-by: user <user@exmaple.com>
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-01-14 00:20:26 +02:00
Wolfsblvt f8c373f55a Macros 2.0 (v0.7.0) -Variable Shorthand: New Operators & Lazy Evaluation (#4997)
* Add new variable shorthand operators and new variable macros

- Add `{{hasvar}}` and `{{deletevar}}` macros for local variables
- Add `{{hasglobalvar}}` and `{{deleteglobalvar}}` macros for global variables
- Implement new variable shorthand operators: `-=`, `||`, `??`, `||=`, `??=`, `==`
- Refactor variable expression evaluation to use direct variable API calls instead of routing through macro registry
- Add comprehensive operator support in lexer with proper token ordering for multi-character operators

* Implement lazy evaluation for variable shorthand value expressions

- Replace eager value evaluation with lazy evaluation pattern for variable operators
- Add `#createLazyValue()` method that caches value expression result on first call
- Change `#executeVariableOperation()` to accept `lazyValue` function instead of pre-evaluated value
- Only evaluate value expressions when actually needed (e.g., when variable is falsy for `||`, when variable doesn't exist for `??`)
- Add comprehensive e2e tests

* Update variable shorthand autocomplete with new operators and add edge case tests

- Add new operators to autocomplete definitions: `-=`, `||`, `??`, `||=`, `??=`, `==`
- Update example lists in `VariableShorthandAutoCompleteOption` and `VariableNameAutoCompleteOption`
- Add operator definitions with descriptions and `needsValue` flags to `VariableOperatorDefinitions`
- Update `parseMacroContext()` to recognize new operators with proper ordering (longer operators checked first)

* Add not equals (!=) operator to variable shorthand expressions

- Add `!=` operator to variable shorthand definitions for local and global variables
- Implement `notEquals` operation in `MacroCstWalker` that returns inverted equality comparison
- Add `NotEquals` token to lexer with pattern `/!=`
- Update parser to handle `!=` operator with value expression
- Add `!=` operator to autocomplete examples and operator definitions
- Update `parseMacroContext()` to recognize `!=` operator and...

* Tiny code review fixes

- Fix typo: "insie" → "inside" in variable shorthand operators comment
- Remove extra space in `{{getglobalvar}}` example usage

* Fix missing closing braces in hasglobalvar macro example usage

* Fix isFalsy to normalize value before checking boolean state in variable shorthand operators

- Apply `normalize()` to value before passing to `isFalseBoolean()` in `isFalsy` helper
- Ensures consistent falsy evaluation for variable shorthand operators like `||`, `??`, `||=`, `??=`

* Fix pipe character inside macro braces being treated as command separator

- Add `isInsideMacroBraces()` method to track unclosed `{{}}` macro braces
- Modify `testCommandEnd()` to only treat `|` as command end when not inside macro braces
- Scan text behind current position to calculate macro brace depth
- Skip second character when detecting `{{` or `}}` pairs
- Ensure `depth` never goes below 0 using `Math.max(0, depth - 1)`

* Add aliases for variable existence and deletion macros

- Add `varexists` alias for `hasvar` macro
- Add `flushvar` alias for `deletevar` macro
- Add `globalvarexists` alias for `hasglobalvar` macro
- Add `flushglobalvar` alias for `deleteglobalvar` macro

* Update variable shorthand operator descriptions to clarify return behavior

- Add "returns nothing" clarification to `=`, `+=`, `-=` operators in examples and definitions
- Add "returns the new value" clarification to `++`, `--` operators in examples and definitions
- Update `VariableOperatorDefinitions` descriptions to match example text
- Ensures users understand which operators return values vs perform silent mutations
2026-01-13 13:32:18 +02:00
Cohee 9e88f23382 Merge branch 'release' into staging 2026-01-13 02:25:03 +02:00
Cohee bba91e38fc Google Translate: Normalize pt-BR target language 2026-01-13 02:23:46 +02:00
Cohee 684b755826 Adjust itemized prompts on message move/delete (#5000)
* Adjust itemized prompts on message move/delete

* Sort itemized prompts on swap

* Remove itemized prompt on regeneration
2026-01-12 22:40:33 +02:00
DeclineThyself 69b7a17c77 refactor/perf-printMessages #3: Extracted updateMessageItemizedPromptButton and getMessageHTML from addOneMessage to improve readability. (#4984)
* Extracted updateMessageItemizedPromptButton and getMessageHTML from addOneMessage to improve readability.

* Fix types and function calls

* Fixed insertBefore, insertAfter and messages without extra.

* Use strict comparison operator

* Use logical OR for display text fallback

* Fixed newMessageId again.

* Faster showMoreMessages.

* removed `insertAfter` and `insertBefore` from `mes_edit_copy`,  `/message-role` and `/message-name`.

* Formatting fix

* Refactor newMessageId

---------

Co-authored-by: user <user@exmaple.com>
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-01-12 21:39:47 +02:00
Cohee 372db63cd5 NanoGPT: Add reasoning effort control
Closes #4999
2026-01-12 21:05:02 +02:00
Cohee 618918535e Show a page reload prompt on EME toggle (#4994)
* Show a page reload prompt on EME toggle
#4992

* Fix lint

* Orange toast
2026-01-12 02:18:57 +02:00
DeclineThyself a9f2d559f4 refactor/perf-printMessages #2: Removed getMessageFromTemplate (#4983)
* Reduced redundant swipe code by fully updating the swipe message.

* `getMessageFromTemplate` is an inconvenient function that requires more lines than it saves.
It cannot be used in any other function, therefore it should not exist.
This change also prevents an unnecessary call of `messageTemplate.clone` in addOneMessage when `type = 'swipe'`.

ESLint.

* Fixed: https://github.com/SillyTavern/SillyTavern/pull/4983#discussion_r2680379455

* Replaced ?? with &&: https://github.com/SillyTavern/SillyTavern/pull/4983#discussion_r2680366010 and removed comments.

* Fixed bias check. "0" is falsy.

* Remove scroll adjust early bail

* Call appendMediaToMessage before updating content
Because we need to preserve chatHeight and scrollPosition according to the previous swipe, not the new one

---------

Co-authored-by: user <user@exmaple.com>
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-01-12 02:12:51 +02:00
Wolfsblvt 491f2a3afd Feature: Enhanced Branch and Checkpoint Naming (#4993)
* Add customizable name builder and max tries to getUniqueName utility

- Add optional `nameBuilder` parameter to allow custom name formatting
- Add `maxTries` parameter to client-side version to prevent infinite loops
- Update JSDoc with new optional parameters
- Use nullish coalescing to set default name builder function
- Default name builder maintains existing "${baseName} (${i})" format

* Add startIndex option to getUniqueName utility for flexible name generation

* Enhance branch creation to use current chat name and ensure unique names

- Import `getCurrentChatDetails` from script.js
- Replace hardcoded branch name format with current chat name as base
- Add custom `buildBranchName` function to format branch names with suffix
- Strip existing " - Branch #N" suffixes before generating new branch name
- Use `getUniqueName` utility with `nameBuilder` to ensure unique branch names
- Remove unused `mainChat` variable and replace with `mainChatName`

* Enhance checkpoint creation to use current chat name and suggest unique names

- Import `getCurrentChatDetails` from script.js to get current chat name
- Add custom `buildCheckpointName` function to format checkpoint names with suffix
- Strip existing " - Checkpoint #N" suffixes before generating new checkpoint name
- Use `getUniqueName` utility with `nameBuilder` to ensure unique checkpoint names
- Pass `suggestedName` to template and popup input for better UX
- Replace manual loop with `getUniqueName`

* Remove automatic timestamp suffix from bookmark names

* Fix getUniqueName utility to correctly handle maxTries and return null on failure

* shut up copilot

* Strip legacy bookmark and branch name prefixes when generating unique names

- Add removal of old "Checkpoint #N - " prefix format in `buildCheckpointName`
- Add removal of old "Branch #N - " prefix format in `buildBranchName`
- Change `cleanName` from const to let to allow multiple replacements
- Ensures clean base names regardless of legacy or current naming format
2026-01-12 01:07:51 +02:00