Browse Source

refac: close artifacts if html codeblock is not found

Timothy J. Baek 7 months ago
parent
commit
cdd024db81
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/lib/components/chat/Artifacts.svelte

+ 8 - 1
src/lib/components/chat/Artifacts.svelte

@@ -17,9 +17,12 @@
 
 	let iframeElement: HTMLIFrameElement;
 
-	$: if (history.currentId) {
+	$: if (history) {
 		messages = createMessagesList(history, history.currentId);
 		getContents();
+	} else {
+		messages = [];
+		getContents();
 	}
 
 	function getContents() {
@@ -97,6 +100,10 @@
 			}
 		});
 
+		if (messages.length === 0 || (messages.at(-1)?.done && contents.length === 0)) {
+			showArtifacts.set(false);
+			showControls.set(false);
+		}
 		selectedContentIdx = contents ? contents.length - 1 : 0;
 	}