ai: actually make chat messages update incrementally

(instead of destroying and recreating every update)
MUCH better performance and no more hundreds of latex files for one integration by parts work
This commit is contained in:
end-4
2025-04-08 11:28:31 +02:00
parent d74ac27db0
commit 9d33e8a404
3 changed files with 73 additions and 47 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ const replaceCategory = (text, replaces) => {
// Main function
export function replaceInlineLatexWithCodeBlocks(text) {
return text.replace(/\\\[(.*?)\\\]|\\\((.*?)\\\)|\$\$(.*?)\$\$|(?<!\w)\$(.*?[^\\])\$(?!\w)/gs, (match, square, round, double, single) => {
return text.replace(/\\\[(.*?)\\\]|\\\((.*?)\\\)|\$\$(.*?)\$\$|(?:^|[^\w])\$(.*?[^\\])\$(?!\w)/gs, (match, square, round, double, single) => {
const latex = square || round || double || single;
return `\n\`\`\`latex\n${latex}\n\`\`\`\n`;
});