@steerable/agent-shell-web 0.14.4 → 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 +25 -4
- package/src/components/chat/ChatInput.tsx +169 -111
- package/src/components/chat/ChatProjectBadge.tsx +233 -88
- package/src/components/chat/ContextUsagePill.tsx +20 -5
- package/src/components/chat/ExecPolicyPicker.tsx +72 -67
- package/src/components/chat/LocalChatPanel.tsx +8 -33
- package/src/components/chat/MessageList.tsx +109 -19
- package/src/components/chat/ModelPicker.tsx +2 -2
- 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/file-preview-registry.ts +57 -0
- package/src/pages/AgentPage.tsx +6 -3
|
@@ -37,7 +37,7 @@ import { TurnProcessGroup } from './TurnProcessGroup';
|
|
|
37
37
|
import { TurnFilesCard } from './TurnFilesCard';
|
|
38
38
|
import type { TurnFile } from './turn-files';
|
|
39
39
|
import type { TurnUsage } from './turn-usage';
|
|
40
|
-
import { stripNextStepsTags } from './next-steps-tags';
|
|
40
|
+
import { omitNextStepsBlocks, stripNextStepsTags } from './next-steps-tags';
|
|
41
41
|
import {
|
|
42
42
|
formatTokenSpeed,
|
|
43
43
|
llmRequestElapsedMs,
|
|
@@ -175,6 +175,12 @@ interface AssistantMessageProps {
|
|
|
175
175
|
/** R7:子代理面板的「继续」/「停止」。 */
|
|
176
176
|
onContinueChild?: (childId: string, recordId: string) => void;
|
|
177
177
|
onStopChild?: (childId: string) => void;
|
|
178
|
+
/**
|
|
179
|
+
* True when follow-up suggestion chips are rendered below this message
|
|
180
|
+
* (or while streaming the tail turn), omitting `[next_steps]...[/next_steps]`
|
|
181
|
+
* from inline Markdown so suggestions are not shown twice.
|
|
182
|
+
*/
|
|
183
|
+
hideInlineNextSteps?: boolean;
|
|
178
184
|
}
|
|
179
185
|
|
|
180
186
|
function agentInitial(name: string): string {
|
|
@@ -492,6 +498,7 @@ export function AssistantMessage({
|
|
|
492
498
|
onInspectTask,
|
|
493
499
|
onContinueChild,
|
|
494
500
|
onStopChild,
|
|
501
|
+
hideInlineNextSteps = false,
|
|
495
502
|
}: AssistantMessageProps) {
|
|
496
503
|
const content = message.content || '';
|
|
497
504
|
const failure = readTurnFailure(message, content);
|
|
@@ -500,8 +507,14 @@ export function AssistantMessage({
|
|
|
500
507
|
const continued = readContinued(message);
|
|
501
508
|
// live 错误文本("[stream error] ...")不当正文渲染;落库的失败回合可能
|
|
502
509
|
// 留有部分正文,此时正文与错误气泡都展示。
|
|
503
|
-
const
|
|
504
|
-
const
|
|
510
|
+
const rawDisplayContent = failure?.contentIsError ? '' : content;
|
|
511
|
+
const displayContent = hideInlineNextSteps
|
|
512
|
+
? omitNextStepsBlocks(rawDisplayContent)
|
|
513
|
+
: rawDisplayContent;
|
|
514
|
+
const copySource = hideInlineNextSteps
|
|
515
|
+
? omitNextStepsBlocks(content)
|
|
516
|
+
: stripNextStepsTags(content);
|
|
517
|
+
const { copied, copy } = useCopy(copySource);
|
|
505
518
|
const [regenerating, setRegenerating] = useState(false);
|
|
506
519
|
const [regenerateError, setRegenerateError] = useState<string | null>(null);
|
|
507
520
|
const persistedAgentId =
|
|
@@ -515,7 +528,15 @@ export function AssistantMessage({
|
|
|
515
528
|
// while it's actively streaming and hasn't flushed agentId to the DB yet.
|
|
516
529
|
const displayAgent = persistedAgent ?? (isStreaming ? currentAgent : null);
|
|
517
530
|
const useTimeline = timeline !== undefined;
|
|
518
|
-
const
|
|
531
|
+
const rawBlocks = timeline ?? [];
|
|
532
|
+
const blocks: TurnBlock[] = hideInlineNextSteps
|
|
533
|
+
? rawBlocks.flatMap<TurnBlock>((block) => {
|
|
534
|
+
if (block.type !== 'text') return [block];
|
|
535
|
+
const cleaned = omitNextStepsBlocks(block.content);
|
|
536
|
+
if (!cleaned.trim() && rawBlocks.length > 1) return [];
|
|
537
|
+
return [{ ...block, content: cleaned }];
|
|
538
|
+
})
|
|
539
|
+
: rawBlocks;
|
|
519
540
|
const toolActions = [
|
|
520
541
|
...(executedActions ?? []),
|
|
521
542
|
...blocks.flatMap((block) => (block.type === 'tools' ? block.actions : [])),
|
|
@@ -19,13 +19,13 @@ import {
|
|
|
19
19
|
LuArrowUp,
|
|
20
20
|
LuBot,
|
|
21
21
|
LuChevronDown,
|
|
22
|
+
LuInfinity,
|
|
22
23
|
LuSquare,
|
|
23
24
|
LuBlocks,
|
|
24
25
|
LuPlug,
|
|
25
26
|
LuFile,
|
|
26
|
-
|
|
27
|
+
LuPlus,
|
|
27
28
|
LuX,
|
|
28
|
-
LuInfinity,
|
|
29
29
|
LuListChecks,
|
|
30
30
|
LuMessageSquare,
|
|
31
31
|
} from 'react-icons/lu';
|
|
@@ -155,13 +155,20 @@ export interface ChatInputProps {
|
|
|
155
155
|
onSelectAgent?: (agentId: string) => void | Promise<void>;
|
|
156
156
|
/** Settings gear callback. When unset, the gear button is hidden. */
|
|
157
157
|
onOpenSettings?: () => void;
|
|
158
|
-
/** Extra controls on the
|
|
159
|
-
* Rendered after the mode toggle and before the settings gear. */
|
|
158
|
+
/** Extra controls on the right toolbar (legacy alias for `toolbarTrailing`). */
|
|
160
159
|
toolbarExtras?: ReactNode;
|
|
161
|
-
/**
|
|
162
|
-
|
|
160
|
+
/** Right-side toolbar controls rendered between the Plan switch and Send button (e.g. ModelPicker + ContextUsagePill). */
|
|
161
|
+
toolbarTrailing?: ReactNode;
|
|
162
|
+
/**
|
|
163
|
+
* Composer presentation variant:
|
|
164
|
+
* - `'hero'`: New-chat landing page with WorkBuddy-style two-tier white card + lower config tray;
|
|
165
|
+
* - `'chat'`: Active conversation single-card layout (collapses default single-agent meta row);
|
|
166
|
+
* - `undefined`: Standalone default preserving explicit `composer-meta-row` slots.
|
|
167
|
+
*/
|
|
168
|
+
layoutVariant?: 'hero' | 'chat';
|
|
169
|
+
/** Slot for project picker/badge (in hero tray for `'hero'`, left toolbar for `'chat'`, or meta row when unset). */
|
|
163
170
|
leadingChrome?: ReactNode;
|
|
164
|
-
/** Slot in the composer meta row above the input box, right-aligned (e.g.
|
|
171
|
+
/** Slot in the composer meta row above the input box, right-aligned (e.g. SessionOrchestrationFlow). */
|
|
165
172
|
trailingChrome?: ReactNode;
|
|
166
173
|
/** Current chat mode. When unset the toggle is hidden (defaults to 'agent'). */
|
|
167
174
|
mode?: ChatMode;
|
|
@@ -960,6 +967,8 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
960
967
|
onSelectAgent,
|
|
961
968
|
onOpenSettings: _onOpenSettings,
|
|
962
969
|
toolbarExtras,
|
|
970
|
+
toolbarTrailing,
|
|
971
|
+
layoutVariant,
|
|
963
972
|
leadingChrome,
|
|
964
973
|
trailingChrome,
|
|
965
974
|
mode,
|
|
@@ -1025,6 +1034,7 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
1025
1034
|
// 工具栏"空间不足时优先隐藏快捷键提示"的测量 refs,见下方 useLayoutEffect。
|
|
1026
1035
|
const toolbarRowRef = useRef<HTMLDivElement>(null);
|
|
1027
1036
|
const toolbarLeftRef = useRef<HTMLDivElement>(null);
|
|
1037
|
+
const toolbarControlsRightRef = useRef<HTMLDivElement>(null);
|
|
1028
1038
|
const hintRef = useRef<HTMLDivElement>(null);
|
|
1029
1039
|
const sendButtonRef = useRef<HTMLButtonElement>(null);
|
|
1030
1040
|
const [hintsSuppressed, setHintsSuppressed] = useState(false);
|
|
@@ -1458,17 +1468,22 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
1458
1468
|
const check = () => {
|
|
1459
1469
|
if (row.clientWidth === 0) return; // 无布局环境(happy-dom)不干预
|
|
1460
1470
|
const hint = hintRef.current;
|
|
1471
|
+
const rightControls = toolbarControlsRightRef.current;
|
|
1461
1472
|
const send = sendButtonRef.current;
|
|
1462
1473
|
const prevShrink = left.style.flexShrink;
|
|
1474
|
+
const prevRightShrink = rightControls?.style.flexShrink ?? '';
|
|
1463
1475
|
left.style.flexShrink = '0';
|
|
1476
|
+
if (rightControls) rightControls.style.flexShrink = '0';
|
|
1464
1477
|
const prevHintDisplay = hint?.style.display ?? '';
|
|
1465
1478
|
if (hint) hint.style.display = 'block';
|
|
1466
1479
|
const needed =
|
|
1467
1480
|
left.getBoundingClientRect().width +
|
|
1468
1481
|
(hint?.getBoundingClientRect().width ?? 0) +
|
|
1482
|
+
(rightControls?.getBoundingClientRect().width ?? 0) +
|
|
1469
1483
|
(send?.getBoundingClientRect().width ?? 0) +
|
|
1470
|
-
|
|
1484
|
+
24; // 左右组间距 + 右侧组内间距
|
|
1471
1485
|
left.style.flexShrink = prevShrink;
|
|
1486
|
+
if (rightControls) rightControls.style.flexShrink = prevRightShrink;
|
|
1472
1487
|
if (hint) hint.style.display = prevHintDisplay;
|
|
1473
1488
|
const available = row.clientWidth - 16; // px-2 两侧
|
|
1474
1489
|
const suppress = needed > available + 1;
|
|
@@ -2151,19 +2166,46 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2151
2166
|
);
|
|
2152
2167
|
}
|
|
2153
2168
|
|
|
2169
|
+
const effectiveTrailing = toolbarTrailing ?? toolbarExtras;
|
|
2170
|
+
const isHeroVariant = layoutVariant === 'hero';
|
|
2171
|
+
const isChatVariant = layoutVariant === 'chat';
|
|
2172
|
+
const hasMentionedAgents = mentionReferences.some(
|
|
2173
|
+
(ref) => ref.type === 'agent' && ref.id !== selectedAgent?.id,
|
|
2174
|
+
);
|
|
2175
|
+
const isDefaultAgent = Boolean(
|
|
2176
|
+
selectedAgent &&
|
|
2177
|
+
sortedAgents.length > 0 &&
|
|
2178
|
+
selectedAgent.id === sortedAgents[0]?.id,
|
|
2179
|
+
);
|
|
2180
|
+
const showMetaAgent = isHeroVariant
|
|
2181
|
+
? false
|
|
2182
|
+
: isChatVariant
|
|
2183
|
+
? Boolean(selectedAgent && (!isDefaultAgent || hasMentionedAgents))
|
|
2184
|
+
: Boolean(selectedAgent);
|
|
2185
|
+
const showMetaLeading = !isHeroVariant && !isChatVariant && Boolean(leadingChrome);
|
|
2186
|
+
const showMetaRow =
|
|
2187
|
+
showMetaLeading || showMetaAgent || Boolean(trailingChrome);
|
|
2188
|
+
const showHeroTray =
|
|
2189
|
+
isHeroVariant &&
|
|
2190
|
+
Boolean(
|
|
2191
|
+
leadingChrome ||
|
|
2192
|
+
(execPolicy && onExecPolicyChange) ||
|
|
2193
|
+
selectedAgent,
|
|
2194
|
+
);
|
|
2195
|
+
|
|
2154
2196
|
return (
|
|
2155
2197
|
// @container:底栏元素的显隐/宽度用容器查询(@sm = 384px)而不是
|
|
2156
2198
|
// 视口断点——侧边栏占宽后,视口够宽但输入框本身可能已经很窄。
|
|
2157
2199
|
<div className="chat-input-container @container relative px-2.5 pb-2.5 pt-1">
|
|
2158
|
-
{
|
|
2200
|
+
{showMetaRow && (
|
|
2159
2201
|
<div
|
|
2160
2202
|
className="relative mb-1 flex min-w-0 items-end gap-1 pl-0.5"
|
|
2161
2203
|
data-testid="composer-meta-row"
|
|
2162
2204
|
>
|
|
2163
|
-
{(
|
|
2205
|
+
{(showMetaLeading || showMetaAgent) && (
|
|
2164
2206
|
<div className="flex h-6 min-w-0 items-center gap-1">
|
|
2165
|
-
{leadingChrome}
|
|
2166
|
-
{selectedAgent && (
|
|
2207
|
+
{showMetaLeading ? leadingChrome : null}
|
|
2208
|
+
{showMetaAgent && selectedAgent && (
|
|
2167
2209
|
<AgentSelect
|
|
2168
2210
|
refEl={agentMenuRef}
|
|
2169
2211
|
agent={selectedAgent}
|
|
@@ -2332,14 +2374,23 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2332
2374
|
)}
|
|
2333
2375
|
</div>
|
|
2334
2376
|
)}
|
|
2377
|
+
<div
|
|
2378
|
+
className={
|
|
2379
|
+
isHeroVariant
|
|
2380
|
+
? 'rounded-2xl border border-agent-border/50 bg-agent-muted/45 p-1 pb-1.5'
|
|
2381
|
+
: undefined
|
|
2382
|
+
}
|
|
2383
|
+
>
|
|
2335
2384
|
<div
|
|
2336
2385
|
ref={dropBoxRef}
|
|
2337
|
-
className={`chat-input-box flex flex-col
|
|
2386
|
+
className={`chat-input-box flex flex-col ${
|
|
2387
|
+
isHeroVariant ? 'rounded-xl shadow-2xs' : 'rounded-agent-lg shadow-sm'
|
|
2388
|
+
} border bg-agent-canvas transition-all duration-200 ${
|
|
2338
2389
|
isDragging
|
|
2339
2390
|
? 'border-blue-500 ring-2 ring-blue-500/20'
|
|
2340
2391
|
: mode === 'plan'
|
|
2341
2392
|
? 'border-amber-400/70 ring-1 ring-amber-400/20'
|
|
2342
|
-
: 'border-agent-border'
|
|
2393
|
+
: 'border-agent-border/85'
|
|
2343
2394
|
}`}
|
|
2344
2395
|
onDragOver={handleDragOver}
|
|
2345
2396
|
onDragLeave={handleDragLeave}
|
|
@@ -2383,7 +2434,7 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2383
2434
|
)}
|
|
2384
2435
|
<div className="chat-input-surface relative overflow-hidden">
|
|
2385
2436
|
<div
|
|
2386
|
-
className="chat-input-placeholder pointer-events-none absolute inset-x-0 top-0 px-2.5 pt-2 text-xs text-agent-muted-foreground"
|
|
2437
|
+
className="chat-input-placeholder pointer-events-none absolute inset-x-0 top-0 truncate px-2.5 pt-2 text-xs text-agent-muted-foreground"
|
|
2387
2438
|
style={{ visibility: value ? 'hidden' : undefined }}
|
|
2388
2439
|
>
|
|
2389
2440
|
{placeholder}
|
|
@@ -2427,65 +2478,53 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2427
2478
|
)}
|
|
2428
2479
|
<div
|
|
2429
2480
|
ref={toolbarRowRef}
|
|
2430
|
-
className="flex items-center justify-between gap-
|
|
2481
|
+
className="flex items-center justify-between gap-2 px-2 py-1.5 text-[12px] leading-[1.45]"
|
|
2431
2482
|
>
|
|
2432
|
-
{/* Left
|
|
2433
|
-
Agent picker lives in the meta row above the box, next to
|
|
2434
|
-
the project badge. min-w-0 允许窄屏时胶囊截断收缩。 */}
|
|
2483
|
+
{/* Left cluster: fixed [+] attachment anchor + active-chat permissions/project. */}
|
|
2435
2484
|
<div ref={toolbarLeftRef} className="flex min-w-0 items-center gap-1">
|
|
2436
|
-
{
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2485
|
+
{allowFileAttach && (
|
|
2486
|
+
<>
|
|
2487
|
+
<button
|
|
2488
|
+
type="button"
|
|
2489
|
+
onClick={handlePickFiles}
|
|
2490
|
+
disabled={disabled || isStreaming}
|
|
2491
|
+
className="flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-agent-muted-foreground transition-colors hover:bg-agent-foreground/8 hover:text-agent-foreground disabled:cursor-not-allowed disabled:opacity-50"
|
|
2492
|
+
title={t('Upload files, or paste images into the input box')}
|
|
2493
|
+
aria-label={t('Upload files')}
|
|
2494
|
+
data-testid="chat-attach"
|
|
2495
|
+
>
|
|
2496
|
+
<LuPlus className="h-4 w-4" />
|
|
2497
|
+
</button>
|
|
2498
|
+
<input
|
|
2499
|
+
ref={fileInputRef}
|
|
2500
|
+
type="file"
|
|
2501
|
+
multiple
|
|
2502
|
+
className="hidden"
|
|
2503
|
+
aria-hidden="true"
|
|
2504
|
+
tabIndex={-1}
|
|
2505
|
+
onChange={handleFileInputChange}
|
|
2506
|
+
/>
|
|
2507
|
+
</>
|
|
2442
2508
|
)}
|
|
2443
|
-
{execPolicy && onExecPolicyChange && (
|
|
2509
|
+
{!isHeroVariant && execPolicy && onExecPolicyChange && (
|
|
2444
2510
|
<ExecPolicyPicker
|
|
2445
2511
|
policy={execPolicy}
|
|
2446
2512
|
disabled={disabled}
|
|
2447
2513
|
onChange={onExecPolicyChange}
|
|
2448
2514
|
/>
|
|
2449
2515
|
)}
|
|
2450
|
-
{
|
|
2451
|
-
{allowFileAttach && (
|
|
2452
|
-
<>
|
|
2453
|
-
<button
|
|
2454
|
-
type="button"
|
|
2455
|
-
onClick={handlePickFiles}
|
|
2456
|
-
disabled={disabled || isStreaming}
|
|
2457
|
-
className="flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-agent-muted-foreground transition-colors hover:bg-agent-foreground/5 hover:text-agent-foreground disabled:cursor-not-allowed disabled:opacity-50"
|
|
2458
|
-
title={t('Upload files, or paste images into the input box')}
|
|
2459
|
-
aria-label={t('Upload files')}
|
|
2460
|
-
data-testid="chat-attach"
|
|
2461
|
-
>
|
|
2462
|
-
<LuPaperclip className="h-3 w-3" />
|
|
2463
|
-
</button>
|
|
2464
|
-
{/* 隐藏的原生多选文件输入:点击回形针按钮触发系统选择框。 */}
|
|
2465
|
-
<input
|
|
2466
|
-
ref={fileInputRef}
|
|
2467
|
-
type="file"
|
|
2468
|
-
multiple
|
|
2469
|
-
className="hidden"
|
|
2470
|
-
aria-hidden="true"
|
|
2471
|
-
tabIndex={-1}
|
|
2472
|
-
onChange={handleFileInputChange}
|
|
2473
|
-
/>
|
|
2474
|
-
</>
|
|
2475
|
-
)}
|
|
2516
|
+
{isChatVariant && leadingChrome ? leadingChrome : null}
|
|
2476
2517
|
</div>
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
<div className="flex
|
|
2480
|
-
{/* 快捷键提示:空闲态隐藏常规 Enter/Shift+Enter 教程以降噪;
|
|
2481
|
-
仅在流式期间提示低频高价值的排队/插队/停止,空间不足时优先收起 */}
|
|
2518
|
+
|
|
2519
|
+
{/* Right cluster: streaming shortcuts + Plan switch + ModelPicker/ContextRing + Send. */}
|
|
2520
|
+
<div className="flex min-w-0 items-center gap-1.5">
|
|
2482
2521
|
{isStreaming && (
|
|
2483
2522
|
<div
|
|
2484
2523
|
ref={hintRef}
|
|
2485
|
-
className={`${hintsSuppressed ? 'hidden' : 'block'} text-[11px] text-agent-muted-foreground/80`}
|
|
2524
|
+
className={`${hintsSuppressed ? 'hidden' : 'block'} shrink-0 text-[11px] text-agent-muted-foreground/80`}
|
|
2486
2525
|
>
|
|
2487
2526
|
{onFollowUp && (
|
|
2488
|
-
<span className="ml-
|
|
2527
|
+
<span className="ml-1.5">
|
|
2489
2528
|
<kbd className="rounded border border-agent-border bg-agent-muted px-1 font-sans text-[10px]">
|
|
2490
2529
|
Enter
|
|
2491
2530
|
</kbd>
|
|
@@ -2493,7 +2532,7 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2493
2532
|
</span>
|
|
2494
2533
|
)}
|
|
2495
2534
|
{onSteer && (
|
|
2496
|
-
<span className="ml-
|
|
2535
|
+
<span className="ml-1.5">
|
|
2497
2536
|
<kbd className="rounded border border-agent-border bg-agent-muted px-1 font-sans text-[10px]">
|
|
2498
2537
|
{MOD_KEY_LABEL}
|
|
2499
2538
|
</kbd>
|
|
@@ -2504,7 +2543,7 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2504
2543
|
<span className="ml-1">{t('Interject')}</span>
|
|
2505
2544
|
</span>
|
|
2506
2545
|
)}
|
|
2507
|
-
<span className="ml-
|
|
2546
|
+
<span className="ml-1.5">
|
|
2508
2547
|
<kbd className="rounded border border-agent-border bg-agent-muted px-1 font-sans text-[10px]">
|
|
2509
2548
|
Esc
|
|
2510
2549
|
</kbd>
|
|
@@ -2512,6 +2551,19 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2512
2551
|
</span>
|
|
2513
2552
|
</div>
|
|
2514
2553
|
)}
|
|
2554
|
+
<div
|
|
2555
|
+
ref={toolbarControlsRightRef}
|
|
2556
|
+
className="flex min-w-0 items-center gap-1"
|
|
2557
|
+
>
|
|
2558
|
+
{mode && onModeChange && getWebChatModes().length > 1 && (
|
|
2559
|
+
<ModePlanToggle
|
|
2560
|
+
mode={mode}
|
|
2561
|
+
disabled={Boolean(disabled)}
|
|
2562
|
+
onChange={onModeChange}
|
|
2563
|
+
/>
|
|
2564
|
+
)}
|
|
2565
|
+
{effectiveTrailing}
|
|
2566
|
+
</div>
|
|
2515
2567
|
<button
|
|
2516
2568
|
ref={sendButtonRef}
|
|
2517
2569
|
type="button"
|
|
@@ -2519,10 +2571,10 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2519
2571
|
disabled={!isStreaming && !canSend}
|
|
2520
2572
|
className={
|
|
2521
2573
|
isStreaming
|
|
2522
|
-
? 'flex h-
|
|
2574
|
+
? 'flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-agent-destructive text-white transition hover:opacity-90'
|
|
2523
2575
|
: canSend
|
|
2524
|
-
? 'flex h-
|
|
2525
|
-
: 'flex h-
|
|
2576
|
+
? 'flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-agent-foreground text-agent-canvas transition hover:opacity-90'
|
|
2577
|
+
: 'flex h-7 w-7 shrink-0 cursor-not-allowed items-center justify-center rounded-full bg-agent-muted text-agent-muted-foreground'
|
|
2526
2578
|
}
|
|
2527
2579
|
title={
|
|
2528
2580
|
isStreaming
|
|
@@ -2546,6 +2598,34 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2546
2598
|
</div>
|
|
2547
2599
|
</div>
|
|
2548
2600
|
</div>
|
|
2601
|
+
{showHeroTray && (
|
|
2602
|
+
<div
|
|
2603
|
+
className="flex flex-wrap items-center gap-1.5 px-2 pt-1.5"
|
|
2604
|
+
data-testid="composer-hero-tray"
|
|
2605
|
+
>
|
|
2606
|
+
{leadingChrome}
|
|
2607
|
+
{execPolicy && onExecPolicyChange && (
|
|
2608
|
+
<ExecPolicyPicker
|
|
2609
|
+
policy={execPolicy}
|
|
2610
|
+
disabled={disabled}
|
|
2611
|
+
onChange={onExecPolicyChange}
|
|
2612
|
+
/>
|
|
2613
|
+
)}
|
|
2614
|
+
{selectedAgent && (
|
|
2615
|
+
<AgentSelect
|
|
2616
|
+
refEl={agentMenuRef}
|
|
2617
|
+
agent={selectedAgent}
|
|
2618
|
+
agents={sortedAgents}
|
|
2619
|
+
open={agentMenuOpen}
|
|
2620
|
+
disabled={disabled || isStreaming || !onSelectAgent}
|
|
2621
|
+
onOpenChange={setAgentMenuOpen}
|
|
2622
|
+
onSelect={handleSelectAgent}
|
|
2623
|
+
mentionReferences={mentionReferences}
|
|
2624
|
+
/>
|
|
2625
|
+
)}
|
|
2626
|
+
</div>
|
|
2627
|
+
)}
|
|
2628
|
+
</div>
|
|
2549
2629
|
</div>
|
|
2550
2630
|
);
|
|
2551
2631
|
},
|
|
@@ -2556,10 +2636,10 @@ function agentInitial(agent: LocalChatAgent): string {
|
|
|
2556
2636
|
}
|
|
2557
2637
|
|
|
2558
2638
|
/**
|
|
2559
|
-
*
|
|
2560
|
-
* Plan
|
|
2639
|
+
* ModePlanToggle — single lightweight switch for Plan mode (WorkBuddy / DeepSeek style).
|
|
2640
|
+
* Off = default Agent execution mode; On = read-only Plan mode with amber highlight.
|
|
2561
2641
|
*/
|
|
2562
|
-
function
|
|
2642
|
+
function ModePlanToggle({
|
|
2563
2643
|
mode,
|
|
2564
2644
|
disabled,
|
|
2565
2645
|
onChange,
|
|
@@ -2568,52 +2648,30 @@ function ModeToggle({
|
|
|
2568
2648
|
disabled: boolean;
|
|
2569
2649
|
onChange: (mode: ChatMode) => void;
|
|
2570
2650
|
}) {
|
|
2651
|
+
const isPlan = mode === 'plan';
|
|
2571
2652
|
return (
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2653
|
+
<button
|
|
2654
|
+
type="button"
|
|
2655
|
+
role="switch"
|
|
2656
|
+
aria-checked={isPlan}
|
|
2657
|
+
disabled={disabled}
|
|
2658
|
+
onClick={() => onChange(isPlan ? 'agent' : 'plan')}
|
|
2659
|
+
title={
|
|
2660
|
+
isPlan
|
|
2661
|
+
? t('Plan mode is on. Click or press Shift+Tab to return to Agent mode')
|
|
2662
|
+
: t('Turn on Plan mode: explore read-only and make a plan first (Shift+Tab)')
|
|
2663
|
+
}
|
|
2664
|
+
data-testid="mode-plan"
|
|
2665
|
+
className={[
|
|
2666
|
+
'inline-flex h-6 shrink-0 items-center gap-1 rounded-full border px-2 text-[12px] leading-[1.45] transition-colors disabled:cursor-not-allowed disabled:opacity-70',
|
|
2667
|
+
isPlan
|
|
2668
|
+
? 'border-amber-400/55 bg-amber-400/15 font-medium text-amber-700 dark:text-amber-300'
|
|
2669
|
+
: 'border-transparent bg-transparent text-agent-muted-foreground hover:bg-agent-foreground/5 hover:text-agent-foreground',
|
|
2670
|
+
].join(' ')}
|
|
2579
2671
|
>
|
|
2580
|
-
<
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
aria-checked={mode === 'agent'}
|
|
2584
|
-
disabled={disabled}
|
|
2585
|
-
onClick={() => onChange('agent')}
|
|
2586
|
-
title={t('Agent mode: carry out the task directly (Shift+Tab)')}
|
|
2587
|
-
data-testid="mode-agent"
|
|
2588
|
-
className={[
|
|
2589
|
-
'inline-flex h-5 items-center gap-1 rounded-full px-1.5 text-[12px] leading-[1.45] transition-colors disabled:cursor-not-allowed disabled:opacity-70',
|
|
2590
|
-
mode === 'agent'
|
|
2591
|
-
? 'bg-agent-foreground/10 text-agent-foreground font-medium'
|
|
2592
|
-
: 'text-agent-muted-foreground hover:text-agent-foreground',
|
|
2593
|
-
].join(' ')}
|
|
2594
|
-
>
|
|
2595
|
-
<LuInfinity className="h-3 w-3" />
|
|
2596
|
-
<span className="@max-sm:hidden">{t('Agent')}</span>
|
|
2597
|
-
</button>
|
|
2598
|
-
<button
|
|
2599
|
-
type="button"
|
|
2600
|
-
role="radio"
|
|
2601
|
-
aria-checked={mode === 'plan'}
|
|
2602
|
-
disabled={disabled}
|
|
2603
|
-
onClick={() => onChange('plan')}
|
|
2604
|
-
title={t('Plan mode: explore read-only and make a plan first (Shift+Tab)')}
|
|
2605
|
-
data-testid="mode-plan"
|
|
2606
|
-
className={[
|
|
2607
|
-
'inline-flex h-5 items-center gap-1 rounded-full px-1.5 text-[12px] leading-[1.45] transition-colors disabled:cursor-not-allowed disabled:opacity-70',
|
|
2608
|
-
mode === 'plan'
|
|
2609
|
-
? 'bg-amber-400/20 text-amber-700 dark:text-amber-300 font-medium'
|
|
2610
|
-
: 'text-agent-muted-foreground hover:text-agent-foreground',
|
|
2611
|
-
].join(' ')}
|
|
2612
|
-
>
|
|
2613
|
-
<LuListChecks className="h-3 w-3" />
|
|
2614
|
-
<span className="@max-sm:hidden">{t('Plan')}</span>
|
|
2615
|
-
</button>
|
|
2616
|
-
</div>
|
|
2672
|
+
<LuListChecks className="h-3.5 w-3.5 shrink-0" />
|
|
2673
|
+
<span className="@max-sm:hidden">{t('Plan')}</span>
|
|
2674
|
+
</button>
|
|
2617
2675
|
);
|
|
2618
2676
|
}
|
|
2619
2677
|
|