From 902166efee489c47459a13520a6c2e5b9942079d Mon Sep 17 00:00:00 2001 From: KevIsDev Date: Mon, 28 Apr 2025 14:34:07 +0100 Subject: [PATCH] fix(chat): ensure artifact actions are correctly evaluated for completion The dependency array in the Artifact component was missing `artifact.type` and `allActionFinished`, which could lead to incorrect evaluation of action completion. Additionally, the logic for determining if all actions are finished was updated to account for 'start' actions that are 'running'. This ensures that the component accurately reflects the state of bundled artifacts. --- app/components/chat/Artifact.tsx | 6 ++++-- app/lib/persistence/useChatHistory.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/components/chat/Artifact.tsx b/app/components/chat/Artifact.tsx index 537a6a6..cc0f301 100644 --- a/app/components/chat/Artifact.tsx +++ b/app/components/chat/Artifact.tsx @@ -54,13 +54,15 @@ export const Artifact = memo(({ messageId }: ArtifactProps) => { } if (actions.length !== 0 && artifact.type === 'bundled') { - const finished = !actions.find((action) => action.status !== 'complete'); + const finished = !actions.find( + (action) => action.status !== 'complete' && !(action.type === 'start' && action.status === 'running'), + ); if (allActionFinished !== finished) { setAllActionFinished(finished); } } - }, [actions]); + }, [actions, artifact.type, allActionFinished]); return ( <> diff --git a/app/lib/persistence/useChatHistory.ts b/app/lib/persistence/useChatHistory.ts index dad3da7..77540a6 100644 --- a/app/lib/persistence/useChatHistory.ts +++ b/app/lib/persistence/useChatHistory.ts @@ -131,7 +131,7 @@ export function useChatHistory() { // Combine followup message and the artifact with files and command actions content: `Bolt Restored your chat from a snapshot. You can revert this message to load the full chat history. - + ${Object.entries(snapshot?.files || {}) .map(([key, value]) => { if (value?.type === 'file') {