From cdd024db81892fbeeb6133d2d16de4d83738ac95 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 6 Oct 2024 01:20:10 -0700 Subject: [PATCH] refac: close artifacts if html codeblock is not found --- src/lib/components/chat/Artifacts.svelte | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/components/chat/Artifacts.svelte b/src/lib/components/chat/Artifacts.svelte index 84906ced9..6df05ade0 100644 --- a/src/lib/components/chat/Artifacts.svelte +++ b/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; }