@steerable/agent-shell-web 0.14.2 → 0.14.4
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/components/chat/ApprovalModal.tsx +426 -124
- package/src/components/chat/AssistantMessage.tsx +37 -11
- package/src/components/chat/ChatInput.tsx +172 -71
- package/src/components/chat/ChatProjectBadge.tsx +89 -23
- package/src/components/chat/ContextUsagePill.tsx +73 -21
- package/src/components/chat/ExecPolicyPicker.tsx +2 -2
- package/src/components/chat/ExecutedActionsCard.tsx +886 -180
- package/src/components/chat/LocalChatPanel.tsx +31 -5
- package/src/components/chat/Markdown.tsx +109 -11
- package/src/components/chat/ModelPicker.tsx +5 -2
- package/src/components/chat/PlanTodoList.tsx +184 -78
- package/src/components/chat/TurnProcessGroup.tsx +37 -3
- package/src/components/chat/TurnProcessTimeline.tsx +533 -50
- package/src/components/chat/executed-actions-model.ts +1103 -61
- package/src/components/chat/process-status.ts +72 -4
- package/src/components/chat/rich-tool-views.tsx +666 -0
- package/src/components/chat/todo-list-model.ts +15 -0
- package/src/components/chat/turn-timeline.ts +51 -4
- package/src/components/settings/LlmSettingsPanel.tsx +1 -1
- package/src/components/settings/llm-vendors.ts +1 -1
- package/src/lib/browser-dev-host-mock.ts +1 -1
- package/src/lib/chat-mode-store.ts +241 -0
- package/src/pages/AgentPage.tsx +183 -77
- package/src/styles/index.css +10 -25
|
@@ -25,7 +25,7 @@ import type { LlmSpeedSnapshot } from './process-status';
|
|
|
25
25
|
import { ComposerStatusStack } from './composer-status-stack';
|
|
26
26
|
import { t } from '@/i18n';
|
|
27
27
|
import { SessionTodoList } from './SessionTodoList';
|
|
28
|
-
import { resolveLatestSessionTodos } from './todo-list-model';
|
|
28
|
+
import { resolveLatestSessionTodos, shouldShowComposerTodos } from './todo-list-model';
|
|
29
29
|
import { SessionOrchestrationFlow } from './SessionOrchestrationFlow';
|
|
30
30
|
import { resolveLatestSessionOrchestrationFlow } from './orchestration-flow-model';
|
|
31
31
|
import {
|
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
saveChatAttachments,
|
|
36
36
|
type AttachmentFile,
|
|
37
37
|
} from '@/lib/attachments';
|
|
38
|
+
import { parseModeSlashCommand } from '@/lib/chat-mode-store';
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
41
|
* LocalChatPanel — the product chat shell.
|
|
@@ -274,6 +275,18 @@ export function LocalChatPanel({
|
|
|
274
275
|
let trimmed = inputValue.trim();
|
|
275
276
|
if (!trimmed && files.length === 0) return;
|
|
276
277
|
|
|
278
|
+
const slashCmd = trimmed ? parseModeSlashCommand(trimmed) : null;
|
|
279
|
+
let effectiveMode = mode;
|
|
280
|
+
if (slashCmd) {
|
|
281
|
+
effectiveMode = slashCmd.targetMode;
|
|
282
|
+
onModeChange?.(slashCmd.targetMode);
|
|
283
|
+
if (!slashCmd.remainder && files.length === 0) {
|
|
284
|
+
setInputValue('');
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
trimmed = slashCmd.remainder;
|
|
288
|
+
}
|
|
289
|
+
|
|
277
290
|
// 把上传的文件持久化到会话空间:成功项用落盘路径(稳定、可被 agent
|
|
278
291
|
// 读回),失败项若在 Electron 下有源路径则退回源路径;浏览器模式下没有
|
|
279
292
|
// 任何可用路径的失败项会被剔除并上报,绝不把空路径写进正文。
|
|
@@ -313,7 +326,7 @@ export function LocalChatPanel({
|
|
|
313
326
|
// persisted record reflects that an image was attached.
|
|
314
327
|
const imageAttachments = collectImageAttachments(resolvedFiles);
|
|
315
328
|
const metadata = {
|
|
316
|
-
...(
|
|
329
|
+
...(effectiveMode === 'plan' ? { mode: 'plan' as const } : {}),
|
|
317
330
|
...(execPolicy === 'full' ? { execPolicy: 'full' as const } : {}),
|
|
318
331
|
...(selectedAgentId ? { agentId: selectedAgentId } : {}),
|
|
319
332
|
...(mentionedAgentIds.length > 0 ? { mentionedAgentIds } : {}),
|
|
@@ -345,7 +358,17 @@ export function LocalChatPanel({
|
|
|
345
358
|
setFiles(submittedFiles);
|
|
346
359
|
setMentionReferences(submittedMentions);
|
|
347
360
|
}
|
|
348
|
-
}, [
|
|
361
|
+
}, [
|
|
362
|
+
inputValue,
|
|
363
|
+
files,
|
|
364
|
+
mentionReferences,
|
|
365
|
+
onSubmit,
|
|
366
|
+
mode,
|
|
367
|
+
onModeChange,
|
|
368
|
+
execPolicy,
|
|
369
|
+
chatId,
|
|
370
|
+
selectedAgentId,
|
|
371
|
+
]);
|
|
349
372
|
|
|
350
373
|
const sessionTodos = useMemo(
|
|
351
374
|
() =>
|
|
@@ -465,7 +488,8 @@ export function LocalChatPanel({
|
|
|
465
488
|
toolbarExtras={inputToolbarExtras}
|
|
466
489
|
leadingChrome={inputLeadingChrome}
|
|
467
490
|
trailingChrome={
|
|
468
|
-
sessionOrchestrationFlow ||
|
|
491
|
+
sessionOrchestrationFlow ||
|
|
492
|
+
shouldShowComposerTodos(sessionTodos, isStreaming) ? (
|
|
469
493
|
<ComposerStatusStack>
|
|
470
494
|
{sessionOrchestrationFlow ? (
|
|
471
495
|
<SessionOrchestrationFlow
|
|
@@ -474,7 +498,9 @@ export function LocalChatPanel({
|
|
|
474
498
|
onInspectTask={onInspectTask}
|
|
475
499
|
/>
|
|
476
500
|
) : null}
|
|
477
|
-
{sessionTodos ?
|
|
501
|
+
{shouldShowComposerTodos(sessionTodos, isStreaming) ? (
|
|
502
|
+
<SessionTodoList todos={sessionTodos} />
|
|
503
|
+
) : null}
|
|
478
504
|
</ComposerStatusStack>
|
|
479
505
|
) : undefined
|
|
480
506
|
}
|
|
@@ -10,7 +10,14 @@ import {
|
|
|
10
10
|
import ReactMarkdown, { type Components } from 'react-markdown';
|
|
11
11
|
import remarkGfm from 'remark-gfm';
|
|
12
12
|
import rehypeRaw from 'rehype-raw';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
LuBlocks,
|
|
15
|
+
LuCircle,
|
|
16
|
+
LuCircleCheck,
|
|
17
|
+
LuMessageSquare,
|
|
18
|
+
LuPlug,
|
|
19
|
+
} from 'react-icons/lu';
|
|
20
|
+
import { splitMessageWithProposedPlans } from '@steerable/agent-protocol';
|
|
14
21
|
import { t } from '@/i18n';
|
|
15
22
|
import type { LocalChat, LocalChatAgent } from '@/lib/local-api';
|
|
16
23
|
import {
|
|
@@ -446,17 +453,108 @@ export function Markdown({
|
|
|
446
453
|
renderTextWithMentions(node, agents, chats, skills, mcpTools),
|
|
447
454
|
);
|
|
448
455
|
|
|
456
|
+
const cleaned = stripNextStepsTags(children);
|
|
457
|
+
const mayContainPlan =
|
|
458
|
+
cleaned.includes('<proposed_plan>') ||
|
|
459
|
+
cleaned.includes('<PROPOSED_PLAN>') ||
|
|
460
|
+
/(?:^|\n)\s*(?:`{3,}|~{3,})plan\b/i.test(cleaned);
|
|
461
|
+
|
|
462
|
+
if (!mayContainPlan) {
|
|
463
|
+
return (
|
|
464
|
+
<ReactMarkdown
|
|
465
|
+
remarkPlugins={[[remarkGfm, { singleTilde: false }]]}
|
|
466
|
+
rehypePlugins={[rehypeRaw]}
|
|
467
|
+
components={finalComponents}
|
|
468
|
+
>
|
|
469
|
+
{cleaned}
|
|
470
|
+
</ReactMarkdown>
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
const segments = splitMessageWithProposedPlans(cleaned);
|
|
475
|
+
const hasPlanSegment = segments.some((seg) => seg.kind === 'plan');
|
|
476
|
+
if (!hasPlanSegment) {
|
|
477
|
+
return (
|
|
478
|
+
<ReactMarkdown
|
|
479
|
+
remarkPlugins={[[remarkGfm, { singleTilde: false }]]}
|
|
480
|
+
rehypePlugins={[rehypeRaw]}
|
|
481
|
+
components={finalComponents}
|
|
482
|
+
>
|
|
483
|
+
{cleaned}
|
|
484
|
+
</ReactMarkdown>
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
const planBodyComponents: Components = {
|
|
489
|
+
...finalComponents,
|
|
490
|
+
li: (props: ComponentPropsWithoutRef<'li'> & { className?: string }) => {
|
|
491
|
+
const isTaskItem =
|
|
492
|
+
typeof props.className === 'string' &&
|
|
493
|
+
props.className.includes('task-list-item');
|
|
494
|
+
return (
|
|
495
|
+
<li
|
|
496
|
+
{...props}
|
|
497
|
+
className={
|
|
498
|
+
isTaskItem
|
|
499
|
+
? 'flex list-none items-start gap-2 leading-relaxed -ml-4'
|
|
500
|
+
: 'leading-relaxed marker:text-amber-500/70'
|
|
501
|
+
}
|
|
502
|
+
/>
|
|
503
|
+
);
|
|
504
|
+
},
|
|
505
|
+
input: (props: ComponentPropsWithoutRef<'input'>) => {
|
|
506
|
+
if (props.type === 'checkbox') {
|
|
507
|
+
return props.checked ? (
|
|
508
|
+
<LuCircleCheck
|
|
509
|
+
aria-hidden="true"
|
|
510
|
+
className="mt-[3px] h-3.5 w-3.5 shrink-0 text-amber-600 dark:text-amber-400"
|
|
511
|
+
/>
|
|
512
|
+
) : (
|
|
513
|
+
<LuCircle
|
|
514
|
+
aria-hidden="true"
|
|
515
|
+
className="mt-[3px] h-3.5 w-3.5 shrink-0 text-amber-500/65"
|
|
516
|
+
/>
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
return <input {...props} />;
|
|
520
|
+
},
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
let lastPlanIdx = -1;
|
|
524
|
+
for (let i = 0; i < segments.length; i++) {
|
|
525
|
+
if (segments[i]?.kind === 'plan') lastPlanIdx = i;
|
|
526
|
+
}
|
|
527
|
+
|
|
449
528
|
return (
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
529
|
+
<>
|
|
530
|
+
{segments.map((seg, idx) =>
|
|
531
|
+
seg.kind === 'markdown' ? (
|
|
532
|
+
<ReactMarkdown
|
|
533
|
+
key={`md-${idx}`}
|
|
534
|
+
remarkPlugins={[[remarkGfm, { singleTilde: false }]]}
|
|
535
|
+
rehypePlugins={[rehypeRaw]}
|
|
536
|
+
components={finalComponents}
|
|
537
|
+
>
|
|
538
|
+
{seg.content}
|
|
539
|
+
</ReactMarkdown>
|
|
540
|
+
) : (
|
|
541
|
+
<PlanTodoList
|
|
542
|
+
key={`plan-${idx}`}
|
|
543
|
+
plan={seg.plan}
|
|
544
|
+
isLastPlanInMessage={idx === lastPlanIdx}
|
|
545
|
+
renderRichMarkdown={(md) => (
|
|
546
|
+
<ReactMarkdown
|
|
547
|
+
remarkPlugins={[[remarkGfm, { singleTilde: false }]]}
|
|
548
|
+
rehypePlugins={[rehypeRaw]}
|
|
549
|
+
components={planBodyComponents}
|
|
550
|
+
>
|
|
551
|
+
{md}
|
|
552
|
+
</ReactMarkdown>
|
|
553
|
+
)}
|
|
554
|
+
/>
|
|
555
|
+
),
|
|
556
|
+
)}
|
|
557
|
+
</>
|
|
460
558
|
);
|
|
461
559
|
}
|
|
462
560
|
|
|
@@ -122,7 +122,10 @@ export function ModelPicker({
|
|
|
122
122
|
if (next && status !== 'live' && !loading) void refresh();
|
|
123
123
|
}}
|
|
124
124
|
disabled={disabled}
|
|
125
|
-
className=
|
|
125
|
+
className={[
|
|
126
|
+
'inline-flex h-6 min-w-0 max-w-[160px] items-center gap-1 rounded-full border border-transparent bg-transparent px-2 text-[12px] leading-[1.45] transition-colors hover:bg-agent-foreground/5 hover:text-agent-foreground disabled:cursor-not-allowed disabled:opacity-70 @sm:max-w-[220px]',
|
|
127
|
+
model != null ? 'font-medium text-agent-foreground' : 'text-agent-muted-foreground',
|
|
128
|
+
].join(' ')}
|
|
126
129
|
title={
|
|
127
130
|
status === 'offline'
|
|
128
131
|
? catalog?.error
|
|
@@ -261,7 +264,7 @@ export function ModelPicker({
|
|
|
261
264
|
setModelMenuOpen(false);
|
|
262
265
|
}}
|
|
263
266
|
disabled={disabled}
|
|
264
|
-
className="inline-flex h-6 items-center gap-1 rounded-full border border-
|
|
267
|
+
className="inline-flex h-6 items-center gap-1 rounded-full border border-transparent bg-transparent px-1.5 text-[12px] leading-[1.45] text-agent-muted-foreground transition-colors hover:bg-agent-foreground/5 hover:text-agent-foreground disabled:cursor-not-allowed disabled:opacity-70"
|
|
265
268
|
title={t('Reasoning level (sent with every request; an error appears if the model does not support it)')}
|
|
266
269
|
aria-haspopup="menu"
|
|
267
270
|
aria-expanded={effortMenuOpen}
|
|
@@ -1,81 +1,107 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useState, type ReactNode } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
LuArrowRight,
|
|
4
|
+
LuCheck,
|
|
5
|
+
LuCircle,
|
|
6
|
+
LuCircleCheck,
|
|
7
|
+
LuCopy,
|
|
8
|
+
LuListChecks,
|
|
9
|
+
LuSquarePlus,
|
|
10
|
+
} from 'react-icons/lu';
|
|
11
|
+
import {
|
|
12
|
+
parseProposedPlanBody,
|
|
13
|
+
type ParsedProposedPlan,
|
|
14
|
+
} from '@steerable/agent-protocol';
|
|
2
15
|
import { t } from '@/i18n';
|
|
16
|
+
import {
|
|
17
|
+
useCurrentMessageId,
|
|
18
|
+
usePlanActionContext,
|
|
19
|
+
} from '@/lib/chat-mode-store';
|
|
3
20
|
|
|
4
21
|
/**
|
|
5
|
-
* PlanTodoList — renders
|
|
6
|
-
*
|
|
7
|
-
* code block.
|
|
22
|
+
* PlanTodoList — renders `<proposed_plan>` blocks and legacy ```` ```plan ````
|
|
23
|
+
* fenced blocks as an actionable plan artifact card.
|
|
8
24
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* - [ ] 第一步……
|
|
13
|
-
* - [x] 已完成的步骤(执行回顾时可能出现)
|
|
14
|
-
*
|
|
15
|
-
* The parser is intentionally forgiving: numbered lists (`1. …`), plain
|
|
16
|
-
* dashes (`- …`) and bare `[ ] …` lines all count as steps, so a slightly
|
|
17
|
-
* off-spec local model still gets a proper todolist instead of a wall of
|
|
18
|
-
* monospace text. Unclosed fences during streaming parse the same way, so
|
|
19
|
-
* steps appear progressively as tokens arrive.
|
|
25
|
+
* Supports both simple checklist plans and rich Markdown specifications
|
|
26
|
+
* (summaries, subheadings, nested code blocks, tables), plus an inline
|
|
27
|
+
* Codex-style 3-way implementation footer on the latest actionable plan.
|
|
20
28
|
*/
|
|
21
29
|
|
|
22
|
-
interface PlanItem {
|
|
30
|
+
export interface PlanItem {
|
|
23
31
|
text: string;
|
|
24
32
|
done: boolean;
|
|
25
33
|
}
|
|
26
34
|
|
|
27
|
-
interface ParsedPlan {
|
|
35
|
+
export interface ParsedPlan {
|
|
28
36
|
title: string | null;
|
|
29
37
|
items: PlanItem[];
|
|
30
38
|
notes: string[];
|
|
31
39
|
}
|
|
32
40
|
|
|
33
|
-
const CHECKBOX_RE = /^(?:[-*]\s*)?\[([ xX])\]\s*(.*)$/;
|
|
34
|
-
const BULLET_RE = /^[-*]\s+(.*)$/;
|
|
35
|
-
const NUMBERED_RE = /^\d+[.、)]\s*(.*)$/;
|
|
36
|
-
|
|
37
41
|
export function parsePlanContent(raw: string): ParsedPlan {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
const parsed = parseProposedPlanBody(raw);
|
|
43
|
+
return {
|
|
44
|
+
title: parsed.title,
|
|
45
|
+
items: parsed.steps,
|
|
46
|
+
notes: parsed.notes,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
42
49
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
export interface PlanTodoListProps {
|
|
51
|
+
/** Raw inner text when rendered from a standalone ```` ```plan ```` code block. */
|
|
52
|
+
content?: string;
|
|
53
|
+
/** Pre-parsed plan model when split at the message level. */
|
|
54
|
+
plan?: ParsedProposedPlan;
|
|
55
|
+
/** Optional rich Markdown renderer injected by `Markdown.tsx` to avoid circular imports. */
|
|
56
|
+
renderRichMarkdown?: (markdown: string) => ReactNode;
|
|
57
|
+
/** True when this card is the last plan block in its parent message (default: true). */
|
|
58
|
+
isLastPlanInMessage?: boolean;
|
|
59
|
+
}
|
|
48
60
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
export function PlanTodoList({
|
|
62
|
+
content = '',
|
|
63
|
+
plan: providedPlan,
|
|
64
|
+
renderRichMarkdown,
|
|
65
|
+
isLastPlanInMessage = true,
|
|
66
|
+
}: PlanTodoListProps) {
|
|
67
|
+
const plan: ParsedProposedPlan = providedPlan ?? {
|
|
68
|
+
syntax: 'fence',
|
|
69
|
+
complete: true,
|
|
70
|
+
...parseProposedPlanBody(content),
|
|
71
|
+
};
|
|
72
|
+
const { title, steps: items, notes, hasRichMarkdown, bodyMarkdown, markdown } = plan;
|
|
55
73
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (text) plan.items.push({ text, done: false });
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
74
|
+
const [copied, setCopied] = useState(false);
|
|
75
|
+
const currentMessageId = useCurrentMessageId();
|
|
76
|
+
const planActionCtx = usePlanActionContext();
|
|
62
77
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
78
|
+
const showActionFooter = Boolean(
|
|
79
|
+
isLastPlanInMessage &&
|
|
80
|
+
planActionCtx?.actionable &&
|
|
81
|
+
currentMessageId &&
|
|
82
|
+
planActionCtx.actionable.messageId === currentMessageId,
|
|
83
|
+
);
|
|
84
|
+
const contextUsedPercent = planActionCtx?.actionable?.contextUsedPercent ?? null;
|
|
67
85
|
|
|
68
|
-
|
|
69
|
-
|
|
86
|
+
const handleCopy = () => {
|
|
87
|
+
const copyText = markdown || content;
|
|
88
|
+
if (!copyText || typeof navigator === 'undefined' || !navigator.clipboard?.writeText) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
void navigator.clipboard.writeText(copyText).then(() => {
|
|
92
|
+
setCopied(true);
|
|
93
|
+
setTimeout(() => setCopied(false), 1800);
|
|
94
|
+
});
|
|
95
|
+
};
|
|
70
96
|
|
|
71
97
|
return (
|
|
72
98
|
<div
|
|
73
|
-
className="my-2 overflow-hidden rounded-agent-lg border border-amber-400/50 bg-amber-400/5 not-italic dark:border-amber-500/30"
|
|
99
|
+
className="my-2.5 overflow-hidden rounded-agent-lg border border-amber-400/50 bg-amber-400/5 not-italic dark:border-amber-500/30"
|
|
74
100
|
data-testid="plan-todo-list"
|
|
75
101
|
>
|
|
76
102
|
<div className="flex items-center gap-2 border-b border-amber-400/30 bg-amber-400/10 px-3 py-2 dark:border-amber-500/20">
|
|
77
103
|
<LuListChecks className="h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400" />
|
|
78
|
-
<span className="flex-1 truncate text-[13px] font-semibold text-amber-
|
|
104
|
+
<span className="flex-1 truncate text-[13px] font-semibold text-amber-900 dark:text-amber-100">
|
|
79
105
|
{title || t('Execution plan')}
|
|
80
106
|
</span>
|
|
81
107
|
{items.length > 0 && (
|
|
@@ -83,36 +109,116 @@ export function PlanTodoList({ content }: { content: string }) {
|
|
|
83
109
|
{items.filter((i) => i.done).length}/{items.length}
|
|
84
110
|
</span>
|
|
85
111
|
)}
|
|
112
|
+
{markdown && (
|
|
113
|
+
<button
|
|
114
|
+
type="button"
|
|
115
|
+
onClick={handleCopy}
|
|
116
|
+
title={copied ? t('Copied') : t('Copy plan')}
|
|
117
|
+
aria-label={copied ? t('Copied') : t('Copy plan')}
|
|
118
|
+
data-testid="plan-copy"
|
|
119
|
+
className="inline-flex h-5 items-center gap-1 rounded px-1.5 text-[11px] text-amber-800/80 transition-colors hover:bg-amber-400/20 hover:text-amber-900 dark:text-amber-200/80 dark:hover:text-amber-100"
|
|
120
|
+
>
|
|
121
|
+
{copied ? (
|
|
122
|
+
<>
|
|
123
|
+
<LuCheck className="h-3 w-3 shrink-0" />
|
|
124
|
+
<span>{t('Copied')}</span>
|
|
125
|
+
</>
|
|
126
|
+
) : (
|
|
127
|
+
<>
|
|
128
|
+
<LuCopy className="h-3 w-3 shrink-0" />
|
|
129
|
+
<span className="hidden sm:inline">{t('Copy plan')}</span>
|
|
130
|
+
</>
|
|
131
|
+
)}
|
|
132
|
+
</button>
|
|
133
|
+
)}
|
|
86
134
|
</div>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
className=
|
|
98
|
-
item.done
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
135
|
+
|
|
136
|
+
{hasRichMarkdown && renderRichMarkdown && bodyMarkdown ? (
|
|
137
|
+
<div className="px-3 py-2.5 text-[12.5px] leading-relaxed text-agent-foreground [&_pre]:bg-agent-canvas/90">
|
|
138
|
+
{renderRichMarkdown(bodyMarkdown)}
|
|
139
|
+
</div>
|
|
140
|
+
) : (
|
|
141
|
+
<>
|
|
142
|
+
{items.length > 0 && (
|
|
143
|
+
<ol className="m-0 list-none space-y-1 px-3 py-2">
|
|
144
|
+
{items.map((item, idx) => (
|
|
145
|
+
<li key={idx} className="flex items-start gap-2 text-[13px] leading-relaxed">
|
|
146
|
+
{item.done ? (
|
|
147
|
+
<LuCircleCheck className="mt-[3px] h-3.5 w-3.5 shrink-0 text-amber-600 dark:text-amber-400" />
|
|
148
|
+
) : (
|
|
149
|
+
<LuCircle className="mt-[3px] h-3.5 w-3.5 shrink-0 text-amber-500/60" />
|
|
150
|
+
)}
|
|
151
|
+
<span
|
|
152
|
+
className={
|
|
153
|
+
item.done
|
|
154
|
+
? 'text-agent-muted-foreground line-through'
|
|
155
|
+
: 'text-agent-foreground'
|
|
156
|
+
}
|
|
157
|
+
>
|
|
158
|
+
{item.text}
|
|
159
|
+
</span>
|
|
160
|
+
</li>
|
|
161
|
+
))}
|
|
162
|
+
</ol>
|
|
163
|
+
)}
|
|
164
|
+
{notes.length > 0 && (
|
|
165
|
+
<div className="border-t border-amber-400/20 px-3 py-1.5 text-[12px] text-agent-muted-foreground">
|
|
166
|
+
{notes.map((note, idx) => (
|
|
167
|
+
<p key={idx} className="my-0.5">
|
|
168
|
+
{note}
|
|
169
|
+
</p>
|
|
170
|
+
))}
|
|
171
|
+
</div>
|
|
172
|
+
)}
|
|
173
|
+
</>
|
|
108
174
|
)}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
175
|
+
|
|
176
|
+
{showActionFooter && planActionCtx && currentMessageId && (
|
|
177
|
+
<div
|
|
178
|
+
className="flex flex-wrap items-center justify-between gap-2 border-t border-amber-400/30 bg-amber-400/10 px-3 py-2 text-xs dark:border-amber-500/20"
|
|
179
|
+
data-testid="plan-action-bar"
|
|
180
|
+
>
|
|
181
|
+
<div className="flex min-w-0 items-center gap-2 text-amber-800 dark:text-amber-200">
|
|
182
|
+
<span className="font-medium">
|
|
183
|
+
{t('Plan ready. How would you like to proceed?')}
|
|
184
|
+
</span>
|
|
185
|
+
{contextUsedPercent !== null && contextUsedPercent >= 25 && (
|
|
186
|
+
<span className="rounded-full bg-amber-400/20 px-1.5 py-0.5 text-[10px] text-amber-700 dark:text-amber-300">
|
|
187
|
+
{t('{percent}% context used', { percent: contextUsedPercent })}
|
|
188
|
+
</span>
|
|
189
|
+
)}
|
|
190
|
+
</div>
|
|
191
|
+
<div className="flex flex-wrap items-center gap-1.5">
|
|
192
|
+
<button
|
|
193
|
+
type="button"
|
|
194
|
+
onClick={() => planActionCtx.onDismiss(currentMessageId)}
|
|
195
|
+
className="rounded-full px-2.5 py-1 text-agent-muted-foreground transition-colors hover:bg-agent-foreground/5 hover:text-agent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50"
|
|
196
|
+
data-testid="plan-dismiss"
|
|
197
|
+
>
|
|
198
|
+
{t('Keep refining')}
|
|
199
|
+
</button>
|
|
200
|
+
{planActionCtx.onExecuteInFreshChat && markdown && (
|
|
201
|
+
<button
|
|
202
|
+
type="button"
|
|
203
|
+
onClick={() => planActionCtx.onExecuteInFreshChat?.(markdown)}
|
|
204
|
+
title={t('Start a fresh chat in Agent mode with only this approved plan')}
|
|
205
|
+
className="inline-flex items-center gap-1 rounded-full border border-amber-500/40 bg-agent-canvas/80 px-2.5 py-1 font-medium text-amber-800 transition-colors hover:bg-amber-400/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50 dark:border-amber-400/35 dark:text-amber-200"
|
|
206
|
+
data-testid="plan-execute-fresh"
|
|
207
|
+
>
|
|
208
|
+
<LuSquarePlus className="h-3.5 w-3.5 shrink-0" />
|
|
209
|
+
<span>{t('Execute in new chat')}</span>
|
|
210
|
+
</button>
|
|
211
|
+
)}
|
|
212
|
+
<button
|
|
213
|
+
type="button"
|
|
214
|
+
onClick={planActionCtx.onExecuteInPlace}
|
|
215
|
+
className="inline-flex items-center gap-1 rounded-full bg-agent-foreground px-3 py-1 font-medium text-agent-canvas transition hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50"
|
|
216
|
+
data-testid="plan-execute"
|
|
217
|
+
>
|
|
218
|
+
<span>{t('Execute plan')}</span>
|
|
219
|
+
<LuArrowRight className="h-3.5 w-3.5 shrink-0" />
|
|
220
|
+
</button>
|
|
221
|
+
</div>
|
|
116
222
|
</div>
|
|
117
223
|
)}
|
|
118
224
|
</div>
|
|
@@ -3,7 +3,16 @@ import type { LocalChat, LocalChatAgent } from '@/lib/local-api';
|
|
|
3
3
|
import type { ThinkingDisplayMode } from '@/lib/show-thinking-content';
|
|
4
4
|
import { Markdown } from './Markdown';
|
|
5
5
|
import { ToolsFlow } from './ExecutedActionsCard';
|
|
6
|
-
import
|
|
6
|
+
import { ImageRoundFoldStrip } from './rich-tool-views';
|
|
7
|
+
import {
|
|
8
|
+
classifyFoldableRoundAction,
|
|
9
|
+
expandRunCodeActions,
|
|
10
|
+
filterRedundantPresentFiles,
|
|
11
|
+
isActionRunning,
|
|
12
|
+
isInteractiveRunningAction,
|
|
13
|
+
isTerminalHousekeepingAction,
|
|
14
|
+
type InspectTaskInput,
|
|
15
|
+
} from './executed-actions-model';
|
|
7
16
|
import type { ChildInfo } from './OrchestrationChildrenCard';
|
|
8
17
|
import { OrchestrationChildrenCard } from './OrchestrationChildrenCard';
|
|
9
18
|
import { TurnUsageLine } from './TurnUsageLine';
|
|
@@ -30,6 +39,7 @@ export { THINKING_PEEK_HEIGHT, THINKING_PEEK_LINES };
|
|
|
30
39
|
export function TurnProcessGroup({
|
|
31
40
|
blocks,
|
|
32
41
|
isStreaming,
|
|
42
|
+
turnFailed,
|
|
33
43
|
agents,
|
|
34
44
|
chats,
|
|
35
45
|
chatId,
|
|
@@ -45,10 +55,13 @@ export function TurnProcessGroup({
|
|
|
45
55
|
thinkingDisplay,
|
|
46
56
|
showThinkingContent,
|
|
47
57
|
collapseWhenFinished = true,
|
|
58
|
+
deliveredFilePaths,
|
|
48
59
|
renderAnswer,
|
|
49
60
|
}: {
|
|
50
61
|
blocks: TurnBlock[];
|
|
51
62
|
isStreaming: boolean;
|
|
63
|
+
/** True only when the turn itself terminated in failure; suppresses self-healed tool error counts on succeeded turns. */
|
|
64
|
+
turnFailed?: boolean;
|
|
52
65
|
agents: LocalChatAgent[];
|
|
53
66
|
chats: LocalChat[];
|
|
54
67
|
chatId?: string | null;
|
|
@@ -80,8 +93,20 @@ export function TurnProcessGroup({
|
|
|
80
93
|
* Task inspector sets false so the replay stays open.
|
|
81
94
|
*/
|
|
82
95
|
collapseWhenFinished?: boolean;
|
|
96
|
+
/** Settled deliverable file paths rendered in `TurnFilesCard` below the answer; deduplicates `present_files`. */
|
|
97
|
+
deliveredFilePaths?: ReadonlySet<string> | null;
|
|
83
98
|
renderAnswer: (block: Extract<TurnBlock, { type: 'text' }>, isLast: boolean) => ReactNode;
|
|
84
99
|
}) {
|
|
100
|
+
const effectiveBlocks: TurnBlock[] = blocks.flatMap((block): TurnBlock[] => {
|
|
101
|
+
if (block.type !== 'tools') return [block];
|
|
102
|
+
const expanded = expandRunCodeActions(block.actions);
|
|
103
|
+
const remaining =
|
|
104
|
+
deliveredFilePaths && deliveredFilePaths.size > 0
|
|
105
|
+
? filterRedundantPresentFiles(expanded, deliveredFilePaths)
|
|
106
|
+
: expanded;
|
|
107
|
+
return remaining.length > 0 ? [{ ...block, actions: remaining }] : [];
|
|
108
|
+
});
|
|
109
|
+
|
|
85
110
|
const hasChildrenCard = (orchestrationChildren?.length ?? 0) >= 2;
|
|
86
111
|
const processFooter =
|
|
87
112
|
hasChildrenCard || Boolean(turnUsage) ? (
|
|
@@ -101,13 +126,21 @@ export function TurnProcessGroup({
|
|
|
101
126
|
|
|
102
127
|
return (
|
|
103
128
|
<TurnProcessTimeline
|
|
104
|
-
blocks={
|
|
129
|
+
blocks={effectiveBlocks}
|
|
105
130
|
isStreaming={isStreaming}
|
|
131
|
+
turnFailed={turnFailed}
|
|
106
132
|
startedAtMs={startedAtMs}
|
|
107
133
|
durationMs={durationMs}
|
|
108
134
|
thinkingDisplay={thinkingDisplay}
|
|
109
135
|
showThinkingContent={showThinkingContent}
|
|
110
136
|
collapseWhenFinished={collapseWhenFinished}
|
|
137
|
+
isToolRunning={isActionRunning}
|
|
138
|
+
isInteractiveRunningTool={isInteractiveRunningAction}
|
|
139
|
+
isTrailingHousekeepingTool={isTerminalHousekeepingAction}
|
|
140
|
+
classifyFoldableRoundAction={classifyFoldableRoundAction}
|
|
141
|
+
renderRoundFoldPreview={(actions, { expand }) => (
|
|
142
|
+
<ImageRoundFoldStrip actions={actions} chatId={chatId} onExpand={expand} />
|
|
143
|
+
)}
|
|
111
144
|
emptyFallback={emptyFallback}
|
|
112
145
|
streamingHint={streamingHint}
|
|
113
146
|
processFooter={processFooter}
|
|
@@ -119,10 +152,11 @@ export function TurnProcessGroup({
|
|
|
119
152
|
chatId={chatId}
|
|
120
153
|
onInspectTask={onInspectTask}
|
|
121
154
|
orchestrationChildren={orchestrationChildren}
|
|
155
|
+
deliveredFilePaths={deliveredFilePaths}
|
|
122
156
|
/>
|
|
123
157
|
)}
|
|
124
158
|
renderIntermediateText={(block, isLiveLast) => (
|
|
125
|
-
<div>
|
|
159
|
+
<div className="px-1.5 py-0.5">
|
|
126
160
|
<div className="markdown-content text-xs leading-relaxed text-agent-foreground">
|
|
127
161
|
<Markdown agents={agents} chats={chats} chatId={chatId}>
|
|
128
162
|
{block.content}
|