@swisper.ai/web-chat-ui 0.3.0 → 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 (32) 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 +55 -18
  9. package/dist/components/chat-thinking-process/chat-thinking-process.d.ts.map +1 -1
  10. package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts +11 -6
  11. package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts.map +1 -1
  12. package/dist/components/index.d.ts +1 -0
  13. package/dist/components/index.d.ts.map +1 -1
  14. package/dist/docs/agent.stories.d.ts.map +1 -1
  15. package/dist/docs/chatbot-panel.d.ts.map +1 -1
  16. package/dist/index.css +1 -1
  17. package/dist/index.es.js +1371 -883
  18. package/dist/index.es.js.map +1 -1
  19. package/package.json +4 -3
  20. package/src/components/chat-message/__stories__/tool-steps.tsx +44 -20
  21. package/src/components/chat-reasoning/__stories__/fixtures.ts +144 -0
  22. package/src/components/chat-reasoning/chat-reasoning.json +241 -0
  23. package/src/components/chat-reasoning/chat-reasoning.stories.tsx +462 -0
  24. package/src/components/chat-reasoning/chat-reasoning.tsx +1042 -0
  25. package/src/components/chat-reasoning/index.ts +51 -0
  26. package/src/components/chat-thinking-process/chat-thinking-process.json +23 -14
  27. package/src/components/chat-thinking-process/chat-thinking-process.stories.tsx +115 -25
  28. package/src/components/chat-thinking-process/chat-thinking-process.tsx +93 -10
  29. package/src/components/index.ts +1 -0
  30. package/src/docs/agent.stories.tsx +28 -23
  31. package/src/docs/chatbot-panel.tsx +48 -22
  32. package/src/docs/chatbot.mdx +5 -4
@@ -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,13 +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
- ChatThinkingProcessTriggerIcon,
30
- ChatThinkingProcessTriggerLabel,
31
- } 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';
32
34
  import {
33
35
  ChatThread,
34
36
  ChatThreadAnswer,
@@ -474,30 +476,33 @@ function AgentToolCall({ step, isRunning }: AgentToolCallProps) {
474
476
  const isStopped = step.status === 'stopped';
475
477
 
476
478
  return (
477
- <ChatThinkingProcess
478
- isStreaming={isRunning}
479
+ <ChatReasoning
480
+ status={isRunning ? 'running' : isStopped ? 'stopped' : 'done'}
479
481
  open={isRunning || isExpanded}
480
482
  onOpenChange={setIsExpanded}
481
483
  >
482
- <ChatThinkingProcessTrigger>
483
- <ChatThinkingProcessTriggerIcon className="text-text-secondary">
484
- {isStopped ? <ErrorIcon /> : step.icon}
485
- </ChatThinkingProcessTriggerIcon>
486
- <ChatThinkingProcessTriggerLabel className="min-w-0 truncate">
484
+ <ChatReasoningTrigger>
485
+ <ChatReasoningTriggerSymbol>
486
+ {isStopped ? <StopIcon /> : step.icon}
487
+ </ChatReasoningTriggerSymbol>
488
+ <ChatReasoningTriggerLabel>
487
489
  <span className="font-ibm-plex-mono">{step.name}</span>
488
490
  {' · '}
489
491
  {isRunning ? 'Running…' : isStopped ? 'Stopped' : step.summary}
490
- </ChatThinkingProcessTriggerLabel>
491
- </ChatThinkingProcessTrigger>
492
+ </ChatReasoningTriggerLabel>
493
+ <ChatReasoningTriggerArrow />
494
+ </ChatReasoningTrigger>
492
495
 
493
- <ChatThinkingProcessContent itemsClassName="font-ibm-plex-mono whitespace-pre-wrap">
496
+ <ChatReasoningSteps>
494
497
  {step.lines.map((line, index) => (
495
- <ChatThinkingProcessContentItem key={index} className="text-xs not-italic">
496
- {line}
497
- </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>
498
503
  ))}
499
- </ChatThinkingProcessContent>
500
- </ChatThinkingProcess>
504
+ </ChatReasoningSteps>
505
+ </ChatReasoning>
501
506
  );
502
507
  }
503
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,14 +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
- ChatThinkingProcessTriggerIcon,
35
- ChatThinkingProcessTriggerLabel,
36
- } from '../components/chat-thinking-process';
37
46
  import {
38
47
  ChatThread,
39
48
  ChatThreadAnswer,
@@ -332,22 +341,39 @@ function ChatbotTurn({ turn, pending }: ChatbotTurnProps) {
332
341
 
333
342
  <ChatThreadAnswer messageId={`${turn.id}-answer`}>
334
343
  <ChatMessage>
335
- <ChatThinkingProcess isStreaming={isThinking}>
336
- <ChatThinkingProcessTrigger>
337
- <ChatThinkingProcessTriggerIcon>
338
- <BrainIcon />
339
- </ChatThinkingProcessTriggerIcon>
340
- <ChatThinkingProcessTriggerLabel>
344
+ <ChatReasoning status={isThinking ? 'running' : 'done'}>
345
+ <ChatReasoningTrigger>
346
+ <ChatReasoningTriggerSymbol>
347
+ <ChatReasoningTriggerSymbolSwisper />
348
+ </ChatReasoningTriggerSymbol>
349
+ <ChatReasoningTriggerLabel>
341
350
  {isThinking
342
- ? 'Thinking…'
351
+ ? (tools.at(-1) ?? 'Thinking…')
343
352
  : `Used ${tools.length} ${tools.length === 1 ? 'tool' : 'tools'}`}
344
- </ChatThinkingProcessTriggerLabel> </ChatThinkingProcessTrigger>
345
- <ChatThinkingProcessContent>
346
- {tools.map((step) => (
347
- <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>
348
366
  ))}
349
- </ChatThinkingProcessContent>
350
- </ChatThinkingProcess>
367
+ {!isThinking && (
368
+ <ChatReasoningEnd>
369
+ <ChatReasoningEndIcon>
370
+ <CheckIcon />
371
+ </ChatReasoningEndIcon>
372
+ <ChatReasoningEndText>Done</ChatReasoningEndText>
373
+ </ChatReasoningEnd>
374
+ )}
375
+ </ChatReasoningSteps>
376
+ </ChatReasoning>
351
377
 
352
378
  {answer && (
353
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,7 +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, listed once expanded.
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.
74
75
  - **`MarkdownViewer`**: renders the model's Markdown, with a caret while it streams.
75
76
  - **`ChatMessageToolbar`**: timestamp and actions under an answer, shown on hover through
76
77
  `ChatMessageActions`.
@@ -127,7 +128,7 @@ transcript fills the height and the composer sits under it.
127
128
 
128
129
  <Canvas of={AgentStories.Agent} />
129
130
 
130
- - **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
131
132
  and a one-line result. It stays open while the tool runs, so the output prints line by line, and
132
133
  folds to its summary once done.
133
134
  - **Output in mono.** Tool output uses `font-ibm-plex-mono`, so aligned columns stay aligned.
@@ -141,7 +142,7 @@ transcript fills the height and the composer sits under it.
141
142
  - [CanvasShell](?path=/docs/chat-canvasshell--docs)
142
143
  - [ChatThread](?path=/docs/chat-chatthread--docs)
143
144
  - [ChatMessage](?path=/docs/chat-chatmessage--docs)
144
- - [ChatThinkingProcess](?path=/docs/chat-chatthinkingprocess--docs)
145
+ - [ChatReasoning](?path=/docs/chat-chatreasoning--docs)
145
146
  - [ChatMessageToolbar](?path=/docs/chat-chatmessagetoolbar--docs)
146
147
  - [MarkdownViewer](?path=/docs/chat-markdownviewer--docs)
147
148
  - [ChatSuggestion](?path=/docs/chat-chatsuggestion--docs)