@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.
Files changed (29) hide show
  1. package/README.md +2 -1
  2. package/dist/components/chat-reasoning/chat-reasoning.d.ts +194 -0
  3. package/dist/components/chat-reasoning/chat-reasoning.d.ts.map +1 -0
  4. package/dist/components/chat-reasoning/chat-reasoning.stories.d.ts +38 -0
  5. package/dist/components/chat-reasoning/chat-reasoning.stories.d.ts.map +1 -0
  6. package/dist/components/chat-reasoning/index.d.ts +2 -0
  7. package/dist/components/chat-reasoning/index.d.ts.map +1 -0
  8. package/dist/components/chat-thinking-process/chat-thinking-process.d.ts +34 -6
  9. package/dist/components/chat-thinking-process/chat-thinking-process.d.ts.map +1 -1
  10. package/dist/components/index.d.ts +1 -0
  11. package/dist/components/index.d.ts.map +1 -1
  12. package/dist/docs/agent.stories.d.ts.map +1 -1
  13. package/dist/docs/chatbot-panel.d.ts.map +1 -1
  14. package/dist/index.css +1 -1
  15. package/dist/index.es.js +1816 -1359
  16. package/dist/index.es.js.map +1 -1
  17. package/package.json +3 -3
  18. package/src/components/chat-message/__stories__/tool-steps.tsx +44 -23
  19. package/src/components/chat-reasoning/__stories__/fixtures.ts +144 -0
  20. package/src/components/chat-reasoning/chat-reasoning.json +241 -0
  21. package/src/components/chat-reasoning/chat-reasoning.stories.tsx +462 -0
  22. package/src/components/chat-reasoning/chat-reasoning.tsx +1042 -0
  23. package/src/components/chat-reasoning/index.ts +51 -0
  24. package/src/components/chat-thinking-process/chat-thinking-process.json +2 -0
  25. package/src/components/chat-thinking-process/chat-thinking-process.tsx +34 -6
  26. package/src/components/index.ts +1 -0
  27. package/src/docs/agent.stories.tsx +29 -29
  28. package/src/docs/chatbot-panel.tsx +48 -25
  29. package/src/docs/chatbot.mdx +5 -5
@@ -0,0 +1,51 @@
1
+ export {
2
+ ChatReasoning,
3
+ ChatReasoningTrigger,
4
+ ChatReasoningTriggerSymbol,
5
+ ChatReasoningTriggerSymbolSwisper,
6
+ ChatReasoningTriggerLabel,
7
+ ChatReasoningTriggerArrow,
8
+ ChatReasoningSteps,
9
+ ChatReasoningStep,
10
+ ChatReasoningStepHead,
11
+ ChatReasoningStepIcon,
12
+ ChatReasoningStepIconDot,
13
+ ChatReasoningStepIconLogo,
14
+ ChatReasoningStepIconWeb,
15
+ ChatReasoningStepText,
16
+ ChatReasoningStepNotes,
17
+ ChatReasoningStepNote,
18
+ ChatReasoningStepNotePages,
19
+ ChatReasoningStepNotePageRow,
20
+ ChatReasoningStepNotePageIcon,
21
+ ChatReasoningStepNotePageTitle,
22
+ ChatReasoningStepNotePageDomain,
23
+ ChatReasoningEnd,
24
+ ChatReasoningEndIcon,
25
+ ChatReasoningEndText,
26
+ type ChatReasoningStatus,
27
+ type ChatReasoningProps,
28
+ type ChatReasoningTriggerProps,
29
+ type ChatReasoningTriggerSymbolProps,
30
+ type ChatReasoningTriggerSymbolSwisperProps,
31
+ type ChatReasoningTriggerLabelProps,
32
+ type ChatReasoningTriggerArrowProps,
33
+ type ChatReasoningStepsProps,
34
+ type ChatReasoningStepProps,
35
+ type ChatReasoningStepHeadProps,
36
+ type ChatReasoningStepIconProps,
37
+ type ChatReasoningStepIconDotProps,
38
+ type ChatReasoningStepIconLogoProps,
39
+ type ChatReasoningStepIconWebProps,
40
+ type ChatReasoningStepTextProps,
41
+ type ChatReasoningStepNotesProps,
42
+ type ChatReasoningStepNoteProps,
43
+ type ChatReasoningStepNotePagesProps,
44
+ type ChatReasoningStepNotePageRowProps,
45
+ type ChatReasoningStepNotePageIconProps,
46
+ type ChatReasoningStepNotePageTitleProps,
47
+ type ChatReasoningStepNotePageDomainProps,
48
+ type ChatReasoningEndProps,
49
+ type ChatReasoningEndIconProps,
50
+ type ChatReasoningEndTextProps,
51
+ } from './chat-reasoning';
@@ -33,6 +33,7 @@
33
33
  "Keeping the steps available but out of the way once the answer is shown"
34
34
  ],
35
35
  "avoidWhen": [
36
+ "Deprecated — use web-chat-ui/chat-reasoning for new code; ChatThinkingProcess stays only so existing imports keep compiling",
36
37
  "A plain wait with no steps to show — use ui/spinner",
37
38
  "Collapsible content that is not the assistant's process (settings, FAQs, details) — use ui/collapsible",
38
39
  "The answer itself — render it with web-chat-ui/markdown-viewer in the message content"
@@ -133,6 +134,7 @@
133
134
  }
134
135
  ],
135
136
  "relatedComponents": [
137
+ "web-chat-ui/chat-reasoning",
136
138
  "ui/collapsible",
137
139
  "web-chat-ui/chat-message",
138
140
  "web-chat-ui/markdown-viewer",
@@ -21,6 +21,8 @@ export interface ChatThinkingProcessProps extends Omit<CollapsibleProps, 'isDisa
21
21
  /**
22
22
  * Collapsible disclosure of the assistant's reasoning or tool steps. Collapsed by default; exposes
23
23
  * `data-state` (`open` / `closed`) and `data-streaming` for its parts to style from.
24
+ *
25
+ * @deprecated Use `ChatReasoning` (chat-reasoning), with `status` in place of `isStreaming`.
24
26
  */
25
27
  export const ChatThinkingProcess = forwardRef<HTMLDivElement, ChatThinkingProcessProps>(
26
28
  function ChatThinkingProcess(
@@ -51,7 +53,11 @@ export interface ChatThinkingProcessTriggerProps extends ComponentProps<'button'
51
53
  isLoading?: boolean;
52
54
  }
53
55
 
54
- /** The button that expands and collapses the steps; holds the icon, the label and the arrow. */
56
+ /**
57
+ * The button that expands and collapses the steps; holds the icon, the label and the arrow.
58
+ *
59
+ * @deprecated Use `ChatReasoningTrigger`.
60
+ */
55
61
  export function ChatThinkingProcessTrigger({
56
62
  children,
57
63
  className,
@@ -84,7 +90,11 @@ export interface ChatThinkingProcessTriggerIconProps extends ComponentProps<'spa
84
90
  className?: string;
85
91
  }
86
92
 
87
- /** The icon before the label: what kind of work the process is. */
93
+ /**
94
+ * The icon before the label: what kind of work the process is.
95
+ *
96
+ * @deprecated Use `ChatReasoningTriggerSymbol`, with `ChatReasoningTriggerSymbolSwisper` inside.
97
+ */
88
98
  export function ChatThinkingProcessTriggerIcon({
89
99
  children,
90
100
  className,
@@ -112,7 +122,11 @@ export interface ChatThinkingProcessTriggerLabelProps extends ComponentProps<'sp
112
122
  className?: string;
113
123
  }
114
124
 
115
- /** The trigger's text and accessible name; shimmers while the root is streaming. */
125
+ /**
126
+ * The trigger's text and accessible name; shimmers while the root is streaming.
127
+ *
128
+ * @deprecated Use `ChatReasoningTriggerLabel`.
129
+ */
116
130
  export function ChatThinkingProcessTriggerLabel({
117
131
  children,
118
132
  className,
@@ -142,7 +156,11 @@ export interface ChatThinkingProcessTriggerArrowProps extends ComponentProps<'sp
142
156
  className?: string;
143
157
  }
144
158
 
145
- /** The chevron after the label; points up while the steps are expanded. Hidden from assistive tech. */
159
+ /**
160
+ * The chevron after the label; points up while the steps are expanded. Hidden from assistive tech.
161
+ *
162
+ * @deprecated Use `ChatReasoningTriggerArrow`.
163
+ */
146
164
  export function ChatThinkingProcessTriggerArrow({
147
165
  className,
148
166
  ...rest
@@ -176,6 +194,8 @@ export interface ChatThinkingProcessContentProps extends ComponentProps<'div'> {
176
194
  /**
177
195
  * The steps, listed under the label once expanded. The last one is previewed while the root is
178
196
  * streaming and collapsed.
197
+ *
198
+ * @deprecated Use `ChatReasoningSteps`.
179
199
  */
180
200
  export function ChatThinkingProcessContent({
181
201
  children,
@@ -257,7 +277,11 @@ export interface ChatThinkingProcessContentItemProps extends ComponentProps<'div
257
277
  className?: string;
258
278
  }
259
279
 
260
- /** One step of the process: text, or any node such as streamed Markdown, after an optional icon. */
280
+ /**
281
+ * One step of the process: text, or any node such as streamed Markdown, after an optional icon.
282
+ *
283
+ * @deprecated Use `ChatReasoningStep` with a `ChatReasoningStepHead` and a `ChatReasoningStepText`.
284
+ */
261
285
  export function ChatThinkingProcessContentItem({
262
286
  children,
263
287
  className,
@@ -281,7 +305,11 @@ export interface ChatThinkingProcessContentItemIconProps extends ComponentProps<
281
305
  className?: string;
282
306
  }
283
307
 
284
- /** The logo or icon before a step's text: which tool the step used. The height is fixed; a logo's width follows its image. */
308
+ /**
309
+ * The logo or icon before a step's text: which tool the step used. The height is fixed; a logo's width follows its image.
310
+ *
311
+ * @deprecated Use `ChatReasoningStepIcon` with a `ChatReasoningStepIconDot`, `-Logo` or `-Web` inside.
312
+ */
285
313
  export function ChatThinkingProcessContentItemIcon({
286
314
  children,
287
315
  className,
@@ -17,6 +17,7 @@ export * from './chat-thread';
17
17
  export * from './chat-artifact';
18
18
  export * from './canvas-shell';
19
19
  export * from './new-chat-trigger';
20
+ export * from './chat-reasoning';
20
21
  export * from './chat-thinking-process';
21
22
  export * from './deprecated-empty-state';
22
23
  export * from './markdown-viewer';
@@ -5,7 +5,7 @@ import { expect, waitFor, within } from 'storybook/test';
5
5
  import {
6
6
  CopyIcon,
7
7
  DatabaseSearchIcon,
8
- ErrorIcon,
8
+ StopIcon,
9
9
  TableIcon,
10
10
  ThumbsDownIcon,
11
11
  ThumbsUpIcon,
@@ -22,14 +22,15 @@ import {
22
22
  ChatMessageToolbarTimestamp,
23
23
  } from '../components/chat-message-toolbar';
24
24
  import {
25
- ChatThinkingProcess,
26
- ChatThinkingProcessContent,
27
- ChatThinkingProcessContentItem,
28
- ChatThinkingProcessTrigger,
29
- ChatThinkingProcessTriggerArrow,
30
- ChatThinkingProcessTriggerIcon,
31
- ChatThinkingProcessTriggerLabel,
32
- } from '../components/chat-thinking-process';
25
+ ChatReasoning,
26
+ ChatReasoningStep,
27
+ ChatReasoningSteps,
28
+ ChatReasoningStepText,
29
+ ChatReasoningTrigger,
30
+ ChatReasoningTriggerArrow,
31
+ ChatReasoningTriggerLabel,
32
+ ChatReasoningTriggerSymbol,
33
+ } from '../components/chat-reasoning';
33
34
  import {
34
35
  ChatThread,
35
36
  ChatThreadAnswer,
@@ -475,34 +476,33 @@ function AgentToolCall({ step, isRunning }: AgentToolCallProps) {
475
476
  const isStopped = step.status === 'stopped';
476
477
 
477
478
  return (
478
- <ChatThinkingProcess
479
- isStreaming={isRunning}
479
+ <ChatReasoning
480
+ status={isRunning ? 'running' : isStopped ? 'stopped' : 'done'}
480
481
  open={isRunning || isExpanded}
481
482
  onOpenChange={setIsExpanded}
482
483
  >
483
- <ChatThinkingProcessTrigger>
484
- <ChatThinkingProcessTriggerIcon className="text-text-secondary">
485
- {isStopped ? <ErrorIcon /> : step.icon}
486
- </ChatThinkingProcessTriggerIcon>
487
- <ChatThinkingProcessTriggerLabel className="min-w-0 truncate">
484
+ <ChatReasoningTrigger>
485
+ <ChatReasoningTriggerSymbol>
486
+ {isStopped ? <StopIcon /> : step.icon}
487
+ </ChatReasoningTriggerSymbol>
488
+ <ChatReasoningTriggerLabel>
488
489
  <span className="font-ibm-plex-mono">{step.name}</span>
489
490
  {' · '}
490
491
  {isRunning ? 'Running…' : isStopped ? 'Stopped' : step.summary}
491
- </ChatThinkingProcessTriggerLabel>
492
- <ChatThinkingProcessTriggerArrow />
493
- </ChatThinkingProcessTrigger>
494
-
495
- <ChatThinkingProcessContent
496
- hasLastMessagePreview={false}
497
- itemsClassName="font-ibm-plex-mono whitespace-pre-wrap"
498
- >
492
+ </ChatReasoningTriggerLabel>
493
+ <ChatReasoningTriggerArrow />
494
+ </ChatReasoningTrigger>
495
+
496
+ <ChatReasoningSteps>
499
497
  {step.lines.map((line, index) => (
500
- <ChatThinkingProcessContentItem key={index} className="text-xs not-italic">
501
- {line}
502
- </ChatThinkingProcessContentItem>
498
+ <ChatReasoningStep key={index}>
499
+ <ChatReasoningStepText className="pl-reasoning-row-spacing-padding-horizontal-base font-ibm-plex-mono text-xs whitespace-pre-wrap">
500
+ {line}
501
+ </ChatReasoningStepText>
502
+ </ChatReasoningStep>
503
503
  ))}
504
- </ChatThinkingProcessContent>
505
- </ChatThinkingProcess>
504
+ </ChatReasoningSteps>
505
+ </ChatReasoning>
506
506
  );
507
507
  }
508
508
 
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useRef, useState } from 'react';
2
2
 
3
3
  import {
4
- BrainIcon,
4
+ CheckIcon,
5
5
  CopyIcon,
6
6
  EnterIcon,
7
7
  NewChatIcon,
@@ -19,6 +19,23 @@ import {
19
19
  ChatMessageToolbarActions,
20
20
  ChatMessageToolbarTimestamp,
21
21
  } from '../components/chat-message-toolbar';
22
+ import {
23
+ ChatReasoning,
24
+ ChatReasoningEnd,
25
+ ChatReasoningEndIcon,
26
+ ChatReasoningEndText,
27
+ ChatReasoningStep,
28
+ ChatReasoningStepHead,
29
+ ChatReasoningStepIcon,
30
+ ChatReasoningStepIconDot,
31
+ ChatReasoningSteps,
32
+ ChatReasoningStepText,
33
+ ChatReasoningTrigger,
34
+ ChatReasoningTriggerArrow,
35
+ ChatReasoningTriggerLabel,
36
+ ChatReasoningTriggerSymbol,
37
+ ChatReasoningTriggerSymbolSwisper,
38
+ } from '../components/chat-reasoning';
22
39
  import {
23
40
  ChatSuggestion,
24
41
  ChatSuggestionActions,
@@ -26,15 +43,6 @@ import {
26
43
  ChatSuggestionLabelIcon,
27
44
  ChatSuggestions,
28
45
  } from '../components/chat-suggestion';
29
- import {
30
- ChatThinkingProcess,
31
- ChatThinkingProcessContent,
32
- ChatThinkingProcessContentItem,
33
- ChatThinkingProcessTrigger,
34
- ChatThinkingProcessTriggerArrow,
35
- ChatThinkingProcessTriggerIcon,
36
- ChatThinkingProcessTriggerLabel,
37
- } from '../components/chat-thinking-process';
38
46
  import {
39
47
  ChatThread,
40
48
  ChatThreadAnswer,
@@ -333,24 +341,39 @@ function ChatbotTurn({ turn, pending }: ChatbotTurnProps) {
333
341
 
334
342
  <ChatThreadAnswer messageId={`${turn.id}-answer`}>
335
343
  <ChatMessage>
336
- <ChatThinkingProcess isStreaming={isThinking}>
337
- <ChatThinkingProcessTrigger>
338
- <ChatThinkingProcessTriggerIcon>
339
- <BrainIcon />
340
- </ChatThinkingProcessTriggerIcon>
341
- <ChatThinkingProcessTriggerLabel>
344
+ <ChatReasoning status={isThinking ? 'running' : 'done'}>
345
+ <ChatReasoningTrigger>
346
+ <ChatReasoningTriggerSymbol>
347
+ <ChatReasoningTriggerSymbolSwisper />
348
+ </ChatReasoningTriggerSymbol>
349
+ <ChatReasoningTriggerLabel>
342
350
  {isThinking
343
- ? 'Thinking…'
351
+ ? (tools.at(-1) ?? 'Thinking…')
344
352
  : `Used ${tools.length} ${tools.length === 1 ? 'tool' : 'tools'}`}
345
- </ChatThinkingProcessTriggerLabel>
346
- <ChatThinkingProcessTriggerArrow />
347
- </ChatThinkingProcessTrigger>
348
- <ChatThinkingProcessContent>
349
- {tools.map((step) => (
350
- <ChatThinkingProcessContentItem key={step}>{step}</ChatThinkingProcessContentItem>
353
+ </ChatReasoningTriggerLabel>
354
+ <ChatReasoningTriggerArrow />
355
+ </ChatReasoningTrigger>
356
+ <ChatReasoningSteps>
357
+ {tools.map((step, index) => (
358
+ <ChatReasoningStep key={step} isLive={isThinking && index === tools.length - 1}>
359
+ <ChatReasoningStepHead>
360
+ <ChatReasoningStepIcon>
361
+ <ChatReasoningStepIconDot />
362
+ </ChatReasoningStepIcon>
363
+ <ChatReasoningStepText>{step}</ChatReasoningStepText>
364
+ </ChatReasoningStepHead>
365
+ </ChatReasoningStep>
351
366
  ))}
352
- </ChatThinkingProcessContent>
353
- </ChatThinkingProcess>
367
+ {!isThinking && (
368
+ <ChatReasoningEnd>
369
+ <ChatReasoningEndIcon>
370
+ <CheckIcon />
371
+ </ChatReasoningEndIcon>
372
+ <ChatReasoningEndText>Done</ChatReasoningEndText>
373
+ </ChatReasoningEnd>
374
+ )}
375
+ </ChatReasoningSteps>
376
+ </ChatReasoning>
354
377
 
355
378
  {answer && (
356
379
  <ChatMessageContent>
@@ -36,7 +36,7 @@ stream in.
36
36
  </ChatThreadQuestion>
37
37
  <ChatThreadAnswer messageId={answerId}>
38
38
  <ChatMessage>
39
- <ChatThinkingProcess />
39
+ <ChatReasoning />
40
40
  {/* tool steps, collapsed */}
41
41
  <ChatMessageContent>
42
42
  <MarkdownViewer markdown={answer} />
@@ -70,8 +70,8 @@ stream in.
70
70
  - **`ChatThreadGroup`**: one question and its answer; `groupId` tells history apart from new messages.
71
71
  - **`ChatMessage`, `ChatMessageContent`**: a question bubble aligned to the end, or an answer at full
72
72
  width.
73
- - **`ChatThinkingProcess`**: the tools the assistant ran. While thinking, the collapsed trigger
74
- previews the latest step.
73
+ - **`ChatReasoning`**: the steps the assistant took. While it works, the collapsed row shows the
74
+ current step; once done, it says what was checked.
75
75
  - **`MarkdownViewer`**: renders the model's Markdown, with a caret while it streams.
76
76
  - **`ChatMessageToolbar`**: timestamp and actions under an answer, shown on hover through
77
77
  `ChatMessageActions`.
@@ -128,7 +128,7 @@ transcript fills the height and the composer sits under it.
128
128
 
129
129
  <Canvas of={AgentStories.Agent} />
130
130
 
131
- - **One block per tool call.** Each call is a `ChatThinkingProcess`: the tool's icon, its name in mono
131
+ - **One block per tool call.** Each call is a `ChatReasoning`: the tool's icon, its name in mono
132
132
  and a one-line result. It stays open while the tool runs, so the output prints line by line, and
133
133
  folds to its summary once done.
134
134
  - **Output in mono.** Tool output uses `font-ibm-plex-mono`, so aligned columns stay aligned.
@@ -142,7 +142,7 @@ transcript fills the height and the composer sits under it.
142
142
  - [CanvasShell](?path=/docs/chat-canvasshell--docs)
143
143
  - [ChatThread](?path=/docs/chat-chatthread--docs)
144
144
  - [ChatMessage](?path=/docs/chat-chatmessage--docs)
145
- - [ChatThinkingProcess](?path=/docs/chat-chatthinkingprocess--docs)
145
+ - [ChatReasoning](?path=/docs/chat-chatreasoning--docs)
146
146
  - [ChatMessageToolbar](?path=/docs/chat-chatmessagetoolbar--docs)
147
147
  - [MarkdownViewer](?path=/docs/chat-markdownviewer--docs)
148
148
  - [ChatSuggestion](?path=/docs/chat-chatsuggestion--docs)