Skip to content

Commit cf4313d

Browse files
committed
Fix abort issues for autoplay and manual TTS
1 parent 4b325e4 commit cf4313d

10 files changed

Lines changed: 3099 additions & 35 deletions

File tree

dist/components/Bot.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/components/bubbles/BotBubble.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/queries/sendMessageQuery.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export type GenerateTTSRequest = BaseRequest & {
6060
};
6161
export type AbortTTSRequest = BaseRequest & {
6262
body: {
63+
chatflowId: string;
6364
chatId: string;
6465
chatMessageId: string;
6566
};

dist/queries/sendMessageQuery.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/web.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/web.umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Bot.tsx

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,34 +1803,31 @@ export const Bot = (botProps: BotProps & { class?: string }) => {
18031803
// Ensure complete cleanup before starting new TTS
18041804
stopAllTTSLocally();
18051805

1806-
// Wait a bit for cleanup to complete before starting new stream
1807-
setTimeout(() => {
1808-
setIsTTSLoading((prevState) => ({
1809-
...prevState,
1810-
[data.chatMessageId]: true,
1811-
}));
1806+
setIsTTSLoading((prevState) => ({
1807+
...prevState,
1808+
[data.chatMessageId]: true,
1809+
}));
18121810

1813-
setMessages((prevMessages) => {
1814-
const allMessages = [...cloneDeep(prevMessages)];
1815-
const lastMessage = allMessages[allMessages.length - 1];
1816-
if (lastMessage.type === 'userMessage') return allMessages;
1817-
if (lastMessage.id) return allMessages;
1818-
allMessages[allMessages.length - 1].id = data.chatMessageId;
1819-
return allMessages;
1820-
});
1811+
setMessages((prevMessages) => {
1812+
const allMessages = [...cloneDeep(prevMessages)];
1813+
const lastMessage = allMessages[allMessages.length - 1];
1814+
if (lastMessage.type === 'userMessage') return allMessages;
1815+
if (lastMessage.id) return allMessages;
1816+
allMessages[allMessages.length - 1].id = data.chatMessageId;
1817+
return allMessages;
1818+
});
18211819

1822-
setTtsStreamingState({
1823-
mediaSource: null,
1824-
sourceBuffer: null,
1825-
audio: null,
1826-
chunkQueue: [],
1827-
isBuffering: false,
1828-
audioFormat: data.format,
1829-
abortController: null,
1830-
});
1820+
setTtsStreamingState({
1821+
mediaSource: null,
1822+
sourceBuffer: null,
1823+
audio: null,
1824+
chunkQueue: [],
1825+
isBuffering: false,
1826+
audioFormat: data.format,
1827+
abortController: null,
1828+
});
18311829

1832-
setTimeout(() => initializeTTSStreaming(data), 100);
1833-
}, 100);
1830+
setTimeout(() => initializeTTSStreaming(data), 100);
18341831
};
18351832

18361833
const handleTTSDataChunk = (base64Data: string) => {
@@ -2116,6 +2113,7 @@ export const Bot = (botProps: BotProps & { class?: string }) => {
21162113
await abortTTSQuery({
21172114
apiHost: props.apiHost,
21182115
body: {
2116+
chatflowId: props.chatflowid,
21192117
chatId: chatId(),
21202118
chatMessageId: messageId,
21212119
},
@@ -2164,6 +2162,7 @@ export const Bot = (botProps: BotProps & { class?: string }) => {
21642162
await abortTTSQuery({
21652163
apiHost: props.apiHost,
21662164
body: {
2165+
chatflowId: props.chatflowid,
21672166
chatId: chatId(),
21682167
chatMessageId: messageId,
21692168
},

0 commit comments

Comments
 (0)