@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
|
@@ -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;
|
|
@@ -210,6 +217,13 @@ type MentionQuery = {
|
|
|
210
217
|
// 里的工具卡片走同一份数据。
|
|
211
218
|
|
|
212
219
|
type SlashSuggestion =
|
|
220
|
+
| {
|
|
221
|
+
kind: 'command';
|
|
222
|
+
insertToken: string;
|
|
223
|
+
label: string;
|
|
224
|
+
description: string;
|
|
225
|
+
targetMode: ChatMode;
|
|
226
|
+
}
|
|
213
227
|
| { kind: 'skill'; insertToken: string; skill: SkillItem }
|
|
214
228
|
| { kind: 'mcp'; insertToken: string; mcp: McpToolItem };
|
|
215
229
|
|
|
@@ -953,6 +967,8 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
953
967
|
onSelectAgent,
|
|
954
968
|
onOpenSettings: _onOpenSettings,
|
|
955
969
|
toolbarExtras,
|
|
970
|
+
toolbarTrailing,
|
|
971
|
+
layoutVariant,
|
|
956
972
|
leadingChrome,
|
|
957
973
|
trailingChrome,
|
|
958
974
|
mode,
|
|
@@ -1018,6 +1034,7 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
1018
1034
|
// 工具栏"空间不足时优先隐藏快捷键提示"的测量 refs,见下方 useLayoutEffect。
|
|
1019
1035
|
const toolbarRowRef = useRef<HTMLDivElement>(null);
|
|
1020
1036
|
const toolbarLeftRef = useRef<HTMLDivElement>(null);
|
|
1037
|
+
const toolbarControlsRightRef = useRef<HTMLDivElement>(null);
|
|
1021
1038
|
const hintRef = useRef<HTMLDivElement>(null);
|
|
1022
1039
|
const sendButtonRef = useRef<HTMLButtonElement>(null);
|
|
1023
1040
|
const [hintsSuppressed, setHintsSuppressed] = useState(false);
|
|
@@ -1165,6 +1182,37 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
1165
1182
|
useEffect(() => {
|
|
1166
1183
|
if (slashQuery) {
|
|
1167
1184
|
const query = slashQuery.query;
|
|
1185
|
+
const modeCommandDefs: Array<{
|
|
1186
|
+
insertToken: string;
|
|
1187
|
+
label: string;
|
|
1188
|
+
description: string;
|
|
1189
|
+
targetMode: ChatMode;
|
|
1190
|
+
}> =
|
|
1191
|
+
onModeChange && getWebChatModes().includes('plan')
|
|
1192
|
+
? [
|
|
1193
|
+
{
|
|
1194
|
+
insertToken: 'plan',
|
|
1195
|
+
label: t('Plan mode'),
|
|
1196
|
+
description: t('Switch to Plan mode or send a planning request'),
|
|
1197
|
+
targetMode: 'plan',
|
|
1198
|
+
},
|
|
1199
|
+
{
|
|
1200
|
+
insertToken: 'agent',
|
|
1201
|
+
label: t('Agent mode'),
|
|
1202
|
+
description: t('Switch back to Agent mode'),
|
|
1203
|
+
targetMode: 'agent',
|
|
1204
|
+
},
|
|
1205
|
+
]
|
|
1206
|
+
: [];
|
|
1207
|
+
const commandMatches: SlashSuggestion[] = modeCommandDefs
|
|
1208
|
+
.filter(
|
|
1209
|
+
(cmd) =>
|
|
1210
|
+
cmd.insertToken.includes(query) ||
|
|
1211
|
+
cmd.label.toLowerCase().includes(query) ||
|
|
1212
|
+
cmd.description.toLowerCase().includes(query),
|
|
1213
|
+
)
|
|
1214
|
+
.map((cmd) => ({ kind: 'command' as const, ...cmd }));
|
|
1215
|
+
|
|
1168
1216
|
const builtinCommandSkills: SkillItem[] = [
|
|
1169
1217
|
{
|
|
1170
1218
|
name: 'compact',
|
|
@@ -1196,23 +1244,28 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
1196
1244
|
(t.description && t.description.toLowerCase().includes(query))
|
|
1197
1245
|
)
|
|
1198
1246
|
.map((t) => ({ kind: 'mcp' as const, insertToken: t.token, mcp: t }));
|
|
1199
|
-
const combined = [...skillMatches, ...mcpMatches];
|
|
1247
|
+
const combined = [...commandMatches, ...skillMatches, ...mcpMatches];
|
|
1200
1248
|
setSuggestions(combined);
|
|
1201
1249
|
setShowSuggestions(combined.length > 0);
|
|
1202
1250
|
setSelectedIndex(0);
|
|
1203
1251
|
} else {
|
|
1204
1252
|
setShowSuggestions(false);
|
|
1205
1253
|
}
|
|
1206
|
-
}, [slashQuery, skills, mcpTools]);
|
|
1254
|
+
}, [slashQuery, skills, mcpTools, onModeChange]);
|
|
1207
1255
|
|
|
1208
1256
|
// 渲染行:分组标题 + 候选项(idx 对应扁平 suggestions 的下标,供高亮/键盘导航)
|
|
1209
1257
|
const suggestionRows = useMemo(() => {
|
|
1210
1258
|
const rows: Array<
|
|
1211
1259
|
{ type: 'header'; label: string } | { type: 'item'; item: SlashSuggestion; idx: number }
|
|
1212
1260
|
> = [];
|
|
1261
|
+
const commandGroup = suggestions.filter((s) => s.kind === 'command');
|
|
1213
1262
|
const skillGroup = suggestions.filter((s) => s.kind === 'skill');
|
|
1214
1263
|
const mcpGroup = suggestions.filter((s) => s.kind === 'mcp');
|
|
1215
1264
|
let idx = 0;
|
|
1265
|
+
if (commandGroup.length > 0) {
|
|
1266
|
+
rows.push({ type: 'header', label: t('Chat mode') });
|
|
1267
|
+
for (const c of commandGroup) rows.push({ type: 'item', item: c, idx: idx++ });
|
|
1268
|
+
}
|
|
1216
1269
|
if (skillGroup.length > 0) {
|
|
1217
1270
|
rows.push({ type: 'header', label: t('Run a local skill (Skill)') });
|
|
1218
1271
|
for (const s of skillGroup) rows.push({ type: 'item', item: s, idx: idx++ });
|
|
@@ -1236,14 +1289,44 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
1236
1289
|
}
|
|
1237
1290
|
setAgentMenuOpen(false);
|
|
1238
1291
|
};
|
|
1292
|
+
const handleKeyDown = (event: globalThis.KeyboardEvent) => {
|
|
1293
|
+
if (event.key === 'Escape') {
|
|
1294
|
+
event.stopPropagation();
|
|
1295
|
+
setAgentMenuOpen(false);
|
|
1296
|
+
}
|
|
1297
|
+
};
|
|
1239
1298
|
window.addEventListener('pointerdown', handlePointerDown);
|
|
1240
|
-
|
|
1299
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
1300
|
+
return () => {
|
|
1301
|
+
window.removeEventListener('pointerdown', handlePointerDown);
|
|
1302
|
+
window.removeEventListener('keydown', handleKeyDown);
|
|
1303
|
+
};
|
|
1241
1304
|
}, [agentMenuOpen]);
|
|
1242
1305
|
|
|
1243
1306
|
const handleSelectSuggestion = (suggestion: SlashSuggestion) => {
|
|
1307
|
+
const range = slashQuery ?? { start: 0, end: value.length };
|
|
1308
|
+
if (suggestion.kind === 'command') {
|
|
1309
|
+
onModeChange?.(suggestion.targetMode);
|
|
1310
|
+
const before = value.slice(0, range.start);
|
|
1311
|
+
const after = value.slice(range.end).replace(/^\s+/, '');
|
|
1312
|
+
const nextValue = `${before}${after}`;
|
|
1313
|
+
const caret = before.length;
|
|
1314
|
+
pendingCaretOffsetRef.current = caret;
|
|
1315
|
+
onChange(nextValue);
|
|
1316
|
+
setSlashQuery(null);
|
|
1317
|
+
setShowSuggestions(false);
|
|
1318
|
+
setTimeout(() => {
|
|
1319
|
+
const editor = editorRef.current;
|
|
1320
|
+
if (editor) {
|
|
1321
|
+
editor.focus();
|
|
1322
|
+
setCaretOffset(editor, Math.min(caret, getEditableText(editor).length));
|
|
1323
|
+
}
|
|
1324
|
+
}, 50);
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1244
1328
|
const token = `/${suggestion.insertToken} `;
|
|
1245
1329
|
// 只替换光标处的 "/xxx" token,保留输入框里已有的其它内容。
|
|
1246
|
-
const range = slashQuery ?? { start: 0, end: value.length };
|
|
1247
1330
|
const nextValue = `${value.slice(0, range.start)}${token}${value.slice(range.end)}`;
|
|
1248
1331
|
const caret = range.start + token.length;
|
|
1249
1332
|
pendingCaretOffsetRef.current = caret;
|
|
@@ -1385,17 +1468,22 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
1385
1468
|
const check = () => {
|
|
1386
1469
|
if (row.clientWidth === 0) return; // 无布局环境(happy-dom)不干预
|
|
1387
1470
|
const hint = hintRef.current;
|
|
1471
|
+
const rightControls = toolbarControlsRightRef.current;
|
|
1388
1472
|
const send = sendButtonRef.current;
|
|
1389
1473
|
const prevShrink = left.style.flexShrink;
|
|
1474
|
+
const prevRightShrink = rightControls?.style.flexShrink ?? '';
|
|
1390
1475
|
left.style.flexShrink = '0';
|
|
1476
|
+
if (rightControls) rightControls.style.flexShrink = '0';
|
|
1391
1477
|
const prevHintDisplay = hint?.style.display ?? '';
|
|
1392
1478
|
if (hint) hint.style.display = 'block';
|
|
1393
1479
|
const needed =
|
|
1394
1480
|
left.getBoundingClientRect().width +
|
|
1395
1481
|
(hint?.getBoundingClientRect().width ?? 0) +
|
|
1482
|
+
(rightControls?.getBoundingClientRect().width ?? 0) +
|
|
1396
1483
|
(send?.getBoundingClientRect().width ?? 0) +
|
|
1397
|
-
|
|
1484
|
+
24; // 左右组间距 + 右侧组内间距
|
|
1398
1485
|
left.style.flexShrink = prevShrink;
|
|
1486
|
+
if (rightControls) rightControls.style.flexShrink = prevRightShrink;
|
|
1399
1487
|
if (hint) hint.style.display = prevHintDisplay;
|
|
1400
1488
|
const available = row.clientWidth - 16; // px-2 两侧
|
|
1401
1489
|
const suppress = needed > available + 1;
|
|
@@ -1934,6 +2022,21 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
1934
2022
|
}
|
|
1935
2023
|
}
|
|
1936
2024
|
|
|
2025
|
+
if (
|
|
2026
|
+
event.key === 'Tab' &&
|
|
2027
|
+
event.shiftKey &&
|
|
2028
|
+
!event.metaKey &&
|
|
2029
|
+
!event.ctrlKey &&
|
|
2030
|
+
!event.altKey &&
|
|
2031
|
+
mode &&
|
|
2032
|
+
onModeChange &&
|
|
2033
|
+
getWebChatModes().length > 1
|
|
2034
|
+
) {
|
|
2035
|
+
event.preventDefault();
|
|
2036
|
+
onModeChange(mode === 'plan' ? 'agent' : 'plan');
|
|
2037
|
+
return;
|
|
2038
|
+
}
|
|
2039
|
+
|
|
1937
2040
|
// 空闲时 Enter / ⌘/Ctrl+Enter 发送,Shift+Enter 换行。
|
|
1938
2041
|
// IME 候选确认的 Enter 已被上面的 composition 守卫拦截,不会误发送。
|
|
1939
2042
|
const isSendCombo =
|
|
@@ -2063,27 +2166,58 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2063
2166
|
);
|
|
2064
2167
|
}
|
|
2065
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
|
+
|
|
2066
2196
|
return (
|
|
2067
2197
|
// @container:底栏元素的显隐/宽度用容器查询(@sm = 384px)而不是
|
|
2068
2198
|
// 视口断点——侧边栏占宽后,视口够宽但输入框本身可能已经很窄。
|
|
2069
2199
|
<div className="chat-input-container @container relative px-2.5 pb-2.5 pt-1">
|
|
2070
|
-
{
|
|
2200
|
+
{showMetaRow && (
|
|
2071
2201
|
<div
|
|
2072
|
-
className="relative mb-1
|
|
2202
|
+
className="relative mb-1 flex min-w-0 items-end gap-1 pl-0.5"
|
|
2073
2203
|
data-testid="composer-meta-row"
|
|
2074
2204
|
>
|
|
2075
|
-
{
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2205
|
+
{(showMetaLeading || showMetaAgent) && (
|
|
2206
|
+
<div className="flex h-6 min-w-0 items-center gap-1">
|
|
2207
|
+
{showMetaLeading ? leadingChrome : null}
|
|
2208
|
+
{showMetaAgent && selectedAgent && (
|
|
2209
|
+
<AgentSelect
|
|
2210
|
+
refEl={agentMenuRef}
|
|
2211
|
+
agent={selectedAgent}
|
|
2212
|
+
agents={sortedAgents}
|
|
2213
|
+
open={agentMenuOpen}
|
|
2214
|
+
disabled={disabled || isStreaming || !onSelectAgent}
|
|
2215
|
+
onOpenChange={setAgentMenuOpen}
|
|
2216
|
+
onSelect={handleSelectAgent}
|
|
2217
|
+
mentionReferences={mentionReferences}
|
|
2218
|
+
/>
|
|
2219
|
+
)}
|
|
2220
|
+
</div>
|
|
2087
2221
|
)}
|
|
2088
2222
|
{trailingChrome && (
|
|
2089
2223
|
<div className="ml-auto flex items-center min-w-0">
|
|
@@ -2115,6 +2249,7 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2115
2249
|
>
|
|
2116
2250
|
{item.type === 'agent' ? (
|
|
2117
2251
|
<span
|
|
2252
|
+
aria-hidden="true"
|
|
2118
2253
|
className="mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full text-[9px] font-semibold text-white"
|
|
2119
2254
|
style={{ backgroundColor: item.color || '#7c3aed' }}
|
|
2120
2255
|
>
|
|
@@ -2171,13 +2306,31 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2171
2306
|
: 'text-agent-muted-foreground hover:bg-agent-foreground/5 hover:text-agent-foreground'
|
|
2172
2307
|
}`}
|
|
2173
2308
|
>
|
|
2174
|
-
{row.item.kind === '
|
|
2309
|
+
{row.item.kind === 'command' ? (
|
|
2310
|
+
row.item.targetMode === 'plan' ? (
|
|
2311
|
+
<LuListChecks className="h-3.5 w-3.5 mt-0.5 shrink-0 text-amber-600 dark:text-amber-400" />
|
|
2312
|
+
) : (
|
|
2313
|
+
<LuInfinity className="h-3.5 w-3.5 mt-0.5 shrink-0 text-agent-muted-foreground" />
|
|
2314
|
+
)
|
|
2315
|
+
) : row.item.kind === 'skill' ? (
|
|
2175
2316
|
<LuBlocks className="h-3.5 w-3.5 mt-0.5 shrink-0 text-agent-muted-foreground" />
|
|
2176
2317
|
) : (
|
|
2177
2318
|
<LuPlug className="h-3.5 w-3.5 mt-0.5 shrink-0 text-agent-muted-foreground" />
|
|
2178
2319
|
)}
|
|
2179
2320
|
<div className="min-w-0 flex-1">
|
|
2180
|
-
{row.item.kind === '
|
|
2321
|
+
{row.item.kind === 'command' ? (
|
|
2322
|
+
<>
|
|
2323
|
+
<div className="text-xs font-medium truncate">
|
|
2324
|
+
{row.item.label}
|
|
2325
|
+
<span className="ml-1.5 text-[10px] font-normal text-agent-muted-foreground/70">
|
|
2326
|
+
/{row.item.insertToken}
|
|
2327
|
+
</span>
|
|
2328
|
+
</div>
|
|
2329
|
+
<div className="text-[10px] text-agent-muted-foreground/80 line-clamp-1">
|
|
2330
|
+
{row.item.description}
|
|
2331
|
+
</div>
|
|
2332
|
+
</>
|
|
2333
|
+
) : row.item.kind === 'skill' ? (
|
|
2181
2334
|
<>
|
|
2182
2335
|
<div className="text-xs font-medium truncate">
|
|
2183
2336
|
{row.item.skill.displayName ? (
|
|
@@ -2221,14 +2374,23 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2221
2374
|
)}
|
|
2222
2375
|
</div>
|
|
2223
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
|
+
>
|
|
2224
2384
|
<div
|
|
2225
2385
|
ref={dropBoxRef}
|
|
2226
|
-
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 ${
|
|
2227
2389
|
isDragging
|
|
2228
2390
|
? 'border-blue-500 ring-2 ring-blue-500/20'
|
|
2229
2391
|
: mode === 'plan'
|
|
2230
2392
|
? 'border-amber-400/70 ring-1 ring-amber-400/20'
|
|
2231
|
-
: 'border-agent-border'
|
|
2393
|
+
: 'border-agent-border/85'
|
|
2232
2394
|
}`}
|
|
2233
2395
|
onDragOver={handleDragOver}
|
|
2234
2396
|
onDragLeave={handleDragLeave}
|
|
@@ -2272,7 +2434,7 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2272
2434
|
)}
|
|
2273
2435
|
<div className="chat-input-surface relative overflow-hidden">
|
|
2274
2436
|
<div
|
|
2275
|
-
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"
|
|
2276
2438
|
style={{ visibility: value ? 'hidden' : undefined }}
|
|
2277
2439
|
>
|
|
2278
2440
|
{placeholder}
|
|
@@ -2316,65 +2478,53 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2316
2478
|
)}
|
|
2317
2479
|
<div
|
|
2318
2480
|
ref={toolbarRowRef}
|
|
2319
|
-
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]"
|
|
2320
2482
|
>
|
|
2321
|
-
{/* Left
|
|
2322
|
-
Agent picker lives in the meta row above the box, next to
|
|
2323
|
-
the project badge. min-w-0 允许窄屏时胶囊截断收缩。 */}
|
|
2483
|
+
{/* Left cluster: fixed [+] attachment anchor + active-chat permissions/project. */}
|
|
2324
2484
|
<div ref={toolbarLeftRef} className="flex min-w-0 items-center gap-1">
|
|
2325
|
-
{
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
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
|
+
</>
|
|
2331
2508
|
)}
|
|
2332
|
-
{execPolicy && onExecPolicyChange && (
|
|
2509
|
+
{!isHeroVariant && execPolicy && onExecPolicyChange && (
|
|
2333
2510
|
<ExecPolicyPicker
|
|
2334
2511
|
policy={execPolicy}
|
|
2335
2512
|
disabled={disabled}
|
|
2336
2513
|
onChange={onExecPolicyChange}
|
|
2337
2514
|
/>
|
|
2338
2515
|
)}
|
|
2339
|
-
{
|
|
2340
|
-
{allowFileAttach && (
|
|
2341
|
-
<>
|
|
2342
|
-
<button
|
|
2343
|
-
type="button"
|
|
2344
|
-
onClick={handlePickFiles}
|
|
2345
|
-
disabled={disabled || isStreaming}
|
|
2346
|
-
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"
|
|
2347
|
-
title={t('Upload files, or paste images into the input box')}
|
|
2348
|
-
aria-label={t('Upload files')}
|
|
2349
|
-
data-testid="chat-attach"
|
|
2350
|
-
>
|
|
2351
|
-
<LuPaperclip className="h-3 w-3" />
|
|
2352
|
-
</button>
|
|
2353
|
-
{/* 隐藏的原生多选文件输入:点击回形针按钮触发系统选择框。 */}
|
|
2354
|
-
<input
|
|
2355
|
-
ref={fileInputRef}
|
|
2356
|
-
type="file"
|
|
2357
|
-
multiple
|
|
2358
|
-
className="hidden"
|
|
2359
|
-
aria-hidden="true"
|
|
2360
|
-
tabIndex={-1}
|
|
2361
|
-
onChange={handleFileInputChange}
|
|
2362
|
-
/>
|
|
2363
|
-
</>
|
|
2364
|
-
)}
|
|
2516
|
+
{isChatVariant && leadingChrome ? leadingChrome : null}
|
|
2365
2517
|
</div>
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
<div className="flex
|
|
2369
|
-
{/* 快捷键提示:空闲态隐藏常规 Enter/Shift+Enter 教程以降噪;
|
|
2370
|
-
仅在流式期间提示低频高价值的排队/插队/停止,空间不足时优先收起 */}
|
|
2518
|
+
|
|
2519
|
+
{/* Right cluster: streaming shortcuts + Plan switch + ModelPicker/ContextRing + Send. */}
|
|
2520
|
+
<div className="flex min-w-0 items-center gap-1.5">
|
|
2371
2521
|
{isStreaming && (
|
|
2372
2522
|
<div
|
|
2373
2523
|
ref={hintRef}
|
|
2374
|
-
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`}
|
|
2375
2525
|
>
|
|
2376
2526
|
{onFollowUp && (
|
|
2377
|
-
<span className="ml-
|
|
2527
|
+
<span className="ml-1.5">
|
|
2378
2528
|
<kbd className="rounded border border-agent-border bg-agent-muted px-1 font-sans text-[10px]">
|
|
2379
2529
|
Enter
|
|
2380
2530
|
</kbd>
|
|
@@ -2382,7 +2532,7 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2382
2532
|
</span>
|
|
2383
2533
|
)}
|
|
2384
2534
|
{onSteer && (
|
|
2385
|
-
<span className="ml-
|
|
2535
|
+
<span className="ml-1.5">
|
|
2386
2536
|
<kbd className="rounded border border-agent-border bg-agent-muted px-1 font-sans text-[10px]">
|
|
2387
2537
|
{MOD_KEY_LABEL}
|
|
2388
2538
|
</kbd>
|
|
@@ -2393,7 +2543,7 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2393
2543
|
<span className="ml-1">{t('Interject')}</span>
|
|
2394
2544
|
</span>
|
|
2395
2545
|
)}
|
|
2396
|
-
<span className="ml-
|
|
2546
|
+
<span className="ml-1.5">
|
|
2397
2547
|
<kbd className="rounded border border-agent-border bg-agent-muted px-1 font-sans text-[10px]">
|
|
2398
2548
|
Esc
|
|
2399
2549
|
</kbd>
|
|
@@ -2401,6 +2551,19 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2401
2551
|
</span>
|
|
2402
2552
|
</div>
|
|
2403
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>
|
|
2404
2567
|
<button
|
|
2405
2568
|
ref={sendButtonRef}
|
|
2406
2569
|
type="button"
|
|
@@ -2408,10 +2571,10 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2408
2571
|
disabled={!isStreaming && !canSend}
|
|
2409
2572
|
className={
|
|
2410
2573
|
isStreaming
|
|
2411
|
-
? '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'
|
|
2412
2575
|
: canSend
|
|
2413
|
-
? 'flex h-
|
|
2414
|
-
: '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'
|
|
2415
2578
|
}
|
|
2416
2579
|
title={
|
|
2417
2580
|
isStreaming
|
|
@@ -2435,6 +2598,34 @@ export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
|
|
|
2435
2598
|
</div>
|
|
2436
2599
|
</div>
|
|
2437
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>
|
|
2438
2629
|
</div>
|
|
2439
2630
|
);
|
|
2440
2631
|
},
|
|
@@ -2445,10 +2636,10 @@ function agentInitial(agent: LocalChatAgent): string {
|
|
|
2445
2636
|
}
|
|
2446
2637
|
|
|
2447
2638
|
/**
|
|
2448
|
-
*
|
|
2449
|
-
* 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.
|
|
2450
2641
|
*/
|
|
2451
|
-
function
|
|
2642
|
+
function ModePlanToggle({
|
|
2452
2643
|
mode,
|
|
2453
2644
|
disabled,
|
|
2454
2645
|
onChange,
|
|
@@ -2457,52 +2648,30 @@ function ModeToggle({
|
|
|
2457
2648
|
disabled: boolean;
|
|
2458
2649
|
onChange: (mode: ChatMode) => void;
|
|
2459
2650
|
}) {
|
|
2651
|
+
const isPlan = mode === 'plan';
|
|
2460
2652
|
return (
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
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(' ')}
|
|
2468
2671
|
>
|
|
2469
|
-
<
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
aria-checked={mode === 'agent'}
|
|
2473
|
-
disabled={disabled}
|
|
2474
|
-
onClick={() => onChange('agent')}
|
|
2475
|
-
title={t('Agent mode: carry out the task directly')}
|
|
2476
|
-
data-testid="mode-agent"
|
|
2477
|
-
className={[
|
|
2478
|
-
'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',
|
|
2479
|
-
mode === 'agent'
|
|
2480
|
-
? 'bg-agent-foreground/10 text-agent-foreground'
|
|
2481
|
-
: 'text-agent-muted-foreground hover:text-agent-foreground',
|
|
2482
|
-
].join(' ')}
|
|
2483
|
-
>
|
|
2484
|
-
<LuInfinity className="h-3 w-3" />
|
|
2485
|
-
<span className="@max-sm:hidden">Agent</span>
|
|
2486
|
-
</button>
|
|
2487
|
-
<button
|
|
2488
|
-
type="button"
|
|
2489
|
-
role="radio"
|
|
2490
|
-
aria-checked={mode === 'plan'}
|
|
2491
|
-
disabled={disabled}
|
|
2492
|
-
onClick={() => onChange('plan')}
|
|
2493
|
-
title={t('Plan mode: make a plan first, read only and no execution')}
|
|
2494
|
-
data-testid="mode-plan"
|
|
2495
|
-
className={[
|
|
2496
|
-
'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',
|
|
2497
|
-
mode === 'plan'
|
|
2498
|
-
? 'bg-amber-400/20 text-amber-600 dark:text-amber-400'
|
|
2499
|
-
: 'text-agent-muted-foreground hover:text-agent-foreground',
|
|
2500
|
-
].join(' ')}
|
|
2501
|
-
>
|
|
2502
|
-
<LuListChecks className="h-3 w-3" />
|
|
2503
|
-
<span className="@max-sm:hidden">Plan</span>
|
|
2504
|
-
</button>
|
|
2505
|
-
</div>
|
|
2672
|
+
<LuListChecks className="h-3.5 w-3.5 shrink-0" />
|
|
2673
|
+
<span className="@max-sm:hidden">{t('Plan')}</span>
|
|
2674
|
+
</button>
|
|
2506
2675
|
);
|
|
2507
2676
|
}
|
|
2508
2677
|
|
|
@@ -2555,18 +2724,25 @@ function AgentSelect({
|
|
|
2555
2724
|
type="button"
|
|
2556
2725
|
onClick={() => onOpenChange(!open)}
|
|
2557
2726
|
disabled={disabled}
|
|
2558
|
-
className="inline-flex max-w-[140px] items-center gap-1.5 rounded-full px-2
|
|
2727
|
+
className="inline-flex h-6 max-w-[140px] items-center gap-1.5 rounded-full px-2 text-[11px] leading-none text-agent-muted-foreground/85 transition-colors hover:bg-agent-foreground/5 hover:text-agent-foreground disabled:cursor-not-allowed disabled:opacity-70 @sm:max-w-[220px]"
|
|
2559
2728
|
title={buttonTitle}
|
|
2560
2729
|
aria-haspopup="menu"
|
|
2561
2730
|
aria-expanded={open}
|
|
2562
2731
|
data-testid="agent-select"
|
|
2563
2732
|
>
|
|
2564
|
-
<
|
|
2733
|
+
<span
|
|
2734
|
+
aria-hidden="true"
|
|
2735
|
+
data-testid="agent-color-dot"
|
|
2736
|
+
className="h-2 w-2 shrink-0 rounded-full"
|
|
2737
|
+
style={{ backgroundColor: agent.color || '#7c3aed' }}
|
|
2738
|
+
/>
|
|
2565
2739
|
<span className="truncate font-medium">
|
|
2566
2740
|
{agentLabel(agent)}
|
|
2567
2741
|
{mentionedAgentCount > 0 ? ` +${mentionedAgentCount}` : ''}
|
|
2568
2742
|
</span>
|
|
2569
|
-
<LuChevronDown
|
|
2743
|
+
<LuChevronDown
|
|
2744
|
+
className={`h-3 w-3 shrink-0 text-agent-muted-foreground transition-transform ${open ? 'rotate-180' : ''}`}
|
|
2745
|
+
/>
|
|
2570
2746
|
</button>
|
|
2571
2747
|
|
|
2572
2748
|
{open && (
|
|
@@ -2648,7 +2824,8 @@ function AgentSelect({
|
|
|
2648
2824
|
function AgentDot({ agent }: { agent: LocalChatAgent }) {
|
|
2649
2825
|
return (
|
|
2650
2826
|
<span
|
|
2651
|
-
|
|
2827
|
+
aria-hidden="true"
|
|
2828
|
+
className="mt-0.5 inline-flex shrink-0 items-center justify-center rounded-full text-[9px] font-semibold text-white"
|
|
2652
2829
|
style={{
|
|
2653
2830
|
width: 14,
|
|
2654
2831
|
height: 14,
|