@swisper.ai/web-chat-ui 0.3.1 → 0.3.2
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.
- package/README.md +2 -1
- package/dist/components/chat-reasoning/chat-reasoning.d.ts +194 -0
- package/dist/components/chat-reasoning/chat-reasoning.d.ts.map +1 -0
- package/dist/components/chat-reasoning/chat-reasoning.stories.d.ts +38 -0
- package/dist/components/chat-reasoning/chat-reasoning.stories.d.ts.map +1 -0
- package/dist/components/chat-reasoning/index.d.ts +2 -0
- package/dist/components/chat-reasoning/index.d.ts.map +1 -0
- package/dist/components/chat-thinking-process/chat-thinking-process.d.ts +34 -6
- package/dist/components/chat-thinking-process/chat-thinking-process.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/docs/agent.stories.d.ts.map +1 -1
- package/dist/docs/chatbot-panel.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.es.js +1816 -1359
- package/dist/index.es.js.map +1 -1
- package/package.json +3 -3
- package/src/components/chat-message/__stories__/tool-steps.tsx +44 -23
- package/src/components/chat-reasoning/__stories__/fixtures.ts +144 -0
- package/src/components/chat-reasoning/chat-reasoning.json +241 -0
- package/src/components/chat-reasoning/chat-reasoning.stories.tsx +462 -0
- package/src/components/chat-reasoning/chat-reasoning.tsx +1042 -0
- package/src/components/chat-reasoning/index.ts +51 -0
- package/src/components/chat-thinking-process/chat-thinking-process.json +2 -0
- package/src/components/chat-thinking-process/chat-thinking-process.tsx +34 -6
- package/src/components/index.ts +1 -0
- package/src/docs/agent.stories.tsx +29 -29
- package/src/docs/chatbot-panel.tsx +48 -25
- package/src/docs/chatbot.mdx +5 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swisper.ai/web-chat-ui",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "React components for the Swisper chat: messages, composer and cards",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"@radix-ui/react-scroll-area": "^1.2.10",
|
|
64
64
|
"@radix-ui/react-slot": "^1.1.0",
|
|
65
65
|
"@shadcn/react": "^0.3.1",
|
|
66
|
-
"@swisper.ai/design-system": "0.1.
|
|
66
|
+
"@swisper.ai/design-system": "0.1.2",
|
|
67
67
|
"@swisper.ai/icons": "0.0.15",
|
|
68
|
-
"@swisper.ai/tailwind-config": "0.0.
|
|
68
|
+
"@swisper.ai/tailwind-config": "0.0.8",
|
|
69
69
|
"@swisper.ai/ui": "0.4.11",
|
|
70
70
|
"@swisper.ai/web-core": "0.0.8",
|
|
71
71
|
"@tanstack/react-virtual": "^3.14.5",
|
|
@@ -1,37 +1,58 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CheckIcon } from '@swisper.ai/icons';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
ChatReasoning,
|
|
5
|
+
ChatReasoningEnd,
|
|
6
|
+
ChatReasoningEndIcon,
|
|
7
|
+
ChatReasoningEndText,
|
|
8
|
+
ChatReasoningStep,
|
|
9
|
+
ChatReasoningStepHead,
|
|
10
|
+
ChatReasoningStepIcon,
|
|
11
|
+
ChatReasoningStepIconDot,
|
|
12
|
+
ChatReasoningSteps,
|
|
13
|
+
ChatReasoningStepText,
|
|
14
|
+
ChatReasoningTrigger,
|
|
15
|
+
ChatReasoningTriggerArrow,
|
|
16
|
+
ChatReasoningTriggerLabel,
|
|
17
|
+
ChatReasoningTriggerSymbol,
|
|
18
|
+
ChatReasoningTriggerSymbolSwisper,
|
|
19
|
+
} from '../../chat-reasoning';
|
|
12
20
|
|
|
13
21
|
export interface ToolStepsProps {
|
|
14
22
|
steps: readonly string[];
|
|
15
23
|
}
|
|
16
24
|
|
|
17
|
-
/** The collapsed
|
|
25
|
+
/** The collapsed reasoning that opens an assistant answer: what was checked, one step per tool. */
|
|
18
26
|
export function ToolSteps({ steps }: ToolStepsProps) {
|
|
19
27
|
return (
|
|
20
|
-
<
|
|
21
|
-
<
|
|
22
|
-
<
|
|
23
|
-
<
|
|
24
|
-
</
|
|
25
|
-
<
|
|
28
|
+
<ChatReasoning>
|
|
29
|
+
<ChatReasoningTrigger>
|
|
30
|
+
<ChatReasoningTriggerSymbol>
|
|
31
|
+
<ChatReasoningTriggerSymbolSwisper />
|
|
32
|
+
</ChatReasoningTriggerSymbol>
|
|
33
|
+
<ChatReasoningTriggerLabel>
|
|
26
34
|
{`Used ${steps.length} ${steps.length === 1 ? 'tool' : 'tools'}`}
|
|
27
|
-
</
|
|
28
|
-
<
|
|
29
|
-
</
|
|
30
|
-
<
|
|
35
|
+
</ChatReasoningTriggerLabel>
|
|
36
|
+
<ChatReasoningTriggerArrow />
|
|
37
|
+
</ChatReasoningTrigger>
|
|
38
|
+
<ChatReasoningSteps>
|
|
31
39
|
{steps.map((step) => (
|
|
32
|
-
<
|
|
40
|
+
<ChatReasoningStep key={step}>
|
|
41
|
+
<ChatReasoningStepHead>
|
|
42
|
+
<ChatReasoningStepIcon>
|
|
43
|
+
<ChatReasoningStepIconDot />
|
|
44
|
+
</ChatReasoningStepIcon>
|
|
45
|
+
<ChatReasoningStepText>{step}</ChatReasoningStepText>
|
|
46
|
+
</ChatReasoningStepHead>
|
|
47
|
+
</ChatReasoningStep>
|
|
33
48
|
))}
|
|
34
|
-
|
|
35
|
-
|
|
49
|
+
<ChatReasoningEnd>
|
|
50
|
+
<ChatReasoningEndIcon>
|
|
51
|
+
<CheckIcon />
|
|
52
|
+
</ChatReasoningEndIcon>
|
|
53
|
+
<ChatReasoningEndText>Done</ChatReasoningEndText>
|
|
54
|
+
</ChatReasoningEnd>
|
|
55
|
+
</ChatReasoningSteps>
|
|
56
|
+
</ChatReasoning>
|
|
36
57
|
);
|
|
37
58
|
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/** Where a step's information came from: Swisper itself, or a source with its own mark. */
|
|
2
|
+
export type ReasoningSource = 'swisper' | 'sbb' | 'postfinance' | 'web';
|
|
3
|
+
|
|
4
|
+
export interface ReasoningPage {
|
|
5
|
+
letter: string;
|
|
6
|
+
title: string;
|
|
7
|
+
domain: string;
|
|
8
|
+
href: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ReasoningStepFixture {
|
|
12
|
+
id: string;
|
|
13
|
+
/** What Swisper says it will do while the step runs. */
|
|
14
|
+
say: string;
|
|
15
|
+
/** What it did, once the step is finished. */
|
|
16
|
+
did: string;
|
|
17
|
+
source: ReasoningSource;
|
|
18
|
+
notes?: readonly string[];
|
|
19
|
+
pages?: readonly ReasoningPage[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const LUCERNE_REQUEST =
|
|
23
|
+
'Plan a weekend in Lucerne for two from Zürich next weekend: trains on Saturday morning, a hotel near the old town under CHF 250 a night, and a few things to do.';
|
|
24
|
+
|
|
25
|
+
export const LUCERNE_SUMMARY = 'Checked SBB, 23 hotels on PostFinance and 6 places · 40s';
|
|
26
|
+
|
|
27
|
+
export const LUCERNE_ANSWER =
|
|
28
|
+
'Here’s a weekend in Lucerne for the two of you, Saturday 25 and Sunday 26 July. Take the 09:10 IR 70 from Zürich HB, in Lucerne at 09:51, and leave your bags at Hotel Des Alpes, right by Chapel Bridge.';
|
|
29
|
+
|
|
30
|
+
export const LUCERNE_PAGES: readonly ReasoningPage[] = [
|
|
31
|
+
{
|
|
32
|
+
letter: 'L',
|
|
33
|
+
title: 'Lucerne: sights, opening hours and events',
|
|
34
|
+
domain: 'luzern.com',
|
|
35
|
+
href: 'https://www.luzern.com',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
letter: 'M',
|
|
39
|
+
title: 'Lucerne: things to do',
|
|
40
|
+
domain: 'myswitzerland.com',
|
|
41
|
+
href: 'https://www.myswitzerland.com',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
letter: 'R',
|
|
45
|
+
title: 'Rosengart Collection: plan your visit',
|
|
46
|
+
domain: 'rosengart.ch',
|
|
47
|
+
href: 'https://www.rosengart.ch',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
letter: 'V',
|
|
51
|
+
title: 'Swiss Museum of Transport: opening hours',
|
|
52
|
+
domain: 'verkehrshaus.ch',
|
|
53
|
+
href: 'https://www.verkehrshaus.ch',
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
export const LUCERNE_STEPS: readonly ReasoningStepFixture[] = [
|
|
58
|
+
{
|
|
59
|
+
id: 'request',
|
|
60
|
+
say: 'Reading your request',
|
|
61
|
+
did: 'You want a weekend in Lucerne for 2: trains, a hotel and things to do',
|
|
62
|
+
source: 'swisper',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 'preferences',
|
|
66
|
+
say: 'Checking your saved preferences',
|
|
67
|
+
did: 'Using your saved preferences: 2nd class, no Half Fare travelcard',
|
|
68
|
+
source: 'swisper',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'details',
|
|
72
|
+
say: 'Filling in the details',
|
|
73
|
+
did: 'Assumed these details',
|
|
74
|
+
source: 'swisper',
|
|
75
|
+
notes: ['Sat 25 – Sun 26 Jul · 2 adults, 1 double room · 1 night · Back on Sunday evening'],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: 'hotels',
|
|
79
|
+
say: 'Searching hotels near the Old Town under CHF 250',
|
|
80
|
+
did: 'Found 23 hotels in and around the Old Town',
|
|
81
|
+
source: 'postfinance',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: 'places',
|
|
85
|
+
say: 'Looking for sights and restaurants',
|
|
86
|
+
did: 'Found 12 sights and 9 restaurants',
|
|
87
|
+
source: 'swisper',
|
|
88
|
+
notes: [
|
|
89
|
+
'Sights: Chapel Bridge, the Musegg Wall and 10 more',
|
|
90
|
+
'Restaurants: 9 in the Old Town and by the river',
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: 'trains',
|
|
95
|
+
say: 'Searching trains on Sat 25 Jul between 08:00 and 11:00',
|
|
96
|
+
did: 'Found 6 direct trains, two an hour, the fastest 41 min',
|
|
97
|
+
source: 'sbb',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: 'prices',
|
|
101
|
+
say: 'Comparing ticket prices',
|
|
102
|
+
did: 'Supersaver from CHF 17.80 per person each way',
|
|
103
|
+
source: 'swisper',
|
|
104
|
+
notes: ['Cheapest pair: 09:10 out, 17:09 back, CHF 71.20 for both of you'],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: 'shortlist',
|
|
108
|
+
say: 'Checking which hotels have a double under CHF 250',
|
|
109
|
+
did: '7 hotels near the Old Town have a double under CHF 250',
|
|
110
|
+
source: 'postfinance',
|
|
111
|
+
notes: [
|
|
112
|
+
'Hotel Des Alpes, on the river: a double from CHF 141',
|
|
113
|
+
'Its river-view double with breakfast: CHF 240',
|
|
114
|
+
'2 cheaper hotels by the station, a 10-minute walk away',
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
id: 'sites',
|
|
119
|
+
say: 'Checking opening hours on 4 sites',
|
|
120
|
+
did: 'Checked 4 sites: all 6 places are open on Sat 25 and Sun 26 Jul',
|
|
121
|
+
source: 'web',
|
|
122
|
+
pages: LUCERNE_PAGES,
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: 'plan',
|
|
126
|
+
say: 'Building your plan',
|
|
127
|
+
did: 'Built your plan: 2 days, 10 stops',
|
|
128
|
+
source: 'swisper',
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: 'answer',
|
|
132
|
+
say: 'Writing your answer',
|
|
133
|
+
did: 'Wrote your answer',
|
|
134
|
+
source: 'swisper',
|
|
135
|
+
},
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
/** The steps of the "Steps running in parallel" example: two source searches live at once. */
|
|
139
|
+
export const PARALLEL_STEPS: readonly ReasoningStepFixture[] = [
|
|
140
|
+
LUCERNE_STEPS[0],
|
|
141
|
+
{ ...LUCERNE_STEPS[2], notes: undefined },
|
|
142
|
+
{ ...LUCERNE_STEPS[5], did: LUCERNE_STEPS[5].say },
|
|
143
|
+
{ ...LUCERNE_STEPS[3], did: LUCERNE_STEPS[3].say },
|
|
144
|
+
];
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../../int-eslint-config/schemas/component.schema.json",
|
|
3
|
+
"component": "chat-reasoning",
|
|
4
|
+
"purpose": "The reasoning row above an assistant answer and the window of steps it opens: a one-line row (the Swisper symbol, the current or final line, a chevron) and, open, an outlined window of steps, each with a mark (a dot or a source's logo), its text and details hanging under it as a tree, ending with how the work ended. Parts: ChatReasoningTrigger, ChatReasoningTriggerSymbol, ChatReasoningTriggerSymbolSwisper, ChatReasoningTriggerLabel, ChatReasoningTriggerArrow, ChatReasoningSteps, ChatReasoningStep, ChatReasoningStepHead, ChatReasoningStepIcon, ChatReasoningStepIconDot, ChatReasoningStepIconLogo, ChatReasoningStepIconWeb, ChatReasoningStepText, ChatReasoningStepNotes, ChatReasoningStepNote, ChatReasoningStepNotePages, ChatReasoningStepNotePageRow, ChatReasoningStepNotePageIcon, ChatReasoningStepNotePageTitle, ChatReasoningStepNotePageDomain, ChatReasoningEnd, ChatReasoningEndIcon, ChatReasoningEndText.",
|
|
5
|
+
"anatomy": [
|
|
6
|
+
"import {",
|
|
7
|
+
" ChatReasoning,",
|
|
8
|
+
" ChatReasoningTrigger,",
|
|
9
|
+
" ChatReasoningTriggerSymbol,",
|
|
10
|
+
" ChatReasoningTriggerSymbolSwisper,",
|
|
11
|
+
" ChatReasoningTriggerLabel,",
|
|
12
|
+
" ChatReasoningTriggerArrow,",
|
|
13
|
+
" ChatReasoningSteps,",
|
|
14
|
+
" ChatReasoningStep,",
|
|
15
|
+
" ChatReasoningStepHead,",
|
|
16
|
+
" ChatReasoningStepIcon,",
|
|
17
|
+
" ChatReasoningStepIconDot,",
|
|
18
|
+
" ChatReasoningStepIconWeb,",
|
|
19
|
+
" ChatReasoningStepText,",
|
|
20
|
+
" ChatReasoningStepNotes,",
|
|
21
|
+
" ChatReasoningStepNote,",
|
|
22
|
+
" ChatReasoningStepNotePages,",
|
|
23
|
+
" ChatReasoningStepNotePageRow,",
|
|
24
|
+
" ChatReasoningStepNotePageIcon,",
|
|
25
|
+
" ChatReasoningStepNotePageTitle,",
|
|
26
|
+
" ChatReasoningStepNotePageDomain,",
|
|
27
|
+
" ChatReasoningEnd,",
|
|
28
|
+
" ChatReasoningEndIcon,",
|
|
29
|
+
" ChatReasoningEndText,",
|
|
30
|
+
"} from '@swisper.ai/web-chat-ui';",
|
|
31
|
+
"",
|
|
32
|
+
"<ChatReasoning status=\"done\">",
|
|
33
|
+
" <ChatReasoningTrigger>",
|
|
34
|
+
" <ChatReasoningTriggerSymbol>",
|
|
35
|
+
" <ChatReasoningTriggerSymbolSwisper />",
|
|
36
|
+
" </ChatReasoningTriggerSymbol>",
|
|
37
|
+
" <ChatReasoningTriggerLabel />",
|
|
38
|
+
" <ChatReasoningTriggerArrow />",
|
|
39
|
+
" </ChatReasoningTrigger>",
|
|
40
|
+
" <ChatReasoningSteps>",
|
|
41
|
+
" <ChatReasoningStep>",
|
|
42
|
+
" <ChatReasoningStepHead>",
|
|
43
|
+
" <ChatReasoningStepIcon>",
|
|
44
|
+
" <ChatReasoningStepIconDot />",
|
|
45
|
+
" </ChatReasoningStepIcon>",
|
|
46
|
+
" <ChatReasoningStepText />",
|
|
47
|
+
" </ChatReasoningStepHead>",
|
|
48
|
+
" <ChatReasoningStepNotes>",
|
|
49
|
+
" <ChatReasoningStepNote />",
|
|
50
|
+
" </ChatReasoningStepNotes>",
|
|
51
|
+
" </ChatReasoningStep>",
|
|
52
|
+
" <ChatReasoningStep>",
|
|
53
|
+
" <ChatReasoningStepHead>",
|
|
54
|
+
" <ChatReasoningStepIcon>",
|
|
55
|
+
" <ChatReasoningStepIconWeb />",
|
|
56
|
+
" </ChatReasoningStepIcon>",
|
|
57
|
+
" <ChatReasoningStepText />",
|
|
58
|
+
" </ChatReasoningStepHead>",
|
|
59
|
+
" <ChatReasoningStepNotes>",
|
|
60
|
+
" <ChatReasoningStepNotePages>",
|
|
61
|
+
" <ChatReasoningStepNotePageRow asChild>",
|
|
62
|
+
" <a>",
|
|
63
|
+
" <ChatReasoningStepNotePageIcon />",
|
|
64
|
+
" <ChatReasoningStepNotePageTitle />",
|
|
65
|
+
" <ChatReasoningStepNotePageDomain />",
|
|
66
|
+
" </a>",
|
|
67
|
+
" </ChatReasoningStepNotePageRow>",
|
|
68
|
+
" </ChatReasoningStepNotePages>",
|
|
69
|
+
" </ChatReasoningStepNotes>",
|
|
70
|
+
" </ChatReasoningStep>",
|
|
71
|
+
" <ChatReasoningEnd>",
|
|
72
|
+
" <ChatReasoningEndIcon />",
|
|
73
|
+
" <ChatReasoningEndText />",
|
|
74
|
+
" </ChatReasoningEnd>",
|
|
75
|
+
" </ChatReasoningSteps>",
|
|
76
|
+
"</ChatReasoning>"
|
|
77
|
+
],
|
|
78
|
+
"useWhen": [
|
|
79
|
+
"An assistant answer is preceded by steps Swisper took (reading the request, searching sources, reading pages) that the person may want to check",
|
|
80
|
+
"Showing live progress from the first step until the answer starts",
|
|
81
|
+
"Keeping what was checked, and how long it took, one click away once the answer is shown"
|
|
82
|
+
],
|
|
83
|
+
"avoidWhen": [
|
|
84
|
+
"A plain wait with no steps to show — use ui/spinner",
|
|
85
|
+
"Collapsible content that is not the assistant's work (settings, FAQs, details) — use ui/collapsible",
|
|
86
|
+
"The sources under the answer — that is a separate sources row, not this window",
|
|
87
|
+
"The answer itself — render it with web-chat-ui/markdown-viewer in the message content"
|
|
88
|
+
],
|
|
89
|
+
"uxPrinciples": [
|
|
90
|
+
"The answer is the point: the row is one line, and the window opens only while Swisper works through more than one step.",
|
|
91
|
+
"The row reports state: the current step while running, 'Working on your request' while the window is open, what was checked and how long it took once done.",
|
|
92
|
+
"Every step names its source: a dot for Swisper's own steps, the source's logo (SBB, PostFinance, web search) for the others."
|
|
93
|
+
],
|
|
94
|
+
"accessibility": {
|
|
95
|
+
"required": [
|
|
96
|
+
"ChatReasoningTriggerLabel must contain text: it is the row button's accessible name",
|
|
97
|
+
"A logo in ChatReasoningStepIconLogo or ChatReasoningStepIconWeb needs a name screen readers hear before the step's text ('SBB: ', 'Web search: '), e.g. a VisuallyHidden span in ChatReasoningStepIcon",
|
|
98
|
+
"Change the label to the done line once the work ends; the symbol and the sweep alone do not tell assistive tech the state changed",
|
|
99
|
+
"Each page row passed through asChild must be a real link with an href"
|
|
100
|
+
],
|
|
101
|
+
"keyboard": [
|
|
102
|
+
"Tab focuses the row button, then each page row link inside the open window",
|
|
103
|
+
"Enter or Space opens and closes the window"
|
|
104
|
+
],
|
|
105
|
+
"aria": [
|
|
106
|
+
"The row is a Radix Collapsible trigger: a <button> with aria-expanded and aria-controls pointing at the window",
|
|
107
|
+
"ChatReasoningTriggerLabel is aria-live=polite, so a new line is announced; the line leaving is aria-hidden while it slides out",
|
|
108
|
+
"ChatReasoningTriggerSymbol, ChatReasoningTriggerArrow, ChatReasoningStepIconDot, ChatReasoningEndIcon and the tree lines are aria-hidden"
|
|
109
|
+
],
|
|
110
|
+
"focus": [
|
|
111
|
+
"One tab stop for the row; focus stays on it when it toggles",
|
|
112
|
+
"Page rows show the 2px focus outline and brighten their domain on keyboard focus"
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
"behaviour": {
|
|
116
|
+
"states": [
|
|
117
|
+
"running, closed (the current step's line, with a light sweep)",
|
|
118
|
+
"running, open ('Working on your request'; the live steps sweep)",
|
|
119
|
+
"done, closed",
|
|
120
|
+
"done, open",
|
|
121
|
+
"stopped, closed",
|
|
122
|
+
"stopped, open"
|
|
123
|
+
],
|
|
124
|
+
"rules": [
|
|
125
|
+
"status is running, done or stopped (default done); the root exposes it as data-status, and data-state (open / closed) from the collapsible",
|
|
126
|
+
"Uncontrolled and closed on first render (defaultOpen=false); pass open with onOpenChange to open the window with the second step and close it when the answer starts. The component does not count steps itself",
|
|
127
|
+
"Open, the root draws a 1px outline box with a 12px radius and the row becomes its top (square bottom corners)",
|
|
128
|
+
"The root is a container: under 448px wide the row grows from 36px to 44px",
|
|
129
|
+
"ChatReasoningTriggerLabel holds each line at least 1s while running before the next replaces it; once not running it replaces at once. The old line slides up and fades out while the new one comes in from below (280ms). A string child animates on its text; pass contentKey for any other node",
|
|
130
|
+
"While running and closed the label gets a light sweep (2.2s loop); while open the live steps get it instead",
|
|
131
|
+
"ChatReasoningTriggerSymbolSwisper turns its symbol 90° per 1.1s cycle while running; with reduced motion the shield's opacity pulses instead",
|
|
132
|
+
"ChatReasoningSteps opens and closes with a 260ms height animation; rows added while running grow and fade in (240ms); rows already there show at once",
|
|
133
|
+
"ChatReasoningStep isLive: the dot grows to 6px and pulses, a logo sits on a 20px tile that pulses, the web icon brightens, and the text sweeps. Several steps can be live at once",
|
|
134
|
+
"ChatReasoningStepText fades (350ms) when its text changes, e.g. from what Swisper will do to what it did",
|
|
135
|
+
"ChatReasoningStepNotes draws the tree from the order of its children: a trunk from under the mark, a tick per row and a bend into the last one; ChatReasoningStepNotePages points at its first page row",
|
|
136
|
+
"ChatReasoningStepNotePageRow renders a plain row; asChild merges it onto your link so the whole row is the link",
|
|
137
|
+
"ChatReasoningEnd renders whatever icon and text it is given; render it only once the work is done or stopped",
|
|
138
|
+
"Every motion has a prefers-reduced-motion fallback: lines and rows swap at once, no sweep and no pulse",
|
|
139
|
+
"Every part takes a className, merged last, and sets a data-slot: chat-reasoning, -trigger, -trigger-symbol-wrapper, -trigger-symbol, -trigger-symbol-swisper, -trigger-label, -trigger-label-line, -trigger-arrow, -steps, -step, -step-head, -step-icon-wrapper, -step-icon, -step-icon-dot, -step-icon-logo, -step-icon-web, -step-text, -step-text-content, -step-notes, -step-note, -step-note-pages, -step-note-page-row, -step-note-page-icon, -step-note-page-title, -step-note-page-domain, -end, -end-icon, -end-text"
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
"composition": {
|
|
143
|
+
"allowedParents": ["web-chat-ui/ChatMessage"],
|
|
144
|
+
"allowedChildren": [
|
|
145
|
+
"web-chat-ui/ChatReasoningTrigger",
|
|
146
|
+
"web-chat-ui/ChatReasoningTriggerSymbol",
|
|
147
|
+
"web-chat-ui/ChatReasoningTriggerSymbolSwisper",
|
|
148
|
+
"web-chat-ui/ChatReasoningTriggerLabel",
|
|
149
|
+
"web-chat-ui/ChatReasoningTriggerArrow",
|
|
150
|
+
"web-chat-ui/ChatReasoningSteps",
|
|
151
|
+
"web-chat-ui/ChatReasoningStep",
|
|
152
|
+
"web-chat-ui/ChatReasoningStepHead",
|
|
153
|
+
"web-chat-ui/ChatReasoningStepIcon",
|
|
154
|
+
"web-chat-ui/ChatReasoningStepIconDot",
|
|
155
|
+
"web-chat-ui/ChatReasoningStepIconLogo",
|
|
156
|
+
"web-chat-ui/ChatReasoningStepIconWeb",
|
|
157
|
+
"web-chat-ui/ChatReasoningStepText",
|
|
158
|
+
"web-chat-ui/ChatReasoningStepNotes",
|
|
159
|
+
"web-chat-ui/ChatReasoningStepNote",
|
|
160
|
+
"web-chat-ui/ChatReasoningStepNotePages",
|
|
161
|
+
"web-chat-ui/ChatReasoningStepNotePageRow",
|
|
162
|
+
"web-chat-ui/ChatReasoningStepNotePageIcon",
|
|
163
|
+
"web-chat-ui/ChatReasoningStepNotePageTitle",
|
|
164
|
+
"web-chat-ui/ChatReasoningStepNotePageDomain",
|
|
165
|
+
"web-chat-ui/ChatReasoningEnd",
|
|
166
|
+
"web-chat-ui/ChatReasoningEndIcon",
|
|
167
|
+
"web-chat-ui/ChatReasoningEndText",
|
|
168
|
+
"StopIcon (in ChatReasoningTriggerSymbol once stopped)",
|
|
169
|
+
"source logo or icon (in ChatReasoningStepIconLogo / ChatReasoningStepIconWeb)",
|
|
170
|
+
"favicon image or letter (in ChatReasoningStepNotePageIcon)",
|
|
171
|
+
"link (the child of ChatReasoningStepNotePageRow with asChild)",
|
|
172
|
+
"CheckIcon or StopIcon (in ChatReasoningEndIcon)",
|
|
173
|
+
"text"
|
|
174
|
+
],
|
|
175
|
+
"avoidCombinations": [
|
|
176
|
+
"Placing it after the answer content — it belongs above web-chat-ui/ChatMessageContent in the assistant's message",
|
|
177
|
+
"ChatReasoningEnd before the last step, or while running",
|
|
178
|
+
"Interactive controls inside steps other than page row links — the steps are a read-only log"
|
|
179
|
+
],
|
|
180
|
+
"contexts": ["assistant message in a chat thread"]
|
|
181
|
+
},
|
|
182
|
+
"content": {
|
|
183
|
+
"labelRules": [
|
|
184
|
+
"Running and closed: the current step's line ('Searching trains on Sat 25 Jul between 08:00 and 11:00')",
|
|
185
|
+
"Running and open: 'Working on your request'",
|
|
186
|
+
"Done: what was checked and how long it took ('Checked SBB, 23 hotels on PostFinance and 6 places · 40s')",
|
|
187
|
+
"Stopped: 'Stopped after {N}s'"
|
|
188
|
+
],
|
|
189
|
+
"helperTextRules": [
|
|
190
|
+
"Step text: what Swisper will do while live ('Searching trains…'), what it did once finished ('Found 6 direct trains, two an hour')",
|
|
191
|
+
"Notes: one detail each, short ('Hotel Des Alpes, on the river: a double from CHF 141')",
|
|
192
|
+
"End row: 'Done in {N} s' or 'Stopped'"
|
|
193
|
+
],
|
|
194
|
+
"errorRules": []
|
|
195
|
+
},
|
|
196
|
+
"tokenReferences": {
|
|
197
|
+
"source": "packages/design-system/src/tokens.json (ct-chatbot/base → ct.reasoning)",
|
|
198
|
+
"categories": [
|
|
199
|
+
"color-reasoning-row-*",
|
|
200
|
+
"color-reasoning-window-*",
|
|
201
|
+
"color-reasoning-mark-*",
|
|
202
|
+
"color-reasoning-tree-*",
|
|
203
|
+
"color-reasoning-step-*",
|
|
204
|
+
"color-reasoning-note-*",
|
|
205
|
+
"color-reasoning-page-row-*",
|
|
206
|
+
"color-reasoning-source-*",
|
|
207
|
+
"color-reasoning-end-row-*",
|
|
208
|
+
"spacing-reasoning-*",
|
|
209
|
+
"radius-reasoning-*"
|
|
210
|
+
],
|
|
211
|
+
"rule": "Restyle through these tokens; the sweep and pulses read the --ct-reasoning-* variables directly."
|
|
212
|
+
},
|
|
213
|
+
"aiDecisionRules": [
|
|
214
|
+
{
|
|
215
|
+
"condition": "Swisper has started its first step",
|
|
216
|
+
"decision": "Render ChatReasoning with status=\"running\", closed, the step's line as the label",
|
|
217
|
+
"reason": "The row shows from the first step; no typing dots"
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"condition": "The second step starts",
|
|
221
|
+
"decision": "Open it (open={true}) and set the label to 'Working on your request'; mark the current steps isLive",
|
|
222
|
+
"reason": "The window opens with the second step, so a one-step answer never opens it"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"condition": "The answer starts streaming",
|
|
226
|
+
"decision": "Close it, set status=\"done\", change the label to the done line and add ChatReasoningEnd",
|
|
227
|
+
"reason": "The answer is the point, and the label is the only state cue screen readers get"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"condition": "The person stopped the answer",
|
|
231
|
+
"decision": "Set status=\"stopped\", put a StopIcon in ChatReasoningTriggerSymbol and end with 'Stopped'",
|
|
232
|
+
"reason": "The square tells the work did not finish"
|
|
233
|
+
}
|
|
234
|
+
],
|
|
235
|
+
"relatedComponents": [
|
|
236
|
+
"ui/collapsible",
|
|
237
|
+
"web-chat-ui/chat-message",
|
|
238
|
+
"web-chat-ui/markdown-viewer",
|
|
239
|
+
"web-chat-ui/chat-thinking-process"
|
|
240
|
+
]
|
|
241
|
+
}
|