💄 Improve progress bar UI and make avoid starting at 0
This commit is contained in:
@@ -7,6 +7,7 @@ import { startSession } from '@typebot.io/bot-engine/startSession'
|
||||
import { saveStateToDatabase } from '@typebot.io/bot-engine/saveStateToDatabase'
|
||||
import { restartSession } from '@typebot.io/bot-engine/queries/restartSession'
|
||||
import { filterPotentiallySensitiveLogs } from '@typebot.io/bot-engine/logs/filterPotentiallySensitiveLogs'
|
||||
import { computeCurrentProgress } from '@typebot.io/bot-engine/computeCurrentProgress'
|
||||
|
||||
export const startChat = publicProcedure
|
||||
.meta({
|
||||
@@ -83,6 +84,12 @@ export const startChat = publicProcedure
|
||||
),
|
||||
})
|
||||
|
||||
const isEnded =
|
||||
newSessionState.progressMetadata &&
|
||||
!input?.id &&
|
||||
(clientSideActions?.filter((c) => c.expectsDedicatedReply).length ??
|
||||
0) === 0
|
||||
|
||||
return {
|
||||
sessionId: session.id,
|
||||
typebot: {
|
||||
@@ -96,7 +103,15 @@ export const startChat = publicProcedure
|
||||
dynamicTheme,
|
||||
logs: logs?.filter(filterPotentiallySensitiveLogs),
|
||||
clientSideActions,
|
||||
progress: newSessionState.progressMetadata ? 0 : undefined,
|
||||
progress: newSessionState.progressMetadata
|
||||
? isEnded
|
||||
? 100
|
||||
: computeCurrentProgress({
|
||||
typebotsQueue: newSessionState.typebotsQueue,
|
||||
progressMetadata: newSessionState.progressMetadata,
|
||||
currentInputBlockId: input?.id as string,
|
||||
})
|
||||
: undefined,
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ import { startSession } from '@typebot.io/bot-engine/startSession'
|
||||
import { saveStateToDatabase } from '@typebot.io/bot-engine/saveStateToDatabase'
|
||||
import { restartSession } from '@typebot.io/bot-engine/queries/restartSession'
|
||||
import { publicProcedure } from '@/helpers/server/trpc'
|
||||
import { computeCurrentProgress } from '@typebot.io/bot-engine/computeCurrentProgress'
|
||||
|
||||
export const startChatPreview = publicProcedure
|
||||
.meta({
|
||||
@@ -71,6 +72,12 @@ export const startChatPreview = publicProcedure
|
||||
),
|
||||
})
|
||||
|
||||
const isEnded =
|
||||
newSessionState.progressMetadata &&
|
||||
!input?.id &&
|
||||
(clientSideActions?.filter((c) => c.expectsDedicatedReply).length ??
|
||||
0) === 0
|
||||
|
||||
return {
|
||||
sessionId: session.id,
|
||||
typebot: {
|
||||
@@ -83,7 +90,15 @@ export const startChatPreview = publicProcedure
|
||||
dynamicTheme,
|
||||
logs,
|
||||
clientSideActions,
|
||||
progress: newSessionState.progressMetadata ? 0 : undefined,
|
||||
progress: newSessionState.progressMetadata
|
||||
? isEnded
|
||||
? 100
|
||||
: computeCurrentProgress({
|
||||
typebotsQueue: newSessionState.typebotsQueue,
|
||||
progressMetadata: newSessionState.progressMetadata,
|
||||
currentInputBlockId: input?.id as string,
|
||||
})
|
||||
: undefined,
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user