Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bricks/ai-portal/src/cruise-canvas/reducers/conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ export const conversation: Reducer<
case "reset":
return null;

case "started":
if (state) {
return { ...state, finished: false };
}
return state;
Comment on lines +29 to +33
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new started action and the logic for resetting the finished flag lack test coverage. Since the tasks reducer has test coverage (tasks.spec.ts), similar test coverage should be added for the conversation reducer to verify:

  1. The started action correctly sets finished: false when state exists
  2. The started action returns the existing state when state is null
  3. The interaction between started and finished actions works correctly

Copilot uses AI. Check for mistakes.

case "finished":
if (state) {
return { ...state, finished: true };
Expand Down
5 changes: 5 additions & 0 deletions bricks/ai-portal/src/cruise-canvas/reducers/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface CruiseCanvasState {
export type CruiseCanvasAction =
| ConversationSSEAction
| ConversationResetAction
| ConversationStartedAction
| ConversationFinishedAction;

export interface ConversationSSEAction {
Expand All @@ -28,6 +29,10 @@ export interface ConversationResetAction {
type: "reset";
}

export interface ConversationStartedAction {
type: "started";
}

export interface ConversationFinishedAction {
type: "finished";
}
3 changes: 2 additions & 1 deletion bricks/ai-portal/src/cruise-canvas/useConversationDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export function useConversationDetail(

requesting = true;
ctrl = new AbortController();
dispatch({ type: "started" });
try {
const sseRequest = await (content === null && !action
? createSSEStream<ConversationPatch>(
Expand Down Expand Up @@ -157,13 +158,13 @@ export function useConversationDetail(
dispatch({ type: "sse", payload: value, workspace: conversationId });
isInitial = false;
}
dispatch({ type: "finished" });
} catch (e) {
// eslint-disable-next-line no-console
console.error("sse failed", e);
handleHttpError(e);
} finally {
requesting = false;
dispatch({ type: "finished" });
}
};

Expand Down
Loading