mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix {{firstIncludedMessageId}} to not rely on DOM
Up until now, the {{firstIncludedMessageId}} macro relied on searching the DOM for the actual CSS class applied for the context line. Bad design, as the actual message was maybe not display, with display X messages enabled. - Use setInContextMessages() that sets the context line on generation to also update a chat metadata field - Utilize that field inside the macro - Update docs to clarify that this will only show the mesid that was relevant during last generation
This commit is contained in:
@ -202,13 +202,7 @@ export function getLastMessageId({ exclude_swipe_in_propress = true, filter = nu
|
||||
* @returns {number|null} The ID of the first message in the context
|
||||
*/
|
||||
function getFirstIncludedMessageId() {
|
||||
const index = Number(document.querySelector('.lastInContext')?.getAttribute('mesid'));
|
||||
|
||||
if (!isNaN(index) && index >= 0) {
|
||||
return index;
|
||||
}
|
||||
|
||||
return null;
|
||||
return chat_metadata['lastInContextMessageId'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user