@steerable/agent-shell-web 0.14.4 → 0.14.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 (51) hide show
  1. package/package.json +4 -4
  2. package/src/components/AgentSidebar.tsx +189 -46
  3. package/src/components/ChatHeader.tsx +12 -1
  4. package/src/components/SidebarAccount.tsx +33 -41
  5. package/src/components/chat/AssistantMessage.tsx +25 -4
  6. package/src/components/chat/ChatInput.tsx +169 -111
  7. package/src/components/chat/ChatProjectBadge.tsx +233 -88
  8. package/src/components/chat/ContextUsagePill.tsx +20 -5
  9. package/src/components/chat/ExecPolicyPicker.tsx +72 -67
  10. package/src/components/chat/LocalChatPanel.tsx +34 -34
  11. package/src/components/chat/MessageList.tsx +109 -19
  12. package/src/components/chat/ModelPicker.tsx +2 -2
  13. package/src/components/chat/SessionTodoList.tsx +63 -72
  14. package/src/components/chat/TurnFilesCard.tsx +270 -112
  15. package/src/components/chat/TurnProcessGroup.tsx +3 -0
  16. package/src/components/chat/TurnProcessTimeline.tsx +13 -0
  17. package/src/components/chat/UserMessage.tsx +8 -1
  18. package/src/components/chat/next-steps-tags.ts +13 -0
  19. package/src/components/chat/process-status.ts +112 -2
  20. package/src/components/chat/todo-list-model.ts +52 -4
  21. package/src/components/settings/AgentsSettingsPanel.tsx +3 -3
  22. package/src/components/settings/AppUpdateSettingsPanel.tsx +67 -43
  23. package/src/components/settings/AppearanceSettingsPanel.tsx +101 -134
  24. package/src/components/settings/CliInstallSettingsPanel.tsx +25 -23
  25. package/src/components/settings/DiagnoseSettingsPanel.tsx +3 -3
  26. package/src/components/settings/InsightsSettingsPanel.tsx +5 -7
  27. package/src/components/settings/LlmSettingsPanel.tsx +22 -2
  28. package/src/components/settings/McpSettingsPanel.tsx +4 -5
  29. package/src/components/settings/MemorySettingsPanel.tsx +210 -159
  30. package/src/components/settings/OrchestrationSettingsPanel.tsx +79 -121
  31. package/src/components/settings/PortableSettingsPanel.tsx +62 -49
  32. package/src/components/settings/PythonRunnerSettingsPanel.tsx +2 -4
  33. package/src/components/settings/SecuritySettingsPanel.tsx +91 -70
  34. package/src/components/settings/SettingsSidebar.tsx +238 -0
  35. package/src/components/settings/SkillsSettingsPanel.tsx +3 -4
  36. package/src/components/settings/TelemetrySettingsPanel.tsx +2 -7
  37. package/src/components/settings/UsagePanel.tsx +27 -35
  38. package/src/components/settings/WebSearchSettingsPanel.tsx +89 -88
  39. package/src/components/settings/primitives.tsx +302 -0
  40. package/src/components/settings/settings-registry.ts +371 -0
  41. package/src/layouts/AgentLayout.tsx +275 -12
  42. package/src/layouts/PanelToggleButton.tsx +27 -9
  43. package/src/layouts/conversation-preview.ts +3 -0
  44. package/src/layouts/request-chat-slot.ts +20 -0
  45. package/src/layouts/right-panel-tabs.ts +32 -0
  46. package/src/lib/chat-draft-store.ts +43 -0
  47. package/src/lib/file-preview-registry.ts +57 -0
  48. package/src/packs/registry.ts +2 -0
  49. package/src/pages/AgentPage.tsx +17 -4
  50. package/src/pages/SettingsPage.tsx +327 -489
  51. package/src/styles/index.css +6 -0
@@ -1,10 +1,12 @@
1
- import { useEffect, useRef, useState } from 'react';
1
+ import { useContext, useEffect, useRef, useState } from 'react';
2
2
  import {
3
3
  LuCheck,
4
4
  LuChevronDown,
5
+ LuChevronRight,
5
6
  LuCopy,
6
7
  LuDownload,
7
8
  LuExternalLink,
9
+ LuEye,
8
10
  LuFile,
9
11
  LuFileDiff,
10
12
  LuFileSpreadsheet,
@@ -15,6 +17,11 @@ import {
15
17
  LuPresentation,
16
18
  LuUndo2,
17
19
  } from 'react-icons/lu';
20
+ import { CurrentMessageIdContext } from '@/lib/chat-mode-store';
21
+ import {
22
+ findDeliverablePreviewer,
23
+ subscribeDeliverablePreviewers,
24
+ } from '@/lib/file-preview-registry';
18
25
  import { getLocalFileDownload, openLocalPath } from '@/lib/local-api';
19
26
  import { saveBase64AsFile } from '@/lib/download';
20
27
  import { hostToolChrome } from '@/lib/host-tools';
@@ -33,10 +40,10 @@ import {
33
40
  * TurnFilesCard — 回合产物文件展示(Codex 样式)。
34
41
  *
35
42
  * 拆分两层呈现:
36
- * 1. 最终文件(Deliverables):如生成的 Excel、PPT、PDF、图片等,展示为独立的大卡片,
37
- * 带文件类型图标、分类标签(Spreadsheet · XLSX)、以及「Open in ⌵」下拉打开操作。
38
- * 2. 中间修改文件(Edited files):如脚本、代码等修改,展示为「Edited N files (+X -Y)」
39
- * 可折叠卡片,包含 Review 按钮与细粒度行变动列表。
43
+ * 1. 最终文件(Deliverables):如生成的表格、演示文稿、PDF、图片等,展示为独立卡片;
44
+ * 若宿主已注册应用内预览器,主按钮展示「Preview」,外部应用打开收纳至更多菜单。
45
+ * 2. 中间修改文件(Edited files):纯代码回合展示为完整卡片;若本轮已有最终交付文件,
46
+ * 则退化为单行无框轻折叠条,避免临时制件脚本与主交付物争抢视线。
40
47
  */
41
48
 
42
49
  export interface ExecutedActionLike {
@@ -50,15 +57,21 @@ interface TurnFilesCardProps {
50
57
  executedActions?: ExecutedActionLike[];
51
58
  /** 当前会话:浏览器模式下载回合产物必须带 chatId 交给后端做归属校验。 */
52
59
  chatId?: string | null;
60
+ /** 可选文件级回滚回调;未提供时不渲染灰死按钮。 */
61
+ onUndo?: () => void;
53
62
  }
54
63
 
55
- export function TurnFilesCard({ files, executedActions, chatId }: TurnFilesCardProps) {
64
+ export function TurnFilesCard({ files, executedActions, chatId, onUndo }: TurnFilesCardProps) {
56
65
  const [openingPath, setOpeningPath] = useState<string | null>(null);
57
66
  const [openError, setOpenError] = useState<{ path: string; message: string } | null>(null);
58
67
  const [downloadingPath, setDownloadingPath] = useState<string | null>(null);
59
68
  const [downloadError, setDownloadError] = useState<{ path: string; message: string } | null>(null);
69
+ const [, bumpPreviewRegistry] = useState(0);
70
+ const messageId = useContext(CurrentMessageIdContext) ?? undefined;
60
71
  const allowOpenPath = hostToolChrome('local-fs');
61
72
 
73
+ useEffect(() => subscribeDeliverablePreviewers(() => bumpPreviewRegistry((n) => n + 1)), []);
74
+
62
75
  const { deliverables, intermediates, totalAdditions, totalDeletions } = groupTurnFiles(
63
76
  files,
64
77
  executedActions,
@@ -114,35 +127,50 @@ export function TurnFilesCard({ files, executedActions, chatId }: TurnFilesCardP
114
127
  };
115
128
 
116
129
  return (
117
- <div className="space-y-2.5" data-turn-files="">
130
+ <div className="space-y-2" data-turn-files="">
118
131
  {/* 1. 最终文件卡片区 (Deliverables) */}
119
132
  {deliverables.length > 0 && (
120
133
  <div className="space-y-2" data-turn-deliverables="">
121
- {deliverables.map((file) => (
122
- <DeliverableCard
123
- key={file.path}
124
- file={file}
125
- onOpen={() => void handleOpen(file.path)}
126
- onDownload={() => void handleDownload(file.path)}
127
- onReveal={() => void handleReveal(file.path)}
128
- busy={openingPath === file.path}
129
- downloading={downloadingPath === file.path}
130
- error={openError?.path === file.path ? openError.message : null}
131
- downloadError={downloadError?.path === file.path ? downloadError.message : null}
132
- allowOpen={allowOpenPath}
133
- allowDownload={Boolean(chatId)}
134
- />
135
- ))}
134
+ {deliverables.map((file) => {
135
+ const previewer = findDeliverablePreviewer(file.path);
136
+ return (
137
+ <DeliverableCard
138
+ key={file.path}
139
+ file={file}
140
+ onPreview={
141
+ previewer
142
+ ? () =>
143
+ previewer.openPreview({
144
+ chatId: chatId ?? null,
145
+ messageId,
146
+ filePath: file.path,
147
+ })
148
+ : undefined
149
+ }
150
+ onOpen={() => void handleOpen(file.path)}
151
+ onDownload={() => void handleDownload(file.path)}
152
+ onReveal={() => void handleReveal(file.path)}
153
+ busy={openingPath === file.path}
154
+ downloading={downloadingPath === file.path}
155
+ error={openError?.path === file.path ? openError.message : null}
156
+ downloadError={downloadError?.path === file.path ? downloadError.message : null}
157
+ allowOpen={allowOpenPath}
158
+ allowDownload={Boolean(chatId)}
159
+ />
160
+ );
161
+ })}
136
162
  </div>
137
163
  )}
138
164
 
139
- {/* 2. 中间修改文件区 (Edited Files) */}
165
+ {/* 2. 中间修改文件区 (Edited Files):有主交付物时收窄为单行轻折叠条 */}
140
166
  {intermediates.length > 0 && (
141
167
  <EditedFilesCard
142
168
  files={intermediates}
143
169
  totalAdditions={totalAdditions}
144
170
  totalDeletions={totalDeletions}
171
+ compact={deliverables.length > 0}
145
172
  onOpen={(f) => void handleOpen(f.path)}
173
+ onUndo={onUndo}
146
174
  openingPath={openingPath}
147
175
  openError={openError}
148
176
  allowOpen={allowOpenPath}
@@ -158,6 +186,7 @@ export function TurnFilesCard({ files, executedActions, chatId }: TurnFilesCardP
158
186
 
159
187
  interface DeliverableCardProps {
160
188
  file: TurnFile;
189
+ onPreview?: () => void;
161
190
  onOpen: () => void;
162
191
  onDownload: () => void;
163
192
  onReveal: () => void;
@@ -171,6 +200,7 @@ interface DeliverableCardProps {
171
200
 
172
201
  function DeliverableCard({
173
202
  file,
203
+ onPreview,
174
204
  onOpen,
175
205
  onDownload,
176
206
  onReveal,
@@ -184,6 +214,7 @@ function DeliverableCard({
184
214
  const [dropdownOpen, setDropdownOpen] = useState(false);
185
215
  const [copied, setCopied] = useState(false);
186
216
  const menuRef = useRef<HTMLDivElement>(null);
217
+ const moreTriggerRef = useRef<HTMLButtonElement>(null);
187
218
  const { name } = splitTurnFilePath(file.path);
188
219
  const size = formatFileSize(file.size);
189
220
  const meta = getDeliverableMeta(file.path);
@@ -195,8 +226,18 @@ function DeliverableCard({
195
226
  setDropdownOpen(false);
196
227
  }
197
228
  };
229
+ const handleKeyDown = (e: KeyboardEvent) => {
230
+ if (e.key === 'Escape') {
231
+ setDropdownOpen(false);
232
+ moreTriggerRef.current?.focus();
233
+ }
234
+ };
198
235
  document.addEventListener('mousedown', handleClickOutside);
199
- return () => document.removeEventListener('mousedown', handleClickOutside);
236
+ document.addEventListener('keydown', handleKeyDown);
237
+ return () => {
238
+ document.removeEventListener('mousedown', handleClickOutside);
239
+ document.removeEventListener('keydown', handleKeyDown);
240
+ };
200
241
  }, [dropdownOpen]);
201
242
 
202
243
  const handleCopyPath = async () => {
@@ -209,6 +250,9 @@ function DeliverableCard({
209
250
  }
210
251
  };
211
252
 
253
+ const canClickTitle = Boolean(onPreview) || allowOpen;
254
+ const handleTitleClick = onPreview ?? onOpen;
255
+
212
256
  return (
213
257
  <div
214
258
  className="rounded-agent-lg border border-agent-border bg-agent-canvas p-2.5 shadow-xs transition-all hover:border-agent-border/80"
@@ -226,11 +270,11 @@ function DeliverableCard({
226
270
  <div className="min-w-0 flex-1">
227
271
  <button
228
272
  type="button"
229
- onClick={onOpen}
230
- disabled={!allowOpen || busy}
273
+ onClick={handleTitleClick}
274
+ disabled={!canClickTitle || (!onPreview && busy)}
231
275
  title={file.path}
232
276
  className={`block w-full truncate text-left text-xs font-medium text-agent-foreground ${
233
- allowOpen ? 'hover:underline cursor-pointer' : 'cursor-default'
277
+ canClickTitle ? 'hover:underline cursor-pointer' : 'cursor-default'
234
278
  }`}
235
279
  >
236
280
  {name}
@@ -248,8 +292,21 @@ function DeliverableCard({
248
292
  </div>
249
293
  </div>
250
294
 
251
- {/* 右侧:下载 + Open in ⌵ 动作按钮 */}
295
+ {/* 右侧:应用内预览主按钮(若支持)+ 下载 + 打开方式/更多下拉 */}
252
296
  <div className="relative flex shrink-0 items-center gap-1.5" ref={menuRef}>
297
+ {onPreview ? (
298
+ <button
299
+ type="button"
300
+ data-testid="deliverable-preview"
301
+ onClick={onPreview}
302
+ title={file.path}
303
+ className="flex h-[26px] items-center gap-1 rounded-agent-md border border-agent-border bg-agent-foreground/[0.04] px-2.5 text-xs font-medium text-agent-foreground shadow-xs transition-colors hover:border-agent-border/80 hover:bg-agent-foreground/[0.08]"
304
+ >
305
+ <LuEye className="h-3.5 w-3.5 text-agent-muted-foreground" />
306
+ <span>{t('Preview')}</span>
307
+ </button>
308
+ ) : null}
309
+
253
310
  <button
254
311
  type="button"
255
312
  onClick={onDownload}
@@ -265,29 +322,45 @@ function DeliverableCard({
265
322
  <span>{t('Download')}</span>
266
323
  </button>
267
324
 
268
- <div className="flex items-center rounded-agent-md border border-agent-border bg-agent-canvas shadow-xs hover:border-agent-border/80 transition-colors">
269
- <button
270
- type="button"
271
- onClick={onOpen}
272
- disabled={!allowOpen || busy}
273
- title={file.path}
274
- className="flex items-center gap-1.5 rounded-l-agent-md px-2.5 py-1 text-xs font-medium text-agent-foreground hover:bg-agent-muted/50 transition-colors disabled:cursor-wait"
275
- >
276
- {busy ? (
277
- <LuLoaderCircle className="h-3.5 w-3.5 animate-spin text-agent-muted-foreground" />
278
- ) : null}
279
- <span>{t('Open with')}</span>
280
- </button>
325
+ {onPreview ? (
281
326
  <button
327
+ ref={moreTriggerRef}
282
328
  type="button"
283
329
  onClick={() => setDropdownOpen(!dropdownOpen)}
284
330
  disabled={!allowOpen}
285
331
  aria-label={t('More actions')}
286
- className="border-l border-agent-border px-1.5 py-1 text-agent-muted-foreground hover:bg-agent-muted/50 hover:text-agent-foreground rounded-r-agent-md transition-colors"
332
+ aria-expanded={dropdownOpen}
333
+ className="flex h-[26px] items-center justify-center rounded-agent-md border border-agent-border bg-agent-canvas px-1.5 text-agent-muted-foreground shadow-xs transition-colors hover:border-agent-border/80 hover:bg-agent-muted/50 hover:text-agent-foreground disabled:opacity-50"
287
334
  >
288
335
  <LuChevronDown className="h-3.5 w-3.5" />
289
336
  </button>
290
- </div>
337
+ ) : (
338
+ <div className="flex items-center rounded-agent-md border border-agent-border bg-agent-canvas shadow-xs hover:border-agent-border/80 transition-colors">
339
+ <button
340
+ type="button"
341
+ onClick={onOpen}
342
+ disabled={!allowOpen || busy}
343
+ title={file.path}
344
+ className="flex items-center gap-1.5 rounded-l-agent-md px-2.5 py-1 text-xs font-medium text-agent-foreground hover:bg-agent-muted/50 transition-colors disabled:cursor-wait"
345
+ >
346
+ {busy ? (
347
+ <LuLoaderCircle className="h-3.5 w-3.5 animate-spin text-agent-muted-foreground" />
348
+ ) : null}
349
+ <span>{t('Open with')}</span>
350
+ </button>
351
+ <button
352
+ ref={moreTriggerRef}
353
+ type="button"
354
+ onClick={() => setDropdownOpen(!dropdownOpen)}
355
+ disabled={!allowOpen}
356
+ aria-label={t('More actions')}
357
+ aria-expanded={dropdownOpen}
358
+ className="border-l border-agent-border px-1.5 py-1 text-agent-muted-foreground hover:bg-agent-muted/50 hover:text-agent-foreground rounded-r-agent-md transition-colors"
359
+ >
360
+ <LuChevronDown className="h-3.5 w-3.5" />
361
+ </button>
362
+ </div>
363
+ )}
291
364
 
292
365
  {/* 下拉菜单 */}
293
366
  {dropdownOpen && (
@@ -390,36 +463,168 @@ function DeliverableIcon({ meta }: { meta: DeliverableFileMeta }) {
390
463
  }
391
464
 
392
465
  // ─────────────────────────────────────────────────────────────
393
- // 中间修改文件卡片 (Codex Edited Files Card)
466
+ // 中间修改文件卡片 / 过程文件轻折叠条 (Edited Files)
394
467
  // ─────────────────────────────────────────────────────────────
395
468
 
396
469
  interface EditedFilesCardProps {
397
470
  files: TurnFile[];
398
471
  totalAdditions: number;
399
472
  totalDeletions: number;
473
+ compact?: boolean;
474
+ onOpen: (file: TurnFile) => void;
475
+ onUndo?: () => void;
476
+ openingPath: string | null;
477
+ openError: { path: string; message: string } | null;
478
+ allowOpen: boolean;
479
+ }
480
+
481
+ function EditedFilesList({
482
+ files,
483
+ compact,
484
+ onOpen,
485
+ openingPath,
486
+ openError,
487
+ allowOpen,
488
+ }: {
489
+ files: TurnFile[];
490
+ compact: boolean;
400
491
  onOpen: (file: TurnFile) => void;
401
492
  openingPath: string | null;
402
493
  openError: { path: string; message: string } | null;
403
494
  allowOpen: boolean;
495
+ }) {
496
+ return (
497
+ <ul
498
+ className={
499
+ compact
500
+ ? 'mt-1 ml-2 max-h-52 overflow-y-auto border-l border-agent-border/60 pl-2.5 space-y-0.5'
501
+ : 'max-h-60 overflow-y-auto border-t border-agent-border/60 divide-y divide-agent-border/40 py-0.5'
502
+ }
503
+ >
504
+ {files.map((file) => {
505
+ const displayPath = formatIntermediateDisplayPath(file.path);
506
+ const size = formatFileSize(file.size);
507
+ const busy = openingPath === file.path;
508
+ const error = openError?.path === file.path ? openError.message : null;
509
+ const hasDiffStats =
510
+ typeof file.additions === 'number' || typeof file.deletions === 'number';
511
+
512
+ return (
513
+ <li key={file.path}>
514
+ <button
515
+ type="button"
516
+ onClick={() => onOpen(file)}
517
+ disabled={!allowOpen || openingPath !== null}
518
+ title={file.path}
519
+ className={`group flex w-full items-center justify-between ${
520
+ compact ? 'rounded px-1.5 py-1' : 'px-3 py-1.5'
521
+ } text-left text-xs transition-colors ${
522
+ allowOpen
523
+ ? 'hover:bg-agent-foreground/5 cursor-pointer disabled:cursor-wait'
524
+ : 'cursor-default'
525
+ }`}
526
+ data-turn-file=""
527
+ data-kind={file.kind}
528
+ >
529
+ <span className="min-w-0 flex-1 truncate text-xs text-agent-foreground/90 group-hover:text-agent-foreground">
530
+ {displayPath}
531
+ </span>
532
+
533
+ <span className="shrink-0 pl-2">
534
+ {busy ? (
535
+ <LuLoaderCircle className="h-3.5 w-3.5 animate-spin text-agent-muted-foreground" />
536
+ ) : hasDiffStats ? (
537
+ <span className="flex items-center gap-1.5 font-mono text-[11px] tabular-nums">
538
+ <span className="font-medium text-emerald-600 dark:text-emerald-400">
539
+ +{file.additions ?? 0}
540
+ </span>
541
+ <span className="text-agent-muted-foreground">
542
+ -{file.deletions ?? 0}
543
+ </span>
544
+ </span>
545
+ ) : size ? (
546
+ <span className="text-[11px] text-agent-muted-foreground tabular-nums">
547
+ {size}
548
+ </span>
549
+ ) : null}
550
+ </span>
551
+ </button>
552
+
553
+ {error && (
554
+ <div className="px-3 pb-1 text-[11px] text-agent-destructive" role="status">
555
+ {t('Could not open: {error}', { error })}
556
+ </div>
557
+ )}
558
+ </li>
559
+ );
560
+ })}
561
+ </ul>
562
+ );
404
563
  }
405
564
 
406
565
  function EditedFilesCard({
407
566
  files,
408
567
  totalAdditions,
409
568
  totalDeletions,
569
+ compact = false,
410
570
  onOpen,
571
+ onUndo,
411
572
  openingPath,
412
573
  openError,
413
574
  allowOpen,
414
575
  }: EditedFilesCardProps) {
415
576
  const [expanded, setExpanded] = useState(false);
416
577
 
578
+ if (compact) {
579
+ const label =
580
+ files.length === 1
581
+ ? t('1 helper file change')
582
+ : t('{count} helper file changes', { count: files.length });
583
+
584
+ return (
585
+ <div data-edited-files-card="" data-compact="true" className="pt-0.5">
586
+ <button
587
+ type="button"
588
+ aria-expanded={expanded}
589
+ onClick={() => setExpanded(!expanded)}
590
+ className="inline-flex max-w-full items-center gap-1.5 rounded px-1 py-0.5 text-left text-[11px] text-agent-muted-foreground transition-colors hover:text-agent-foreground cursor-pointer"
591
+ >
592
+ {expanded ? (
593
+ <LuChevronDown className="h-3 w-3 shrink-0" />
594
+ ) : (
595
+ <LuChevronRight className="h-3 w-3 shrink-0" />
596
+ )}
597
+ <span className="truncate">{label}</span>
598
+ {(totalAdditions > 0 || totalDeletions > 0) && (
599
+ <span className="inline-flex shrink-0 items-center gap-1 font-mono text-[11px] tabular-nums">
600
+ <span className="font-medium text-emerald-600 dark:text-emerald-400">
601
+ +{totalAdditions}
602
+ </span>
603
+ <span>-{totalDeletions}</span>
604
+ </span>
605
+ )}
606
+ </button>
607
+
608
+ {expanded && (
609
+ <EditedFilesList
610
+ files={files}
611
+ compact
612
+ onOpen={onOpen}
613
+ openingPath={openingPath}
614
+ openError={openError}
615
+ allowOpen={allowOpen}
616
+ />
617
+ )}
618
+ </div>
619
+ );
620
+ }
621
+
417
622
  return (
418
623
  <div
419
624
  className="rounded-agent-lg border border-agent-border bg-agent-canvas shadow-xs overflow-hidden"
420
625
  data-edited-files-card=""
421
626
  >
422
- {/* 头部标题与统计(默认折叠,点击标题栏或 Review 展开) */}
627
+ {/* 头部标题与统计(默认折叠,点击标题栏或查看详情展开) */}
423
628
  <div
424
629
  className="flex items-center justify-between px-3 py-2 cursor-pointer hover:bg-agent-foreground/[0.03] transition-colors select-none"
425
630
  onClick={() => setExpanded(!expanded)}
@@ -443,17 +648,19 @@ function EditedFilesCard({
443
648
  </div>
444
649
  </div>
445
650
 
446
- {/* 右侧动作按钮:Undo 与 查看详情 */}
651
+ {/* 右侧动作按钮:仅在提供真实回滚回调时渲染 Undo */}
447
652
  <div className="flex items-center gap-1.5 shrink-0" onClick={(e) => e.stopPropagation()}>
448
- <button
449
- type="button"
450
- disabled
451
- title={t('Undo file changes from this turn')}
452
- className="flex items-center gap-1 px-1.5 py-0.5 text-xs text-agent-muted-foreground/50 cursor-default"
453
- >
454
- <span>{t('Undo')}</span>
455
- <LuUndo2 className="h-3 w-3" />
456
- </button>
653
+ {onUndo ? (
654
+ <button
655
+ type="button"
656
+ onClick={onUndo}
657
+ title={t('Undo file changes from this turn')}
658
+ className="flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-agent-muted-foreground hover:bg-agent-foreground/5 hover:text-agent-foreground transition-colors"
659
+ >
660
+ <span>{t('Undo')}</span>
661
+ <LuUndo2 className="h-3 w-3" />
662
+ </button>
663
+ ) : null}
457
664
  <button
458
665
  type="button"
459
666
  aria-expanded={expanded}
@@ -467,63 +674,14 @@ function EditedFilesCard({
467
674
 
468
675
  {/* 文件列表 */}
469
676
  {expanded && (
470
- <ul className="max-h-60 overflow-y-auto border-t border-agent-border/60 divide-y divide-agent-border/40 py-0.5">
471
- {files.map((file) => {
472
- const displayPath = formatIntermediateDisplayPath(file.path);
473
- const size = formatFileSize(file.size);
474
- const busy = openingPath === file.path;
475
- const error = openError?.path === file.path ? openError.message : null;
476
- const hasDiffStats =
477
- typeof file.additions === 'number' || typeof file.deletions === 'number';
478
-
479
- return (
480
- <li key={file.path}>
481
- <button
482
- type="button"
483
- onClick={() => onOpen(file)}
484
- disabled={!allowOpen || openingPath !== null}
485
- title={file.path}
486
- className={`group flex w-full items-center justify-between px-3 py-1.5 text-left text-xs transition-colors ${
487
- allowOpen
488
- ? 'hover:bg-agent-foreground/5 cursor-pointer disabled:cursor-wait'
489
- : 'cursor-default'
490
- }`}
491
- data-turn-file=""
492
- data-kind={file.kind}
493
- >
494
- <span className="min-w-0 flex-1 truncate text-xs text-agent-foreground/90 group-hover:text-agent-foreground">
495
- {displayPath}
496
- </span>
497
-
498
- <span className="shrink-0 pl-2">
499
- {busy ? (
500
- <LuLoaderCircle className="h-3.5 w-3.5 animate-spin text-agent-muted-foreground" />
501
- ) : hasDiffStats ? (
502
- <span className="flex items-center gap-1.5 font-mono text-[11px] tabular-nums">
503
- <span className="font-medium text-emerald-600 dark:text-emerald-400">
504
- +{file.additions ?? 0}
505
- </span>
506
- <span className="text-agent-muted-foreground">
507
- -{file.deletions ?? 0}
508
- </span>
509
- </span>
510
- ) : size ? (
511
- <span className="text-[11px] text-agent-muted-foreground tabular-nums">
512
- {size}
513
- </span>
514
- ) : null}
515
- </span>
516
- </button>
517
-
518
- {error && (
519
- <div className="px-3 pb-1 text-[11px] text-agent-destructive" role="status">
520
- {t('Could not open: {error}', { error })}
521
- </div>
522
- )}
523
- </li>
524
- );
525
- })}
526
- </ul>
677
+ <EditedFilesList
678
+ files={files}
679
+ compact={false}
680
+ onOpen={onOpen}
681
+ openingPath={openingPath}
682
+ openError={openError}
683
+ allowOpen={allowOpen}
684
+ />
527
685
  )}
528
686
  </div>
529
687
  );
@@ -137,6 +137,9 @@ export function TurnProcessGroup({
137
137
  isToolRunning={isActionRunning}
138
138
  isInteractiveRunningTool={isInteractiveRunningAction}
139
139
  isTrailingHousekeepingTool={isTerminalHousekeepingAction}
140
+ isBackgroundHousekeepingTool={(action) =>
141
+ action.tool === 'todo_write' || action.tool === 'update_plan'
142
+ }
140
143
  classifyFoldableRoundAction={classifyFoldableRoundAction}
141
144
  renderRoundFoldPreview={(actions, { expand }) => (
142
145
  <ImageRoundFoldStrip actions={actions} chatId={chatId} onExpand={expand} />
@@ -400,6 +400,7 @@ function selectFeaturedToolIndex<TTool>(
400
400
  actions: readonly TTool[],
401
401
  isToolRunning?: (action: TTool) => boolean,
402
402
  isInteractiveRunningTool?: (action: TTool) => boolean,
403
+ isBackgroundHousekeepingTool?: (action: TTool) => boolean,
403
404
  ): number {
404
405
  if (isInteractiveRunningTool) {
405
406
  for (let i = actions.length - 1; i >= 0; i -= 1) {
@@ -411,6 +412,11 @@ function selectFeaturedToolIndex<TTool>(
411
412
  if (isToolRunning(actions[i]!)) return i;
412
413
  }
413
414
  }
415
+ if (isBackgroundHousekeepingTool && actions.length > 1) {
416
+ for (let i = actions.length - 1; i >= 0; i -= 1) {
417
+ if (!isBackgroundHousekeepingTool(actions[i]!)) return i;
418
+ }
419
+ }
414
420
  return actions.length - 1;
415
421
  }
416
422
 
@@ -430,6 +436,7 @@ function partitionNonTextTail<TTool>(
430
436
  options?: {
431
437
  isToolRunning?: (action: TTool) => boolean;
432
438
  isInteractiveRunningTool?: (action: TTool) => boolean;
439
+ isBackgroundHousekeepingTool?: (action: TTool) => boolean;
433
440
  },
434
441
  ): ProcessStageSegment<TTool>[] {
435
442
  if (tail.length === 0) return [];
@@ -456,6 +463,7 @@ function partitionNonTextTail<TTool>(
456
463
  lastEntry.block.actions,
457
464
  options?.isToolRunning,
458
465
  options?.isInteractiveRunningTool,
466
+ options?.isBackgroundHousekeepingTool,
459
467
  );
460
468
  const featured = lastEntry.block.actions[featuredIdx]!;
461
469
  const otherActions = lastEntry.block.actions.filter((_, idx) => idx !== featuredIdx);
@@ -502,6 +510,7 @@ export function partitionProcessSegments<TTool>(
502
510
  options?: {
503
511
  isToolRunning?: (action: TTool) => boolean;
504
512
  isInteractiveRunningTool?: (action: TTool) => boolean;
513
+ isBackgroundHousekeepingTool?: (action: TTool) => boolean;
505
514
  },
506
515
  ): ProcessStageSegment<TTool>[] {
507
516
  if (visibleProcess.length === 0) return [];
@@ -558,6 +567,8 @@ export interface TurnProcessTimelineProps<TTool = unknown> {
558
567
  isInteractiveRunningTool?: (action: TTool) => boolean;
559
568
  /** Predicate identifying terminal housekeeping tools (`todo_write` all done, `present_files`) after final text. */
560
569
  isTrailingHousekeepingTool?: (action: TTool) => boolean;
570
+ /** Predicate identifying progress bookkeeping tools (`todo_write`) deprioritized behind substantive sibling tools in a settled multi-tool batch. */
571
+ isBackgroundHousekeepingTool?: (action: TTool) => boolean;
561
572
  /** Classifier folding consecutive settled routine or `view_image` rounds into a single expandable row. */
562
573
  classifyFoldableRoundAction?: (action: TTool) => FoldableRoundActionKind | null;
563
574
  /** Optional inline preview rendered underneath a collapsed `round-fold` summary (e.g. viewed image strip). */
@@ -596,6 +607,7 @@ export function TurnProcessTimeline<TTool = unknown>({
596
607
  isToolRunning,
597
608
  isInteractiveRunningTool,
598
609
  isTrailingHousekeepingTool,
610
+ isBackgroundHousekeepingTool,
599
611
  classifyFoldableRoundAction,
600
612
  renderRoundFoldPreview,
601
613
  compactHiddenProcess = true,
@@ -697,6 +709,7 @@ export function TurnProcessTimeline<TTool = unknown>({
697
709
  ? partitionProcessSegments(visibleProcess, {
698
710
  isToolRunning,
699
711
  isInteractiveRunningTool,
712
+ isBackgroundHousekeepingTool,
700
713
  })
701
714
  : null;
702
715
 
@@ -24,6 +24,8 @@ interface UserMessageProps {
24
24
  isGrouped?: boolean;
25
25
  /** Whether this message is an appended follow-up inside the group (not the first one). */
26
26
  isAppended?: boolean;
27
+ /** Whether a sticky turn attachment (e.g. TurnTodoStrip) is seamlessly joined below this card. */
28
+ attachedBottom?: boolean;
27
29
  /** Edit and resubmit callback (offered on the latest user message). */
28
30
  onEdit?: (nextContent: string) => void | Promise<void>;
29
31
  }
@@ -34,6 +36,7 @@ export function UserMessage({
34
36
  chats = [],
35
37
  isGrouped = false,
36
38
  isAppended = false,
39
+ attachedBottom = false,
37
40
  onEdit,
38
41
  }: UserMessageProps) {
39
42
  const content = message.content || '';
@@ -304,7 +307,11 @@ export function UserMessage({
304
307
  transition={{ duration: 0.3 }}
305
308
  >
306
309
  <div className="flex justify-start">
307
- <div className="mx-auto w-full max-w-[var(--chat-input-box-width)] rounded-agent-lg border border-agent-border/80 bg-agent-muted/70 px-3 py-2 text-xs text-agent-foreground">
310
+ <div
311
+ className={`mx-auto w-full max-w-[var(--chat-input-box-width)] ${
312
+ attachedBottom ? 'rounded-t-agent-lg rounded-b-none' : 'rounded-agent-lg'
313
+ } border border-agent-border/80 bg-agent-muted/70 px-3 py-2 text-xs text-agent-foreground`}
314
+ >
308
315
  {renderMessageBody()}
309
316
  </div>
310
317
  </div>
@@ -26,3 +26,16 @@ export function stripNextStepsTags(text: string): string {
26
26
  out = out.replace(/\[\/?next_steps\]/gi, '');
27
27
  return stripIncompleteTrailingTag(out);
28
28
  }
29
+
30
+ const UNCLOSED_TAIL_BLOCK_RE = /\[next_steps\][\s\S]*$/i;
31
+
32
+ /**
33
+ * 当底部已渲染可点击追问胶囊(或正在流式生成尾部回合)时,
34
+ * 从正文中整块剥离 `[next_steps]...[/next_steps]`,避免正文列表与胶囊重复。
35
+ */
36
+ export function omitNextStepsBlocks(text: string): string {
37
+ let out = (text ?? '').replace(COMPLETE_BLOCK_RE, '');
38
+ out = out.replace(UNCLOSED_TAIL_BLOCK_RE, '');
39
+ out = out.replace(/\[\/?next_steps\]/gi, '');
40
+ return stripIncompleteTrailingTag(out).trimEnd();
41
+ }