From 28f0c3629de69f2e3b05c83d7386abbf4bdc9bd6 Mon Sep 17 00:00:00 2001 From: Anirban Kar Date: Sat, 21 Dec 2024 17:44:18 +0530 Subject: [PATCH] ignored alert on project reload --- app/components/chat/Chat.client.tsx | 3 +++ app/lib/stores/workbench.ts | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/components/chat/Chat.client.tsx b/app/components/chat/Chat.client.tsx index 908c39236..b78348240 100644 --- a/app/components/chat/Chat.client.tsx +++ b/app/components/chat/Chat.client.tsx @@ -35,6 +35,9 @@ export function Chat() { const { ready, initialMessages, storeMessageHistory, importChat, exportChat } = useChatHistory(); const title = useStore(description); + useEffect(() => { + workbenchStore.setReloadedMessages(initialMessages.map((m) => m.id)); + }, [initialMessages]); return ( <> diff --git a/app/lib/stores/workbench.ts b/app/lib/stores/workbench.ts index 0337e23e8..92c3508cd 100644 --- a/app/lib/stores/workbench.ts +++ b/app/lib/stores/workbench.ts @@ -39,6 +39,8 @@ export class WorkbenchStore { #editorStore = new EditorStore(this.#filesStore); #terminalStore = new TerminalStore(webcontainer); + #reloadedMessages = new Set(); + artifacts: Artifacts = import.meta.hot?.data.artifacts ?? map({}); showWorkbench: WritableAtom = import.meta.hot?.data.showWorkbench ?? atom(false); @@ -243,6 +245,10 @@ export class WorkbenchStore { // TODO: what do we wanna do and how do we wanna recover from this? } + setReloadedMessages(messages: string[]) { + this.#reloadedMessages = new Set(messages); + } + addArtifact({ messageId, title, id, type }: ArtifactCallbackData) { const artifact = this.#getArtifact(messageId); @@ -262,7 +268,13 @@ export class WorkbenchStore { runner: new ActionRunner( webcontainer, () => this.boltTerminal, - (alert) => this.actionAlert.set(alert), + (alert) => { + if (this.#reloadedMessages.has(messageId)) { + return; + } + + this.actionAlert.set(alert); + }, ), }); }