Skip to content

Commit 1c9d0b1

Browse files
ivicacclaude
andcommitted
2311 client - Rename workflow-chat to chats and extract useChat hook
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7012236 commit 1c9d0b1

File tree

10 files changed

+101
-92
lines changed

10 files changed

+101
-92
lines changed

client/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const automationNavigation: NavigationType[] = [
8383
icon: VectorSquareIcon,
8484
name: 'Knowledge Base',
8585
},
86-
{href: '/automation/chat', icon: MessagesSquareIcon, name: 'Chat'},
86+
{href: '/automation/chats', icon: MessagesSquareIcon, name: 'Chats'},
8787
{href: '/automation/approval-tasks', icon: CircleIcon, name: 'Approval Tasks'},
8888
];
8989

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {Thread} from '@/components/assistant-ui/thread';
2+
import useChat from '@/pages/automation/chats/hooks/useChat';
3+
import {ChatRuntimeProvider} from '@/pages/automation/chats/runtime-providers/ChatRuntimeProvider';
4+
5+
const Chat = () => {
6+
const {effectiveWorkflowExecutionId, environmentName, sseStreamResponse} = useChat();
7+
8+
return (
9+
<div className="flex flex-1">
10+
<ChatRuntimeProvider
11+
environmentName={environmentName}
12+
sseStreamResponse={sseStreamResponse}
13+
workflowExecutionId={effectiveWorkflowExecutionId}
14+
>
15+
<div className="relative flex size-full flex-col">
16+
<Thread />
17+
</div>
18+
</ChatRuntimeProvider>
19+
</div>
20+
);
21+
};
22+
23+
export default Chat;

client/src/pages/automation/workflow-chat/WorkflowChatContainer.tsx renamed to client/src/pages/automation/chats/Chats.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import Button from '@/components/Button/Button';
22
import {Tooltip, TooltipContent, TooltipTrigger} from '@/components/ui/tooltip';
3-
import WorkflowChatSidebar from '@/pages/automation/workflow-chat/components/WorkflowChatSidebar';
4-
import {useWorkflowChatStore} from '@/pages/automation/workflow-chat/stores/useWorkflowChatStore';
3+
import ChatsSidebar from '@/pages/automation/chats/components/ChatsSidebar';
4+
import {useChatsStore} from '@/pages/automation/chats/stores/useChatsStore';
55
import EnvironmentSelect from '@/shared/components/EnvironmentSelect';
66
import Header from '@/shared/layout/Header';
77
import LayoutContainer from '@/shared/layout/LayoutContainer';
88
import {MessageSquareIcon, MessageSquareXIcon} from 'lucide-react';
99
import {useEffect} from 'react';
1010
import {Outlet, useParams} from 'react-router-dom';
1111

12-
const WorkflowChatContainer = () => {
12+
const Chats = () => {
1313
const {workflowExecutionId} = useParams();
1414

15-
const currentChatName = useWorkflowChatStore((state) => state.currentChatName);
16-
const isRunning = useWorkflowChatStore((state) => state.isRunning);
17-
const resetAll = useWorkflowChatStore((state) => state.resetAll);
18-
const resetCurrentChat = useWorkflowChatStore((state) => state.resetCurrentChat);
15+
const currentChatName = useChatsStore((state) => state.currentChatName);
16+
const isRunning = useChatsStore((state) => state.isRunning);
17+
const resetAll = useChatsStore((state) => state.resetAll);
18+
const resetCurrentChat = useChatsStore((state) => state.resetCurrentChat);
1919

2020
useEffect(() => {
2121
return () => {
@@ -55,8 +55,8 @@ const WorkflowChatContainer = () => {
5555
title={currentChatName}
5656
/>
5757
}
58-
leftSidebarBody={<WorkflowChatSidebar />}
59-
leftSidebarHeader={<Header position="sidebar" title="Chat" />}
58+
leftSidebarBody={<ChatsSidebar />}
59+
leftSidebarHeader={<Header position="sidebar" title="Chats" />}
6060
leftSidebarWidth="64"
6161
>
6262
{workflowExecutionId ? (
@@ -74,4 +74,4 @@ const WorkflowChatContainer = () => {
7474
);
7575
};
7676

77-
export default WorkflowChatContainer;
77+
export default Chats;

client/src/pages/automation/workflow-chat/components/WorkflowChatSidebar.tsx renamed to client/src/pages/automation/chats/components/ChatsSidebar.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import {useChatsStore} from '@/pages/automation/chats/stores/useChatsStore';
12
import {useWorkspaceStore} from '@/pages/automation/stores/useWorkspaceStore';
2-
import {useWorkflowChatStore} from '@/pages/automation/workflow-chat/stores/useWorkflowChatStore';
33
import {LeftSidebarNav, LeftSidebarNavItem} from '@/shared/layout/LeftSidebarNav';
44
import {useWorkspaceChatWorkflowsQuery} from '@/shared/middleware/graphql';
55
import {useEnvironmentStore} from '@/shared/stores/useEnvironmentStore';
@@ -15,12 +15,12 @@ interface ProjectChatGroupI {
1515
}>;
1616
}
1717

18-
const WorkflowChatSidebar = () => {
18+
const ChatsSidebar = () => {
1919
const {workflowExecutionId} = useParams();
2020

2121
const currentEnvironmentId = useEnvironmentStore((state) => state.currentEnvironmentId);
2222
const currentWorkspaceId = useWorkspaceStore((state) => state.currentWorkspaceId);
23-
const isRunning = useWorkflowChatStore((state) => state.isRunning);
23+
const isRunning = useChatsStore((state) => state.isRunning);
2424

2525
const {data, isLoading} = useWorkspaceChatWorkflowsQuery({
2626
environmentId: String(currentEnvironmentId),
@@ -64,7 +64,7 @@ const WorkflowChatSidebar = () => {
6464
body={
6565
<>
6666
{workflows.map((workflowData) => {
67-
const chatUrl = `/automation/chat/${workflowData.workflowExecutionId}`;
67+
const chatUrl = `/automation/chats/${workflowData.workflowExecutionId}`;
6868
const isActive = workflowExecutionId === workflowData.workflowExecutionId;
6969

7070
return (
@@ -91,4 +91,4 @@ const WorkflowChatSidebar = () => {
9191
);
9292
};
9393

94-
export default WorkflowChatSidebar;
94+
export default ChatsSidebar;

client/src/pages/automation/workflow-chat/WorkflowChat.tsx renamed to client/src/pages/automation/chats/hooks/useChat.ts

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
import {Thread} from '@/components/assistant-ui/thread';
2-
import {WorkflowChatRuntimeProvider} from '@/pages/automation/workflow-chat/runtime-providers/WorkflowChatRuntimeProvider';
3-
import {useWorkflowChatStore} from '@/pages/automation/workflow-chat/stores/useWorkflowChatStore';
1+
import {useChatsStore} from '@/pages/automation/chats/stores/useChatsStore';
42
import {toEnvironmentName} from '@/shared/constants';
53
import {useWorkflowChatProjectDeploymentWorkflowQuery} from '@/shared/middleware/graphql';
64
import {useEnvironmentStore} from '@/shared/stores/useEnvironmentStore';
75
import {useEffect, useMemo} from 'react';
86
import {useNavigate, useParams} from 'react-router-dom';
97

10-
const WorkflowChat = () => {
8+
const useChat = () => {
119
const {workflowExecutionId} = useParams();
1210
const navigate = useNavigate();
1311

1412
const currentEnvironmentId = useEnvironmentStore((state) => state.currentEnvironmentId);
1513

1614
const environmentName = useMemo(() => toEnvironmentName(currentEnvironmentId), [currentEnvironmentId]);
1715

18-
const activeWorkflowExecutionId = useWorkflowChatStore((state) => state.activeWorkflowExecutionId);
19-
const isRunning = useWorkflowChatStore((state) => state.isRunning);
20-
const setCurrentChatName = useWorkflowChatStore((state) => state.setCurrentChatName);
21-
const switchChat = useWorkflowChatStore((state) => state.switchChat);
16+
const activeWorkflowExecutionId = useChatsStore((state) => state.activeWorkflowExecutionId);
17+
const isRunning = useChatsStore((state) => state.isRunning);
18+
const setCurrentChatName = useChatsStore((state) => state.setCurrentChatName);
19+
const switchChat = useChatsStore((state) => state.switchChat);
2220

2321
useEffect(() => {
2422
if (workflowExecutionId) {
@@ -63,19 +61,11 @@ const WorkflowChat = () => {
6361
setCurrentChatName(chatName);
6462
}, [chatName, setCurrentChatName]);
6563

66-
return (
67-
<div className="flex flex-1">
68-
<WorkflowChatRuntimeProvider
69-
environmentName={environmentName}
70-
sseStreamResponse={data?.projectDeploymentWorkflow?.projectWorkflow?.sseStreamResponse}
71-
workflowExecutionId={effectiveWorkflowExecutionId!}
72-
>
73-
<div className="relative flex size-full flex-col">
74-
<Thread />
75-
</div>
76-
</WorkflowChatRuntimeProvider>
77-
</div>
78-
);
64+
return {
65+
effectiveWorkflowExecutionId: effectiveWorkflowExecutionId!,
66+
environmentName,
67+
sseStreamResponse: data?.projectDeploymentWorkflow?.projectWorkflow?.sseStreamResponse,
68+
};
7969
};
8070

81-
export default WorkflowChat;
71+
export default useChat;

client/src/pages/automation/workflow-chat/runtime-providers/WorkflowChatRuntimeProvider.tsx renamed to client/src/pages/automation/chats/runtime-providers/ChatRuntimeProvider.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {useWorkflowChatStore} from '@/pages/automation/workflow-chat/stores/useWorkflowChatStore';
1+
import {useChatsStore} from '@/pages/automation/chats/stores/useChatsStore';
22
import {useSSE} from '@/shared/hooks/useSSE';
33
import {extractStreamChunk} from '@/shared/util/stream-utils';
44
import {
@@ -22,7 +22,7 @@ const attachmentAdapter = new CompositeAttachmentAdapter([
2222
new SimpleTextAttachmentAdapter(),
2323
]);
2424

25-
export const WorkflowChatRuntimeProvider = memo(function WorkflowChatRuntimeProvider({
25+
export const ChatRuntimeProvider = memo(function ChatRuntimeProvider({
2626
children,
2727
environmentName,
2828
sseStreamResponse,
@@ -45,7 +45,7 @@ export const WorkflowChatRuntimeProvider = memo(function WorkflowChatRuntimeProv
4545
setIsRunning,
4646
setLastAssistantMessageContent,
4747
setMessage,
48-
} = useWorkflowChatStore(
48+
} = useChatsStore(
4949
useShallow((state) => ({
5050
appendToLastAssistantMessage: state.appendToLastAssistantMessage,
5151
isRunning: state.isRunning,
@@ -115,7 +115,7 @@ export const WorkflowChatRuntimeProvider = memo(function WorkflowChatRuntimeProv
115115

116116
const formData = new FormData();
117117

118-
const conversationId = useWorkflowChatStore.getState().conversationId;
118+
const conversationId = useChatsStore.getState().conversationId;
119119

120120
formData.append('conversationId', conversationId ?? '');
121121
formData.append('message', input ?? '');

client/src/pages/automation/workflow-chat/runtime-providers/tests/WorkflowChatRuntimeProvider.test.tsx renamed to client/src/pages/automation/chats/runtime-providers/tests/ChatRuntimeProvider.test.tsx

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import {renderHook, waitFor} from '@testing-library/react';
22
import {ReactNode} from 'react';
33
import {describe, expect, it, vi} from 'vitest';
44

5-
import {WorkflowChatRuntimeProvider} from '../WorkflowChatRuntimeProvider';
5+
import {ChatRuntimeProvider} from '../ChatRuntimeProvider';
66

77
// Mock dependencies
8-
vi.mock('@/pages/automation/workflow-chat/stores/useWorkflowChatStore', () => ({
8+
vi.mock('@/pages/automation/chats/stores/useWorkflowChatStore', () => ({
99
useWorkflowChatStore: vi.fn((selector) =>
1010
selector({
1111
appendToLastAssistantMessage: vi.fn(),
@@ -35,13 +35,13 @@ vi.mock('@assistant-ui/react', () => ({
3535
useExternalStoreRuntime: vi.fn(() => ({})),
3636
}));
3737

38-
describe('WorkflowChatRuntimeProvider', () => {
38+
describe('ChatRuntimeProvider', () => {
3939
it('renders children', () => {
4040
const {result} = renderHook(() => null, {
4141
wrapper: ({children}) => (
42-
<WorkflowChatRuntimeProvider environmentName="test" workflowExecutionId="workflow-123">
42+
<ChatRuntimeProvider environmentName="test" workflowExecutionId="workflow-123">
4343
{children}
44-
</WorkflowChatRuntimeProvider>
44+
</ChatRuntimeProvider>
4545
),
4646
});
4747

@@ -51,13 +51,9 @@ describe('WorkflowChatRuntimeProvider', () => {
5151
it('accepts sseStream prop', () => {
5252
const {result} = renderHook(() => null, {
5353
wrapper: ({children}) => (
54-
<WorkflowChatRuntimeProvider
55-
environmentName="test"
56-
sseStreamResponse={true}
57-
workflowExecutionId="workflow-123"
58-
>
54+
<ChatRuntimeProvider environmentName="test" sseStreamResponse={true} workflowExecutionId="workflow-123">
5955
{children}
60-
</WorkflowChatRuntimeProvider>
56+
</ChatRuntimeProvider>
6157
),
6258
});
6359

@@ -67,9 +63,9 @@ describe('WorkflowChatRuntimeProvider', () => {
6763
it('initializes with correct environment', () => {
6864
const {result} = renderHook(() => null, {
6965
wrapper: ({children}) => (
70-
<WorkflowChatRuntimeProvider environmentName="production" workflowExecutionId="workflow-123">
66+
<ChatRuntimeProvider environmentName="production" workflowExecutionId="workflow-123">
7167
{children}
72-
</WorkflowChatRuntimeProvider>
68+
</ChatRuntimeProvider>
7369
),
7470
});
7571

@@ -79,9 +75,9 @@ describe('WorkflowChatRuntimeProvider', () => {
7975
it('handles different workflow execution IDs', () => {
8076
const {result} = renderHook(() => null, {
8177
wrapper: ({children}) => (
82-
<WorkflowChatRuntimeProvider environmentName="test" workflowExecutionId="different-workflow-456">
78+
<ChatRuntimeProvider environmentName="test" workflowExecutionId="different-workflow-456">
8379
{children}
84-
</WorkflowChatRuntimeProvider>
80+
</ChatRuntimeProvider>
8581
),
8682
});
8783

@@ -100,9 +96,9 @@ describe('WorkflowChatRuntimeProvider', () => {
10096

10197
renderHook(() => null, {
10298
wrapper: ({children}) => (
103-
<WorkflowChatRuntimeProvider environmentName="test" workflowExecutionId="workflow-123">
99+
<ChatRuntimeProvider environmentName="test" workflowExecutionId="workflow-123">
104100
{children}
105-
</WorkflowChatRuntimeProvider>
101+
</ChatRuntimeProvider>
106102
),
107103
});
108104

@@ -123,9 +119,9 @@ describe('WorkflowChatRuntimeProvider', () => {
123119

124120
renderHook(() => null, {
125121
wrapper: ({children}) => (
126-
<WorkflowChatRuntimeProvider environmentName="test" workflowExecutionId="workflow-123">
122+
<ChatRuntimeProvider environmentName="test" workflowExecutionId="workflow-123">
127123
{children}
128-
</WorkflowChatRuntimeProvider>
124+
</ChatRuntimeProvider>
129125
),
130126
});
131127

0 commit comments

Comments
 (0)