@tangle-network/ui 6.0.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,294 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react'
2
- import { ToolCallFeed, type FeedSegment } from './tool-call-feed'
3
-
4
- // -- Fixtures --
5
-
6
- const debuggingSession: FeedSegment[] = [
7
- {
8
- kind: 'text',
9
- content: "I'll investigate the failing test and fix it. Let me start by finding the relevant files.",
10
- },
11
- {
12
- kind: 'tool_group',
13
- title: 'Exploration',
14
- calls: [
15
- {
16
- id: 'tc-glob-1',
17
- type: 'glob',
18
- label: 'Find **/*.test.{ts,tsx}',
19
- status: 'success',
20
- duration: 28,
21
- output: 'src/utils/format.test.ts\nsrc/utils/tool-display.test.ts\nsrc/run/run-group.test.ts',
22
- },
23
- {
24
- id: 'tc-read-1',
25
- type: 'read',
26
- label: 'Read src/run/run-group.test.ts',
27
- status: 'success',
28
- duration: 55,
29
- detail: 'src/run/run-group.test.ts',
30
- output: "import { render } from '@testing-library/react'\nimport { RunGroup } from './run-group'\n\ndescribe('RunGroup', () => {\n it('renders tool parts', () => { ... })\n})",
31
- },
32
- {
33
- id: 'tc-read-2',
34
- type: 'read',
35
- label: 'Read src/run/run-group.tsx',
36
- status: 'success',
37
- duration: 61,
38
- detail: 'src/run/run-group.tsx',
39
- output: 'const allParts = useMemo(() => {\n const parts = []\n for (const msg of run.messages) {\n const msgParts = partMap[msg.id] ?? []\n ...',
40
- },
41
- ],
42
- },
43
- {
44
- kind: 'text',
45
- content: "I see the issue. The test is passing `undefined` for `partMap` in one of the cases, but the component always expects a `Record<string, SessionPart[]>`. Let me check the test setup.",
46
- },
47
- {
48
- kind: 'tool_call',
49
- call: {
50
- id: 'tc-grep-1',
51
- type: 'grep',
52
- label: 'Search for partMap in run-group.test.ts',
53
- status: 'success',
54
- duration: 44,
55
- output: 'src/run/run-group.test.ts:18: render(<RunGroup run={mockRun} partMap={undefined} collapsed={false} onToggle={jest.fn()} />)',
56
- },
57
- },
58
- {
59
- kind: 'text',
60
- content: "Found it — the test is passing `partMap={undefined}`. The prop type should default to `{}` rather than requiring the caller to pass a defined value. I'll add a default parameter.",
61
- },
62
- {
63
- kind: 'tool_call',
64
- call: {
65
- id: 'tc-edit-1',
66
- type: 'edit',
67
- label: 'Edit src/run/run-group.tsx',
68
- status: 'success',
69
- duration: 38,
70
- detail: 'Added partMap = {} default',
71
- },
72
- },
73
- {
74
- kind: 'tool_call',
75
- call: {
76
- id: 'tc-bash-1',
77
- type: 'bash',
78
- label: 'pnpm test --run src/run/run-group.test.ts',
79
- status: 'success',
80
- duration: 1240,
81
- output: ' ✓ src/run/run-group.test.ts (3)\n\nTest Files 1 passed (1)\n Tests 3 passed (3)\n Duration 1.24s',
82
- },
83
- },
84
- {
85
- kind: 'text',
86
- content: 'All tests pass. The fix was a one-line change: adding `partMap = {}` as a default parameter so callers that omit it (or pass `undefined`) get a safe empty map rather than a crash.',
87
- },
88
- ]
89
-
90
- const multiPhaseSession: FeedSegment[] = [
91
- {
92
- kind: 'text',
93
- content: "I'll refactor the `formatDuration` utility to support minutes, add tests, and verify the full suite still passes.",
94
- },
95
- {
96
- kind: 'tool_group',
97
- title: 'Read current implementation',
98
- calls: [
99
- {
100
- id: 'mp-read-1',
101
- type: 'read',
102
- label: 'Read src/utils/format.ts',
103
- status: 'success',
104
- duration: 42,
105
- output: "export function formatDuration(ms: number): string {\n if (ms < 1000) return `${ms}ms`\n return `${(ms / 1000).toFixed(1)}s`\n}",
106
- },
107
- {
108
- id: 'mp-read-2',
109
- type: 'read',
110
- label: 'Read src/utils/format.test.ts',
111
- status: 'success',
112
- duration: 38,
113
- output: "describe('formatDuration', () => {\n it('returns ms for sub-second values', ...)\n it('returns seconds for 1000-59999ms', ...)\n})",
114
- },
115
- ],
116
- },
117
- {
118
- kind: 'tool_group',
119
- title: 'Implement changes',
120
- calls: [
121
- {
122
- id: 'mp-write-1',
123
- type: 'write',
124
- label: 'Write src/utils/format.ts',
125
- status: 'success',
126
- duration: 51,
127
- detail: 'Added minutes branch and truncateText helper',
128
- },
129
- {
130
- id: 'mp-write-2',
131
- type: 'write',
132
- label: 'Write src/utils/format.test.ts',
133
- status: 'success',
134
- duration: 48,
135
- detail: 'Added 3 new test cases for minutes and truncation',
136
- },
137
- ],
138
- },
139
- {
140
- kind: 'tool_call',
141
- call: {
142
- id: 'mp-bash-1',
143
- type: 'bash',
144
- label: 'pnpm test --run',
145
- status: 'success',
146
- duration: 1870,
147
- output: 'Test Files 3 passed (3)\n Tests 18 passed (18)\n Duration 1.87s',
148
- },
149
- },
150
- {
151
- kind: 'text',
152
- content: 'Done. `formatDuration` now returns `"2m 14s"` for values over 60 seconds. All 18 tests pass including the 3 new cases.',
153
- },
154
- ]
155
-
156
- const streamingSession: FeedSegment[] = [
157
- {
158
- kind: 'text',
159
- content: "Let me run the full test suite and check for any issues.",
160
- },
161
- {
162
- kind: 'tool_call',
163
- call: {
164
- id: 'stream-bash-1',
165
- type: 'bash',
166
- label: 'pnpm test --run',
167
- status: 'running',
168
- },
169
- },
170
- ]
171
-
172
- const errorSession: FeedSegment[] = [
173
- {
174
- kind: 'text',
175
- content: "Attempting to build the project.",
176
- },
177
- {
178
- kind: 'tool_call',
179
- call: {
180
- id: 'err-bash-1',
181
- type: 'bash',
182
- label: 'pnpm build',
183
- status: 'error',
184
- duration: 3200,
185
- detail: 'Build failed with TypeScript errors',
186
- output: `error TS2322: Type 'string | undefined' is not assignable to type 'string'.\n src/utils/format.ts:8:5\n\nerror TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'.\n src/run/run-item-primitives.tsx:6:48\n\nFound 2 errors.`,
187
- },
188
- },
189
- {
190
- kind: 'text',
191
- content: "Two TypeScript errors. The first is in `format.ts` — I need to add a null guard before calling `.toFixed()`. The second is in `run-item-primitives.tsx` — `startTime` can be undefined per the `ToolTime` type.",
192
- },
193
- {
194
- kind: 'tool_group',
195
- title: 'Apply fixes',
196
- calls: [
197
- {
198
- id: 'err-edit-1',
199
- type: 'edit',
200
- label: 'Edit src/utils/format.ts',
201
- status: 'success',
202
- duration: 35,
203
- detail: 'Added undefined guard on ms parameter',
204
- },
205
- {
206
- id: 'err-edit-2',
207
- type: 'edit',
208
- label: 'Edit src/run/run-item-primitives.tsx',
209
- status: 'success',
210
- duration: 29,
211
- detail: 'Changed startTime prop type to number (non-optional at callsite)',
212
- },
213
- ],
214
- },
215
- {
216
- kind: 'tool_call',
217
- call: {
218
- id: 'err-bash-2',
219
- type: 'bash',
220
- label: 'pnpm build',
221
- status: 'success',
222
- duration: 4100,
223
- output: 'dist/index.js 42.3 kB\ndist/index.js.map 88.1 kB\n✓ built in 4.10s',
224
- },
225
- },
226
- {
227
- kind: 'text',
228
- content: 'Build succeeds. Both TypeScript errors resolved.',
229
- },
230
- ]
231
-
232
- // --
233
-
234
- const meta: Meta<typeof ToolCallFeed> = {
235
- title: 'Run/ToolCallFeed',
236
- component: ToolCallFeed,
237
- parameters: {
238
- layout: 'fullscreen',
239
- backgrounds: { default: 'dark' },
240
- },
241
- }
242
-
243
- export default meta
244
- type Story = StoryObj<typeof ToolCallFeed>
245
-
246
- export const DebuggingSession: Story = {
247
- name: 'Debugging a failing test',
248
- args: { segments: debuggingSession },
249
- render: (args) => (
250
- <div className="p-6 max-w-2xl">
251
- <ToolCallFeed {...args} />
252
- </div>
253
- ),
254
- }
255
-
256
- export const MultiPhaseRefactor: Story = {
257
- name: 'Multi-phase refactor',
258
- args: { segments: multiPhaseSession },
259
- render: (args) => (
260
- <div className="p-6 max-w-2xl">
261
- <ToolCallFeed {...args} />
262
- </div>
263
- ),
264
- }
265
-
266
- export const Streaming: Story = {
267
- name: 'In-progress (running)',
268
- args: { segments: streamingSession },
269
- render: (args) => (
270
- <div className="p-6 max-w-2xl">
271
- <ToolCallFeed {...args} />
272
- </div>
273
- ),
274
- }
275
-
276
- export const BuildErrorAndFix: Story = {
277
- name: 'Build error → fix → success',
278
- args: { segments: errorSession },
279
- render: (args) => (
280
- <div className="p-6 max-w-2xl">
281
- <ToolCallFeed {...args} />
282
- </div>
283
- ),
284
- }
285
-
286
- export const Empty: Story = {
287
- args: { segments: [] },
288
- render: (args) => (
289
- <div className="p-6 max-w-2xl">
290
- <ToolCallFeed {...args} />
291
- <p className="text-sm text-muted-foreground italic">(empty feed — renders nothing)</p>
292
- </div>
293
- ),
294
- }
@@ -1,198 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react'
2
- import { ToolCallStep, ToolCallGroup } from './tool-call-step'
3
-
4
- const meta: Meta<typeof ToolCallStep> = {
5
- title: 'Run/ToolCallStep',
6
- component: ToolCallStep,
7
- parameters: {
8
- layout: 'fullscreen',
9
- backgrounds: { default: 'dark' },
10
- },
11
- }
12
-
13
- export default meta
14
- type Story = StoryObj<typeof ToolCallStep>
15
-
16
- // -- Single step stories --
17
-
18
- export const BashSuccess: Story = {
19
- args: {
20
- type: 'bash',
21
- label: 'pnpm test --run --reporter=verbose',
22
- status: 'success',
23
- duration: 1420,
24
- output: `Test Files 2 passed (2)\n Tests 15 passed (15)\n Duration 1.42s`,
25
- },
26
- render: (args) => (
27
- <div className="p-6 max-w-2xl">
28
- <ToolCallStep {...args} />
29
- </div>
30
- ),
31
- }
32
-
33
- export const BashRunning: Story = {
34
- args: {
35
- type: 'bash',
36
- label: 'pnpm build',
37
- status: 'running',
38
- },
39
- render: (args) => (
40
- <div className="p-6 max-w-2xl">
41
- <ToolCallStep {...args} />
42
- </div>
43
- ),
44
- }
45
-
46
- export const BashError: Story = {
47
- args: {
48
- type: 'bash',
49
- label: 'pnpm test --run',
50
- status: 'error',
51
- duration: 890,
52
- detail: 'src/components/RunGroup.test.tsx',
53
- output: `FAIL src/components/RunGroup.test.tsx\n ● RunGroup › renders tool parts\n\n TypeError: Cannot read properties of undefined (reading 'map')\n at RunGroup (src/run/run-group.tsx:42:40)`,
54
- },
55
- render: (args) => (
56
- <div className="p-6 max-w-2xl">
57
- <ToolCallStep {...args} />
58
- </div>
59
- ),
60
- }
61
-
62
- export const ReadFile: Story = {
63
- args: {
64
- type: 'read',
65
- label: 'Read src/run/run-group.tsx',
66
- status: 'success',
67
- duration: 62,
68
- detail: '/home/user/project/src/run/run-group.tsx',
69
- output: `import { memo, useMemo } from 'react'\nexport const RunGroup = memo(({ run, partMap, ...`,
70
- },
71
- render: (args) => (
72
- <div className="p-6 max-w-2xl">
73
- <ToolCallStep {...args} />
74
- </div>
75
- ),
76
- }
77
-
78
- export const WriteFile: Story = {
79
- args: {
80
- type: 'write',
81
- label: 'Write src/utils/format.ts',
82
- status: 'success',
83
- duration: 45,
84
- detail: '/home/user/project/src/utils/format.ts',
85
- },
86
- render: (args) => (
87
- <div className="p-6 max-w-2xl">
88
- <ToolCallStep {...args} />
89
- </div>
90
- ),
91
- }
92
-
93
- export const EditFile: Story = {
94
- args: {
95
- type: 'edit',
96
- label: 'Edit src/run/run-group.tsx',
97
- status: 'success',
98
- duration: 38,
99
- detail: 'Replaced 3 lines at L42',
100
- },
101
- render: (args) => (
102
- <div className="p-6 max-w-2xl">
103
- <ToolCallStep {...args} />
104
- </div>
105
- ),
106
- }
107
-
108
- export const GlobFind: Story = {
109
- args: {
110
- type: 'glob',
111
- label: 'Find **/*.test.ts',
112
- status: 'success',
113
- duration: 28,
114
- output: `src/utils/format.test.ts\nsrc/utils/tool-display.test.ts\nsrc/run/run-group.test.ts`,
115
- },
116
- render: (args) => (
117
- <div className="p-6 max-w-2xl">
118
- <ToolCallStep {...args} />
119
- </div>
120
- ),
121
- }
122
-
123
- export const GrepSearch: Story = {
124
- args: {
125
- type: 'grep',
126
- label: 'Search for partMap\\[',
127
- status: 'success',
128
- duration: 44,
129
- output: `src/run/run-group.tsx:184: const msgParts = partMap[msg.id] ?? []\nsrc/hooks/useRunGroup.ts:44: setPartMap(prev => ({ ...prev, [msgId]: parts }))`,
130
- },
131
- render: (args) => (
132
- <div className="p-6 max-w-2xl">
133
- <ToolCallStep {...args} />
134
- </div>
135
- ),
136
- }
137
-
138
- export const NoExpandable: Story = {
139
- name: 'No detail/output (not expandable)',
140
- args: {
141
- type: 'bash',
142
- label: 'git add -p',
143
- status: 'success',
144
- duration: 120,
145
- },
146
- render: (args) => (
147
- <div className="p-6 max-w-2xl">
148
- <ToolCallStep {...args} />
149
- </div>
150
- ),
151
- }
152
-
153
- // -- Group stories --
154
-
155
- export const GroupedToolCalls: Story = {
156
- name: 'ToolCallGroup — exploration phase',
157
- render: () => (
158
- <div className="p-6 max-w-2xl">
159
- <ToolCallGroup title="Exploration">
160
- <ToolCallStep type="glob" label="Find **/*.test.ts" status="success" duration={28} output="src/utils/format.test.ts\nsrc/utils/tool-display.test.ts\nsrc/run/run-group.test.ts" />
161
- <ToolCallStep type="read" label="Read src/run/run-group.tsx" status="success" duration={62} detail="Checking for partMap access patterns" output="export const RunGroup = memo(({ run, partMap, ..." />
162
- <ToolCallStep type="grep" label="Search for partMap\[" status="success" duration={44} output="src/run/run-group.tsx:184\nsrc/hooks/useRunGroup.ts:44" />
163
- </ToolCallGroup>
164
- </div>
165
- ),
166
- }
167
-
168
- export const MixedStatuses: Story = {
169
- name: 'Mixed statuses in a group',
170
- render: () => (
171
- <div className="p-6 max-w-2xl">
172
- <ToolCallGroup title="Test cycle">
173
- <ToolCallStep type="bash" label="pnpm test --run src/utils/" status="success" duration={890} />
174
- <ToolCallStep type="edit" label="Edit src/run/run-group.tsx" status="success" duration={38} />
175
- <ToolCallStep type="bash" label="pnpm test --run" status="error" duration={740} output="FAIL src/run/run-group.test.ts\n ● 1 test failed" />
176
- <ToolCallStep type="bash" label="pnpm test --run" status="running" />
177
- </ToolCallGroup>
178
- </div>
179
- ),
180
- }
181
-
182
- export const AllTypes: Story = {
183
- render: () => (
184
- <div className="p-6 max-w-2xl space-y-2">
185
- <p className="text-xs font-mono uppercase tracking-widest text-muted-foreground px-1 pb-1">All tool types</p>
186
- <ToolCallStep type="bash" label="npm run build" status="success" duration={4200} />
187
- <ToolCallStep type="read" label="Read package.json" status="success" duration={18} />
188
- <ToolCallStep type="write" label="Write dist/index.js" status="success" duration={55} />
189
- <ToolCallStep type="edit" label="Edit tsconfig.json" status="success" duration={30} />
190
- <ToolCallStep type="glob" label="Find src/**/*.tsx" status="success" duration={22} />
191
- <ToolCallStep type="grep" label="Search for export default" status="success" duration={66} />
192
- <ToolCallStep type="list" label="List node_modules/.cache" status="success" duration={14} />
193
- <ToolCallStep type="download" label="Download schema.json" status="success" duration={380} />
194
- <ToolCallStep type="inspect" label="Inspect bundle size" status="running" />
195
- <ToolCallStep type="audit" label="Audit dependencies" status="error" duration={1100} />
196
- </div>
197
- ),
198
- }
File without changes