@steerable/agent-shell-web 0.12.4 → 0.12.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.
- package/package.json +4 -4
- package/src/AppShell.tsx +14 -2
- package/src/components/chat/TurnProcessGroup.tsx +55 -412
- package/src/components/chat/TurnProcessTimeline.tsx +374 -0
- package/src/components/chat/process-status.ts +5 -3
- package/src/components/chat/turn-timeline.ts +47 -11
- package/src/fixtures/browser-dev-data.json +117 -199
- package/src/lib/browser-dev-host-mock.ts +873 -338
- package/src/lib/demo-playbook.ts +766 -0
- package/src/pages/AgentPage.tsx +128 -67
- package/vite.base.js +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steerable/agent-shell-web",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Steerable framework — product-neutral renderer SPA source for @steerable/agent-shell (React + Vite). Consumed by product web entry points via the `@/` alias (anchored at this package's src/) and the createProductViteConfig factory. Published as a source package (src/), plus the compiled vite.base config factory (vite.base.js + .d.ts) for Node-side config loading.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"react-router-dom": "^6.30.0",
|
|
46
46
|
"rehype-raw": "^7.0.0",
|
|
47
47
|
"remark-gfm": "^4.0.1",
|
|
48
|
-
"@steerable/agent-protocol": "0.12.
|
|
49
|
-
"@steerable/agent-ui": "0.12.
|
|
48
|
+
"@steerable/agent-protocol": "0.12.6",
|
|
49
|
+
"@steerable/agent-ui": "0.12.6"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@tailwindcss/vite": "^4.3.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"typescript": "^5.8.3",
|
|
60
60
|
"vite": "^5.4.21",
|
|
61
61
|
"vitest": "^3.2.4",
|
|
62
|
-
"@steerable/pack-sdk": "0.12.
|
|
62
|
+
"@steerable/pack-sdk": "0.12.6"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"gen": "echo agent-shell-web",
|
package/src/AppShell.tsx
CHANGED
|
@@ -11,8 +11,20 @@ export function AppShell() {
|
|
|
11
11
|
<Outlet />
|
|
12
12
|
</main>
|
|
13
13
|
{isDemoMode() ? (
|
|
14
|
-
<div className="border-t border-agent-border bg-agent-muted px-3 py-1 text-xs text-agent-muted-foreground">
|
|
15
|
-
|
|
14
|
+
<div className="flex flex-wrap items-center justify-between gap-2 border-t border-agent-border bg-agent-muted px-3 py-1 text-xs text-agent-muted-foreground">
|
|
15
|
+
<span>
|
|
16
|
+
Demo · interactive CoreLoop & sandbox playbook (no live model — run{' '}
|
|
17
|
+
<code className="rounded bg-agent-canvas px-1 py-0.5 font-mono text-[11px] text-agent-foreground">
|
|
18
|
+
steerable-cli login
|
|
19
|
+
</code>{' '}
|
|
20
|
+
locally for live LLMs)
|
|
21
|
+
</span>
|
|
22
|
+
<a
|
|
23
|
+
href="../"
|
|
24
|
+
className="font-medium text-agent-foreground underline underline-offset-2 hover:opacity-80"
|
|
25
|
+
>
|
|
26
|
+
← Docs
|
|
27
|
+
</a>
|
|
16
28
|
</div>
|
|
17
29
|
) : (
|
|
18
30
|
!hasHostBridge() && (
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LuChevronDown, LuChevronRight } from 'react-icons/lu';
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
3
2
|
import type { LocalChat, LocalChatAgent } from '@/lib/local-api';
|
|
4
|
-
import {
|
|
5
|
-
useThinkingDisplay,
|
|
6
|
-
type ThinkingDisplayMode,
|
|
7
|
-
} from '@/lib/show-thinking-content';
|
|
3
|
+
import type { ThinkingDisplayMode } from '@/lib/show-thinking-content';
|
|
8
4
|
import { Markdown } from './Markdown';
|
|
9
5
|
import { ToolsFlow } from './ExecutedActionsCard';
|
|
10
6
|
import type { InspectTaskInput } from './executed-actions-model';
|
|
@@ -12,12 +8,12 @@ import type { ChildInfo } from './OrchestrationChildrenCard';
|
|
|
12
8
|
import { OrchestrationChildrenCard } from './OrchestrationChildrenCard';
|
|
13
9
|
import { TurnUsageLine } from './TurnUsageLine';
|
|
14
10
|
import type { TurnUsage } from './turn-usage';
|
|
11
|
+
import type { TurnBlock } from './turn-timeline';
|
|
15
12
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} from './
|
|
20
|
-
import { splitTurnProcess, type TurnBlock } from './turn-timeline';
|
|
13
|
+
THINKING_PEEK_HEIGHT,
|
|
14
|
+
THINKING_PEEK_LINES,
|
|
15
|
+
TurnProcessTimeline,
|
|
16
|
+
} from './TurnProcessTimeline';
|
|
21
17
|
|
|
22
18
|
/**
|
|
23
19
|
* Codex / DeepSeek-style turn process. Each LLM round keeps three surfaces
|
|
@@ -29,289 +25,7 @@ import { splitTurnProcess, type TurnBlock } from './turn-timeline';
|
|
|
29
25
|
* only the live round stays open. Tools and the work row stay independent.
|
|
30
26
|
*/
|
|
31
27
|
|
|
32
|
-
export
|
|
33
|
-
/** 思考正文行高(`leading-snug`)。 */
|
|
34
|
-
const THINKING_LINE_HEIGHT = 1.375;
|
|
35
|
-
/**
|
|
36
|
-
* 最多 5 行:用 max-height,短思考按内容收,不撑空。
|
|
37
|
-
* 不用 CSS `lh`:Windows Electron 在中文字体尚未就绪时 `lh` 会算成 0,
|
|
38
|
-
* 思考 peek 整块消失,字体加载后又把主列表高度撑跳。
|
|
39
|
-
*/
|
|
40
|
-
export const THINKING_PEEK_HEIGHT = `${THINKING_PEEK_LINES * THINKING_LINE_HEIGHT}em`;
|
|
41
|
-
|
|
42
|
-
const THINKING_TEXT =
|
|
43
|
-
'border-l border-agent-border/70 pl-2 text-xs leading-snug text-agent-muted-foreground';
|
|
44
|
-
|
|
45
|
-
function splitThinkingParagraphs(content: string): string[] {
|
|
46
|
-
return content.split(/\n{2,}/).filter((part) => part.length > 0);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function ReasoningBody({
|
|
50
|
-
content,
|
|
51
|
-
showCursor,
|
|
52
|
-
}: {
|
|
53
|
-
content: string;
|
|
54
|
-
showCursor?: boolean;
|
|
55
|
-
}) {
|
|
56
|
-
const parts = splitThinkingParagraphs(content);
|
|
57
|
-
return (
|
|
58
|
-
<>
|
|
59
|
-
<div className="space-y-1">
|
|
60
|
-
{parts.map((part, index) => (
|
|
61
|
-
<div key={index} className="whitespace-pre-wrap break-words">
|
|
62
|
-
{part}
|
|
63
|
-
</div>
|
|
64
|
-
))}
|
|
65
|
-
</div>
|
|
66
|
-
{showCursor ? (
|
|
67
|
-
<span className="ml-0.5 inline-block h-3 w-[2px] animate-agent-cursor-blink bg-agent-muted-foreground/60 align-text-bottom" />
|
|
68
|
-
) : null}
|
|
69
|
-
</>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function resolveThinkingDisplay(
|
|
74
|
-
preference: ThinkingDisplayMode,
|
|
75
|
-
thinkingDisplay?: ThinkingDisplayMode,
|
|
76
|
-
showThinkingContent?: boolean,
|
|
77
|
-
): ThinkingDisplayMode {
|
|
78
|
-
if (thinkingDisplay) return thinkingDisplay;
|
|
79
|
-
if (showThinkingContent === true) return 'full';
|
|
80
|
-
if (showThinkingContent === false) return 'peek';
|
|
81
|
-
return preference;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function useLiveNow(enabled: boolean): number {
|
|
85
|
-
const [now, setNow] = useState(() => Date.now());
|
|
86
|
-
useEffect(() => {
|
|
87
|
-
if (!enabled) return;
|
|
88
|
-
setNow(Date.now());
|
|
89
|
-
const id = window.setInterval(() => setNow(Date.now()), 1000);
|
|
90
|
-
return () => window.clearInterval(id);
|
|
91
|
-
}, [enabled]);
|
|
92
|
-
return now;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function ReasoningPane({
|
|
96
|
-
content,
|
|
97
|
-
showCursor,
|
|
98
|
-
clipped,
|
|
99
|
-
}: {
|
|
100
|
-
content: string;
|
|
101
|
-
showCursor?: boolean;
|
|
102
|
-
clipped?: boolean;
|
|
103
|
-
}) {
|
|
104
|
-
const scrollerRef = useRef<HTMLDivElement>(null);
|
|
105
|
-
useLayoutEffect(() => {
|
|
106
|
-
if (!clipped) return;
|
|
107
|
-
const el = scrollerRef.current;
|
|
108
|
-
if (!el) return;
|
|
109
|
-
el.scrollTop = el.scrollHeight;
|
|
110
|
-
}, [clipped, content]);
|
|
111
|
-
const body = (
|
|
112
|
-
<div className={THINKING_TEXT}>
|
|
113
|
-
<ReasoningBody content={content} showCursor={showCursor} />
|
|
114
|
-
</div>
|
|
115
|
-
);
|
|
116
|
-
if (!clipped) return body;
|
|
117
|
-
return (
|
|
118
|
-
<div
|
|
119
|
-
ref={scrollerRef}
|
|
120
|
-
className="overflow-y-auto overflow-anchor-none [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden"
|
|
121
|
-
style={{ maxHeight: THINKING_PEEK_HEIGHT }}
|
|
122
|
-
data-thinking-peek=""
|
|
123
|
-
data-testid="thinking-peek"
|
|
124
|
-
data-peek-lines={THINKING_PEEK_LINES}
|
|
125
|
-
>
|
|
126
|
-
{body}
|
|
127
|
-
</div>
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function ThinkingFold({
|
|
132
|
-
content,
|
|
133
|
-
label,
|
|
134
|
-
showCursor,
|
|
135
|
-
mode,
|
|
136
|
-
defaultOpen,
|
|
137
|
-
}: {
|
|
138
|
-
content: string;
|
|
139
|
-
label: string;
|
|
140
|
-
showCursor?: boolean;
|
|
141
|
-
mode: ThinkingDisplayMode;
|
|
142
|
-
defaultOpen: boolean;
|
|
143
|
-
}) {
|
|
144
|
-
const [open, setOpen] = useState(defaultOpen);
|
|
145
|
-
useEffect(() => {
|
|
146
|
-
setOpen(defaultOpen);
|
|
147
|
-
}, [defaultOpen]);
|
|
148
|
-
|
|
149
|
-
if (mode === 'hidden') return null;
|
|
150
|
-
|
|
151
|
-
return (
|
|
152
|
-
<div className="space-y-1" data-testid="turn-thinking">
|
|
153
|
-
<button
|
|
154
|
-
type="button"
|
|
155
|
-
onClick={() => setOpen((value) => !value)}
|
|
156
|
-
className="flex min-w-0 items-center gap-1 py-0.5 text-left text-[11px] text-agent-muted-foreground/80 transition-colors hover:text-agent-foreground"
|
|
157
|
-
aria-expanded={open}
|
|
158
|
-
data-thinking-fold=""
|
|
159
|
-
>
|
|
160
|
-
<span className="truncate">{label}</span>
|
|
161
|
-
{open ? (
|
|
162
|
-
<LuChevronDown className="h-3 w-3 shrink-0" />
|
|
163
|
-
) : (
|
|
164
|
-
<LuChevronRight className="h-3 w-3 shrink-0" />
|
|
165
|
-
)}
|
|
166
|
-
</button>
|
|
167
|
-
{open ? (
|
|
168
|
-
<ReasoningPane
|
|
169
|
-
content={content}
|
|
170
|
-
showCursor={showCursor}
|
|
171
|
-
clipped={mode === 'peek'}
|
|
172
|
-
/>
|
|
173
|
-
) : null}
|
|
174
|
-
</div>
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function ProcessBlockItems({
|
|
179
|
-
blocks,
|
|
180
|
-
isStreaming,
|
|
181
|
-
agents,
|
|
182
|
-
chats,
|
|
183
|
-
chatId,
|
|
184
|
-
onInspectTask,
|
|
185
|
-
orchestrationChildren,
|
|
186
|
-
thinkingDisplay,
|
|
187
|
-
keepFinishedThinkingOpen = false,
|
|
188
|
-
thinkingElapsedByIndex,
|
|
189
|
-
}: {
|
|
190
|
-
blocks: TurnBlock[];
|
|
191
|
-
isStreaming: boolean;
|
|
192
|
-
agents: LocalChatAgent[];
|
|
193
|
-
chats: LocalChat[];
|
|
194
|
-
chatId?: string | null;
|
|
195
|
-
onInspectTask?: (task: InspectTaskInput) => void;
|
|
196
|
-
orchestrationChildren?: ChildInfo[];
|
|
197
|
-
thinkingDisplay: ThinkingDisplayMode;
|
|
198
|
-
keepFinishedThinkingOpen?: boolean;
|
|
199
|
-
thinkingElapsedByIndex?: Array<number | undefined>;
|
|
200
|
-
}) {
|
|
201
|
-
const lastIndex = blocks.length - 1;
|
|
202
|
-
return (
|
|
203
|
-
<>
|
|
204
|
-
{blocks.map((block, index) => {
|
|
205
|
-
const isLast = index === lastIndex;
|
|
206
|
-
if (block.type === 'reasoning') {
|
|
207
|
-
const isLive = isStreaming && isLast;
|
|
208
|
-
const elapsedMs =
|
|
209
|
-
thinkingElapsedByIndex?.[index]
|
|
210
|
-
?? block.durationMs
|
|
211
|
-
?? (isLive ? undefined : estimateReasoningDurationMs(block.content));
|
|
212
|
-
return (
|
|
213
|
-
<ThinkingFold
|
|
214
|
-
key={`reasoning-${index}`}
|
|
215
|
-
content={block.content}
|
|
216
|
-
label={thinkingFoldLabel({
|
|
217
|
-
content: block.content,
|
|
218
|
-
isLive,
|
|
219
|
-
elapsedMs,
|
|
220
|
-
})}
|
|
221
|
-
showCursor={isLive}
|
|
222
|
-
mode={thinkingDisplay}
|
|
223
|
-
defaultOpen={isLive || keepFinishedThinkingOpen}
|
|
224
|
-
/>
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
if (block.type === 'tools') {
|
|
228
|
-
return (
|
|
229
|
-
<div key={`tools-${index}`} data-testid="turn-tools">
|
|
230
|
-
<ToolsFlow
|
|
231
|
-
actions={block.actions}
|
|
232
|
-
compact
|
|
233
|
-
agents={agents}
|
|
234
|
-
chatId={chatId}
|
|
235
|
-
onInspectTask={onInspectTask}
|
|
236
|
-
orchestrationChildren={orchestrationChildren}
|
|
237
|
-
/>
|
|
238
|
-
</div>
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
return (
|
|
242
|
-
<div key={`text-${index}`} data-testid="turn-response">
|
|
243
|
-
<div>
|
|
244
|
-
<div className="markdown-content text-xs leading-relaxed text-agent-foreground">
|
|
245
|
-
<Markdown agents={agents} chats={chats} chatId={chatId}>{block.content}</Markdown>
|
|
246
|
-
</div>
|
|
247
|
-
{isStreaming && isLast ? (
|
|
248
|
-
<span className="ml-0.5 inline-block h-3.5 w-[3px] animate-agent-cursor-blink bg-agent-foreground/60 align-text-bottom" />
|
|
249
|
-
) : null}
|
|
250
|
-
</div>
|
|
251
|
-
</div>
|
|
252
|
-
);
|
|
253
|
-
})}
|
|
254
|
-
</>
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
function ProcessBlocks({
|
|
259
|
-
blocks,
|
|
260
|
-
isStreaming,
|
|
261
|
-
agents,
|
|
262
|
-
chats,
|
|
263
|
-
chatId,
|
|
264
|
-
onInspectTask,
|
|
265
|
-
orchestrationChildren,
|
|
266
|
-
thinkingDisplay,
|
|
267
|
-
keepFinishedThinkingOpen,
|
|
268
|
-
thinkingElapsedByIndex,
|
|
269
|
-
onContinueChild,
|
|
270
|
-
onStopChild,
|
|
271
|
-
turnUsage,
|
|
272
|
-
}: {
|
|
273
|
-
blocks: TurnBlock[];
|
|
274
|
-
isStreaming: boolean;
|
|
275
|
-
agents: LocalChatAgent[];
|
|
276
|
-
chats: LocalChat[];
|
|
277
|
-
chatId?: string | null;
|
|
278
|
-
onInspectTask?: (task: InspectTaskInput) => void;
|
|
279
|
-
orchestrationChildren?: ChildInfo[];
|
|
280
|
-
thinkingDisplay: ThinkingDisplayMode;
|
|
281
|
-
keepFinishedThinkingOpen: boolean;
|
|
282
|
-
thinkingElapsedByIndex?: Array<number | undefined>;
|
|
283
|
-
onContinueChild?: (childId: string, recordId: string) => void;
|
|
284
|
-
onStopChild?: (childId: string) => void;
|
|
285
|
-
/** R6:本回合账单,画在子代理看板下方。 */
|
|
286
|
-
turnUsage?: TurnUsage;
|
|
287
|
-
}) {
|
|
288
|
-
return (
|
|
289
|
-
<div className="space-y-1.5">
|
|
290
|
-
<ProcessBlockItems
|
|
291
|
-
blocks={blocks}
|
|
292
|
-
isStreaming={isStreaming}
|
|
293
|
-
agents={agents}
|
|
294
|
-
chats={chats}
|
|
295
|
-
chatId={chatId}
|
|
296
|
-
onInspectTask={onInspectTask}
|
|
297
|
-
orchestrationChildren={orchestrationChildren}
|
|
298
|
-
thinkingDisplay={thinkingDisplay}
|
|
299
|
-
keepFinishedThinkingOpen={keepFinishedThinkingOpen}
|
|
300
|
-
thinkingElapsedByIndex={thinkingElapsedByIndex}
|
|
301
|
-
/>
|
|
302
|
-
{/* R7 子代理看板:挂在过程块之后、正文之前。≥2 个子代理才渲染,
|
|
303
|
-
单次委派已在工具行里有同一条进度。 */}
|
|
304
|
-
<OrchestrationChildrenCard
|
|
305
|
-
children={orchestrationChildren ?? []}
|
|
306
|
-
agents={agents}
|
|
307
|
-
onContinue={onContinueChild}
|
|
308
|
-
onStop={onStopChild}
|
|
309
|
-
/>
|
|
310
|
-
{/* R6 回合账单:紧随看板,读的是「父级 + 子代理」的整份数字。 */}
|
|
311
|
-
<TurnUsageLine usage={turnUsage} />
|
|
312
|
-
</div>
|
|
313
|
-
);
|
|
314
|
-
}
|
|
28
|
+
export { THINKING_PEEK_HEIGHT, THINKING_PEEK_LINES };
|
|
315
29
|
|
|
316
30
|
export function TurnProcessGroup({
|
|
317
31
|
blocks,
|
|
@@ -328,8 +42,8 @@ export function TurnProcessGroup({
|
|
|
328
42
|
streamingHint,
|
|
329
43
|
startedAtMs,
|
|
330
44
|
durationMs,
|
|
331
|
-
thinkingDisplay
|
|
332
|
-
showThinkingContent
|
|
45
|
+
thinkingDisplay,
|
|
46
|
+
showThinkingContent,
|
|
333
47
|
collapseWhenFinished = true,
|
|
334
48
|
renderAnswer,
|
|
335
49
|
}: {
|
|
@@ -368,129 +82,58 @@ export function TurnProcessGroup({
|
|
|
368
82
|
collapseWhenFinished?: boolean;
|
|
369
83
|
renderAnswer: (block: Extract<TurnBlock, { type: 'text' }>, isLast: boolean) => ReactNode;
|
|
370
84
|
}) {
|
|
371
|
-
const
|
|
372
|
-
const
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
const answerLenRef = useRef(answer.length);
|
|
388
|
-
answerLenRef.current = answer.length;
|
|
389
|
-
const now = useLiveNow(isStreaming);
|
|
390
|
-
const streamClockRef = useRef<number | undefined>(undefined);
|
|
391
|
-
if (isStreaming) {
|
|
392
|
-
streamClockRef.current ??= startedAtMs ?? now;
|
|
393
|
-
} else {
|
|
394
|
-
streamClockRef.current = undefined;
|
|
395
|
-
}
|
|
396
|
-
const liveElapsedMs = isStreaming
|
|
397
|
-
? Math.max(0, now - (startedAtMs ?? streamClockRef.current ?? now))
|
|
398
|
-
: undefined;
|
|
399
|
-
const lastLiveElapsedRef = useRef<number | undefined>(undefined);
|
|
400
|
-
if (isStreaming && liveElapsedMs != null) {
|
|
401
|
-
lastLiveElapsedRef.current = liveElapsedMs;
|
|
402
|
-
}
|
|
403
|
-
const elapsedMs = isStreaming
|
|
404
|
-
? liveElapsedMs
|
|
405
|
-
: durationMs ?? lastLiveElapsedRef.current;
|
|
406
|
-
|
|
407
|
-
const lastProcess = process[process.length - 1];
|
|
408
|
-
const lastIsReasoning = lastProcess?.type === 'reasoning';
|
|
409
|
-
const reasoningDurationsRef = useRef<number[]>([]);
|
|
410
|
-
const reasoningClockRef = useRef<{ index: number; startedAt: number } | null>(null);
|
|
411
|
-
if (isStreaming && lastIsReasoning) {
|
|
412
|
-
const index = process.length - 1;
|
|
413
|
-
if (reasoningClockRef.current?.index !== index) {
|
|
414
|
-
const prev = reasoningClockRef.current;
|
|
415
|
-
if (prev) {
|
|
416
|
-
reasoningDurationsRef.current[prev.index] = Math.max(0, now - prev.startedAt);
|
|
417
|
-
}
|
|
418
|
-
reasoningClockRef.current = { index, startedAt: now };
|
|
419
|
-
}
|
|
420
|
-
} else if (reasoningClockRef.current) {
|
|
421
|
-
const prev = reasoningClockRef.current;
|
|
422
|
-
reasoningDurationsRef.current[prev.index] = Math.max(0, now - prev.startedAt);
|
|
423
|
-
reasoningClockRef.current = null;
|
|
424
|
-
}
|
|
425
|
-
const thinkingElapsedByIndex = process.map((block, index) => {
|
|
426
|
-
if (block.type !== 'reasoning') return undefined;
|
|
427
|
-
if (
|
|
428
|
-
isStreaming &&
|
|
429
|
-
lastIsReasoning &&
|
|
430
|
-
index === process.length - 1 &&
|
|
431
|
-
reasoningClockRef.current
|
|
432
|
-
) {
|
|
433
|
-
return Math.max(0, now - reasoningClockRef.current.startedAt);
|
|
434
|
-
}
|
|
435
|
-
return reasoningDurationsRef.current[index];
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
if (blocks.length === 0) return <>{emptyFallback}</>;
|
|
439
|
-
|
|
440
|
-
const showToggle = process.length > 0;
|
|
441
|
-
const showProcess = !showToggle || open;
|
|
442
|
-
const showStreamingHint =
|
|
443
|
-
Boolean(streamingHint) && isStreaming && answer.length === 0 && !showToggle;
|
|
85
|
+
const hasChildrenCard = (orchestrationChildren?.length ?? 0) >= 2;
|
|
86
|
+
const processFooter =
|
|
87
|
+
hasChildrenCard || Boolean(turnUsage) ? (
|
|
88
|
+
<>
|
|
89
|
+
{/* R7 子代理看板:挂在过程块之后、正文之前。≥2 个子代理才渲染,
|
|
90
|
+
单次委派已在工具行里有同一条进度。 */}
|
|
91
|
+
<OrchestrationChildrenCard
|
|
92
|
+
children={orchestrationChildren ?? []}
|
|
93
|
+
agents={agents}
|
|
94
|
+
onContinue={onContinueChild}
|
|
95
|
+
onStop={onStopChild}
|
|
96
|
+
/>
|
|
97
|
+
{/* R6 回合账单:紧随看板,读的是「父级 + 子代理」的整份数字。 */}
|
|
98
|
+
<TurnUsageLine usage={turnUsage} />
|
|
99
|
+
</>
|
|
100
|
+
) : undefined;
|
|
444
101
|
|
|
445
102
|
return (
|
|
446
|
-
<
|
|
447
|
-
{
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
elapsedMs,
|
|
462
|
-
})}
|
|
463
|
-
</span>
|
|
464
|
-
{open ? (
|
|
465
|
-
<LuChevronDown className="h-3.5 w-3.5 shrink-0" />
|
|
466
|
-
) : (
|
|
467
|
-
<LuChevronRight className="h-3.5 w-3.5 shrink-0" />
|
|
468
|
-
)}
|
|
469
|
-
</button>
|
|
470
|
-
)}
|
|
471
|
-
{showProcess && (
|
|
472
|
-
<ProcessBlocks
|
|
473
|
-
blocks={process}
|
|
474
|
-
isStreaming={isStreaming && answer.length === 0}
|
|
103
|
+
<TurnProcessTimeline
|
|
104
|
+
blocks={blocks}
|
|
105
|
+
isStreaming={isStreaming}
|
|
106
|
+
startedAtMs={startedAtMs}
|
|
107
|
+
durationMs={durationMs}
|
|
108
|
+
thinkingDisplay={thinkingDisplay}
|
|
109
|
+
showThinkingContent={showThinkingContent}
|
|
110
|
+
collapseWhenFinished={collapseWhenFinished}
|
|
111
|
+
emptyFallback={emptyFallback}
|
|
112
|
+
streamingHint={streamingHint}
|
|
113
|
+
processFooter={processFooter}
|
|
114
|
+
renderTools={(actions) => (
|
|
115
|
+
<ToolsFlow
|
|
116
|
+
actions={actions}
|
|
117
|
+
compact
|
|
475
118
|
agents={agents}
|
|
476
|
-
chats={chats}
|
|
477
119
|
chatId={chatId}
|
|
478
120
|
onInspectTask={onInspectTask}
|
|
479
121
|
orchestrationChildren={orchestrationChildren}
|
|
480
|
-
thinkingDisplay={thinkingDisplay}
|
|
481
|
-
keepFinishedThinkingOpen={!collapseWhenFinished}
|
|
482
|
-
thinkingElapsedByIndex={thinkingElapsedByIndex}
|
|
483
|
-
onContinueChild={onContinueChild}
|
|
484
|
-
onStopChild={onStopChild}
|
|
485
|
-
turnUsage={turnUsage}
|
|
486
122
|
/>
|
|
487
123
|
)}
|
|
488
|
-
{
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
124
|
+
renderIntermediateText={(block, isLiveLast) => (
|
|
125
|
+
<div>
|
|
126
|
+
<div className="markdown-content text-xs leading-relaxed text-agent-foreground">
|
|
127
|
+
<Markdown agents={agents} chats={chats} chatId={chatId}>
|
|
128
|
+
{block.content}
|
|
129
|
+
</Markdown>
|
|
130
|
+
</div>
|
|
131
|
+
{isLiveLast ? (
|
|
132
|
+
<span className="ml-0.5 inline-block h-3.5 w-[3px] animate-agent-cursor-blink bg-agent-foreground/60 align-text-bottom" />
|
|
133
|
+
) : null}
|
|
134
|
+
</div>
|
|
135
|
+
)}
|
|
136
|
+
renderAnswer={(block, isLast) => renderAnswer(block, isLast)}
|
|
137
|
+
/>
|
|
495
138
|
);
|
|
496
139
|
}
|