Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aafef5a

Browse files
committed
Add more tools
1 parent 5a879a9 commit aafef5a

File tree

2 files changed

+210
-103
lines changed

2 files changed

+210
-103
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { Meta, StoryObj } from "@storybook/react";
22
import { ChatToolInvocation } from "./ChatToolInvocation";
3-
import { MockWorkspace } from "testHelpers/entities";
3+
import {
4+
MockStartingWorkspace,
5+
MockStoppedWorkspace,
6+
MockStoppingWorkspace,
7+
MockWorkspace,
8+
} from "testHelpers/entities";
49

510
const meta: Meta<typeof ChatToolInvocation> = {
611
title: "pages/ChatPage/ChatToolInvocation",
@@ -11,32 +16,93 @@ export default meta;
1116
type Story = StoryObj<typeof ChatToolInvocation>;
1217

1318
export const GetWorkspace: Story = {
14-
args: {
15-
toolInvocation: {
16-
toolName: "coder_get_workspace",
17-
args: {
19+
render: () =>
20+
renderInvocations(
21+
"coder_get_workspace",
22+
{
1823
id: MockWorkspace.id,
1924
},
20-
result: MockWorkspace,
21-
state: "result",
22-
toolCallId: "some-id",
23-
},
24-
},
25+
MockWorkspace,
26+
),
2527
};
2628

2729
export const CreateWorkspace: Story = {
28-
args: {
29-
toolInvocation: {
30-
toolName: "coder_create_workspace",
31-
args: {
30+
render: () =>
31+
renderInvocations(
32+
"coder_create_workspace",
33+
{
3234
name: MockWorkspace.name,
3335
rich_parameters: {},
3436
template_version_id: MockWorkspace.template_active_version_id,
3537
user: MockWorkspace.owner_name,
3638
},
37-
result: MockWorkspace,
38-
state: "result",
39-
toolCallId: "some-id",
40-
},
41-
},
39+
MockWorkspace,
40+
),
41+
};
42+
43+
export const ListWorkspaces: Story = {
44+
render: () =>
45+
renderInvocations(
46+
"coder_list_workspaces",
47+
{
48+
owner: "me",
49+
},
50+
[
51+
MockWorkspace,
52+
MockStoppedWorkspace,
53+
MockStoppingWorkspace,
54+
MockStartingWorkspace,
55+
],
56+
),
57+
};
58+
59+
const renderInvocations = <T extends ChatToolInvocation["toolName"]>(
60+
toolName: T,
61+
args: Extract<ChatToolInvocation, { toolName: T }>["args"],
62+
result: Extract<
63+
ChatToolInvocation,
64+
{ toolName: T; state: "result" }
65+
>["result"],
66+
error?: string,
67+
) => {
68+
return (
69+
<>
70+
<ChatToolInvocation
71+
toolInvocation={{
72+
toolCallId: "call",
73+
toolName,
74+
args: args as any,
75+
state: "call",
76+
}}
77+
/>
78+
<ChatToolInvocation
79+
toolInvocation={{
80+
toolCallId: "partial-call",
81+
toolName,
82+
args: args as any,
83+
state: "partial-call",
84+
}}
85+
/>
86+
<ChatToolInvocation
87+
toolInvocation={{
88+
toolCallId: "result",
89+
toolName,
90+
args: args as any,
91+
state: "result",
92+
result: result as any,
93+
}}
94+
/>
95+
<ChatToolInvocation
96+
toolInvocation={{
97+
toolCallId: "result",
98+
toolName,
99+
args: args as any,
100+
state: "result",
101+
result: {
102+
error: error || "Something bad happened!",
103+
},
104+
}}
105+
/>
106+
</>
107+
);
42108
};

0 commit comments

Comments
 (0)