@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.
- 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 +55 -18
- package/dist/components/chat-thinking-process/chat-thinking-process.d.ts.map +1 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts +11 -6
- package/dist/components/chat-thinking-process/chat-thinking-process.stories.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 +1371 -883
- package/dist/index.es.js.map +1 -1
- package/package.json +4 -3
- package/src/components/chat-message/__stories__/tool-steps.tsx +44 -20
- 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 +23 -14
- package/src/components/chat-thinking-process/chat-thinking-process.stories.tsx +115 -25
- package/src/components/chat-thinking-process/chat-thinking-process.tsx +93 -10
- package/src/components/index.ts +1 -0
- package/src/docs/agent.stories.tsx +28 -23
- package/src/docs/chatbot-panel.tsx +48 -22
- 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
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
<
|
|
478
|
-
|
|
479
|
+
<ChatReasoning
|
|
480
|
+
status={isRunning ? 'running' : isStopped ? 'stopped' : 'done'}
|
|
479
481
|
open={isRunning || isExpanded}
|
|
480
482
|
onOpenChange={setIsExpanded}
|
|
481
483
|
>
|
|
482
|
-
<
|
|
483
|
-
<
|
|
484
|
-
{isStopped ? <
|
|
485
|
-
</
|
|
486
|
-
<
|
|
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
|
-
</
|
|
491
|
-
|
|
492
|
+
</ChatReasoningTriggerLabel>
|
|
493
|
+
<ChatReasoningTriggerArrow />
|
|
494
|
+
</ChatReasoningTrigger>
|
|
492
495
|
|
|
493
|
-
<
|
|
496
|
+
<ChatReasoningSteps>
|
|
494
497
|
{step.lines.map((line, index) => (
|
|
495
|
-
<
|
|
496
|
-
|
|
497
|
-
|
|
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
|
-
</
|
|
500
|
-
</
|
|
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
|
-
|
|
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
|
-
<
|
|
336
|
-
<
|
|
337
|
-
<
|
|
338
|
-
<
|
|
339
|
-
</
|
|
340
|
-
<
|
|
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
|
-
</
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
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
|
-
|
|
350
|
-
|
|
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>
|
package/src/docs/chatbot.mdx
CHANGED
|
@@ -36,7 +36,7 @@ stream in.
|
|
|
36
36
|
</ChatThreadQuestion>
|
|
37
37
|
<ChatThreadAnswer messageId={answerId}>
|
|
38
38
|
<ChatMessage>
|
|
39
|
-
<
|
|
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
|
-
- **`
|
|
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 `
|
|
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
|
-
- [
|
|
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)
|