Skip to content

Commit 46e6a25

Browse files
New chat always enabled (#1107)
1 parent d19a613 commit 46e6a25

File tree

7 files changed

+5
-46
lines changed

7 files changed

+5
-46
lines changed

packages/react-ui/src/app/features/ai/assistant-ui/assistant-ui-chat.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ const AssistantUiChat = ({
4141
shouldRenderChat,
4242
openChatResponse,
4343
isLoading,
44-
hasMessages,
4544
createNewChat,
4645
} = useAssistantChat({
4746
chatId,
@@ -83,7 +82,6 @@ const AssistantUiChat = ({
8382
runtime={runtime}
8483
onNewChat={createNewChat}
8584
title={title}
86-
enableNewChat={hasMessages}
8785
availableModels={availableModels}
8886
onModelSelected={onModelSelected}
8987
isModelSelectorLoading={isModelSelectorLoading}

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ export const useAssistantChat = (props: UseAssistantChatProps) => {
148148

149149
const runtime = useChatRuntime(runtimeConfig);
150150

151-
const [hasMessages, setHasMessages] = useState(!!openChatResponse?.messages);
152-
153151
useEffect(() => {
154152
if (pendingConversation && runtime && shouldRenderChat) {
155153
if (pendingConversation.chatId !== chatId) {
@@ -182,7 +180,6 @@ export const useAssistantChat = (props: UseAssistantChatProps) => {
182180
await aiChatApi.delete(oldChatId);
183181
}
184182
}
185-
setHasMessages(false);
186183
} catch (error) {
187184
toast({
188185
title: t('There was an error creating the new chat, please try again'),
@@ -194,20 +191,11 @@ export const useAssistantChat = (props: UseAssistantChatProps) => {
194191
}
195192
}, [chatId, onChatIdChange, runtime.thread, selectedStep, flowVersion]);
196193

197-
useEffect(() => {
198-
const unsubscribe = runtime.thread.subscribe(() => {
199-
setHasMessages(!!runtime.thread.getState().messages?.length);
200-
});
201-
202-
return () => unsubscribe();
203-
}, [runtime.thread]);
204-
205194
return {
206195
runtime,
207196
shouldRenderChat,
208197
isLoading,
209198
openChatResponse,
210-
hasMessages,
211199
createNewChat,
212200
};
213201
};

packages/react-ui/src/app/features/builder/ai-chat/step-settings-assistant-ui-chat.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ const StepSettingsAssistantUiChat = ({
3636
state.applyMidpanelAction,
3737
]);
3838

39-
const { runtime, createNewChat, hasMessages, onInject } =
40-
useStepSettingsAssistantChat(flowVersion, selectedStep);
39+
const { runtime, createNewChat, onInject } = useStepSettingsAssistantChat(
40+
flowVersion,
41+
selectedStep,
42+
);
4143

4244
const onToggleContainerSizeState = useCallback(
4345
(size: AiCliChatContainerSizeState) => {
@@ -76,7 +78,6 @@ const StepSettingsAssistantUiChat = ({
7678
parentWidth={middlePanelSize.width}
7779
showAiChat={showAiChat}
7880
onCloseClick={onCloseClick}
79-
enableNewChat={hasMessages}
8081
handleInject={onInject}
8182
onNewChatClick={createNewChat}
8283
containerSize={aiContainerSize}

packages/ui-components/src/components/ai-chat-container/step-settings-assistant-ui-chat-container.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ type StepSettingsAssistantUiChatContainerProps = {
2424
onCloseClick: () => void;
2525
onNewChatClick: () => void;
2626
containerSize: AiCliChatContainerSizeState;
27-
enableNewChat: boolean;
2827
toggleContainerSizeState: (state: AiCliChatContainerSizeState) => void;
2928
className?: string;
3029
isModelSelectorLoading: boolean;
@@ -44,7 +43,6 @@ const StepSettingsAssistantUiChatContainer = ({
4443
onCloseClick,
4544
onNewChatClick,
4645
containerSize,
47-
enableNewChat,
4846
toggleContainerSizeState,
4947
className,
5048
isModelSelectorLoading,
@@ -99,7 +97,6 @@ const StepSettingsAssistantUiChatContainer = ({
9997
runtime={runtime}
10098
onClose={onCloseClick}
10199
onNewChat={onNewChatClick}
102-
enableNewChat={enableNewChat}
103100
availableModels={availableModels}
104101
theme={theme}
105102
title={t('AI Chat')}

packages/ui-components/src/components/assistant-ui/assistant-top-bar.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ import { Button } from '../../ui/button';
77
type AssistantTopBarProps = {
88
onClose: () => void;
99
onNewChat: () => void;
10-
enableNewChat: boolean;
1110
title?: string;
1211
children: ReactNode;
1312
};
1413

1514
const AssistantTopBar = ({
1615
onNewChat,
1716
onClose,
18-
enableNewChat,
1917
title,
2018
children,
2119
}: AssistantTopBarProps) => {
@@ -28,7 +26,6 @@ const AssistantTopBar = ({
2826
e.stopPropagation();
2927
onNewChat();
3028
}}
31-
disabled={!enableNewChat}
3229
variant="secondary"
3330
size="icon"
3431
className="text-outline size-[36px]"

packages/ui-components/src/components/assistant-ui/assistant-ui-chat-container.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ type AssistantUiChatContainerProps = {
1919
const AssistantUiChatContainer = ({
2020
onClose,
2121
onNewChat,
22-
enableNewChat,
2322
runtime,
2423
title,
2524
availableModels,
@@ -39,12 +38,7 @@ const AssistantUiChatContainer = ({
3938

4039
return (
4140
<div className="h-full w-full flex flex-col bg-background overflow-hidden">
42-
<AssistantTopBar
43-
onClose={onClose}
44-
onNewChat={onNewChat}
45-
enableNewChat={enableNewChat}
46-
title={title}
47-
>
41+
<AssistantTopBar onClose={onClose} onNewChat={onNewChat} title={title}>
4842
{children}
4943
</AssistantTopBar>
5044
<AssistantRuntimeProvider runtime={runtime}>

packages/ui-components/src/stories/assistant-ui/assistant-top-bar.stories.tsx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const meta = {
2525
args: {
2626
onClose: action('Close clicked'),
2727
onNewChat: action('New chat clicked'),
28-
enableNewChat: true,
2928
title: 'AI Assistant',
3029
children: null,
3130
},
@@ -36,10 +35,6 @@ const meta = {
3635
onNewChat: {
3736
description: 'Function called when the new chat button is clicked',
3837
},
39-
enableNewChat: {
40-
description: 'Whether the new chat button is enabled',
41-
control: 'boolean',
42-
},
4338
children: {
4439
description: 'Optional elements to render in the header',
4540
},
@@ -69,16 +64,6 @@ type Story = StoryObj<typeof meta>;
6964
*/
7065
export const Default: Story = {};
7166

72-
/**
73-
* AssistantTopBar with the new chat button disabled.
74-
* This demonstrates how the component appears when starting a new chat is not allowed.
75-
*/
76-
export const NewChatDisabled: Story = {
77-
args: {
78-
enableNewChat: false,
79-
},
80-
};
81-
8267
/**
8368
* AssistantTopBar with additional action buttons.
8469
* This demonstrates how the component can be extended with custom controls.
@@ -133,7 +118,6 @@ export const WithSingleButton: Story = {
133118
*/
134119
export const ComplexExample: Story = {
135120
args: {
136-
enableNewChat: false,
137121
children: (
138122
<>
139123
<Button

0 commit comments

Comments
 (0)