Skip to content

Commit 56b7330

Browse files
Fix agent stale session (#1551)
<!-- Ensure the title clearly reflects what was changed. Provide a clear and concise description of the changes made. The PR should only contain the changes related to the issue, and no other unrelated changes. --> Fixes OPS-2961
1 parent 9db5cdf commit 56b7330

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

packages/react-ui/src/app/features/ai/lib/assistant-ui-chat-hook.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,14 @@ export const useAssistantChat = ({
129129
stepDetails &&
130130
flowId
131131
) {
132+
const stepId =
133+
flowHelper.getStep(context.flowVersion, context.selectedStep)?.id ??
134+
context.selectedStep;
135+
132136
return await aiChatApi.open(
133137
flowId,
134138
getBlockName(stepDetails),
135-
context.selectedStep,
139+
stepId,
136140
getActionName(stepDetails),
137141
);
138142
}
@@ -292,7 +296,11 @@ export const useAssistantChat = ({
292296

293297
if (oldChatId) {
294298
const context = getBuilderState();
295-
if (context?.selectedStep && context?.flowVersion) {
299+
if (
300+
context?.selectedStep &&
301+
context?.flowVersion &&
302+
chatMode === ChatMode.StepSettings
303+
) {
296304
await aiChatApi.delete(oldChatId);
297305
chat.setMessages([]);
298306
} else {
@@ -308,7 +316,7 @@ export const useAssistantChat = ({
308316
`There was an error canceling the current run and invalidating queries while creating a new chat: ${error}`,
309317
);
310318
}
311-
}, [chatId, chat, onChatIdChange, getBuilderState]);
319+
}, [chatId, chat, getBuilderState, chatMode, onChatIdChange]);
312320

313321
return {
314322
runtime,

0 commit comments

Comments
 (0)