@steerable/agent-shell-web 0.14.3 → 0.14.5
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/AgentSidebar.tsx +189 -46
- package/src/components/ChatHeader.tsx +12 -1
- package/src/components/SidebarAccount.tsx +33 -41
- package/src/components/chat/AssistantMessage.tsx +36 -10
- package/src/components/chat/ChatInput.tsx +308 -131
- package/src/components/chat/ChatProjectBadge.tsx +311 -100
- package/src/components/chat/ContextUsagePill.tsx +20 -5
- package/src/components/chat/ExecPolicyPicker.tsx +72 -67
- package/src/components/chat/LocalChatPanel.tsx +33 -35
- package/src/components/chat/Markdown.tsx +109 -11
- package/src/components/chat/MessageList.tsx +109 -19
- package/src/components/chat/ModelPicker.tsx +2 -2
- package/src/components/chat/PlanTodoList.tsx +184 -78
- package/src/components/chat/SessionTodoList.tsx +63 -72
- package/src/components/chat/TurnFilesCard.tsx +270 -112
- package/src/components/chat/TurnProcessGroup.tsx +3 -0
- package/src/components/chat/TurnProcessTimeline.tsx +13 -0
- package/src/components/chat/UserMessage.tsx +8 -1
- package/src/components/chat/next-steps-tags.ts +13 -0
- package/src/components/chat/process-status.ts +112 -2
- package/src/components/chat/todo-list-model.ts +52 -4
- package/src/layouts/AgentLayout.tsx +173 -10
- package/src/layouts/PanelToggleButton.tsx +27 -9
- package/src/layouts/conversation-preview.ts +3 -0
- package/src/layouts/request-chat-slot.ts +20 -0
- package/src/layouts/right-panel-tabs.ts +32 -0
- package/src/lib/chat-mode-store.ts +241 -0
- package/src/lib/file-preview-registry.ts +57 -0
- package/src/pages/AgentPage.tsx +188 -78
|
@@ -1,35 +1,16 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { LuChevronDown,
|
|
2
|
+
import { LuChevronDown, LuShieldAlert, LuShieldCheck } from 'react-icons/lu';
|
|
3
3
|
import type { ExecPolicy } from '@/lib/exec-policy';
|
|
4
4
|
import { t } from '@/i18n';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* ExecPolicyPicker —
|
|
7
|
+
* ExecPolicyPicker — WorkBuddy-style sandbox permission pill + Switch card.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* = 不下发命令沙箱,本机路径(如 Downloads)不再被 Operation not permitted 拦住。
|
|
9
|
+
* Default (`workspace`) confines writes and shell commands to the current
|
|
10
|
+
* workspace/project folders and prompts before stepping outside; toggling
|
|
11
|
+
* `Allow full access` (`full`) turns off the command sandbox for this session.
|
|
13
12
|
*/
|
|
14
13
|
|
|
15
|
-
const OPTIONS: Array<{
|
|
16
|
-
id: ExecPolicy;
|
|
17
|
-
label: string;
|
|
18
|
-
description: string;
|
|
19
|
-
}> = [
|
|
20
|
-
{
|
|
21
|
-
id: 'workspace',
|
|
22
|
-
label: 'Workspace',
|
|
23
|
-
description: 'Can only write to the current workspace. Paths outside it are blocked.',
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
id: 'full',
|
|
27
|
-
label: 'Full access',
|
|
28
|
-
description:
|
|
29
|
-
'Turns off the command sandbox so any path on this computer can be written. Tool approvals still apply.',
|
|
30
|
-
},
|
|
31
|
-
];
|
|
32
|
-
|
|
33
14
|
export function ExecPolicyPicker({
|
|
34
15
|
policy,
|
|
35
16
|
disabled,
|
|
@@ -41,81 +22,105 @@ export function ExecPolicyPicker({
|
|
|
41
22
|
}) {
|
|
42
23
|
const [open, setOpen] = useState(false);
|
|
43
24
|
const rootRef = useRef<HTMLDivElement>(null);
|
|
44
|
-
const current = OPTIONS.find((option) => option.id === policy) ?? OPTIONS[0];
|
|
45
25
|
const isFull = policy === 'full';
|
|
46
26
|
|
|
47
27
|
useEffect(() => {
|
|
48
28
|
if (!open) return;
|
|
49
|
-
const onPointerDown = (event: MouseEvent) => {
|
|
29
|
+
const onPointerDown = (event: PointerEvent | MouseEvent) => {
|
|
50
30
|
if (rootRef.current && !rootRef.current.contains(event.target as Node)) {
|
|
51
31
|
setOpen(false);
|
|
52
32
|
}
|
|
53
33
|
};
|
|
54
|
-
|
|
55
|
-
|
|
34
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
35
|
+
if (event.key === 'Escape') {
|
|
36
|
+
event.stopPropagation();
|
|
37
|
+
setOpen(false);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
document.addEventListener('pointerdown', onPointerDown);
|
|
41
|
+
document.addEventListener('keydown', onKeyDown);
|
|
42
|
+
return () => {
|
|
43
|
+
document.removeEventListener('pointerdown', onPointerDown);
|
|
44
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
45
|
+
};
|
|
56
46
|
}, [open]);
|
|
57
47
|
|
|
48
|
+
const descriptionText = isFull
|
|
49
|
+
? t(
|
|
50
|
+
'Full access is enabled. The command sandbox is off so any path on this computer can be accessed.',
|
|
51
|
+
)
|
|
52
|
+
: t(
|
|
53
|
+
'Running with default permissions. Operations stay within the safety sandbox and ask before going outside.',
|
|
54
|
+
);
|
|
55
|
+
|
|
58
56
|
return (
|
|
59
57
|
<div ref={rootRef} className="relative">
|
|
60
58
|
<button
|
|
61
59
|
type="button"
|
|
62
60
|
disabled={disabled}
|
|
63
|
-
aria-haspopup="
|
|
61
|
+
aria-haspopup="dialog"
|
|
64
62
|
aria-expanded={open}
|
|
65
63
|
aria-label={t('Command sandbox')}
|
|
66
64
|
data-testid="exec-policy-picker"
|
|
67
|
-
title={
|
|
65
|
+
title={descriptionText}
|
|
68
66
|
onClick={() => setOpen((next) => !next)}
|
|
69
67
|
className={[
|
|
70
|
-
'inline-flex h-6 max-w-[
|
|
68
|
+
'inline-flex h-6 max-w-[150px] items-center gap-1 rounded-full border px-2 text-[12px] leading-[1.45] transition-colors disabled:cursor-not-allowed disabled:opacity-70',
|
|
71
69
|
isFull
|
|
72
|
-
? 'border-amber-400/
|
|
70
|
+
? 'border-amber-400/55 bg-amber-400/12 font-medium text-amber-700 dark:text-amber-300'
|
|
73
71
|
: 'border-transparent bg-transparent text-agent-muted-foreground hover:bg-agent-foreground/5 hover:text-agent-foreground',
|
|
74
72
|
].join(' ')}
|
|
75
73
|
>
|
|
76
74
|
{isFull ? (
|
|
77
|
-
<
|
|
75
|
+
<LuShieldAlert className="h-3.5 w-3.5 shrink-0" />
|
|
78
76
|
) : (
|
|
79
|
-
<
|
|
77
|
+
<LuShieldCheck className="h-3.5 w-3.5 shrink-0" />
|
|
80
78
|
)}
|
|
81
|
-
<span className="truncate">
|
|
82
|
-
|
|
79
|
+
<span className="truncate">
|
|
80
|
+
{isFull ? t('Full access') : t('Default permissions')}
|
|
81
|
+
</span>
|
|
82
|
+
<LuChevronDown
|
|
83
|
+
className={`h-3 w-3 shrink-0 text-current opacity-75 transition-transform ${
|
|
84
|
+
open ? 'rotate-180' : ''
|
|
85
|
+
}`}
|
|
86
|
+
/>
|
|
83
87
|
</button>
|
|
88
|
+
|
|
84
89
|
{open && (
|
|
85
90
|
<div
|
|
86
|
-
role="
|
|
91
|
+
role="dialog"
|
|
87
92
|
aria-label={t('Command sandbox')}
|
|
88
|
-
className="absolute bottom-full left-0 z-
|
|
93
|
+
className="absolute bottom-full left-0 z-40 mb-1.5 w-64 rounded-agent-lg border border-agent-border bg-agent-canvas p-3 shadow-lg"
|
|
89
94
|
>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
95
|
+
<p className="m-0 text-[11px] leading-relaxed text-agent-muted-foreground">
|
|
96
|
+
{descriptionText}
|
|
97
|
+
</p>
|
|
98
|
+
<div className="my-2.5 border-t border-agent-border/60" />
|
|
99
|
+
<button
|
|
100
|
+
type="button"
|
|
101
|
+
role="switch"
|
|
102
|
+
aria-checked={isFull}
|
|
103
|
+
data-testid="exec-policy-full"
|
|
104
|
+
onClick={() => {
|
|
105
|
+
onChange(isFull ? 'workspace' : 'full');
|
|
106
|
+
setOpen(false);
|
|
107
|
+
}}
|
|
108
|
+
className="flex w-full cursor-pointer items-center justify-between gap-2 rounded-agent-sm py-0.5 text-left text-[12px] font-medium text-agent-foreground transition-opacity hover:opacity-90"
|
|
109
|
+
>
|
|
110
|
+
<span>{t('Allow full access')}</span>
|
|
111
|
+
<span
|
|
112
|
+
aria-hidden="true"
|
|
113
|
+
className={`inline-flex h-5 w-9 shrink-0 items-center rounded-full p-0.5 transition-colors ${
|
|
114
|
+
isFull ? 'bg-amber-500' : 'bg-agent-muted-foreground/30'
|
|
115
|
+
}`}
|
|
116
|
+
>
|
|
117
|
+
<span
|
|
118
|
+
className={`h-4 w-4 rounded-full bg-white shadow-xs transition-transform ${
|
|
119
|
+
isFull ? 'translate-x-4' : 'translate-x-0'
|
|
120
|
+
}`}
|
|
121
|
+
/>
|
|
122
|
+
</span>
|
|
123
|
+
</button>
|
|
119
124
|
</div>
|
|
120
125
|
)}
|
|
121
126
|
</div>
|
|
@@ -24,8 +24,6 @@ import type { TurnFailureCardProps } from './TurnFailureCard';
|
|
|
24
24
|
import type { LlmSpeedSnapshot } from './process-status';
|
|
25
25
|
import { ComposerStatusStack } from './composer-status-stack';
|
|
26
26
|
import { t } from '@/i18n';
|
|
27
|
-
import { SessionTodoList } from './SessionTodoList';
|
|
28
|
-
import { resolveLatestSessionTodos, shouldShowComposerTodos } from './todo-list-model';
|
|
29
27
|
import { SessionOrchestrationFlow } from './SessionOrchestrationFlow';
|
|
30
28
|
import { resolveLatestSessionOrchestrationFlow } from './orchestration-flow-model';
|
|
31
29
|
import {
|
|
@@ -35,6 +33,7 @@ import {
|
|
|
35
33
|
saveChatAttachments,
|
|
36
34
|
type AttachmentFile,
|
|
37
35
|
} from '@/lib/attachments';
|
|
36
|
+
import { parseModeSlashCommand } from '@/lib/chat-mode-store';
|
|
38
37
|
|
|
39
38
|
/**
|
|
40
39
|
* LocalChatPanel — the product chat shell.
|
|
@@ -274,6 +273,18 @@ export function LocalChatPanel({
|
|
|
274
273
|
let trimmed = inputValue.trim();
|
|
275
274
|
if (!trimmed && files.length === 0) return;
|
|
276
275
|
|
|
276
|
+
const slashCmd = trimmed ? parseModeSlashCommand(trimmed) : null;
|
|
277
|
+
let effectiveMode = mode;
|
|
278
|
+
if (slashCmd) {
|
|
279
|
+
effectiveMode = slashCmd.targetMode;
|
|
280
|
+
onModeChange?.(slashCmd.targetMode);
|
|
281
|
+
if (!slashCmd.remainder && files.length === 0) {
|
|
282
|
+
setInputValue('');
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
trimmed = slashCmd.remainder;
|
|
286
|
+
}
|
|
287
|
+
|
|
277
288
|
// 把上传的文件持久化到会话空间:成功项用落盘路径(稳定、可被 agent
|
|
278
289
|
// 读回),失败项若在 Electron 下有源路径则退回源路径;浏览器模式下没有
|
|
279
290
|
// 任何可用路径的失败项会被剔除并上报,绝不把空路径写进正文。
|
|
@@ -313,7 +324,7 @@ export function LocalChatPanel({
|
|
|
313
324
|
// persisted record reflects that an image was attached.
|
|
314
325
|
const imageAttachments = collectImageAttachments(resolvedFiles);
|
|
315
326
|
const metadata = {
|
|
316
|
-
...(
|
|
327
|
+
...(effectiveMode === 'plan' ? { mode: 'plan' as const } : {}),
|
|
317
328
|
...(execPolicy === 'full' ? { execPolicy: 'full' as const } : {}),
|
|
318
329
|
...(selectedAgentId ? { agentId: selectedAgentId } : {}),
|
|
319
330
|
...(mentionedAgentIds.length > 0 ? { mentionedAgentIds } : {}),
|
|
@@ -345,25 +356,17 @@ export function LocalChatPanel({
|
|
|
345
356
|
setFiles(submittedFiles);
|
|
346
357
|
setMentionReferences(submittedMentions);
|
|
347
358
|
}
|
|
348
|
-
}, [
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
[
|
|
360
|
-
messages,
|
|
361
|
-
executedActionsByMessageId,
|
|
362
|
-
currentTurnActions,
|
|
363
|
-
timelineByMessageId,
|
|
364
|
-
currentTurnTimeline,
|
|
365
|
-
],
|
|
366
|
-
);
|
|
359
|
+
}, [
|
|
360
|
+
inputValue,
|
|
361
|
+
files,
|
|
362
|
+
mentionReferences,
|
|
363
|
+
onSubmit,
|
|
364
|
+
mode,
|
|
365
|
+
onModeChange,
|
|
366
|
+
execPolicy,
|
|
367
|
+
chatId,
|
|
368
|
+
selectedAgentId,
|
|
369
|
+
]);
|
|
367
370
|
|
|
368
371
|
const sessionOrchestrationFlow = useMemo(
|
|
369
372
|
() =>
|
|
@@ -462,22 +465,17 @@ export function LocalChatPanel({
|
|
|
462
465
|
selectedAgentId={selectedAgentId}
|
|
463
466
|
onSelectAgent={onSelectAgent}
|
|
464
467
|
onOpenSettings={onOpenSettings}
|
|
465
|
-
|
|
468
|
+
layoutVariant={showEmptyHero ? 'hero' : 'chat'}
|
|
469
|
+
toolbarTrailing={inputToolbarExtras}
|
|
466
470
|
leadingChrome={inputLeadingChrome}
|
|
467
471
|
trailingChrome={
|
|
468
|
-
sessionOrchestrationFlow
|
|
469
|
-
shouldShowComposerTodos(sessionTodos, isStreaming) ? (
|
|
472
|
+
sessionOrchestrationFlow ? (
|
|
470
473
|
<ComposerStatusStack>
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
/>
|
|
477
|
-
) : null}
|
|
478
|
-
{shouldShowComposerTodos(sessionTodos, isStreaming) ? (
|
|
479
|
-
<SessionTodoList todos={sessionTodos} />
|
|
480
|
-
) : null}
|
|
474
|
+
<SessionOrchestrationFlow
|
|
475
|
+
flow={sessionOrchestrationFlow}
|
|
476
|
+
chatId={chatId}
|
|
477
|
+
onInspectTask={onInspectTask}
|
|
478
|
+
/>
|
|
481
479
|
</ComposerStatusStack>
|
|
482
480
|
) : undefined
|
|
483
481
|
}
|
|
@@ -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
|
|
|
@@ -28,6 +28,8 @@ import { inferDurationMs, readPersistedDurationMs } from './elapsed';
|
|
|
28
28
|
import type { LlmSpeedSnapshot } from './process-status';
|
|
29
29
|
import type { RetryState } from './RetryStatus';
|
|
30
30
|
import type { TurnFailureCardProps } from './TurnFailureCard';
|
|
31
|
+
import { TurnTodoStrip } from './SessionTodoList';
|
|
32
|
+
import { resolveTurnTodos, shouldShowTurnTodoStrip } from './todo-list-model';
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
35
|
* MessageList — scrolling viewport that renders user/assistant message
|
|
@@ -327,39 +329,80 @@ export function MessageList({
|
|
|
327
329
|
}, [checkAtBottom]);
|
|
328
330
|
|
|
329
331
|
// 右侧预览跟着这一屏在看的回合。停在底部时用最近一份能打开的产物。
|
|
332
|
+
// 区分「历史会话水合」与「本会话活跃流式回合新产出的主交付物」:仅后者带 autoReveal: true 自动开栏。
|
|
333
|
+
const previewHistoryByChatRef = useRef<
|
|
334
|
+
Map<string, { hadLiveStream: boolean; seenPaths: Set<string> }>
|
|
335
|
+
>(new Map());
|
|
336
|
+
if (chatId) {
|
|
337
|
+
let entry = previewHistoryByChatRef.current.get(chatId);
|
|
338
|
+
if (!entry) {
|
|
339
|
+
entry = { hadLiveStream: false, seenPaths: new Set() };
|
|
340
|
+
previewHistoryByChatRef.current.set(chatId, entry);
|
|
341
|
+
}
|
|
342
|
+
if (isStreaming) {
|
|
343
|
+
entry.hadLiveStream = true;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
330
347
|
useEffect(() => {
|
|
331
348
|
if (!chatId) return;
|
|
332
|
-
|
|
349
|
+
let entry = previewHistoryByChatRef.current.get(chatId);
|
|
350
|
+
if (!entry) {
|
|
351
|
+
entry = { hadLiveStream: isStreaming, seenPaths: new Set() };
|
|
352
|
+
previewHistoryByChatRef.current.set(chatId, entry);
|
|
353
|
+
}
|
|
354
|
+
if (isStreaming) {
|
|
355
|
+
entry.hadLiveStream = true;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const ordered = visibleMessages
|
|
359
|
+
.filter((message) => message.role === 'assistant')
|
|
360
|
+
.map((message) => ({
|
|
361
|
+
id: message.id,
|
|
362
|
+
files: message.id === lastAssistantId
|
|
363
|
+
? (turnFilesByMessageId?.[message.id] ?? currentTurnFiles)
|
|
364
|
+
: turnFilesByMessageId?.[message.id],
|
|
365
|
+
}));
|
|
366
|
+
|
|
367
|
+
// 首次未经历流式的静态水合:把既有产物全部记入基准集合,避免打开旧会话时突然弹开右侧栏。
|
|
368
|
+
if (!entry.hadLiveStream) {
|
|
369
|
+
for (const item of ordered) {
|
|
370
|
+
for (const file of item.files ?? []) {
|
|
371
|
+
if (file.path) entry.seenPaths.add(file.path);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const publish = (allowAutoReveal: boolean) => {
|
|
333
377
|
const el = containerRef.current;
|
|
334
378
|
if (!el) return;
|
|
335
379
|
const atBottom =
|
|
336
380
|
el.scrollHeight - el.scrollTop - el.clientHeight < NEAR_BOTTOM_THRESHOLD_PX;
|
|
337
|
-
const ordered = visibleMessages
|
|
338
|
-
.filter((message) => message.role === 'assistant')
|
|
339
|
-
.map((message) => ({
|
|
340
|
-
id: message.id,
|
|
341
|
-
files: message.id === lastAssistantId
|
|
342
|
-
? (turnFilesByMessageId?.[message.id] ?? currentTurnFiles)
|
|
343
|
-
: turnFilesByMessageId?.[message.id],
|
|
344
|
-
}));
|
|
345
381
|
const selected = followedPreviewPath(ordered, {
|
|
346
382
|
atBottom,
|
|
347
383
|
focusedId: atBottom ? null : assistantIdInView(el),
|
|
348
384
|
});
|
|
349
385
|
if (!selected) return;
|
|
386
|
+
const isNewLiveDeliverable =
|
|
387
|
+
allowAutoReveal &&
|
|
388
|
+
Boolean(entry?.hadLiveStream) &&
|
|
389
|
+
!entry!.seenPaths.has(selected.path);
|
|
390
|
+
entry?.seenPaths.add(selected.path);
|
|
350
391
|
publishConversationPreview({
|
|
351
392
|
chatId,
|
|
352
393
|
messageId: selected.messageId,
|
|
353
394
|
path: selected.path,
|
|
395
|
+
...(isNewLiveDeliverable ? { autoReveal: true } : {}),
|
|
354
396
|
});
|
|
355
397
|
};
|
|
356
|
-
publish();
|
|
398
|
+
publish(true);
|
|
399
|
+
const onScroll = () => publish(false);
|
|
357
400
|
const el = containerRef.current;
|
|
358
|
-
el?.addEventListener('scroll',
|
|
401
|
+
el?.addEventListener('scroll', onScroll, { passive: true });
|
|
359
402
|
return () => {
|
|
360
|
-
el?.removeEventListener('scroll',
|
|
403
|
+
el?.removeEventListener('scroll', onScroll);
|
|
361
404
|
};
|
|
362
|
-
}, [chatId, currentTurnFiles, lastAssistantId, messages, turnFilesByMessageId]);
|
|
405
|
+
}, [chatId, currentTurnFiles, isStreaming, lastAssistantId, messages, turnFilesByMessageId]);
|
|
363
406
|
|
|
364
407
|
// Snap to bottom on first paint, regardless of whether the user "was" at
|
|
365
408
|
// the bottom — there's no "before" on mount.
|
|
@@ -471,15 +514,44 @@ export function MessageList({
|
|
|
471
514
|
emptyState ?? null
|
|
472
515
|
) : (
|
|
473
516
|
<div className="mx-auto w-full max-w-3xl space-y-4">
|
|
474
|
-
{conversationTurns.map((turn) =>
|
|
517
|
+
{conversationTurns.map((turn, turnIndex) => {
|
|
518
|
+
const isLatestTurn = turnIndex === conversationTurns.length - 1;
|
|
519
|
+
const hasVisibleUserGroup = Boolean(
|
|
520
|
+
turn.userGroup &&
|
|
521
|
+
!turn.userGroup.messages.every((message) => internalTrigger(message) !== null),
|
|
522
|
+
);
|
|
523
|
+
const isSingleCompactionDivider = Boolean(
|
|
524
|
+
turn.userGroup &&
|
|
525
|
+
turn.userGroup.messages.length === 1 &&
|
|
526
|
+
turn.userGroup.messages[0].content.startsWith(COMPACTED_SUMMARY_PREFIX),
|
|
527
|
+
);
|
|
528
|
+
const turnTodos =
|
|
529
|
+
hasVisibleUserGroup && !isSingleCompactionDivider
|
|
530
|
+
? resolveTurnTodos({
|
|
531
|
+
assistantMessageIds: turn.assistants.map((item) => item.message.id),
|
|
532
|
+
isLatestTurn,
|
|
533
|
+
executedActionsByMessageId,
|
|
534
|
+
timelineByMessageId,
|
|
535
|
+
currentTurnActions,
|
|
536
|
+
currentTurnTimeline,
|
|
537
|
+
})
|
|
538
|
+
: null;
|
|
539
|
+
const showTurnTodoStrip =
|
|
540
|
+
hasVisibleUserGroup &&
|
|
541
|
+
!isSingleCompactionDivider &&
|
|
542
|
+
shouldShowTurnTodoStrip(turnTodos, {
|
|
543
|
+
isLatestTurn,
|
|
544
|
+
isTurnStreaming: isLatestTurn && isStreaming,
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
return (
|
|
475
548
|
<div
|
|
476
549
|
key={turn.key}
|
|
477
550
|
className="conversation-turn relative space-y-4"
|
|
478
551
|
data-conversation-turn={turn.key}
|
|
479
552
|
>
|
|
480
|
-
{turn.userGroup
|
|
481
|
-
|
|
482
|
-
<div className="sticky top-0 z-10 -mx-3 px-3 py-1 bg-agent-canvas/95 backdrop-blur-xs">
|
|
553
|
+
{hasVisibleUserGroup && turn.userGroup ? (
|
|
554
|
+
<div className="sticky top-0 z-20 -mx-3 px-3 py-1 bg-agent-canvas/95 backdrop-blur-xs">
|
|
483
555
|
{turn.userGroup.messages.length === 1 ? (
|
|
484
556
|
internalTrigger(turn.userGroup.messages[0]) ? (
|
|
485
557
|
null
|
|
@@ -494,6 +566,7 @@ export function MessageList({
|
|
|
494
566
|
message={turn.userGroup.messages[0]}
|
|
495
567
|
agents={agents}
|
|
496
568
|
chats={chats}
|
|
569
|
+
attachedBottom={showTurnTodoStrip}
|
|
497
570
|
onEdit={
|
|
498
571
|
turn.userGroup.messages[0].id === lastUserId && onEditUserMessage
|
|
499
572
|
? (nextText) => onEditUserMessage(turn.userGroup!.messages[0].id, nextText)
|
|
@@ -508,7 +581,13 @@ export function MessageList({
|
|
|
508
581
|
data-message-role="user-group"
|
|
509
582
|
>
|
|
510
583
|
<div className="flex justify-start">
|
|
511
|
-
<div
|
|
584
|
+
<div
|
|
585
|
+
className={`mx-auto w-full max-w-[var(--chat-input-box-width)] overflow-hidden ${
|
|
586
|
+
showTurnTodoStrip
|
|
587
|
+
? 'rounded-t-agent-lg rounded-b-none'
|
|
588
|
+
: 'rounded-agent-lg'
|
|
589
|
+
} border border-agent-border/80 bg-agent-muted/70 shadow-sm`}
|
|
590
|
+
>
|
|
512
591
|
{turn.userGroup.messages.map((msg, idx) => (
|
|
513
592
|
internalTrigger(msg) ? (
|
|
514
593
|
null
|
|
@@ -536,6 +615,11 @@ export function MessageList({
|
|
|
536
615
|
</div>
|
|
537
616
|
</div>
|
|
538
617
|
)}
|
|
618
|
+
{showTurnTodoStrip && turnTodos ? (
|
|
619
|
+
<div className="mx-auto w-full max-w-[var(--chat-input-box-width)]">
|
|
620
|
+
<TurnTodoStrip todos={turnTodos} attachedTop />
|
|
621
|
+
</div>
|
|
622
|
+
) : null}
|
|
539
623
|
</div>
|
|
540
624
|
) : null}
|
|
541
625
|
|
|
@@ -651,6 +735,11 @@ export function MessageList({
|
|
|
651
735
|
onInspectTask={onInspectTask}
|
|
652
736
|
onContinueChild={onContinueChild}
|
|
653
737
|
onStopChild={onStopChild}
|
|
738
|
+
hideInlineNextSteps={
|
|
739
|
+
isStreamingTail ||
|
|
740
|
+
(message.id === lastAssistantId &&
|
|
741
|
+
Boolean(suggestedReplies && suggestedReplies.length > 0 && onSelectSuggestion))
|
|
742
|
+
}
|
|
654
743
|
/>
|
|
655
744
|
{!isStreaming &&
|
|
656
745
|
message.id === lastAssistantId &&
|
|
@@ -666,7 +755,8 @@ export function MessageList({
|
|
|
666
755
|
);
|
|
667
756
|
})}
|
|
668
757
|
</div>
|
|
669
|
-
|
|
758
|
+
);
|
|
759
|
+
})}
|
|
670
760
|
{/* W7-1: 中断提示卡在消息列尾部、与最后一条用户消息同列——
|
|
671
761
|
视觉上隶属于被截断的那一轮,而非全局横幅。流式期间不显示
|
|
672
762
|
(进行中的流不是中断)。 */}
|
|
@@ -150,7 +150,7 @@ export function ModelPicker({
|
|
|
150
150
|
{modelMenuOpen && (
|
|
151
151
|
<div
|
|
152
152
|
role="menu"
|
|
153
|
-
className="absolute bottom-full
|
|
153
|
+
className="absolute bottom-full right-0 z-50 mb-1 max-h-72 w-80 max-w-[calc(100vw-2rem)] overflow-y-auto rounded-agent-md border border-agent-border bg-agent-canvas p-1 shadow-lg"
|
|
154
154
|
>
|
|
155
155
|
<div className="flex items-center justify-between gap-2 px-2 py-1">
|
|
156
156
|
<span className="text-[10px] font-semibold uppercase tracking-wider text-agent-muted-foreground">
|
|
@@ -275,7 +275,7 @@ export function ModelPicker({
|
|
|
275
275
|
{effortMenuOpen && (
|
|
276
276
|
<div
|
|
277
277
|
role="menu"
|
|
278
|
-
className="absolute bottom-full
|
|
278
|
+
className="absolute bottom-full right-0 z-50 mb-1 w-36 overflow-y-auto rounded-agent-md border border-agent-border bg-agent-canvas p-1 shadow-lg"
|
|
279
279
|
>
|
|
280
280
|
<button
|
|
281
281
|
type="button"
|