Timothy J. Baek 7 months ago
parent
commit
e06667ead8

+ 0 - 1
src/lib/components/chat/ChatControls.svelte

@@ -128,7 +128,6 @@
 					: 30
 				: 0}
 			onResize={(size) => {
-				console.log(size);
 				if (size === 0) {
 					showControls.set(false);
 				} else {

+ 14 - 1
src/lib/components/chat/Messages/CodeBlock.svelte

@@ -20,6 +20,8 @@
 	export let lang = '';
 	export let code = '';
 
+	let _token = null;
+
 	let mermaidHtml = null;
 
 	let highlightedCode = null;
@@ -226,7 +228,7 @@ __builtins__.input = input`);
 		}
 	};
 
-	$: if (token) {
+	const render = async () => {
 		if (lang === 'mermaid' && (token?.raw ?? '').slice(-4).includes('```')) {
 			(async () => {
 				await drawMermaidDiagram();
@@ -242,6 +244,17 @@ __builtins__.input = input`);
 			// Set a new timeout to debounce the code highlighting
 			debounceTimeout = setTimeout(highlightCode, 10);
 		}
+	};
+
+	$: if (token) {
+		if (JSON.stringify(token) !== JSON.stringify(_token)) {
+			console.log('hi');
+			_token = token;
+		}
+	}
+
+	$: if (_token) {
+		render();
 	}
 
 	onMount(async () => {