🐛 Fix remember user streaming messages

This commit is contained in:
Baptiste Arnaud
2024-07-15 15:06:38 +02:00
parent 043f0054b0
commit f4cd1d5ba3
7 changed files with 21 additions and 9 deletions

View File

@@ -171,7 +171,10 @@ export const ChatChunk = (props: Props) => {
: '100%',
}}
>
<StreamingBubble streamingMessageId={streamingMessageId} />
<StreamingBubble
streamingMessageId={streamingMessageId}
context={props.context}
/>
</div>
</div>
)}

View File

@@ -73,7 +73,7 @@ type Props = {
export const ConversationContainer = (props: Props) => {
let chatContainer: HTMLDivElement | undefined
const [chatChunks, setChatChunks, isRecovered] = persist(
const [chatChunks, setChatChunks, isRecovered, setIsRecovered] = persist(
createSignal<ChatChunkType[]>([
{
input: props.initialChatReply.input,
@@ -146,6 +146,7 @@ export const ConversationContainer = (props: Props) => {
message?: string,
attachments?: Answer['attachments']
) => {
setIsRecovered(false)
setHasError(false)
const currentInputBlock = [...chatChunks()].pop()?.input
if (currentInputBlock?.id && props.onAnswer && message)
@@ -274,6 +275,7 @@ export const ConversationContainer = (props: Props) => {
const processClientSideActions = async (
actions: NonNullable<ContinueChatResponse['clientSideActions']>
) => {
console.log('YES')
if (isRecovered()) return
for (const action of actions) {
if (

View File

@@ -3,13 +3,19 @@ import { For, createEffect, createSignal } from 'solid-js'
import { marked } from 'marked'
import domPurify from 'dompurify'
import { isNotEmpty } from '@typebot.io/lib'
import { persist } from '@/utils/persist'
import { BotContext } from '@/types'
type Props = {
streamingMessageId: string
context: BotContext
}
export const StreamingBubble = (props: Props) => {
const [content, setContent] = createSignal<string[]>([])
const [content, setContent] = persist(createSignal<string[]>([]), {
key: `typebot-streaming-message-${props.streamingMessageId}`,
storage: props.context.storage,
})
marked.use({
renderer: {