Skip to content

Commit a44a640

Browse files
authored
Merge pull request #484 from easyops-cn/steve/chat-panel
fix(): reset finished when send message again
2 parents faa75ba + 67b0456 commit a44a640

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

bricks/ai-portal/src/cruise-canvas/reducers/conversation.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ export const conversation: Reducer<
2626
case "reset":
2727
return null;
2828

29+
case "started":
30+
if (state) {
31+
return { ...state, finished: false };
32+
}
33+
return state;
34+
2935
case "finished":
3036
if (state) {
3137
return { ...state, finished: true };

bricks/ai-portal/src/cruise-canvas/reducers/interfaces.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface CruiseCanvasState {
1616
export type CruiseCanvasAction =
1717
| ConversationSSEAction
1818
| ConversationResetAction
19+
| ConversationStartedAction
1920
| ConversationFinishedAction;
2021

2122
export interface ConversationSSEAction {
@@ -28,6 +29,10 @@ export interface ConversationResetAction {
2829
type: "reset";
2930
}
3031

32+
export interface ConversationStartedAction {
33+
type: "started";
34+
}
35+
3136
export interface ConversationFinishedAction {
3237
type: "finished";
3338
}

bricks/ai-portal/src/cruise-canvas/useConversationDetail.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export function useConversationDetail(
104104

105105
requesting = true;
106106
ctrl = new AbortController();
107+
dispatch({ type: "started" });
107108
try {
108109
const sseRequest = await (content === null && !action
109110
? createSSEStream<ConversationPatch>(
@@ -157,13 +158,13 @@ export function useConversationDetail(
157158
dispatch({ type: "sse", payload: value, workspace: conversationId });
158159
isInitial = false;
159160
}
160-
dispatch({ type: "finished" });
161161
} catch (e) {
162162
// eslint-disable-next-line no-console
163163
console.error("sse failed", e);
164164
handleHttpError(e);
165165
} finally {
166166
requesting = false;
167+
dispatch({ type: "finished" });
167168
}
168169
};
169170

0 commit comments

Comments
 (0)