53 Commits

Author SHA1 Message Date
Copilot a93fc0443e Preserve image dimensions when generating swipe images (#5205)
* Initial plan

* feat: preserve image width/height when generating swipe images

Save width and height in ImageGenerationAttachmentProps when creating
MediaAttachment objects, and apply saved dimensions when generating
image swipes. Falls back to current extension settings if not specified.

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

* fix: validate dimension override with Number.isInteger and skip setTypeSpecificDimensions when override is present

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

* fix: call restoreOriginalDimensions when setTypeSpecificDimensions was used

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

* Contain the logic to setTypeSpecificDimensions

* Diff clean-up

* feat: enhance prompt refinement with negative input and saved resolution options

* fix: Only save image dimensions when running from command

* Fix wording in refine prompt dialog

---------

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-23 20:51:25 +02:00
Copilot f687bc95e9 Overhaul /bgcol: Oklch color space, full palette generation, save as new theme (#5162)
* Initial plan

* Overhaul /bgcol command: Oklab color space, dominant color extraction, full theme palette generation

- Create ThemeGenerator module in public/scripts/util/ with:
  - Oklab color space conversions (sRGB ↔ Oklab ↔ LCH)
  - Chroma-weighted dominant color extraction (vivid over muddy averages)
  - Color theory palette: complementary, analogous, triadic hue relationships
  - WCAG contrast ratio enforcement (≥3.5:1 for all text colors)
- Replace old setAvgBG with new implementation using ThemeGenerator
- Save generated theme as "Generated - <background name>" instead of overwriting
- Update command help string to reflect production-ready status

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

* Extract hue shift constants for clarity (code review feedback)

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

* Add name and bg arguments to /bgcol command

- Add `name` named argument to override the generated theme name
- Add `bg` named argument with enum provider listing available backgrounds
  from /api/backgrounds/all to override the current background

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

* Improve types, add enum provider, reduce transparency

* Adjust alpha channel for better readability

* Refactor ThemeGenerator to work directly in Oklch, removing intermediate Oklab conversions

Replaced srgbToOklab/oklabToSrgb + oklabToLCH/lchToOklab with direct
srgbToOklch/oklchToSrgb functions. All color manipulations now use
{L, C, h} directly without converting through {a, b} intermediates.
The ensureContrast function now takes (L, C, h) parameters instead of
an Oklab object.

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

* Add custom background URL check and enhance theme generation logic

---------

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-15 16:39:55 +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
Sammy 9a1ded5202 Allow editing of global Worldinfo settings (#4921)
* create and export updateWorldInfoSettings

* Add WorldInfoSettings type and refactor updateWorldInfoSettings function

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2025-12-27 20:08:29 +02:00
mightytribble 2cd2bd4a4d Implement Gemini thought signatures (#4886)
* Implement Gemini thought signatures

* Implement streaming support for Gemini thought signatures

* Implement OR support for Gemini thought signatures

* Remove unnecessary extraction of thought sigs from response parts

* Update thought sig comments to remove explicit Gemini mention

* Fix thought_signature naming convention in message.extra

* Add thought_signatures to ReasoningMessageExtra typedef

* Prevent thought sigs being sent to incompatible endpoints

* Move signatures to populateChatHistory, update for consistent casing

* Code clean-up

* Only send thought signatures if target model and API match original

* Implement content-hash thought signature mapping

* Change the data model + split for text/functions

* Don't include signature to invocations if the model doesn't match

* Fix function description

* Remove misleading comment

* Handle OpenRouter signatures

* Improve message extra types

* Prevent modifying original invocations when removing signatures

* Fix return of openrouter non-streaming signatures

* Remove redundant array check

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2025-12-17 22:23:47 +02:00
qvink a4cc9b3989 Facillitate extension use of ConnectionManagerRequestService (#4841)
* Separate prompt-building functionality from request-sending functionality

* removing logs and clarifying comments

* separating parameter construction functionality to allow ConnectionManagerRequestService to use all other preset parameters

* fixing chat completion issues, adding documentation to new functions.

* Improving ConnectionManagerRequestService errors. Adding parseReasoningFromString option to override reasoning template.

* Adjusting TextCompletionService prompt formatting

* linting

* Use settingsToUpdate to convert from OAI preset to OAI settings.

* lint

* throw errors when profile ID not found

* Fix missed instances of global completion settings being used (CC and TC), replaced with optional argument. Specified typing for ChatCompletionSettings and TextCompletionSettings.

* Adjusting parameters of parseReasoningFromString and adding getReasoningTemplateByName

* using messages.role as a fallback for custom requests, fixing newline removal.

* parameters => settings
I like how it sounds better

* ditto

* You know I had to do it to 'em

* Update getCustomTokenBans

* Fix calculateLogitBias

* Fix param attributes

* Fix type checks

* Less strict role type on ChatCompletionMessage

* Add missing space

* fixing getChatCompletionModel to use an arbitrary chat completion settings object

* Fixing issues with preset overriding custom data passed.

* Pass model to createGenerationParameters externally

* Unify seed param handling for CHUTES

* Fix non-existing CC source

* Use strict comparison

* Use global settings as a base for generation parameters creation

* removing unnecessary handling of preset fields

* don't pass preset prompts, use the passed payload override messages

* refactoring text generation prompt building of last line

* Pass model to getReasoningEffort

* Pass model name to canPerformToolCalls

* Pass model to createTextGenGenerationData

---------

Co-authored-by: qvink <qvink@users.noreply.github.com>
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2025-12-03 20:09:02 +02:00
Cohee 1af87ea165 Backfill missing swipe_info (#4831)
* Backfill missing swipe_info

* Add type for SwipeInfo

* Init SwipeInfo with empty extra
2025-11-28 18:17:14 +02:00
Cohee cd992472d5 Add deprecated user_name and character_name fields for backward compatibility 2025-11-26 19:59:05 +02:00
DeclineThyself fc85b205ac Backport feat/chat-tree and fix #4709 (#4712)
* Performance improvements due to using chatElement instead of $('#chat').

* Reverts change `hideSwipeButtons()` change.

https://github.com/SillyTavern/SillyTavern/pull/4576#discussion_r2394996102

* I’ve been working on a PR for issue #1731: [Swipes on every AI message, not just the last one](https://github.com/SillyTavern/SillyTavern/issues/1731). I’d appreciate feedback to avoid unnecessary effort.

Currently, I have User and Assistant branches working.
I have not touched `/api/chats/save` or '/api/chats/get', so branches do not persist.

To keep `context.chat` unmodified (so extensions and the rest of the code remain unaffected), I’ve stored branches in `chatTree`:
```javascript
chatTree = {
  branch_id: 1,
  branch: [
    { mes: "Hi" },
    { mes: "Hello", branch_id: 0, branch: [...] },
  ]
}
```

When a message is swiped, chatTree is updated via `saveChatToTree()`, then the next branch is loaded using get`ChatFromTree()`.

Questions:
According to Cohee: [This requires reorganizations in the file format for chats, not viable in the short term.](https://github.com/SillyTavern/SillyTavern/issues/1731#issuecomment-1937845036)
I'm hesitant to proceed. May I store chatTree.json files alongside the existing .jsonl chats?
Should I create a new /save endpoint, modify the existing one, or discontinue using .jsonl for saving.

Known issues:
Branches do not persist on refresh.
Swiping multiple messages at once throws `Cannot read properties of undefined (reading 'mes')
`. This will be fixed in the UI.
Branches persist between chats/characters. This will be fixed when loading a chat.
The Swipe arrows overlap with messages.
No animation plays when swiping then editing a user message.

* Fixed bug.

Gemini:
The calculation of mesId is fragile and contains a bug. The fallback chat[chat.length - 1] is a message object, and Number(object) will result in NaN. This will break the swipe functionality if the preceding expressions are falsy. Additionally, chat.indexOf(message) will almost always point to the last message in the chat, which is incorrect when swiping on an earlier message.

A more robust approach is recommended to reliably get the message ID from the clicked element.

    const mesId = Number($(this).closest('.mes').attr('mesid'));

* Fixes swipes on long chats.

* chatTree is now persistent. Fixed bugs.

* Fixed bugs.
https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2390042262
The logic to rename the chat tree file (.json) is currently in an unreachable else block. The if condition !fs.existsSync(pathToOriginalFile) || fs.existsSync(pathToRenamedFile) will almost always evaluate to true after the preceding copyFileSync and unlinkSync operations, because pathToOriginalFile will no longer exist. This prevents the chat tree file from being renamed, which breaks the persistence of message branches when a chat is renamed.

The scrollChatToMessage function is implemented incorrectly. Calling .scrollTop() without any arguments on a jQuery object retrieves the current vertical scroll position; it does not scroll the element into view. This function will not have the intended effect of scrolling the chat to the specified message.

* Fixed bugs. https://github.com/SillyTavern/SillyTavern/pull/4573#pullrequestreview-3282889120

There's a typo in the property name being deleted. It should be branch to match the data structure you've defined, not branches. This error will prevent the pruning logic from working correctly, potentially leading to corrupted or bloated chatTree data.

The modified treeData is not being saved here. Instead, the global chatTree is being sent in the request. This will cause any renames of group members within message branches to be lost upon saving. You should send treeData, which contains the modifications.

This function may have performance issues on large chats due to multiple structuredClone calls within a loop. swipelessMessage is created from a deep clone, and then it's deep-cloned again for every swipe. While this ensures data integrity, it is inefficient. Consider refactoring to reduce the number of deep-cloning operations, for instance, by creating swipelessMessage once per message and deep-cloning it only when creating a new branch for a swipe.

* Fix warning. https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2390183161

The logic for renaming the chat tree file seems to have a flaw. The condition !fs.existsSync(pathToOriginalTreeFile) || fs.existsSync(pathToRenamedTreeFile) will be true if the original tree file does not exist. In this case, a warning is logged. However, it's a valid scenario for a chat to not have a corresponding tree file, so no warning should be logged. The current logic could lead to confusing log messages.

* Refactored chatTree into `public/scripts/chat-tree.js`.

https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2390269514

* Displaying swipes on past messages and the entire chat tree functionality is now an opt-in toggle.

https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2390273599

* Only allow one concurrent swipe.
Fixed:
Swiping multiple messages at once throws Cannot read properties of undefined (reading 'mes') .

* Fixed bugs.
Now `swipe_id >= swipes.length` is set to swipes.length.

* Fixed bug.
Swiping a user message did not re-show swipe buttons after the generation finished.

* Moved `Show Swipes for All Messages` Toggle to `Chat/Message Handling`.
https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2395008961

* `JSON.stringify doesn't add spaces by default`
https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2395047031

* Fixed "Tree file left behind when renaming chats"

https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2395546142

* Fixed "Guard chatTree recursion in group member rename"
https://github.com/SillyTavern/SillyTavern/pull/4573#pullrequestreview-3290587129

* Re-implement: https://github.com/SillyTavern/SillyTavern/pull/4576#discussion_r2395506501

* Moved chat trees to a separate directory. https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2395045583
Enabled chat tree backups.

* Removed structuredClone() for improved performance.

* Fixed bugs.
Characters are now correctly renamed in the chatTree.
Directories are now recursively created.

* Reverts `hideSwipeButtons` to original functionality when `show_swipes_for_all_messages` is false.

https://github.com/SillyTavern/SillyTavern/pull/4576#discussion_r2395375718

* Added `refreshSwipeButtons`.
Updated `showSwipeButtons` and `hideSwipeButtons`.
Fixed bugs.

* Fixed.
https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2400143193
https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2400143202

* Added `clamp` to util.js.
Refactored `swipe`.

* Fixed bugs.
https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2400685914
https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2400685911

* Fixed bugs.

* Fixed swipe animations.

* Fixed bug by setting ids with `Number`.

* Delete swipes, and bugfixes.

* Merged `refactor/swipe`.

* Fixed bug created in `Delete swipes, and bugfixes.`.

* Merged from origin/staging.

* Merged changes from refactor/swipe.

* Fixed bug and refactored `syncWithSwipeId`.

* Merged from `origin/staging`.

* Fixed merge.

* Fixed overlapping message generations.

* Warn user, and refresh chat.

* Added metadata to chatTree file.

* Fixed "a sacrifice for the sake of simplicity." https://github.com/SillyTavern/SillyTavern/pull/2752#issuecomment-2323512022

Gemini:
https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2464165990
https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2464165991

* Improved swipeGenerate's animation.

* Added `SWIPE_SOURCE` constant.

* await `switchSwipesAllMessages`.

* Added `swipeState`.

* Fixed:
https://github.com/SillyTavern/SillyTavern/pull/4573#issuecomment-3449690308

* Done:
https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2466884547
https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2466884547
https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2466894947
https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2466902075
https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2466911245
https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2466938169

* Removed `NEUTRAL_CHAT_TREE_KEY`

* Moved backups

* Fixed `/send` and fixed a bug in `sendMessageAs`.

* Fixed: https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2466913570

* Fixes usage of `ENOENT`: https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2466929980

* Removed LLM attribution.

* Updated link and warning.

* Removed debugging comments.

* Fixed: https://github.com/SillyTavern/SillyTavern/pull/4573#discussion_r2466905341

* Replaced `isSwipingAllowed` with `swipeState`.

* Backported many changes from feat/chat-tree.

* Refactored `showSwipeButtons` and `hideSwipeButtons` into `refreshSwipeButtons`

* Refactored `showSwipeButtons` and `hideSwipeButtons` into `refreshSwipeButtons`

* Fixed: https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2472109888
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2472113323

* Merged from `refactor/backport-chat-tree`.

* Proposed fix for https://github.com/SillyTavern/SillyTavern/issues/4709
Reverts commit: https://github.com/SillyTavern/SillyTavern/commit/1b3db273891c1ba8c781d2f691ad2e41937ca2aa

On PR: https://github.com/SillyTavern/SillyTavern/pull/2940

* Proposed fix for https://github.com/SillyTavern/SillyTavern/issues/4709
Reverts commit: https://github.com/SillyTavern/SillyTavern/commit/1b3db273891c1ba8c781d2f691ad2e41937ca2aa

On PR: https://github.com/SillyTavern/SillyTavern/pull/2940

* Fixed regenerate and continue while editing the last message.

* Added swipesHidden.
Messages can now be designated as non-swipeable with `message.extra.swipeable`.

* Use `.hidden` and classes instead of `.css` to display swipe chevrons.

* Fixed:
https://github.com/SillyTavern/SillyTavern/pull/4712#issuecomment-3465749700
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2476136375
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2476140043
https://github.com/SillyTavern/SillyTavern/pull/4712#issuecomment-3465776056
https://github.com/SillyTavern/SillyTavern/pull/4712#issuecomment-3465794330

* Fixed bug.

* Fixed broken JQuery animation.

* Fixed:
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2479003956
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2479011525
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2479014001

* Fixed active arrow transition.

* Fixed swipe shake direction.

* Fixed truthy check.

* Added temporary link to documentation PR.

* Moved `switchSwipesAllMessages`

* Fixed failed generations deleting the branch.
Fixed `forceSwipeId`.
Always call `saveChatConditional` if the `swipe_id` has changed.

* ESLint.

* Fixed bug.
Better `syncSwipeToMes` error handling.

* Backported changes from `feat/chat-tree`

Added failed swipe animation.
Fixed `newSwipeId`.

* Fixed: https://github.com/SillyTavern/SillyTavern/pull/4712

* Fixed:
https://github.com/SillyTavern/SillyTavern/pull/4712#pullrequestreview-3406878337

* Fixed:
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2483143387

* Fixed:
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2483143387

* Added `showSwipes: false` to `showMoreMessages`.

And a few more performance improvements.

* Fixed animations.

* Added `'.mes'` to `.children`.

* Significantly improved `animateSwipeTransition` performance on large chats.

* Improved `syncSwipeToMes` error handling.

* Significantly improved `animateSwipeTransition` performance on large chats.

* Improved `syncSwipeToMes` error handling.

* Corrected Merge.

* Corrected Merge.

* Improved: `redisplayChat`
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2484177521

* Fixed: https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2484215469

* Fixed: https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2484217230

* Added a temporary implementation of `branchChat`.

* Fixed bug when generating a swipe.

* Fixed bug in `branchChat`.

* Fixed Off by one error due to `chatElement.children()` selecting `show_more_messages`.
https://github.com/SillyTavern/SillyTavern/pull/4712#issuecomment-3478331073

* Fixed Off by one error due to `chatElement.children()` selecting `show_more_messages`.
https://github.com/SillyTavern/SillyTavern/pull/4712#issuecomment-3478331073

* Cleaned system messages array and moved `swipeable`

* Removed CSS nesting.

* Fixed merge.

* Improved `syncSwipeToMes` error handling.

* Matched `swipes-counter` fade to chevrons.
https://github.com/SillyTavern/SillyTavern/pull/4712#issuecomment-3478192184

* Wrapped `transition-behavior: allow-discrete;` in `@supports`.

* Fixed types.

* Improved swipeability feedback and functions.

* Improved `refreshSwipeButtons` performance again.

* Swapped `.attr` to `.prop`.

* Fixed: `@supports (transition-behavior: allow-discrete)`

* Fixed and clarified typo.

* Fixed:
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2495919425
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2495923036
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2495927019
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2495930080
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2495943870
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2495950927
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2495954387
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2495974324
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2495974683

* Fixed: https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2495957181
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2495960920
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2495968137
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2495968922
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2495959430
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2495924599

* Fixed: https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2495918468
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2495931979
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2495933092
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2495939511

* Improved `refreshSwipeButtons` performance by skipping 'swipes-counter' updates by default.

* Fixed: https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2496382916
https://github.com/SillyTavern/SillyTavern/pull/4712#discussion_r2496379401

* Removed chevron fade-in on Cohee's request: https://github.com/SillyTavern/SillyTavern/pull/4712#issuecomment-3493829978

* Set most system messages to `swipeable: false`.

* Implemented `OVERSWIPE_BEHAVIOR`.

* Fixed: https://github.com/SillyTavern/SillyTavern/pull/4712#issuecomment-3499706714

* Fix formatting, make comments IDE friendly

* IDE friendly enum comments

* Move animation frames to a dedicated file

* Do not compare with -1

* overswipeBehavior => getOverswipeBehavior

* Formatting fix

* Don't let regenerate on is_system

* Fixed canceled generations in pristine chats.
https://github.com/SillyTavern/SillyTavern/pull/4712#issuecomment-3499819670

* Fixed `AUTO_SWIPE` when `animation_duration = 0`.

* Fixed mistake in `redisplayChat`.

* Holding the swipe button speeds up `swipeDuration`.

* Fixed 'animationend' never ending.
Altered resetTime.

* Swapped from `saveChatConditional` to `saveChatDebounced` in `swipe`.

* Skip the animation if it's faster than 50ms instead of 10ms.

* Typo.

* Fixed:
https://github.com/SillyTavern/SillyTavern/pull/4712#pullrequestreview-3457198109

* Adjust duration reset cooldown

* Add quotes to selector

* Specify type for message parameter in swipe function

* Add type for swipe UI event

* Disabled fade-in during printMessages.
https://github.com/SillyTavern/SillyTavern/pull/4712#issuecomment-3539315919

* Typo.

* Added quotes to selector .

* Reduce reset time 500 -> 350

* Loops do not cause a generation so their chevrons should not have increased opacity.
https://github.com/SillyTavern/SillyTavern/pull/4712#issuecomment-3543692019

* Revert reset time

* Renamed `heldSwipes` to `recentSwipes`.

* Autofix the swipes array during `updateSwipeCounter`.

* User messages should not have swipes.

* Chevrons should always be shown on pristine greetings: https://github.com/SillyTavern/SillyTavern/pull/4712#issuecomment-3557893373

* Improve formatting

* Fixed: https://github.com/SillyTavern/SillyTavern/pull/4712#issuecomment-3559617088

* Show `pristineGreetingSwipeNotice` once.

* `clearMessageData` when swipe-regenerating a message.

* accountStorage is already imported in the module

* Removed `await`.

* Removed pristine greeting notice.
https://github.com/SillyTavern/SillyTavern/pull/4712#issuecomment-3560758598

* Removed redundant functions in `StreamingProcessor` and fixed streamed replies missing counters.

* Moved `markUIGenStopped` after `eventSource.emit`.

Swapped to `saveChatDebounced` to fix: https://github.com/SillyTavern/SillyTavern/pull/4712#issuecomment-3567014810.

* Save a structuredClone of `chat` to prevent an invalid chat from being saved.

* Only `structuredClone` `chat` on `saveChatDebounced`.

* Revert "Only `structuredClone` `chat` on `saveChatDebounced`."

This reverts commit 49498b7aa1410107b294555fb945d977e60bfebf.

* Revert "Save a structuredClone of `chat` to prevent an invalid chat from being saved."

This reverts commit 5f137ed1380107fde0765b951dc634081bdbf2ff.

* Prevent `saveChatDebounced` from saving while the swipe is in progress.
See: https://github.com/SillyTavern/SillyTavern/pull/4712#issuecomment-3567077312

* Fixed animation never ending: https://github.com/SillyTavern/SillyTavern/pull/4712#issuecomment-3567106213

* `forceMesId` and `forceSwipeId` are not objects.

* Fixed Reduced Motion causing a warning when swiping back.

* Only  hide `.mes_buttons` when generating.

* Fix eslint

* Reset duration on switching direction

---------

Co-authored-by: user <user@exmaple.com>
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2025-11-26 17:38:31 +02:00
Cohee 929d377da8 Update group chat metadata format (#4805)
* Migrate group metadata to group chat files

* Skip migration if chat already has metadata

* Fix active group not being set on group conversion

* Improve types in createGroup

* Fix padding in hotswap group avatars

* Fix centering of empty hotswap avatar

* Added automatic backups of migrated data

* Fix 'OVERWRITE' for GC

* Fix metadata parsing order in migration

* Remove color accents from regular migration logs

* Always set gen_id in converted message

* Clone messages before conversion

* Reduce size of add/remove buttons

* Fix group chat file size calculation
2025-11-25 23:48:43 +02:00
Cohee b10f680371 Preserve media playback state when running appendMediaToMessage (#4771)
* Preserve media playback state when running appendMediaToMessage

* Better selector specificity

* Fix local variable name

* Move typedef to global.d.ts

* Check for readyState on save/restore

* Only check for currentSrc on restoration callback
2025-11-16 21:56:53 +02:00
Cohee 38679897c6 Add captioning for video attachments (#4749)
* Add captioning for video attachments

* Unify error toast titles

* Add MEDIA_SOURCE enum and update media handling to include source information

* Unify attachment handling logic

* Add error handling for auto-captioning failures

* Use string formatting for console error
2025-11-08 02:07:28 +02:00
Cohee de7c113346 Multiple attachments (#4719)
* Multiple file uploads

* mes_img_wrapper

* mes_video_wrapper

* Named export instead of function wrapper

* Update public/scripts/chats.js

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Fix optional chaining for message extra

* Preserve existing files with paste

* Improve swipe message extras clean-up

* Clean-up: Add chat_backgrounds to known images

* Add ensureMessageMediaIsArray to getContext

* Fix compatibility warning

* Update to media array

* Move de-dupe check logic

* Fix comment

* Fix clean-up logic

* Improve typing

* `feat/multi-file` Added a toggle between the old gallery and new image list. (#4722)

* Added "Toggle Gallery" button.
Added `getContainerInfo`.

* Refactor

* Change checkbox toggle to select

* Ensure media_display is set correctly only if any image_swipes were migrated

* Rename function

* Support Date in parseTimestamp

* Add type to main chat array

* Add media display reload prompt

---------

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

* Use a single wrapper block for media

* Fix type annotation

* Fix video display in list mode

* Refactor saveImageToMessage to include title in media object

* Use named constants in migrateMediaToArray

* Update img control styles

* Fix error container state

* Refactor onImageSwiped

* Remove redundant event handler

* Refactor expandMessageMedia

* Use shared function for display handling, fix notice logic

* Enhance ChatMessage and ChatMessageExtra types

* Refactor media display reload logic

* Improve styling for media containers

* Adjust spacing in file form styles

* Fix scroll handling in appendMediaToMessage

* Reduce flicker in appendMediaToMessage

* Extract scrollOnMediaLoad func

* Improve scroll behavior in gallery display

* Improve delegation for click events

* Add file d&d handler to #form_sheld

* Improve scroll adjust for slow connections

* Adjust debounce timeout

* Add messageMedia enum provider

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: DeclineThyself <FallenHaze@tutamail.com>
Co-authored-by: user <user@exmaple.com>
2025-11-02 20:10:43 +02:00
Cohee 55969bc96e Chat Completion: Streamline settings and API key handling (#4687)
* refactor: streamline CC settings and API key handling

* Add types for API settings

* Allow keyless custom source connection
2025-10-23 21:28:37 +03:00
epyllia 9f257b602f Fix compiler errors in public/global.d.ts (#4464)
* Fix TS1038 errors

"A 'declare' modifier cannot be used in an already ambient context."

* Fix TS1040 errors

"'async' modifier cannot be used in an ambient context."

* Fix TS2371 errors

"A parameter initializer is only allowed in a function or constructor
implementation."

* Fix TS2430 errors

"Interface 'ColorPickerEvent' incorrectly extends interface
'ChangeEvent<HTMLElement, any, any, any>'".

The issue here is that the "ColorPickerEvent" objects provided by
toolcool-color-picker.js are vanilla JS CustomEvent objects, not JQuery
event objects. We need to mangle the types here a bit to make JQuery
happy. (At runtime, JQuery is happy to pass along the vanilla Event
object; JQuery's types just don't reflect this.)

* Remove variable and type exports

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2025-08-31 16:30:38 +03:00
Cohee b0820c4517 Text Completion: Inject Story String @ depth (#4362)
* TC/AF: Add Story String position

* Update public/scripts/power-user.js

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

* Add before/after anchors as story string params

* Move autofix story string at settings load

* Substitute in story string wrappers

* Only add an auto-newline after story string if wrap is enabled

* Do not init names_force_groups with default value

* Update default settings

* Auto-delete obsolete fields from instruct templates

* Update default templates

* Remove newline from GLM-4 prefix

* Format as one line

* Remove auto-fix leftovers from renderStoryString

* Remove pointless reassignments in autoFixMissingField

* Update KoboldAI template

* Add info hint for Story String sequences

* Update default templates

* Reformat extractMessageFromData

* Fix condition in autoFixStoryString

* Update tooltip text for Story String Sequences

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-08-09 20:33:04 +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 4fa7de9c93 Add typing for QR API global 2025-06-09 22:53:34 +03:00
Cohee b3c636fe91 Refactor and fix type errors in WI and script modules (#4123)
* remove unnecessary arg passage from WI helper funcs

* remove some typescript red from script.js

* hide in shame

* Add JSDoc to helper functions

* Fix fav_ch_checked not updating

* Move PWA mode match to firstLoadInit

* Fix more type errors and deprecations

* Fix the rest of type errors in script.js

---------

Co-authored-by: RossAscends <124905043+RossAscends@users.noreply.github.com>
2025-06-08 19:14:03 +03:00
Cohee d05373cdd2 Upload video bg via converter extension 2025-04-03 23:48:01 +03:00
bmen25124 d42a81f97c New connection manager events, ConnectionManagerRequestService (#3603) 2025-03-16 16:58:34 +02:00
Cohee e65b72ea41 Fix global.d.ts var declarations 2025-03-12 20:54:07 +02:00
Cohee 58bbfc0d4e Add types for global translation function 2025-02-19 22:18:09 +02:00
Cohee 616fc34826 Add type definitions for jQuery plugins 2024-12-23 01:08:56 +02:00
Cohee 77841dbc21 Add types for SillyTavern.getContext 2024-12-06 16:41:26 +02:00
Cohee 5fe1bc46e6 Fix jquery plugins typedef 2024-10-31 21:05:22 +02:00
Cohee 33f8cd4241 Add typehints for libs 2024-10-17 21:18:34 +03:00
Cohee 2620522333 Revert epubjs vendoring 2024-10-17 20:59:42 +03:00
Cohee e48cf68a13 Revert pdfjsLib vendoring 2024-10-17 20:53:18 +03:00
Cohee b6f9c6480b unvendor: Move formula rendering from core to extensions 2024-10-17 10:08:00 +00:00
Cohee e9a002bc2b unvendor: Replace droll 2024-10-17 08:12:28 +00:00
Cohee ec4763b0c5 unvendor: Replace popperjs/core 2024-10-17 08:03:58 +00:00
Cohee 81bdeb6da8 unvendor: Replace moment 2024-10-17 02:02:45 +03:00
Cohee 7b0f7306c0 unvendor: Replace showdown 2024-10-17 01:51:35 +03:00
Cohee 8b8f2f1144 unvendor: Replace SVGInject 2024-10-17 01:39:15 +03:00
Cohee ca844c8b0a unvendor: Replace Readability 2024-10-17 01:30:04 +03:00
Cohee a32fe00e34 unvendor: Replace pdfjs-dist 2024-10-17 01:16:39 +03:00
Cohee 553920ee8e unvendor: Replace epubjs 2024-10-17 01:03:33 +03:00
Cohee d5fdf307c8 unvendor: Replace handlebars 2024-10-17 00:34:07 +03:00
Cohee 1c4e87b25b unvendor: Replace localforage 2024-10-16 23:37:54 +03:00
Cohee 416282ae1f unvendor: Replace hljs 2024-10-16 23:18:23 +03:00
Cohee 3387fe4bd6 unvendor: Replace DOMPurify 2024-10-16 23:11:13 +03:00
Cohee e6d8f0a33e unvendor: Replace Fuse 2024-10-16 22:15:38 +03:00
Cohee 2e36f45e24 Fix types for dompurify and toastr 2024-10-06 19:51:59 +03:00
Cohee 8006795897 New tool calling framework 2024-10-02 01:00:48 +03:00
Cohee 2bdc6f27cc Add SillyTavern globals 2024-08-12 21:56:32 +03:00
Cohee 8dd5d9321d Fix gallery duplicate uploads 2024-07-27 18:00:30 +03:00
Cohee a20c6bb01e Extension framework for function tool calling 2024-05-25 15:31:57 +03:00
Cohee e73b5713fd Add types for moment 2024-05-11 14:49:11 +03:00
steve green f421139402 Create char-data.js for type hint (#2209)
* Create char-data.js for type hint

code from https://github.com/steve02081504/GentianAphrodite/blob/7df0d1e06d98469c0ecae6190c4ee75661dfcfc7/src/charData.mjs

* add hint

* fixes

* `class` -> JSdoc typedef by AI

* use `import`

* `v2DataWorldInfo`

* Rename book typedef

* Fix type errors

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2024-05-11 12:05:13 +03:00