mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
World Info: Allow disabling recursion on entries
Recursive scanning is a very great tool used to create a tree hierarchy of entries. However, some entries should not be included in recursion due to possible conflicts and resulting leakage in chats. Add an individual opt-out toggle to exclude the entry from recursive scanning if the main option is enabled. Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
@ -2920,6 +2920,10 @@
|
|||||||
<input type="checkbox" name="disable" />
|
<input type="checkbox" name="disable" />
|
||||||
<span data-i18n="Disable">Disable</span>
|
<span data-i18n="Disable">Disable</span>
|
||||||
</label>
|
</label>
|
||||||
|
<label class="checkbox flex-container alignitemscenter">
|
||||||
|
<input type="checkbox" name="exclude_recursion" />
|
||||||
|
<span data-i18n="Exclude from recursion">Exclude from recursion</span>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<input class="menu_button delete_entry_button" type="submit" value="Delete Entry" />
|
<input class="menu_button delete_entry_button" type="submit" value="Delete Entry" />
|
||||||
</div>
|
</div>
|
||||||
|
@ -332,6 +332,19 @@ function appendWorldEntry(entry) {
|
|||||||
$(this).siblings("input").click();
|
$(this).siblings("input").click();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const excludeRecursionInput = template.find('input[name="exclude_recursion"]');
|
||||||
|
excludeRecursionInput.data("uid", entry.uid);
|
||||||
|
excludeRecursionInput.on("input", function () {
|
||||||
|
const uid = $(this).data("uid");
|
||||||
|
const value = $(this).prop("checked");
|
||||||
|
world_info_data.entries[uid].excludeRecursion = value;
|
||||||
|
saveWorldInfo();
|
||||||
|
});
|
||||||
|
excludeRecursionInput.prop("checked", entry.excludeRecursion).trigger("input");
|
||||||
|
excludeRecursionInput.siblings(".checkbox_fancy").click(function () {
|
||||||
|
$(this).siblings("input").click();
|
||||||
|
});
|
||||||
|
|
||||||
// delete button
|
// delete button
|
||||||
const deleteButton = template.find("input.delete_entry_button");
|
const deleteButton = template.find("input.delete_entry_button");
|
||||||
deleteButton.data("uid", entry.uid);
|
deleteButton.data("uid", entry.uid);
|
||||||
@ -366,6 +379,7 @@ function createWorldInfoEntry() {
|
|||||||
order: 100,
|
order: 100,
|
||||||
position: 0,
|
position: 0,
|
||||||
disable: false,
|
disable: false,
|
||||||
|
excludeRecursion: false
|
||||||
};
|
};
|
||||||
const newUid = getFreeWorldEntryUid();
|
const newUid = getFreeWorldEntryUid();
|
||||||
|
|
||||||
@ -505,6 +519,7 @@ function checkWorldInfo(chat) {
|
|||||||
let worldInfoBefore = "";
|
let worldInfoBefore = "";
|
||||||
let worldInfoAfter = "";
|
let worldInfoAfter = "";
|
||||||
let needsToScan = true;
|
let needsToScan = true;
|
||||||
|
let count = 0;
|
||||||
let allActivatedEntries = new Set();
|
let allActivatedEntries = new Set();
|
||||||
|
|
||||||
const sortedEntries = Object.keys(world_info_data.entries)
|
const sortedEntries = Object.keys(world_info_data.entries)
|
||||||
@ -512,10 +527,13 @@ function checkWorldInfo(chat) {
|
|||||||
.sort((a, b) => b.order - a.order);
|
.sort((a, b) => b.order - a.order);
|
||||||
|
|
||||||
while (needsToScan) {
|
while (needsToScan) {
|
||||||
|
// Track how many times the loop has run
|
||||||
|
count++;
|
||||||
|
|
||||||
let activatedNow = new Set();
|
let activatedNow = new Set();
|
||||||
|
|
||||||
for (let entry of sortedEntries) {
|
for (let entry of sortedEntries) {
|
||||||
if (allActivatedEntries.has(entry.uid) || entry.disable == true) {
|
if (allActivatedEntries.has(entry.uid) || entry.disable == true || (count > 1 && world_info_recursive && entry.excludeRecursion)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user