@tbox.cn/app-agent-ui-kit 1.0.0-alpha.1 → 1.0.0-alpha.6

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 (46) hide show
  1. package/README.md +1 -1
  2. package/package.json +9 -6
  3. package/src/ChatPage.tsx +34 -7
  4. package/src/card/define-card.ts +34 -0
  5. package/src/card/primitives.test.tsx +147 -0
  6. package/src/card/primitives.tsx +627 -0
  7. package/src/card/use-card-actions.ts +86 -0
  8. package/src/chat-config.test.ts +35 -71
  9. package/src/chat-config.ts +18 -0
  10. package/src/components/ActionBar/DebugButton.tsx +3 -3
  11. package/src/components/ActionBar/index.tsx +13 -14
  12. package/src/components/ChatHeader/index.tsx +19 -17
  13. package/src/components/ChatInput/index.tsx +32 -26
  14. package/src/components/ChatInput/voice/VoicePressField.tsx +12 -3
  15. package/src/components/ChatInput/voice/VoiceRecordingOverlay.tsx +9 -9
  16. package/src/components/HistoryEntry/index.tsx +3 -4
  17. package/src/components/MediaList/index.tsx +42 -28
  18. package/src/components/MessageBubble/index.tsx +52 -27
  19. package/src/components/PullDownIndicator/index.tsx +3 -4
  20. package/src/components/QuickCommands/index.tsx +6 -6
  21. package/src/components/ReasoningBlock/index.tsx +14 -9
  22. package/src/components/ScrollToBottomButton/index.tsx +2 -4
  23. package/src/components/ToolCallBlock/index.tsx +54 -36
  24. package/src/icons.ts +39 -0
  25. package/src/index.ts +54 -1
  26. package/src/shell.contract.json +59 -0
  27. package/src/shell.test.ts +61 -0
  28. package/src/shell.ts +45 -0
  29. package/src/theme/base.css +132 -0
  30. package/src/theme/contract.json +1 -1
  31. package/src/theme/theme-contract.test.ts +3 -3
  32. package/src/theme/{tokens.less → tokens.css} +14 -12
  33. package/src/ChatPage.less +0 -62
  34. package/src/components/ActionBar/index.less +0 -123
  35. package/src/components/ChatHeader/index.less +0 -148
  36. package/src/components/ChatInput/index.less +0 -394
  37. package/src/components/HistoryEntry/index.less +0 -49
  38. package/src/components/MediaList/index.less +0 -241
  39. package/src/components/MessageBubble/index.less +0 -325
  40. package/src/components/PullDownIndicator/index.less +0 -32
  41. package/src/components/QuickCommands/index.less +0 -63
  42. package/src/components/ReasoningBlock/index.less +0 -90
  43. package/src/components/ScrollToBottomButton/index.less +0 -32
  44. package/src/components/ToolCallBlock/index.less +0 -312
  45. package/src/theme/global.less +0 -99
  46. /package/src/theme/{motion.less → motion.css} +0 -0
@@ -1,7 +1,6 @@
1
1
  // 顶部历史入口胶囊:同时承载点击入口和轻量下拉状态反馈。
2
2
  // 常驻渲染是刻意的:运行时未就绪时只禁用,不隐藏——否则就绪后插入 DOM 会把下方欢迎区顶开。
3
3
  import type { PullStatus } from '../../utils/pull-down-machine';
4
- import './index.less';
5
4
 
6
5
  function labelOf(status: PullStatus, loading: boolean): string {
7
6
  if (loading || status === 'loading') return '加载中...';
@@ -27,14 +26,14 @@ export default function HistoryEntry({
27
26
  if (!visible) return null;
28
27
 
29
28
  return (
30
- <div className="history-entry">
29
+ <div className="history-entry flex justify-center p-0">
31
30
  <button
32
31
  type="button"
33
- className="history-entry__button"
32
+ className="history-entry__button inline-flex appearance-none items-center gap-[5px] rounded-[25px] border-0 bg-[rgba(15,64,113,0.06)] px-3 py-[3px] text-xs font-normal leading-[16px] text-muted-foreground transition-[background] duration-[var(--tbox-motion-duration-fast)] ease-[var(--tbox-motion-easing-standard)] [font-family:inherit] active:bg-[rgba(15,64,113,0.1)] disabled:cursor-default"
34
33
  disabled={disabled}
35
34
  onClick={onLoad}
36
35
  >
37
- {(loading || pullStatus === 'loading') && <span className="history-entry__spinner" />}
36
+ {(loading || pullStatus === 'loading') && <span className="history-entry__spinner size-[10px] rounded-full border-[1.5px] border-[rgba(15,64,113,0.18)] border-t-primary animate-[history-entry-spin_0.6s_linear_infinite]" />}
38
37
  {labelOf(pullStatus, loading)}
39
38
  </button>
40
39
  </div>
@@ -3,7 +3,6 @@ import { X, Warning, Prohibit, Plus, VideoCamera } from '@phosphor-icons/react';
3
3
  import { previewImages } from '../../utils/imagePreview';
4
4
  import { toast } from '../../utils/toast';
5
5
  import type { MediaItem } from '../../types';
6
- import './index.less';
7
6
 
8
7
  /** 媒体选项图标(远程素材,对齐原模板)。 */
9
8
  const POPOVER_ICONS: Record<string, { icon: string; label: string; bg: string }> = {
@@ -24,6 +23,10 @@ const POPOVER_ICONS: Record<string, { icon: string; label: string; bg: string }>
24
23
  },
25
24
  };
26
25
 
26
+ /** 媒体删除按钮:图片卡与文件卡共用(旧 Less 两处规则同值)。 */
27
+ const MEDIA_REMOVE_CLASS =
28
+ 'tbox-media-item__remove absolute top-1.5 right-1.5 z-[2] flex size-[18px] items-center justify-center rounded-[9px] bg-[rgba(0,0,0,0.55)] shadow-[0_1px_2px_rgba(0,0,0,0.15)]';
29
+
27
30
  function formatSize(bytes?: number): string {
28
31
  if (!bytes) return '';
29
32
  if (bytes < 1024) return `${bytes}B`;
@@ -55,42 +58,45 @@ function ImageItemCard({
55
58
  };
56
59
 
57
60
  return (
58
- <div className="tbox-media-item tbox-media-item--image" onClick={onClick}>
59
- <img className="tbox-media-item__thumb" src={item.src} alt="" />
61
+ <div
62
+ className="tbox-media-item tbox-media-item--image relative h-[var(--tbox-media-item-size)] w-[var(--tbox-media-item-size)] min-w-[var(--tbox-media-item-size)] overflow-hidden rounded-[var(--tbox-media-item-radius)] bg-[#f5f5f5]"
63
+ onClick={onClick}
64
+ >
65
+ <img className="tbox-media-item__thumb block h-full w-full object-cover" src={item.src} alt="" />
60
66
 
61
67
  {isUploading && (
62
- <div className="tbox-media-item__overlay">
68
+ <div className="tbox-media-item__overlay absolute inset-0 flex flex-col items-center justify-center gap-1 rounded-[var(--tbox-media-item-radius)] bg-[rgba(0,0,0,0.5)]">
63
69
  <div
64
- className="tbox-media-item__progress-ring"
70
+ className="tbox-media-item__progress-ring flex size-[30px] items-center justify-center rounded-full transition-[background] duration-[var(--tbox-motion-duration-base)] ease-[ease]"
65
71
  style={{ background: `conic-gradient(#fff ${progress}%, rgba(255,255,255,0.25) ${progress}%)` }}
66
72
  >
67
- <div className="tbox-media-item__progress-inner">
68
- <span className="tbox-media-item__progress-text">{progress}%</span>
73
+ <div className="tbox-media-item__progress-inner flex size-6 items-center justify-center rounded-full bg-[rgba(0,0,0,0.7)]">
74
+ <span className="tbox-media-item__progress-text text-center text-xs leading-[normal] font-bold text-white">{progress}%</span>
69
75
  </div>
70
76
  </div>
71
77
  </div>
72
78
  )}
73
79
 
74
80
  {isFailed && (
75
- <div className="tbox-media-item__overlay">
76
- <div className="tbox-media-item__status-icon">
81
+ <div className="tbox-media-item__overlay absolute inset-0 flex flex-col items-center justify-center gap-1 rounded-[var(--tbox-media-item-radius)] bg-[rgba(0,0,0,0.5)]">
82
+ <div className="tbox-media-item__status-icon flex items-center justify-center">
77
83
  <Warning size={20} color="#fff" />
78
84
  </div>
79
- <span className="tbox-media-item__status-text">点击重试</span>
85
+ <span className="tbox-media-item__status-text text-center text-xs leading-[normal] font-medium whitespace-nowrap text-[rgba(255,255,255,0.85)]">点击重试</span>
80
86
  </div>
81
87
  )}
82
88
 
83
89
  {isIllegal && (
84
- <div className="tbox-media-item__overlay">
85
- <div className="tbox-media-item__status-icon">
90
+ <div className="tbox-media-item__overlay absolute inset-0 flex flex-col items-center justify-center gap-1 rounded-[var(--tbox-media-item-radius)] bg-[rgba(0,0,0,0.5)]">
91
+ <div className="tbox-media-item__status-icon flex items-center justify-center">
86
92
  <Prohibit size={20} color="#fff" />
87
93
  </div>
88
- <span className="tbox-media-item__status-text">未过审核</span>
94
+ <span className="tbox-media-item__status-text text-center text-xs leading-[normal] font-medium whitespace-nowrap text-[rgba(255,255,255,0.85)]">未过审核</span>
89
95
  </div>
90
96
  )}
91
97
 
92
98
  {!isUploading && (
93
- <div className="tbox-media-item__remove" onClick={(e) => { e.stopPropagation(); onRemove(item.id); }}>
99
+ <div className={MEDIA_REMOVE_CLASS} onClick={(e) => { e.stopPropagation(); onRemove(item.id); }}>
94
100
  <X size={14} color="#fff" />
95
101
  </div>
96
102
  )}
@@ -117,16 +123,19 @@ function FileItemCard({
117
123
  : formatSize(item.size);
118
124
 
119
125
  return (
120
- <div className="tbox-file-item" onClick={() => isFailed && onRetry?.(item.id)}>
121
- <div className="tbox-file-item__icon">
126
+ <div
127
+ className="tbox-file-item relative flex h-[var(--tbox-media-item-size)] min-w-[140px] flex-row items-center gap-1.5 overflow-visible rounded-[var(--tbox-media-item-radius)] bg-[#fcfcfc] p-2"
128
+ onClick={() => isFailed && onRetry?.(item.id)}
129
+ >
130
+ <div className="tbox-file-item__icon flex size-6 shrink-0 items-center justify-center">
122
131
  <VideoCamera size={28} color="#506fff" />
123
132
  </div>
124
- <div className="tbox-file-item__info">
125
- <span className="tbox-file-item__name">{item.name ?? '未知文件'}</span>
126
- <span className={`tbox-file-item__meta${isFailed ? ' tbox-file-item__meta--failed' : ''}`}>{meta}</span>
133
+ <div className="tbox-file-item__info flex min-w-0 flex-1 flex-col justify-center gap-0.5">
134
+ <span className="tbox-file-item__name max-w-full truncate text-xs leading-[normal] font-medium text-[#333]">{item.name ?? '未知文件'}</span>
135
+ <span className={`tbox-file-item__meta whitespace-nowrap text-xs leading-[normal] ${isFailed ? 'tbox-file-item__meta--failed text-destructive' : 'text-[rgba(0,0,0,0.25)]'}`}>{meta}</span>
127
136
  </div>
128
137
  {!isUploading && (
129
- <div className="tbox-media-item__remove" onClick={(e) => { e.stopPropagation(); onRemove(item.id); }}>
138
+ <div className={MEDIA_REMOVE_CLASS} onClick={(e) => { e.stopPropagation(); onRemove(item.id); }}>
130
139
  <X size={14} color="#fff" />
131
140
  </div>
132
141
  )}
@@ -144,17 +153,19 @@ function MediaPopover({
144
153
  onSelect: (type: string) => void;
145
154
  }) {
146
155
  return (
147
- <div className={`tbox-media-popover${visible ? ' tbox-media-popover--visible' : ''}`}>
156
+ <div
157
+ className={`tbox-media-popover absolute right-0 z-10 w-[var(--tbox-media-item-size)] rounded-[10px] bg-white py-2 shadow-[0_2px_10px_rgba(0,0,0,0.08)] transition-[opacity,transform] duration-[var(--tbox-motion-duration-fast)] ease-out bottom-[calc(var(--tbox-media-item-size)_+_4px)] ${visible ? 'tbox-media-popover--visible pointer-events-auto opacity-100 [transform:translateY(0)]' : 'pointer-events-none opacity-0 [transform:translateY(4px)]'}`}
158
+ >
148
159
  {options.map((opt) => (
149
160
  <div
150
161
  key={opt.type}
151
- className="tbox-media-popover__item"
162
+ className="tbox-media-popover__item flex h-[30px] flex-row items-center gap-1 px-2 [&+&]:mt-1"
152
163
  onClick={(e) => { e.stopPropagation(); onSelect(opt.type); }}
153
164
  >
154
- <div className="tbox-media-popover__icon-wrap" style={{ background: opt.bg }}>
155
- <img className="tbox-media-popover__icon" src={opt.icon} alt="" />
165
+ <div className="tbox-media-popover__icon-wrap flex size-5 shrink-0 items-center justify-center rounded-[4px]" style={{ background: opt.bg }}>
166
+ <img className="tbox-media-popover__icon size-4" src={opt.icon} alt="" />
156
167
  </div>
157
- <span className="tbox-media-popover__label">{opt.label}</span>
168
+ <span className="tbox-media-popover__label text-sm leading-[1.4] font-normal text-[rgba(31,59,99,0.88)]">{opt.label}</span>
158
169
  </div>
159
170
  ))}
160
171
  </div>
@@ -235,8 +246,8 @@ export function MediaList({
235
246
  const showAddButton = options.length > 0;
236
247
 
237
248
  return (
238
- <div className="tbox-media-list">
239
- <div className="tbox-media-list__scroll">
249
+ <div className="tbox-media-list flex items-end gap-2 overflow-visible pb-2">
250
+ <div className="tbox-media-list__scroll flex min-w-0 flex-nowrap gap-2 overflow-x-auto [-webkit-overflow-scrolling:touch] [&::-webkit-scrollbar]:hidden">
240
251
  {items.map((item) =>
241
252
  item.type === 'image' ? (
242
253
  <ImageItemCard key={item.id} item={item} allImages={allImages} onRemove={onRemove} onRetry={onRetry} />
@@ -246,7 +257,10 @@ export function MediaList({
246
257
  )}
247
258
  </div>
248
259
  {showAddButton && (
249
- <div className="tbox-media-add" onClick={handleAddClick}>
260
+ <div
261
+ className="tbox-media-add relative flex h-[var(--tbox-media-item-size)] w-[var(--tbox-media-item-size)] min-w-[var(--tbox-media-item-size)] shrink-0 items-center justify-center rounded-[var(--tbox-media-item-radius)] bg-[rgba(255,255,255,0.6)]"
262
+ onClick={handleAddClick}
263
+ >
250
264
  <Plus size={22} color="rgba(0,0,0,0.65)" />
251
265
  <MediaPopover visible={popoverVisible} options={options} onSelect={handleSelect} />
252
266
  </div>
@@ -11,9 +11,9 @@ import { DebugButton } from '../../components/ActionBar/DebugButton';
11
11
  import { CardRenderer } from '../CardRenderer';
12
12
  import { CardCarousel } from '@tbox.cn/app-agent-sdk-client';
13
13
  import { useChatStore, useInlineCardFilter } from '../../store-context';
14
+ import { useChatConfigStore } from '../../chat-config';
14
15
  import { copyText } from '../../utils/copyText';
15
16
  import { toast } from '../../utils/toast';
16
- import './index.less';
17
17
 
18
18
  const TBOX_FILE_URL = 'https://mdn.alipayobjects.com/tcmarket/afts/file/';
19
19
 
@@ -22,6 +22,10 @@ export function MessageBubble({ message }: { message: ChatMessage }) {
22
22
  const cardsByMessageId = useChatStore((s) => s.cardsByMessageId);
23
23
  // 018 tool-debug:服务端旗标单源(HELLO_ACK;无 URL 逃逸——数据面信任锚点在服务端)
24
24
  const toolDebug = useChatStore((s) => s.helloAck?.toolDebug === true);
25
+ const retryOnError = useChatConfigStore((s) => s.retryOnError);
26
+ const messages = useChatStore((s) => s.messages);
27
+ const sendMessage = useChatStore((s) => s.sendMessage);
28
+ const generating = useChatStore((s) => s.isGenerating);
25
29
  const isUser = message.role === 'user';
26
30
  const roleName = isUser ? '你' : 'AI 助手';
27
31
  const timeLabel = new Date(message.createdAt).toLocaleTimeString('zh-CN', {
@@ -66,20 +70,20 @@ export function MessageBubble({ message }: { message: ChatMessage }) {
66
70
  }
67
71
 
68
72
  return (
69
- <div className={`msg-row ${isUser ? 'msg-row--user' : 'msg-row--bot'}`}>
70
- <div className="msg-main">
73
+ <div className={`msg-row mb-2.5 flex items-start px-page ${isUser ? 'msg-row--user flex-row-reverse' : 'msg-row--bot flex-row'}`}>
74
+ <div className={isUser ? 'msg-main min-w-0' : 'msg-main min-w-0 flex-1'}>
71
75
  <div
72
- className={`msg-meta ${isUser ? 'msg-meta--user' : 'msg-meta--bot'}${!showBubble && messageCards.length > 0 ? ' msg-meta--solo-card' : ''}`}
76
+ className={`msg-meta flex items-center ${isUser ? 'msg-meta--user justify-end' : 'msg-meta--bot justify-start'} ${!showBubble && messageCards.length > 0 ? 'msg-meta--solo-card mb-1.5' : 'mb-[3px]'}`}
73
77
  >
74
- <span className="msg-meta__role">{roleName}</span>
75
- <span className="msg-meta__time">{timeLabel}</span>
78
+ <span className="msg-meta__role mr-1 text-xs leading-[normal] text-secondary-foreground">{roleName}</span>
79
+ <span className="msg-meta__time text-xs leading-[normal] text-muted-foreground">{timeLabel}</span>
76
80
  </div>
77
81
 
78
82
  {isPureThinking && (
79
- <div className="msg-thinking">
80
- <div className="msg-thinking__dot" />
81
- <div className="msg-thinking__dot msg-thinking__dot--2" />
82
- <div className="msg-thinking__dot msg-thinking__dot--3" />
83
+ <div className="msg-thinking ml-1.5 flex items-center justify-start gap-1 py-[5px]">
84
+ <div className="msg-thinking__dot h-[5px] w-[5px] animate-[dot-fade_1.4s_ease-in-out_infinite] rounded-full bg-[#aab3c2]" />
85
+ <div className="msg-thinking__dot msg-thinking__dot--2 h-[5px] w-[5px] animate-[dot-fade_1.4s_ease-in-out_infinite] rounded-full bg-[#aab3c2] [animation-delay:0.2s]" />
86
+ <div className="msg-thinking__dot msg-thinking__dot--3 h-[5px] w-[5px] animate-[dot-fade_1.4s_ease-in-out_infinite] rounded-full bg-[#aab3c2] [animation-delay:0.4s]" />
83
87
  </div>
84
88
  )}
85
89
 
@@ -88,33 +92,35 @@ export function MessageBubble({ message }: { message: ChatMessage }) {
88
92
  {hasToolCalls && <ToolCallBlock toolCalls={visibleToolCalls} debug={toolDebug} />}
89
93
 
90
94
  {isThinking && hasToolCalls && !message.content && (
91
- <div className="msg-thinking-inline">
92
- <div className="msg-thinking-inline__dot" />
93
- <div className="msg-thinking-inline__dot msg-thinking-inline__dot--2" />
94
- <div className="msg-thinking-inline__dot msg-thinking-inline__dot--3" />
95
+ <div className="msg-thinking-inline ml-1.5 flex items-center justify-start gap-1 py-[5px]">
96
+ <div className="msg-thinking-inline__dot h-[5px] w-[5px] animate-[dot-fade_1.4s_ease-in-out_infinite] rounded-full bg-[#aab3c2]" />
97
+ <div className="msg-thinking-inline__dot msg-thinking-inline__dot--2 h-[5px] w-[5px] animate-[dot-fade_1.4s_ease-in-out_infinite] rounded-full bg-[#aab3c2] [animation-delay:0.2s]" />
98
+ <div className="msg-thinking-inline__dot msg-thinking-inline__dot--3 h-[5px] w-[5px] animate-[dot-fade_1.4s_ease-in-out_infinite] rounded-full bg-[#aab3c2] [animation-delay:0.4s]" />
95
99
  </div>
96
100
  )}
97
101
 
98
102
  {showBubble && (
99
- <div className={`msg-bubble ${isUser ? 'msg-bubble--user' : 'msg-bubble--bot'}`}>
103
+ <div
104
+ className={`msg-bubble leading-[1.6] ${isUser ? 'msg-bubble--user mb-1 ml-auto mr-0 flex min-h-6 w-fit max-w-full items-center rounded-[24px_4px_24px_24px] bg-[rgba(255,255,255,0.9)] px-[11px] py-[9px] shadow-[0_2px_8px_rgba(50,65,92,0.08)]' : 'msg-bubble--bot relative mb-1.5 rounded-[4px_24px_24px] border-[0.5px] border-[#edf0f6] bg-[rgba(255,255,255,0.4)] p-[11px] text-base text-foreground shadow-[0_1.5px_4px_2.5px_rgba(1,112,254,0.0392),0_1px_2px_rgba(72,78,86,0.0706)]'}`}
105
+ >
100
106
  {isUser ? (
101
- <span className="msg-bubble__text">{message.content}</span>
107
+ <span className="msg-bubble__text text-xs leading-[1.6] font-medium text-foreground [overflow-wrap:break-word]">{message.content}</span>
102
108
  ) : (
103
109
  <>
104
110
  {message.content && (
105
- <div className="msg-markdown">
111
+ <div className="msg-markdown text-xs leading-[1.6] text-foreground [overflow-wrap:anywhere] [&_h1]:mt-2! [&_h1]:mb-1! [&_h1]:text-lg [&_h1]:font-semibold [&_h1]:leading-[1.4] [&_h2]:mt-2! [&_h2]:mb-1! [&_h2]:text-base [&_h2]:font-semibold [&_h2]:leading-[1.4] [&_h3]:mt-2! [&_h3]:mb-1! [&_h3]:text-base [&_h3]:font-semibold [&_h3]:leading-[1.4] [&_h4]:mt-2! [&_h4]:mb-1! [&_h4]:text-sm [&_h4]:font-semibold [&_h4]:leading-[1.4] [&_h5]:mt-2! [&_h5]:mb-1! [&_h5]:font-semibold [&_h5]:leading-[1.4] [&_h6]:mt-2! [&_h6]:mb-1! [&_h6]:font-semibold [&_h6]:leading-[1.4] [&_p]:my-1! [&_strong]:font-semibold [&_em]:italic [&_a]:text-primary [&_a]:underline [&_ul]:my-1! [&_ul]:pl-4 [&_ol]:my-1! [&_ol]:pl-4 [&_li]:my-0.5 [&_blockquote]:my-1.5 [&_blockquote]:border-l-2 [&_blockquote]:border-l-[#667eea] [&_blockquote]:pl-2 [&_blockquote]:text-secondary-foreground [&_code]:rounded-[3px] [&_code]:bg-[rgba(0,0,0,0.06)] [&_code]:px-1 [&_code]:py-[1px] [&_code]:text-sm [&_code]:leading-[1.6] [&_code]:font-mono [&_pre]:my-1.5 [&_pre]:overflow-x-auto [&_pre]:rounded-[6px] [&_pre]:bg-[#1e1e2e] [&_pre]:p-2.5 [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-xs [&_pre_code]:leading-[1.6] [&_pre_code]:text-[#cdd6f4] [&_table]:my-1.5 [&_table]:w-full [&_table]:border-collapse [&_th]:border-[0.5px] [&_th]:border-border [&_th]:bg-muted [&_th]:px-1.5 [&_th]:py-1 [&_th]:text-left [&_th]:text-sm [&_th]:leading-[1.6] [&_th]:font-semibold [&_td]:border-[0.5px] [&_td]:border-border [&_td]:px-1.5 [&_td]:py-1 [&_td]:text-left [&_td]:text-sm [&_td]:leading-[1.6]">
106
112
  <ReactMarkdown remarkPlugins={[remarkGfm]}>{message.content}</ReactMarkdown>
107
113
  </div>
108
114
  )}
109
115
  {message.error && (
110
116
  <div
111
- className={`msg-bubble__error${message.content ? ' msg-bubble__error--with-content' : ''}`}
117
+ className={`msg-bubble__error whitespace-pre-wrap text-xs leading-[1.6] text-destructive [overflow-wrap:anywhere] ${message.content ? 'msg-bubble__error--with-content mt-[7px] border-t-[0.5px] border-t-destructive pt-[7px]' : ''}`}
112
118
  role="alert"
113
119
  >
114
120
  {message.error}
115
121
  </div>
116
122
  )}
117
- {isStreaming && <span className="msg-cursor" />}
123
+ {isStreaming && <span className="msg-cursor ml-0.5 inline-block h-3 w-[2px] animate-[blink_1s_step-end_infinite] align-middle bg-[#5874ff]" />}
118
124
  </>
119
125
  )}
120
126
  </div>
@@ -122,17 +128,17 @@ export function MessageBubble({ message }: { message: ChatMessage }) {
122
128
 
123
129
  {/* 卡片在对话气泡之后显示(决策出卡多张/意图卡/历史卡统一经 cardsByMessageId 挂载,多卡纵向铺开) */}
124
130
  <CardCarousel
125
- className="msg-cards"
131
+ className="msg-cards mt-1"
126
132
  cards={messageCards}
127
133
  renderItem={(card) => <CardRenderer key={card.id} card={card} />}
128
134
  />
129
135
 
130
136
  {imageItems && imageItems.length > 0 && (
131
- <div className="msg-media">
137
+ <div className="msg-media mt-0.5 mr-1.5 flex flex-nowrap gap-2 overflow-x-auto [direction:rtl] [-webkit-overflow-scrolling:touch] [&::-webkit-scrollbar]:hidden">
132
138
  {imageItems.map((item, idx) => (
133
139
  <img
134
140
  key={item.id}
135
- className="msg-media__thumb"
141
+ className="msg-media__thumb h-[var(--tbox-media-item-size)] w-[var(--tbox-media-item-size)] min-w-[var(--tbox-media-item-size)] shrink-0 rounded-[var(--tbox-media-item-radius)] object-cover [direction:ltr]"
136
142
  src={item.src || `${TBOX_FILE_URL}${item.fileId}`}
137
143
  alt=""
138
144
  onClick={() => previewImages(imageUrls, idx)}
@@ -142,23 +148,42 @@ export function MessageBubble({ message }: { message: ChatMessage }) {
142
148
  )}
143
149
 
144
150
  {isUser && !!message.content && (
145
- <div className="msg-toolbar msg-toolbar--user">
146
- <div className="msg-toolbar__action" onClick={copy}>
151
+ <div className="msg-toolbar msg-toolbar--user mt-1 flex items-center justify-end pr-1.5 opacity-40">
152
+ <div className="msg-toolbar__action flex h-[14px] w-[17px] items-center justify-center" onClick={copy}>
147
153
  <Copy size={12} color="#535b6c" />
148
154
  </div>
149
155
  </div>
150
156
  )}
151
157
 
152
158
  {!isUser && message.status === 'done' && !!message.content && (
153
- <div className="msg-toolbar-row">
159
+ <div className="msg-toolbar-row flex flex-wrap items-center gap-1.5">
154
160
  <ActionBar message={message} />
155
161
  </div>
156
162
  )}
157
163
 
158
- {/* 出错消息不提供朗读/反馈,但支持复制错误详情和拉 trace 排查。 */}
164
+ {/* 出错消息不提供朗读/反馈;支持重试(重发上一条用户消息)、复制错误详情与拉 trace 排查。 */}
159
165
  {!isUser && message.status === 'error' && (
160
- <div className="msg-toolbar-row">
166
+ <div className="msg-toolbar-row flex flex-wrap items-center gap-1.5">
161
167
  <div className="tbox-action-bar">
168
+ {retryOnError ? (
169
+ <button
170
+ type="button"
171
+ className="msg-retry cursor-pointer border-0 bg-transparent px-1 py-0.5 text-xs leading-[normal] text-primary [font-family:inherit] disabled:cursor-not-allowed disabled:text-muted-foreground"
172
+ disabled={generating}
173
+ onClick={() => {
174
+ const index = messages.findIndex((item) => item.id === message.id);
175
+ const scope = index >= 0 ? messages.slice(0, index) : messages;
176
+ const lastUser = [...scope].reverse().find((item) => item.role === 'user');
177
+ if (!lastUser?.content) {
178
+ void toast('没有可重发的消息', 'info');
179
+ return;
180
+ }
181
+ sendMessage(lastUser.content);
182
+ }}
183
+ >
184
+ 重试
185
+ </button>
186
+ ) : null}
162
187
  <CopyButton text={getMessageCopyText(message)} />
163
188
  {message.requestId && (
164
189
  <DebugButton
@@ -1,6 +1,5 @@
1
1
  import type { PullStatus } from '../../utils/pull-down-machine';
2
2
  import { PULL_DOWN_THRESHOLD } from '../../utils/pull-down-machine';
3
- import './index.less';
4
3
 
5
4
  /** 下拉加载历史的顶部指示器。 */
6
5
  export default function PullDownIndicator({ status, distance }: { status: PullStatus; distance: number }) {
@@ -22,11 +21,11 @@ export default function PullDownIndicator({ status, distance }: { status: PullSt
22
21
 
23
22
  return (
24
23
  <div
25
- className={`pull-indicator${showTransition ? ' pull-indicator--animated' : ''}`}
24
+ className={`pull-indicator flex h-[30px] items-center justify-center gap-[6px] ${showTransition ? ' pull-indicator--animated transition-[margin-top] duration-[var(--tbox-motion-duration-base)] ease-out' : ''}`}
26
25
  style={{ marginTop: `${marginTop}px` }}
27
26
  >
28
- {status === 'loading' && <div className="pull-indicator__spinner" />}
29
- <span className="pull-indicator__text">{content}</span>
27
+ {status === 'loading' && <div className="pull-indicator__spinner size-4 rounded-full border-[1.5px] border-border-strong border-t-primary animate-[pull-spin_0.6s_linear_infinite]" />}
28
+ <span className="pull-indicator__text text-sm leading-none text-[#8c8c8c]">{content}</span>
30
29
  </div>
31
30
  );
32
31
  }
@@ -4,7 +4,6 @@
4
4
  import { useChatConfigStore } from '../../chat-config';
5
5
  import { useChatStore } from '../../store-context';
6
6
  import starIcon from '../../../assets/quick-command-star.svg';
7
- import './index.less';
8
7
 
9
8
  export function QuickCommands({
10
9
  onCommand,
@@ -14,7 +13,8 @@ export function QuickCommands({
14
13
  hidden?: boolean;
15
14
  }) {
16
15
  const staticCommands = useChatConfigStore((s) => s.quickCommands);
17
- const serverCommands = useChatStore((s) => s.helloAck?.chatConfig.quickCommands);
16
+ // chatConfig 可选链:旧 server 的 HELLO_ACK 可能不带该段(与「ack 缺席回落静态」同语义)
17
+ const serverCommands = useChatStore((s) => s.helloAck?.chatConfig?.quickCommands);
18
18
  // 服务端下发优先;未收到 HELLO_ACK(非 mall 部署)回落本地静态
19
19
  const staticByLabel = new Map(staticCommands.map((command) => [command.label, command]));
20
20
  const commands = serverCommands && serverCommands.length > 0
@@ -28,23 +28,23 @@ export function QuickCommands({
28
28
 
29
29
  return (
30
30
  <div
31
- className={`quick-commands${hidden ? ' quick-commands--hidden' : ''}`}
31
+ className={`quick-commands relative z-[1] mx-auto flex w-full max-w-content gap-2 overflow-x-auto px-page pb-[9px] [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden ${hidden ? ' quick-commands--hidden invisible pointer-events-none' : ''}`}
32
32
  aria-hidden={hidden || undefined}
33
33
  >
34
34
  {commands.map((cmd) => (
35
35
  <button
36
36
  key={cmd.label}
37
- className="quick-commands__item"
37
+ className="quick-commands__item inline-flex h-[34px] flex-[1_0_auto] appearance-none items-center justify-center gap-[5px] rounded-[25px] border border-[rgba(15,64,113,0.14)] bg-[rgba(255,255,255,0.92)] px-[13px] py-0 shadow-[0_4px_16px_rgba(38,59,92,0.05)] transition-[background,border-color] duration-[var(--tbox-motion-duration-fast)] ease-[var(--tbox-motion-easing-standard)] [font-family:inherit] active:border-primary"
38
38
  disabled={hidden}
39
39
  onClick={() => onCommand(cmd.query)}
40
40
  >
41
41
  <img
42
- className="quick-commands__icon"
42
+ className="quick-commands__icon size-4 object-contain"
43
43
  src={cmd.icon ?? starIcon}
44
44
  alt=""
45
45
  onError={(event) => { event.currentTarget.src = starIcon; }}
46
46
  />
47
- <span className="quick-commands__label">{cmd.label}</span>
47
+ <span className="quick-commands__label whitespace-nowrap text-sm font-medium leading-[18px] text-foreground">{cmd.label}</span>
48
48
  </button>
49
49
  ))}
50
50
  </div>
@@ -1,7 +1,6 @@
1
1
  import { useEffect, useRef, useState } from 'react';
2
2
  import ReactMarkdown from 'react-markdown';
3
3
  import remarkGfm from 'remark-gfm';
4
- import './index.less';
5
4
 
6
5
  interface Props {
7
6
  reasoning: string;
@@ -35,19 +34,25 @@ export default function ReasoningBlock({ reasoning, isActive }: Props) {
35
34
  const durationLabel = elapsed > 0 ? `${elapsed}s` : '';
36
35
 
37
36
  return (
38
- <div className={`reasoning ${isActive ? 'reasoning--active' : 'reasoning--done'}`}>
39
- <div className="reasoning__header" onClick={() => setExpanded(!expanded)}>
40
- <div className="reasoning__left">
41
- <div className={`reasoning__indicator${isActive ? ' reasoning__indicator--pulse' : ''}`} />
42
- <span className="reasoning__title">{isActive ? '思考中...' : '思考过程'}</span>
43
- {durationLabel && <span className="reasoning__duration">({durationLabel})</span>}
37
+ <div
38
+ className={`reasoning mb-2 max-w-full min-w-0 overflow-hidden rounded-[7px] ${isActive ? 'reasoning--active bg-[linear-gradient(135deg,rgba(102,126,234,0.08)_0%,rgba(118,75,162,0.06)_100%)]' : 'reasoning--done bg-[rgba(0,0,0,0.03)]'}`}
39
+ >
40
+ <div className="reasoning__header flex items-center justify-between px-[9px] py-[7px]" onClick={() => setExpanded(!expanded)}>
41
+ <div className="reasoning__left flex items-center gap-1">
42
+ <div
43
+ className={`reasoning__indicator size-[5px] shrink-0 rounded-full ${isActive ? 'reasoning__indicator--pulse animate-[reasoning-pulse_1.5s_ease-in-out_infinite] bg-[#667eea]' : 'bg-[#b0bec5]'}`}
44
+ />
45
+ <span className={`reasoning__title text-xs leading-[normal] font-semibold ${isActive ? 'text-[#667eea]' : 'text-[#6b7a99]'}`}>{isActive ? '思考中...' : '思考过程'}</span>
46
+ {durationLabel && <span className="reasoning__duration text-xs leading-[normal] text-[#9ba7c3]">({durationLabel})</span>}
44
47
  </div>
45
- <span className={`reasoning__toggle${expanded ? ' reasoning__toggle--up' : ''}`}>
48
+ <span className={`reasoning__toggle text-xs leading-[normal] text-[#8b95b0] ${expanded ? 'reasoning__toggle--up' : ''}`}>
46
49
  {expanded ? '收起' : '展开'}
47
50
  </span>
48
51
  </div>
49
52
  {expanded && (
50
- <div className="reasoning__content">
53
+ <div
54
+ className={`reasoning__content mx-[9px] mb-2 overflow-hidden border-l-[1.5px] pl-[21px] text-xs leading-[1.7] text-[#8b95b0] [overflow-wrap:break-word] [&_p]:my-[3px]! ${isActive ? 'border-l-[#667eea]' : 'border-l-[#d6dce8]'}`}
55
+ >
51
56
  <ReactMarkdown remarkPlugins={[remarkGfm]}>{reasoning}</ReactMarkdown>
52
57
  </div>
53
58
  )}
@@ -1,10 +1,8 @@
1
- import './index.less';
2
-
3
1
  /** 生成时出现的“回到底部”悬浮按钮。 */
4
2
  export default function ScrollToBottomButton({ visible, onClick }: { visible: boolean; onClick: () => void }) {
5
3
  return (
6
- <div className={`scroll-to-bottom-btn${visible ? ' scroll-to-bottom-btn--visible' : ''}`} onClick={onClick}>
7
- <div className="scroll-to-bottom-btn__arrow" />
4
+ <div className={`scroll-to-bottom-btn absolute right-4 bottom-4 z-10 flex size-9 items-center justify-center rounded-full bg-white shadow-[0_2px_8px_0_rgba(0,0,0,0.12)] transition-[opacity,transform] duration-[var(--tbox-motion-duration-fast)] ease-[ease] ${visible ? ' scroll-to-bottom-btn--visible pointer-events-auto opacity-100 [transform:scale(1)]' : ' pointer-events-none opacity-0 [transform:scale(0.8)]'}`} onClick={onClick}>
5
+ <div className="scroll-to-bottom-btn__arrow h-0 w-0 border-x-[6px] border-t-[7px] border-x-transparent border-t-[#666]" />
8
6
  </div>
9
7
  );
10
8
  }