From bbeb12cad2bad3ed9899cc04a70563ef67fdabc6 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Mon, 11 Mar 2024 08:56:50 +0100 Subject: [PATCH] :bug: Fix progress bar crash when input is undefined --- apps/viewer/src/features/chat/api/continueChat.ts | 2 +- apps/viewer/src/features/chat/api/startChat.ts | 2 +- apps/viewer/src/features/chat/api/startChatPreview.ts | 2 +- packages/bot-engine/computeCurrentProgress.ts | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/viewer/src/features/chat/api/continueChat.ts b/apps/viewer/src/features/chat/api/continueChat.ts index fc85c8b91..a6f2ffd09 100644 --- a/apps/viewer/src/features/chat/api/continueChat.ts +++ b/apps/viewer/src/features/chat/api/continueChat.ts @@ -113,7 +113,7 @@ export const continueChat = publicProcedure : computeCurrentProgress({ typebotsQueue: newSessionState.typebotsQueue, progressMetadata: newSessionState.progressMetadata, - currentInputBlockId: input?.id as string, + currentInputBlockId: input?.id, }) : undefined, } diff --git a/apps/viewer/src/features/chat/api/startChat.ts b/apps/viewer/src/features/chat/api/startChat.ts index 1f01298ed..01fa45725 100644 --- a/apps/viewer/src/features/chat/api/startChat.ts +++ b/apps/viewer/src/features/chat/api/startChat.ts @@ -109,7 +109,7 @@ export const startChat = publicProcedure : computeCurrentProgress({ typebotsQueue: newSessionState.typebotsQueue, progressMetadata: newSessionState.progressMetadata, - currentInputBlockId: input?.id as string, + currentInputBlockId: input?.id, }) : undefined, } diff --git a/apps/viewer/src/features/chat/api/startChatPreview.ts b/apps/viewer/src/features/chat/api/startChatPreview.ts index 8d7f0ed5e..4d473af74 100644 --- a/apps/viewer/src/features/chat/api/startChatPreview.ts +++ b/apps/viewer/src/features/chat/api/startChatPreview.ts @@ -98,7 +98,7 @@ export const startChatPreview = publicProcedure : computeCurrentProgress({ typebotsQueue: newSessionState.typebotsQueue, progressMetadata: newSessionState.progressMetadata, - currentInputBlockId: input?.id as string, + currentInputBlockId: input?.id, }) : undefined, } diff --git a/packages/bot-engine/computeCurrentProgress.ts b/packages/bot-engine/computeCurrentProgress.ts index 9a3c5f11c..c5ce72d8c 100644 --- a/packages/bot-engine/computeCurrentProgress.ts +++ b/packages/bot-engine/computeCurrentProgress.ts @@ -5,7 +5,7 @@ import { Block, SessionState } from '@typebot.io/schemas' type Props = { typebotsQueue: SessionState['typebotsQueue'] progressMetadata: NonNullable - currentInputBlockId: string + currentInputBlockId: string | undefined } export const computeCurrentProgress = ({ @@ -13,6 +13,7 @@ export const computeCurrentProgress = ({ progressMetadata, currentInputBlockId, }: Props) => { + if (!currentInputBlockId) return const paths = computePossibleNextInputBlocks({ typebotsQueue: typebotsQueue, blockId: currentInputBlockId,