Skip to content

Commit f6e9904

Browse files
committed
fix: when user input a prompt, it wont have stop message before the new prompt
1 parent 99367ad commit f6e9904

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

chat-client/src/client/mynahUi.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export const handlePromptInputChange = (mynahUi: MynahUI, tabId: string, options
9494
}
9595
}
9696

97-
export const handleChatPrompt = (
97+
export const handleChatPrompt = async (
9898
mynahUi: MynahUI,
9999
tabId: string,
100100
prompt: ChatPrompt,
@@ -104,7 +104,24 @@ export const handleChatPrompt = (
104104
agenticMode?: boolean
105105
) => {
106106
let userPrompt = prompt.escapedPrompt
107-
messager.onStopChatResponse(tabId)
107+
108+
const tabStore = mynahUi.getTabData(tabId)?.getStore()
109+
const isLoading = tabStore?.loadingChat === true
110+
if (isLoading) {
111+
messager.onStopChatResponse(tabId)
112+
mynahUi.addChatItem(tabId, {
113+
type: ChatItemType.DIRECTIVE,
114+
messageId: `stopped-${Date.now()}`,
115+
})
116+
mynahUi.updateStore(tabId, {
117+
loadingChat: false,
118+
cancelButtonWhenLoading: true,
119+
promptInputDisabledState: false,
120+
})
121+
122+
await new Promise(resolve => setTimeout(resolve, 50))
123+
}
124+
108125
if (prompt.command) {
109126
// Temporary solution to handle clear quick actions on the client side
110127
if (prompt.command === '/clear') {

0 commit comments

Comments
 (0)