Merge pull request #2766 from SillyTavern/wi-prefer-sticky-on-budget Prefer stickied WI for budget-limited cases

a2710b70c15711720003d9343c6f252274d776ce

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
1 files changed, +9 -1Ignore whitespace
public/scripts/world-info.js+9 -1
@@ -3940,8 +3940,16 @@ export async function checkWorldInfo(chat, maxContext, isDryRun) {
39403940 }
39413941
39423942 console.debug(`[WI] Search done. Found ${activatedNow.size} possible entries.`);
3943+
3944+ // Sort the entries for the probability and the budget limit checks
39433945 const newEntries = [...activatedNow]
39443946 .sort((a, b) => sortedEntries.indexOf(a) - sortedEntries.indexOf(b));{
3947+ const isASticky = timedEffects.isEffectActive('sticky', a) ? 1 : 0;
3948+ const isBSticky = timedEffects.isEffectActive('sticky', b) ? 1 : 0;
3949+ return isBSticky - isASticky || sortedEntries.indexOf(a) - sortedEntries.indexOf(b);
3950+ });
3951+
3952+
39453953 let newContent = '';
39463954 const textToScanTokens = await getTokenCountAsync(allActivatedText);
39473955