112 Commits

Author SHA1 Message Date
Cohee 2e4ca3dabf fix: improve sanitation of toasts that bypass HTML escaping (#5540)
* fix: improve sanitation of toasts that bypass HTML escaping

* fix: replace absolute lib.js import with relative

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-04-28 01:00:31 +03:00
Wolfsblvt 8aeda4a101 Add Persona CRUD Slash Commands with Shared Avatar Utilities (#5466)
* Add persona CRUD slash commands with enhanced utilities

- Add `/persona-create`, `/persona-update`, `/persona-delete`, `/persona-duplicate`, and `/persona-get` slash commands for programmatic persona management
- Move `persona_description_positions` enum from power-user.js to personas.js for better encapsulation
- Add position and role parsing utilities (`parsePersonaPosition`, `parsePersonaRole`) with name-to-value mapping
- Extend `initPersona()` to accept optional position, depth, role, and lorebook parameters
- Refactor `deleteUserAvatar()` to delegate to new `deletePersona

* Add NaN validation for descriptionDepth parameter in createPersonaCallback

- Add isNaN() check for depth parameter after Number() conversion
- Display warning toast when invalid depth value is provided
- Fall back to DEFAULT_DEPTH when depth is NaN
- Change depth from const to let to allow reassignment after validation

* Refactor persona lookup to support avatar key targeting and fix enum provider currying

- Refactor `autoSelectPersona()` to accept optional `personaKey` parameter for targeting specific persona when multiple share the same name
- Replace manual persona lookup loops with `findPersona()` helper calls in `autoSelectPersona()` and `setNameCallback()`
- Update `setNameCallback()` to pass both persona name and avatar key to `autoSelectPersona()` for precise targeting
- Refactor `commonEnumProviders.personas()`
2026-04-20 02:26:08 +03:00
Wolfsblvt 0ac31c8fcd Enhanced /persona-sync Command with Range, Name Filter, and Quiet Mode (#5460)
* Add range and silent parameters to /persona-sync command with optional confirmation suppression

- Add optional start/end range parameters to syncUserNameToPersona() function
- Add silent parameter to suppress confirmation popup when needed
- Update /persona-sync slash command to accept range argument (index or range string) and named silent argument
- Parse range using stringToRange() utility, default to full chat if not provided
- Update confirmation message to reflect whether syncing all messages or specified

* Add `from` named argument to /persona-sync command for filtering by persona name

- Add `from` named argument to filter messages by persona name (case-insensitive)
- Rename `silent` argument to `quiet` with inverted default (true) for consistency
- Add userMessageNamesEnumProvider() to provide autocomplete for existing user message names in chat
- Update syncUserNameToPersona() to accept nameFilter parameter and filter messages accordingly
- Update confirmation message to reflect name filtering when

* Add async/await wrapper to sync_name_button click handler for proper promise handling

Function now has arguments, so using just the function as the event is shown as wrong usage

* Post-merge imports fix

* Use canonical command name in examples

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-04-15 23:41:10 +03:00
Wolfsblvt d72f4b6fcb Emit PERSONA_CREATED event on persona duplication (#5448)
* feat: emit PERSONA_CREATED event when duplicating a persona

Adds PERSONA_CREATED event emission in duplicatePersona() to notify listeners when a persona is duplicated. Includes the new avatarId, name, and duplicatedFromAvatarId in the event payload.

* fix: event data and execution order

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-04-14 00:19:02 +03:00
Wolfsblvt 7d3d1231a9 Chore: Add persona lifecycle events (PERSONA_CREATED, PERSONA_UPDATED, PERSONA_RENAMED, PERSONA_DELETED) (#5443)
* Add persona lifecycle events (created, updated, renamed, deleted) and emit them throughout persona management functions

* fix: await event emissions

* fix: await event in convertCharacterToPersona

* fix: await PERSONA_UPDATED in callbacks

* fix: delete multiple personas without reloading the chat

* fix: add CHAT_RENAMED event and adjust welcome screen pin update logic

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-04-13 19:24:38 +03:00
Cohee d2b2b1b4a6 fix: require long press to open swipe picker on phones (#5382)
* fix: require long press to open swipe picker on phones

* fix: clarify parameter description in assignLorebookToChat function

* fix: update event parameter type in onSwipeCounterClick to include TouchEvent

* fix: update event parameter types in onSwipeCounterClick and addLongPressEvent
2026-03-31 20:08:56 +03:00
Wolfsblvt 276a0c2125 Remove long deprecated STscript commands and parameters (#5312)
* Remove deprecated 'format' argument from /listinjects and /listvars commands

* Remove deprecated /lock command and add as alias to /persona-lock

* Add 'bind' as an alias for /persona-lock command (#5321)

* Initial plan

* Add 'bind' as an alias for /persona-lock command

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

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Cohee1207 <18619528+Cohee1207@users.noreply.github.com>

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Cohee1207 <18619528+Cohee1207@users.noreply.github.com>
2026-03-18 18:30:53 +02:00
Stardust bf91d9afc9 Chat lorebook click unify (#5246)
* Unify chat lorebook button click behavior with character lorebook button

* Update locale strings for chat lorebook button

* Unify chat lorebook button click behavior with character lorebook button

* Update locale strings for chat lorebook button

* Also unify character lorebook button to support Alt modifier

* Update locale strings for character lorebook button

* Update public/locales/fr-fr.json

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add long-press support for lorebook buttons on mobile

* Update locale strings for lorebook button long-press

* Fix long-press to use event delegation for dynamic elements

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-15 20:14:32 +02:00
Copilot ccf8ce7a06 Add PERSONA_CHANGED event (#5218)
* Initial plan

* Add PERSONA_CHANGED event emission when active user avatar changes

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

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Cohee1207 <18619528+Cohee1207@users.noreply.github.com>
2026-02-24 20:52:04 +02:00
Cohee 4d1619ba47 Chore: enable brace-style eslint check (#5159)
* eslint: enable brace-style check

* Fix jsdoc and color

* fix: correct CSS color syntax in CreateZenSliders function
2026-02-15 01:46:32 +02:00
Cohee 357da3219b Chore: Add code formatting conventions as eslint rules (#5158)
* Add code formatting conventions as eslint rules

* Improve formatting in addQuickReply
2026-02-15 01:16:34 +02:00
DeclineThyself 8372e7bf9d "gradually replacing property access with a dot operator" (#4965)
* "gradually replacing property access with a dot operator"
https://github.com/SillyTavern/SillyTavern/pull/4963#discussion_r2663003561

(?<=\w|\])\['([a-zA-Z]\w+)'\]
My regex found 593 matches across 47 files.
Also, two typos.

* Fixed chat[0].chat_metadata type error.
https://github.com/SillyTavern/SillyTavern/pull/4965#discussion_r2664275854

* Fixed `swipedElementsDiv[0]?.getAnimations().filter((a) => a.animationName` type error.
https://github.com/SillyTavern/SillyTavern/pull/4965#discussion_r2664274593

* Fixed config.MESSAGE_SANITIZE and config.MESSAGE_ALLOW_SYSTEM_UI type errors.
https://github.com/SillyTavern/SillyTavern/pull/4965#discussion_r2664266271

* Fixed group.date_last_chat type error.
https://github.com/SillyTavern/SillyTavern/pull/4965#discussion_r2664295652

* Reverted SlashCommandParser dot property access.
https://github.com/SillyTavern/SillyTavern/pull/4965#discussion_r2664310931

* LLM fixed canUseNegativeLookbehind.result; type error.
https://github.com/SillyTavern/SillyTavern/pull/4965#discussion_r2664314288

* Reverted chat-completions.js bodyParams and headers dot property access.

https://github.com/SillyTavern/SillyTavern/pull/4965#discussion_r2664317848
https://github.com/SillyTavern/SillyTavern/pull/4965#discussion_r2664320088
https://github.com/SillyTavern/SillyTavern/pull/4965#discussion_r2664324438

* Reverted openai.js data dot property access.

https://github.com/SillyTavern/SillyTavern/pull/4965#discussion_r2664326244

* Reverted tests/frontend/MacroEnvBuilder.e2e.js env.dynamicMacros dot property access.

https://github.com/SillyTavern/SillyTavern/pull/4965#discussion_r2664330990

* Partially reverted `window` dot property access.

* Reverted result.json() and settings dot property access.

* Reverted google.js headers dot property access.

* Fixed regex: `(?<=\w|\])\['([a-zA-Z]\w*)'\]`

* Swapped window to globalThis with dot property access.

* LLM fixed canUseNegativeLookbehind type.

* Refactor property access

* Consistency

---------

Co-authored-by: user <user@exmaple.com>
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-01-08 23:58:21 +02:00
Cohee f26a672811 Omit content type in POST request if no body 2025-12-07 23:26:47 +02:00
Wolfsblvt 9463d1a152 Reprint non-tainted group chat on switching personas (#4603)
* fix: reprint non-tainted group chat on switching personas

* feat: mark chat as tainted when sending user message

* feat: mark chat as tainted when adding custom messages or captions

* feat: export createOrEditCharacter function and integrate it into retriggerFirstMessageOnEmptyChat

* fix: optimize loadPersonaForCurrentChat by storing current chat ID in a variable

* Improve conditions of first message retrigger

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2025-10-06 22:45:26 +03:00
Wolfsblvt a65f708fd8 Allow create new world books via /getpersonabook and /getcharbook (#4597)
* feat: allow create new world books via /getpersonabook and /getcharbook

Refactor character world info management into dedicated functions

Extract character world assignment logic from UI handlers into reusable functions
Add support for automatic lorebook creation in slash commands
Improve code maintainability by centralizing world info operations

* refactor: update boolean enum provider from onOffToggle to trueFalse in world info commands

* fix: improve world info name uniqueness check using getUniqueName utility

* Unset current persona WI on file deletion

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2025-10-05 16:41:54 +03:00
Wolfsblvt 06f5cea402 Fix group chat on new chat not respecting saved persona connections (#4594)
* fix: (new) group chat doesn't respect persona connections

Fixes #3876

* refactor: simplify persona connection filtering with destructuring and type comparison

* fix: remove redundant type check in persona connection filtering logic

(char avatar and group key *should* always be unique and different anyway, no need to check on type. Makes this more flexible)
2025-10-04 13:24:49 +03:00
Cohee 334a5409a0 Persona description editor expand (#4591)
* Enhance persona description section with expandable editor icon

* Fix selector for persona description update to use data attribute
2025-10-04 13:15:32 +03:00
Cohee 7b67769c92 Fix convert to persona with unusual names (#4319)
* Fix convert to persona with unusual names

* Fix picking new persona on current persona deletion

* Prefer actual path on page reload
2025-07-27 14:16:15 +03:00
Cohee 96bdc13937 Replace ajax with fetch (#4241)
* Replace ajax with fetch
Fix type errors in power-user / group-chats modules

* Fix single sprite upload

* Return empty object on failed upload
2025-07-06 23:27:53 +03:00
Cohee 51904c2f10 Add persona titles (#4224)
* Add persona titles

* Refactor persona title editing
2025-07-03 19:28:09 +03:00
Cohee cdefddef6c Implement persona thumbnails (#4210)
* Implement persona thumbnails

* Dear Firefox, fix your overzealous image cache

* Add cache busting for avatar uploads when overwriting existing files
2025-06-28 21:39:32 +03:00
Cohee 51431b1a75 Include persona name in delete confirmation
Closes #4119
2025-06-15 23:09:09 +03:00
omahs d7d20a67fa Fix typos 2025-05-29 11:56:59 +02:00
Cohee 637e9d5469 Set any char as assistant. Rework welcome prompt 2025-05-12 20:50:17 +03:00
Yokayo 1822c4f91b More work on tl 2025-05-03 18:12:18 +07:00
Yokayo f0d01d35a6 eslint fixes 2025-04-28 18:55:10 +07:00
Yokayo 11908f7363 Work on tl 2025-04-28 18:45:16 +07:00
Wolfsblvt d95524032e Centralize first message retrigger on persona changes
Moves retrigger logic to setUserAvatar entry point
to avoid duplicate calls when updating personas
Removes redundant triggers from name/avatar handlers

Fixes #3774
2025-03-28 01:28:36 +01:00
Wolfsblvt 6dc33e9637 Cast this_chid to number in personas.js
Ensure numeric type for character ID comparisons
Explicitly converts this_chid to Number in multiple functions
to prevent type mismatch issues when checking character connections
and persona states
2025-03-28 01:25:13 +01:00
Yokayo 40c3674da1 Update tl 2025-03-17 16:09:36 +07:00
Wolfsblvt 67699d9cfa Fix persona auto-lock to chat not working
- When auto lock was enabled, it didn't auto-lock to chat when the persona was already selected (like choosing the same persona you have used before)
2025-03-09 15:27:48 +01:00
Cohee 90be2eee71 Only navigate to persona if switched by connection 2025-02-26 00:13:55 +02:00
Cohee 6541dcbc66 Comment out persona preservation on character swap with personas open 2025-02-26 00:03:46 +02:00
Cohee 0274d800f9 Navigate to current persona on switching chats 2025-02-25 23:50:49 +02:00
Cohee cf792c8195 Don't choose chat persona if it's already chosen 2025-02-25 23:37:02 +02:00
Wolfsblvt fec0e248c5 Fix persona UI states sometimes not updating 2025-02-25 21:57:25 +01:00
Wolfsblvt e27e045054 Update persona.js code documentation for exported 2025-02-23 04:58:48 +01:00
Wolfsblvt 76fa90ed9e Switch to char from persona panel decision tree 2025-02-23 02:33:51 +01:00
Cohee 7f9960fa7a Clickable char personas 2025-02-22 22:48:51 +02:00
Wolfsblvt e0f3a22b80 Refactor: move persona slash commands 2025-02-22 21:45:35 +01:00
Cohee ac8c2799b8 Add missing personas on load 2025-02-22 22:26:34 +02:00
Cohee 2194bdfd56 Rerender the list if migrated persona 2025-02-22 22:20:45 +02:00
Wolfsblvt bb03c60c39 Refactor: move showCharConnections 2025-02-22 21:17:56 +01:00
Wolfsblvt 8f38298f90 fix linting errors 2025-02-22 20:48:41 +01:00
Wolfsblvt 9e7f485b65 Merge branch 'persona-improvements' of https://github.com/SillyTavern/SillyTavern into persona-improvements 2025-02-22 20:47:10 +01:00
Cohee 4a9503c056 Align message block baseline 2025-02-22 21:43:16 +02:00
Wolfsblvt f37541d629 Remove unused old username functions 2025-02-22 20:42:35 +01:00
Wolfsblvt 8bd4fd76ae Merge branch 'staging' into persona-improvements 2025-02-22 19:23:59 +01:00
Cohee d5bdf1cb90 Add settings.json-backed KV string storage
Fixes #3461, #3443
2025-02-11 20:17:48 +02:00
Cohee cbeb7ddcec Update persona upload methods to fetch 2025-01-30 02:30:51 +02:00