forked from OtterMind/youclaw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat-timeline.test.ts
More file actions
71 lines (66 loc) · 1.76 KB
/
Copy pathchat-timeline.test.ts
File metadata and controls
71 lines (66 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { describe, expect, test } from 'bun:test'
import { buildRenderableTimeline } from '../web/src/components/chat/timeline.ts'
import type { TimelineItem } from '../web/src/hooks/useChat.ts'
describe('chat timeline rendering', () => {
test('groups consecutive tool items and preserves surrounding order', () => {
const items: TimelineItem[] = [
{
id: 'm1',
kind: 'message',
role: 'user',
content: 'hello',
timestamp: '2026-03-19T10:00:00.000Z',
},
{
id: 't1',
kind: 'tool_use',
name: 'Read',
input: '{"file_path":"a.txt"}',
status: 'done',
timestamp: '2026-03-19T10:00:01.000Z',
},
{
id: 't2',
kind: 'tool_use',
name: 'Grep',
input: '{"pattern":"foo"}',
status: 'done',
timestamp: '2026-03-19T10:00:02.000Z',
},
{
id: 's1',
kind: 'assistant_stream',
content: 'working...',
timestamp: '2026-03-19T10:00:03.000Z',
},
{
id: 't3',
kind: 'tool_use',
name: 'Bash',
input: '{"command":"echo ok"}',
status: 'running',
timestamp: '2026-03-19T10:00:04.000Z',
},
]
const renderable = buildRenderableTimeline(items)
expect(renderable.map((item) => item.kind)).toEqual([
'message',
'tool_use_group',
'assistant_stream',
'tool_use_group',
])
expect(renderable[1]).toMatchObject({
kind: 'tool_use_group',
items: [
{ name: 'Read', status: 'done' },
{ name: 'Grep', status: 'done' },
],
})
expect(renderable[3]).toMatchObject({
kind: 'tool_use_group',
items: [
{ name: 'Bash', status: 'running' },
],
})
})
})