@steerable/agent-shell-web 0.14.4 → 0.14.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/package.json +4 -4
  2. package/src/components/AgentSidebar.tsx +189 -46
  3. package/src/components/ChatHeader.tsx +12 -1
  4. package/src/components/SidebarAccount.tsx +33 -41
  5. package/src/components/chat/AssistantMessage.tsx +25 -4
  6. package/src/components/chat/ChatInput.tsx +169 -111
  7. package/src/components/chat/ChatProjectBadge.tsx +233 -88
  8. package/src/components/chat/ContextUsagePill.tsx +20 -5
  9. package/src/components/chat/ExecPolicyPicker.tsx +72 -67
  10. package/src/components/chat/LocalChatPanel.tsx +34 -34
  11. package/src/components/chat/MessageList.tsx +109 -19
  12. package/src/components/chat/ModelPicker.tsx +2 -2
  13. package/src/components/chat/SessionTodoList.tsx +63 -72
  14. package/src/components/chat/TurnFilesCard.tsx +270 -112
  15. package/src/components/chat/TurnProcessGroup.tsx +3 -0
  16. package/src/components/chat/TurnProcessTimeline.tsx +13 -0
  17. package/src/components/chat/UserMessage.tsx +8 -1
  18. package/src/components/chat/next-steps-tags.ts +13 -0
  19. package/src/components/chat/process-status.ts +112 -2
  20. package/src/components/chat/todo-list-model.ts +52 -4
  21. package/src/components/settings/AgentsSettingsPanel.tsx +3 -3
  22. package/src/components/settings/AppUpdateSettingsPanel.tsx +67 -43
  23. package/src/components/settings/AppearanceSettingsPanel.tsx +101 -134
  24. package/src/components/settings/CliInstallSettingsPanel.tsx +25 -23
  25. package/src/components/settings/DiagnoseSettingsPanel.tsx +3 -3
  26. package/src/components/settings/InsightsSettingsPanel.tsx +5 -7
  27. package/src/components/settings/LlmSettingsPanel.tsx +22 -2
  28. package/src/components/settings/McpSettingsPanel.tsx +4 -5
  29. package/src/components/settings/MemorySettingsPanel.tsx +210 -159
  30. package/src/components/settings/OrchestrationSettingsPanel.tsx +79 -121
  31. package/src/components/settings/PortableSettingsPanel.tsx +62 -49
  32. package/src/components/settings/PythonRunnerSettingsPanel.tsx +2 -4
  33. package/src/components/settings/SecuritySettingsPanel.tsx +91 -70
  34. package/src/components/settings/SettingsSidebar.tsx +238 -0
  35. package/src/components/settings/SkillsSettingsPanel.tsx +3 -4
  36. package/src/components/settings/TelemetrySettingsPanel.tsx +2 -7
  37. package/src/components/settings/UsagePanel.tsx +27 -35
  38. package/src/components/settings/WebSearchSettingsPanel.tsx +89 -88
  39. package/src/components/settings/primitives.tsx +302 -0
  40. package/src/components/settings/settings-registry.ts +371 -0
  41. package/src/layouts/AgentLayout.tsx +275 -12
  42. package/src/layouts/PanelToggleButton.tsx +27 -9
  43. package/src/layouts/conversation-preview.ts +3 -0
  44. package/src/layouts/request-chat-slot.ts +20 -0
  45. package/src/layouts/right-panel-tabs.ts +32 -0
  46. package/src/lib/chat-draft-store.ts +43 -0
  47. package/src/lib/file-preview-registry.ts +57 -0
  48. package/src/packs/registry.ts +2 -0
  49. package/src/pages/AgentPage.tsx +17 -4
  50. package/src/pages/SettingsPage.tsx +327 -489
  51. package/src/styles/index.css +6 -0
@@ -1,24 +1,8 @@
1
- import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
2
- import {
3
- LuActivity,
4
- LuBlocks,
5
- LuBookOpen,
6
- LuBot,
7
- LuChartBar,
8
- LuCodeXml,
9
- LuDownload,
10
- LuGitFork,
11
- LuInfo,
12
- LuMonitor,
13
- LuNetwork,
14
- LuPlug,
15
- LuSearch,
16
- LuSettings,
17
- LuShieldCheck,
18
- } from 'react-icons/lu';
19
- import { useOutletContext, useSearchParams } from 'react-router-dom';
1
+ import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react';
2
+ import { LuArrowLeft } from 'react-icons/lu';
3
+ import { useNavigate, useOutletContext, useSearchParams } from 'react-router-dom';
20
4
  import { hasHostBridge } from '@/lib/host-bridge';
21
- import { getLocale, t } from '@/i18n';
5
+ import { t } from '@/i18n';
22
6
  import { useAppRelease } from '@/components/SidebarRelease';
23
7
  import { AgentsSettingsPanel } from '@/components/settings/AgentsSettingsPanel';
24
8
  import { AppearanceSettingsPanel } from '@/components/settings/AppearanceSettingsPanel';
@@ -41,502 +25,356 @@ import { SettingsSaveButton } from '@/components/settings/SettingsSaveButton';
41
25
  import { TelemetrySettingsPanel } from '@/components/settings/TelemetrySettingsPanel';
42
26
  import { UsagePanel } from '@/components/settings/UsagePanel';
43
27
  import { WebSearchSettingsPanel } from '@/components/settings/WebSearchSettingsPanel';
44
- import { SettingsNavMenu, type SettingsNavItem } from '@/components/settings/SettingsNavMenu';
28
+ import {
29
+ SettingDisclosure,
30
+ SettingPageShell,
31
+ SettingSection,
32
+ } from '@/components/settings/primitives';
33
+ import {
34
+ buildSettingsNavEntries,
35
+ resolveSettingsRoute,
36
+ } from '@/components/settings/settings-registry';
45
37
  import { getPackSettingsPanels } from '@/packs/registry';
46
38
  import { settingsChrome } from '@/lib/host-tools';
47
- import { isPortableEnabled } from '@/lib/portable';
48
39
  import type { AgentOutletContext } from '@/layouts/AgentLayout';
49
40
 
50
- type SettingsSection = 'plugins' | 'general';
51
- type PluginTab = 'agents' | 'skills' | 'mcp' | 'web-search';
52
-
53
- const PLUGIN_TABS: readonly PluginTab[] = ['agents', 'skills', 'mcp', 'web-search'];
54
-
55
- /** 每次渲染现取,文案跟随当前语言。 */
56
- function pluginTabMeta(): Record<PluginTab, { label: string; noun: string; Icon: typeof LuBot }> {
57
- return {
58
- agents: { label: t('Agents'), noun: t('agents'), Icon: LuBot },
59
- skills: { label: 'Skills', noun: t('skills'), Icon: LuBlocks },
60
- mcp: { label: 'MCP', noun: t('MCP servers'), Icon: LuPlug },
61
- 'web-search': { label: t('Web search'), noun: t('web search'), Icon: LuSearch },
62
- };
63
- }
64
-
65
- function isPluginTab(value: string | null): value is PluginTab {
66
- return (PLUGIN_TABS as readonly string[]).includes(value ?? '');
67
- }
68
-
69
- function pluginsSummary(tabs: readonly PluginTab[]): string {
70
- const meta = pluginTabMeta();
71
- const nouns = tabs.map((id) => meta[id].noun);
72
- const items =
73
- nouns.length === 0
74
- ? t('plugins')
75
- : new Intl.ListFormat(getLocale(), { type: 'conjunction' }).format(nouns);
76
- return t('Manage {items}.', { items });
77
- }
78
-
79
- function enabledPluginTabs(): PluginTab[] {
80
- return PLUGIN_TABS.filter((id) => settingsChrome(id));
81
- }
82
-
83
- function resolveSection(raw: string | null): SettingsSection {
84
- if (raw === 'plugins') return enabledPluginTabs().length > 0 ? 'plugins' : 'general';
85
- if ((raw === 'agents' || raw === 'skills' || raw === 'mcp') && settingsChrome(raw)) {
86
- return 'plugins';
87
- }
88
- return 'general';
89
- }
90
-
91
- /** `?section=agents|skills|mcp` 是旧深链,仍打开插件页上对应分类。 */
92
- function resolvePluginTab(section: string | null, tab: string | null): PluginTab | null {
93
- const enabled = enabledPluginTabs();
94
- const requested =
95
- section === 'agents' || section === 'skills' || section === 'mcp' ? section : tab;
96
- if (isPluginTab(requested) && enabled.includes(requested)) {
97
- return requested;
98
- }
99
- return enabled[0] ?? null;
100
- }
101
-
102
41
  /**
103
- * `/settings` — 右侧内容区的设置页,按 `?section=` 分成独立页面:
104
- * - `plugins` 侧栏「插件」。顶栏分类切换智能体 / Skills / MCP / 网络搜索
105
- * (`?tab=`,旧的 `?section=agents|skills|mcp` 仍落到对应分类)
106
- * - 缺省/`general` 侧栏底「设置」(界面 / 模型 / 搜索 / 用量 / 安全 / 洞察 / 遥测 / 关于)
107
- *
108
- * Panel 数据自管理(挂载即拉取),页面本身不持有后端状态。
42
+ * `/settings` — Codex × WorkBuddy 式单页按需懒挂载设置画布:
43
+ * - 左侧导航栏已在 `AgentLayout` 原地切换为 `SettingsSidebar`(含搜索与返回原对话);
44
+ * - 右侧主画布每次仅挂载当前 `activeTabId` 对应的单个子页,根除 14 路并发请求风暴;
45
+ * - 100% 兼容 `?tab=<id>` 与存量 `?section=plugins|agents|skills|mcp|llm|diagnose|...` 深链;
46
+ * - 撤除误导性全局顶栏保存按钮,仅在 `llm`(模型服务)子页页头提供就地凭证保存。
109
47
  */
110
48
  export function SettingsPage() {
111
49
  const [searchParams, setSearchParams] = useSearchParams();
112
- const rawSection = searchParams.get('section');
113
- const section = resolveSection(rawSection);
114
- const pluginTab = section === 'plugins' ? resolvePluginTab(rawSection, searchParams.get('tab')) : null;
115
- const pluginTabs = section === 'plugins' ? enabledPluginTabs() : [];
116
- const selectPluginTab = useCallback((id: PluginTab) => {
117
- setSearchParams({ section: 'plugins', tab: id });
118
- }, [setSearchParams]);
50
+ const navigate = useNavigate();
119
51
  const catalog = useOutletContext<AgentOutletContext | null>();
120
52
  const release = useAppRelease();
121
53
  const llmPanelRef = useRef<LlmSettingsPanelHandle>(null);
122
- const pageContainerRef = useRef<HTMLDivElement>(null);
123
- const scrollRef = useRef<HTMLDivElement>(null);
124
- const contentRef = useRef<HTMLDivElement>(null);
125
- const [containerWidth, setContainerWidth] = useState<number>(0);
126
- const [activeSectionId, setActiveSectionId] = useState<string | null>(null);
127
- const [renderedSectionIds, setRenderedSectionIds] = useState<Set<string> | null>(null);
128
54
  const [llmSaveUi, setLlmSaveUi] = useState<LlmSaveUi>({
129
55
  saving: false,
130
56
  savedOk: false,
131
57
  loading: true,
132
58
  });
133
59
 
134
- useEffect(() => {
135
- const el = pageContainerRef.current;
136
- if (!el || typeof ResizeObserver === 'undefined') return;
137
- const ro = new ResizeObserver((entries) => {
138
- for (const entry of entries) {
139
- setContainerWidth(entry.contentRect.width);
140
- }
141
- });
142
- ro.observe(el);
143
- return () => ro.disconnect();
144
- }, []);
145
-
146
- // 扫描右侧实际挂载且未被隐藏 (display !== 'none') 的设置分段
147
- const updateRenderedSections = useCallback(() => {
148
- const container = contentRef.current;
149
- if (!container) return;
150
- const sectionEls = container.querySelectorAll<HTMLElement>('[data-testid^="settings-section-"]');
151
- const ids = new Set<string>();
152
- sectionEls.forEach((el) => {
153
- const tid = el.getAttribute('data-testid');
154
- if (!tid) return;
155
- const id = tid.replace('settings-section-', '');
156
- if (typeof window !== 'undefined' && window.getComputedStyle) {
157
- const style = window.getComputedStyle(el);
158
- if (style.display === 'none' || style.visibility === 'hidden') return;
159
- }
160
- ids.add(id);
161
- });
162
-
163
- setRenderedSectionIds((prev) => {
164
- if (prev && prev.size === ids.size && [...ids].every((id) => prev.has(id))) {
165
- return prev;
166
- }
167
- return ids;
168
- });
169
- }, []);
170
-
171
- useLayoutEffect(() => {
172
- updateRenderedSections();
173
- const container = contentRef.current;
174
- if (!container || typeof MutationObserver === 'undefined') return;
175
- const observer = new MutationObserver(() => {
176
- updateRenderedSections();
177
- });
178
- observer.observe(container, {
179
- childList: true,
180
- subtree: true,
181
- attributes: true,
182
- attributeFilter: ['style', 'class', 'hidden'],
183
- });
184
- return () => observer.disconnect();
185
- }, [updateRenderedSections]);
186
-
187
- // 页面宽度 >= 920px 视为宽屏(有足够空间并排容纳左侧边栏目录与主设置表单)
188
- const isWide = containerWidth >= 920;
189
-
190
- const allCandidates = useMemo<SettingsNavItem[]>(() => {
191
- if (section !== 'general') return [];
192
- const list: SettingsNavItem[] = [];
193
-
194
- if (settingsChrome('appearance')) {
195
- list.push({ id: 'appearance', label: t('Interface'), Icon: LuMonitor });
196
- }
197
- list.push({ id: 'orchestration', label: t('Orchestration'), Icon: LuGitFork });
198
-
199
- if (settingsChrome('llm')) {
200
- list.push({ id: 'llm', label: t('Local model settings'), Icon: LuSettings });
201
- }
202
- if (settingsChrome('web-search')) {
203
- list.push({ id: 'web-search', label: t('Web search'), Icon: LuSearch });
204
- }
205
- if (settingsChrome('usage')) {
206
- list.push({ id: 'usage', label: t('Usage and cost'), Icon: LuChartBar });
207
- }
208
- if (settingsChrome('diagnose')) {
209
- list.push({ id: 'diagnose', label: t('Connection diagnostics'), Icon: LuNetwork });
210
- }
211
- if (settingsChrome('security')) {
212
- list.push({ id: 'security', label: t('Security'), Icon: LuShieldCheck });
213
- }
214
- list.push({ id: 'memory', label: t('Memory'), Icon: LuBookOpen });
215
- if (settingsChrome('insights')) {
216
- list.push({ id: 'insights', label: t('Help improve the product'), Icon: LuChartBar });
217
- }
218
- if (settingsChrome('telemetry')) {
219
- list.push({ id: 'telemetry', label: t('Telemetry (OTLP)'), Icon: LuActivity });
220
- }
221
-
222
- const packPanels = getPackSettingsPanels();
223
- for (const panel of packPanels) {
224
- list.push({
225
- id: panel.panelId,
226
- label: t(panel.title),
227
- Icon: panel.Icon ?? LuSettings,
228
- });
229
- }
230
-
231
- if (isPortableEnabled()) {
232
- list.push({ id: 'portable', label: t('Backup and migration'), Icon: LuDownload });
233
- }
234
- if (hasHostBridge()) {
235
- list.push({ id: 'python-runner', label: t('Python runtime'), Icon: LuCodeXml });
236
- }
237
- if (release.version) {
238
- list.push({ id: 'update', label: t('Software update'), Icon: LuInfo });
239
- }
240
-
241
- return list;
242
- }, [section, release.version]);
60
+ const navEntries = useMemo(
61
+ () =>
62
+ buildSettingsNavEntries({
63
+ hiddenNavItems: catalog?.hiddenNavItems,
64
+ releaseVersion: release.version,
65
+ }),
66
+ [catalog?.hiddenNavItems, release.version],
67
+ );
243
68
 
244
- // 严格过滤:右侧实际未挂载或隐藏的分段,左侧菜单一律不显示
245
- const menuItems = useMemo<SettingsNavItem[]>(() => {
246
- if (section !== 'general') return [];
247
- if (renderedSectionIds !== null) {
248
- return allCandidates.filter((item) => renderedSectionIds.has(item.id));
249
- }
250
- return allCandidates;
251
- }, [section, allCandidates, renderedSectionIds]);
69
+ const { tabId: activeTabId, anchorId } = useMemo(
70
+ () =>
71
+ resolveSettingsRoute(
72
+ searchParams,
73
+ navEntries.map((entry) => entry.id),
74
+ ),
75
+ [searchParams, navEntries],
76
+ );
252
77
 
253
- const handleSelectSection = useCallback((id: string) => {
254
- setActiveSectionId(id);
255
- const target = document.querySelector(`[data-testid="settings-section-${id}"]`);
256
- if (target) {
257
- target.scrollIntoView({ behavior: 'smooth', block: 'start' });
78
+ useEffect(() => {
79
+ if (!anchorId) return;
80
+ const target = document.getElementById(anchorId);
81
+ target?.scrollIntoView?.({ behavior: 'smooth', block: 'start' });
82
+ }, [activeTabId, anchorId]);
83
+
84
+ const previewBanner = !hasHostBridge() ? (
85
+ <p className="rounded-agent-md border border-agent-destructive/20 bg-agent-destructive/10 p-2.5 text-xs text-agent-destructive">
86
+ {t('Browser preview mode: no host bridge, so some settings are unavailable.')}
87
+ </p>
88
+ ) : null;
89
+
90
+ const packPanels = getPackSettingsPanels();
91
+ const activePackPanel = packPanels.find((panel) => panel.panelId === activeTabId);
92
+
93
+ const selectMobileTab = (id: string) => {
94
+ const next = new URLSearchParams();
95
+ if (id !== 'general') {
96
+ next.set('tab', id);
258
97
  }
259
- }, []);
260
-
261
- const handleScroll = useCallback(() => {
262
- if (!scrollRef.current || menuItems.length === 0) return;
263
- const containerTop = scrollRef.current.getBoundingClientRect().top;
264
- let closestId: string | null = null;
265
- let minDistance = Infinity;
98
+ setSearchParams(next);
99
+ };
266
100
 
267
- for (const item of menuItems) {
268
- const el = document.querySelector(`[data-testid="settings-section-${item.id}"]`);
269
- if (el) {
270
- const top = el.getBoundingClientRect().top - containerTop;
271
- if (top <= 120 && Math.abs(top) < minDistance) {
272
- minDistance = Math.abs(top);
273
- closestId = item.id;
274
- }
275
- }
276
- }
277
- if (closestId) {
278
- setActiveSectionId(closestId);
279
- }
280
- }, [menuItems]);
101
+ const withMobileChrome = (page: ReactNode) => (
102
+ <div className="flex h-full flex-col overflow-hidden">
103
+ <div className="flex flex-col gap-2 border-b border-agent-border/60 bg-agent-canvas px-4 py-2.5 sm:hidden">
104
+ <button
105
+ type="button"
106
+ data-testid="settings-mobile-back"
107
+ onClick={() => (catalog?.onExitSettings ? catalog.onExitSettings() : navigate('/agent'))}
108
+ className="inline-flex w-fit items-center gap-1.5 text-xs font-medium text-agent-muted-foreground hover:text-agent-foreground"
109
+ >
110
+ <LuArrowLeft className="h-3.5 w-3.5" />
111
+ <span>{t('Back to chat')}</span>
112
+ </button>
113
+ <div
114
+ role="tablist"
115
+ aria-label={t('Settings navigation')}
116
+ className="flex items-center gap-1 overflow-x-auto pb-0.5"
117
+ >
118
+ {navEntries.map((entry) => {
119
+ const active = entry.id === activeTabId;
120
+ return (
121
+ <button
122
+ key={entry.id}
123
+ type="button"
124
+ role="tab"
125
+ aria-selected={active}
126
+ data-testid={`settings-mobile-tab-${entry.id}`}
127
+ onClick={() => selectMobileTab(entry.id)}
128
+ className={[
129
+ 'h-7 shrink-0 rounded-full px-2.5 text-xs font-medium transition-colors',
130
+ active
131
+ ? 'bg-agent-foreground text-agent-canvas'
132
+ : 'bg-agent-muted/60 text-agent-muted-foreground hover:text-agent-foreground',
133
+ ].join(' ')}
134
+ >
135
+ {t(entry.label)}
136
+ </button>
137
+ );
138
+ })}
139
+ </div>
140
+ </div>
141
+ <div className="min-h-0 flex-1 overflow-hidden">{page}</div>
142
+ </div>
143
+ );
281
144
 
282
- const title = section === 'plugins' ? t('Plugins') : t('Settings');
283
- const pluginMeta = pluginTabMeta();
145
+ if (activePackPanel) {
146
+ return withMobileChrome(
147
+ <SettingPageShell
148
+ title={t(activePackPanel.title)}
149
+ description={activePackPanel.description ? t(activePackPanel.description) : undefined}
150
+ banner={previewBanner}
151
+ testId={`settings-section-${activePackPanel.panelId}`}
152
+ >
153
+ <activePackPanel.Component />
154
+ </SettingPageShell>,
155
+ );
156
+ }
284
157
 
285
- return (
286
- <div ref={pageContainerRef} className="flex h-full w-full flex-col overflow-hidden">
287
- <header className="flex h-9 flex-shrink-0 items-center justify-between gap-2 border-b border-agent-border px-2.5">
288
- <div className="flex min-w-0 items-center gap-2">
289
- <h1 className="shrink-0 text-xs font-semibold text-agent-foreground">{title}</h1>
290
- {section === 'plugins' && pluginTabs.length > 1 && (
291
- <div
292
- role="tablist"
293
- aria-label={t('Plugins')}
294
- data-testid="plugins-tabs"
295
- className="flex min-w-0 items-center gap-1"
296
- >
297
- {pluginTabs.map((id) => {
298
- const meta = pluginMeta[id];
299
- const active = pluginTab === id;
300
- return (
301
- <button
302
- key={id}
303
- type="button"
304
- role="tab"
305
- aria-selected={active}
306
- data-testid={`plugins-tab-${id}`}
307
- onClick={() => selectPluginTab(id)}
308
- className={[
309
- 'flex h-7 items-center gap-1.5 rounded-full px-2.5 text-xs transition-colors',
310
- active
311
- ? 'bg-agent-foreground/10 font-medium text-agent-foreground'
312
- : 'text-agent-muted-foreground hover:bg-agent-foreground/5 hover:text-agent-foreground',
313
- ].join(' ')}
314
- >
315
- <meta.Icon className="h-3.5 w-3.5" />
316
- {meta.label}
317
- </button>
318
- );
319
- })}
320
- </div>
158
+ const pageBody = (() => {
159
+ switch (activeTabId) {
160
+ case 'llm':
161
+ return (
162
+ <SettingPageShell
163
+ title={t('Models')}
164
+ description={t(
165
+ 'Configure model provider, gateway URL, API key, and advanced parameters.',
321
166
  )}
322
- </div>
323
- {section === 'general' && settingsChrome('llm') && (
324
- <SettingsSaveButton
325
- testId="settings-header-save"
326
- saving={llmSaveUi.saving}
327
- savedOk={llmSaveUi.savedOk}
328
- disabled={llmSaveUi.saving || llmSaveUi.loading}
329
- onClick={() => void llmPanelRef.current?.save()}
167
+ banner={previewBanner}
168
+ testId="settings-section-llm"
169
+ headerAction={
170
+ <SettingsSaveButton
171
+ testId="settings-header-save"
172
+ saving={llmSaveUi.saving}
173
+ savedOk={llmSaveUi.savedOk}
174
+ disabled={llmSaveUi.saving || llmSaveUi.loading}
175
+ onClick={() => void llmPanelRef.current?.save()}
176
+ />
177
+ }
178
+ >
179
+ <LlmSettingsPanel
180
+ ref={llmPanelRef}
181
+ showFooterSave={false}
182
+ collapseAdvanced
183
+ onSaveUiChange={setLlmSaveUi}
330
184
  />
331
- )}
332
- </header>
333
-
334
- <div
335
- ref={scrollRef}
336
- onScroll={handleScroll}
337
- className="min-h-0 flex-1 overflow-y-auto"
338
- >
339
- <div
340
- className={`mx-auto px-4 py-3 ${
341
- isWide && menuItems.length > 0 ? 'flex max-w-5xl justify-center gap-6' : 'max-w-3xl'
342
- }`}
185
+ </SettingPageShell>
186
+ );
187
+
188
+ case 'agents':
189
+ return (
190
+ <SettingPageShell
191
+ title={t('Agents')}
192
+ description={t('Create and customize role prompts, skills, and tool permissions.')}
193
+ width="wide"
194
+ banner={previewBanner}
195
+ testId="settings-section-agents"
343
196
  >
344
- {isWide && menuItems.length > 0 ? (
345
- <SettingsNavMenu
346
- items={menuItems}
347
- activeId={activeSectionId ?? menuItems[0]?.id ?? null}
348
- onSelect={handleSelectSection}
349
- />
350
- ) : null}
351
-
352
- <div ref={contentRef} className="min-w-0 flex-1 max-w-3xl space-y-4">
353
- {!hasHostBridge() && (
354
- <p className="rounded-agent-md border border-agent-destructive/20 bg-agent-destructive/10 p-2.5 text-xs text-agent-destructive">
355
- {t('Browser preview mode: no host bridge, so some settings are unavailable.')}
356
- </p>
357
- )}
358
-
359
- {section === 'plugins' && (
360
- <>
361
- <p className="text-xs text-agent-muted-foreground" data-testid="plugins-summary">
362
- {pluginsSummary(pluginTabs)}
363
- </p>
364
- {pluginTab === 'skills' && (
365
- <section className="space-y-2" data-testid="settings-section-skills">
366
- <h2 className="flex items-center gap-1.5 text-xs font-semibold text-agent-foreground">
367
- <LuBlocks className="h-3.5 w-3.5 text-agent-muted-foreground" />
368
- {t('Local skills')}
369
- </h2>
370
- <SkillsSettingsPanel />
371
- </section>
372
- )}
373
- {pluginTab === 'mcp' && (
374
- <section className="space-y-2" data-testid="settings-section-mcp">
375
- <h2 className="flex items-center gap-1.5 text-xs font-semibold text-agent-foreground">
376
- <LuPlug className="h-3.5 w-3.5 text-agent-muted-foreground" />
377
- {t('MCP servers')}
378
- </h2>
379
- <McpSettingsPanel />
380
- </section>
381
- )}
382
- {pluginTab === 'agents' && (
383
- <section className="space-y-2" data-testid="settings-section-agents">
384
- <h2 className="flex items-center gap-1.5 text-xs font-semibold text-agent-foreground">
385
- <LuBot className="h-3.5 w-3.5 text-agent-muted-foreground" />
386
- {t('Agents')}
387
- </h2>
388
- <AgentsSettingsPanel onCatalogChange={catalog?.refreshAgents} />
389
- </section>
390
- )}
391
- {pluginTab === 'web-search' && settingsChrome('web-search') && (
392
- <section className="space-y-2" data-testid="settings-section-web-search">
393
- <h2 className="flex items-center gap-1.5 text-xs font-semibold text-agent-foreground">
394
- <LuSearch className="h-3.5 w-3.5 text-agent-muted-foreground" />
395
- {t('Web search')}
396
- </h2>
397
- <WebSearchSettingsPanel />
398
- </section>
399
- )}
400
- </>
197
+ <AgentsSettingsPanel onCatalogChange={catalog?.refreshAgents} />
198
+ </SettingPageShell>
199
+ );
200
+
201
+ case 'skills':
202
+ return (
203
+ <SettingPageShell
204
+ title="Skills"
205
+ description={t('Import local skill folders and inspect loaded workspace skills.')}
206
+ width="wide"
207
+ banner={previewBanner}
208
+ testId="settings-section-skills"
209
+ >
210
+ <SkillsSettingsPanel />
211
+ </SettingPageShell>
212
+ );
213
+
214
+ case 'mcp':
215
+ return (
216
+ <SettingPageShell
217
+ title={t('MCP servers')}
218
+ description={t('Connect local stdio or remote Streamable HTTP MCP tool servers.')}
219
+ width="wide"
220
+ banner={previewBanner}
221
+ testId="settings-section-mcp"
222
+ >
223
+ <McpSettingsPanel />
224
+ </SettingPageShell>
225
+ );
226
+
227
+ case 'web-search':
228
+ return (
229
+ <SettingPageShell
230
+ title={t('Web search')}
231
+ description={t('Choose free DuckDuckGo search or configure a Tavily API key.')}
232
+ banner={previewBanner}
233
+ testId="settings-section-web-search"
234
+ >
235
+ <WebSearchSettingsPanel />
236
+ </SettingPageShell>
237
+ );
238
+
239
+ case 'memory':
240
+ return (
241
+ <SettingPageShell
242
+ title={t('Memory')}
243
+ description={t('Manage automatic memory mode, personal notes, and project rules.')}
244
+ width="wide"
245
+ banner={previewBanner}
246
+ testId="settings-section-memory"
247
+ >
248
+ <MemorySettingsPanel />
249
+ </SettingPageShell>
250
+ );
251
+
252
+ case 'usage':
253
+ return (
254
+ <SettingPageShell
255
+ title={t('Usage & diagnostics')}
256
+ description={t('Inspect token consumption, estimated cost, and gateway connectivity.')}
257
+ width="wide"
258
+ banner={previewBanner}
259
+ testId="settings-page-usage"
260
+ >
261
+ {settingsChrome('usage') && (
262
+ <SettingSection
263
+ title={t('Usage and cost')}
264
+ divided={false}
265
+ testId="settings-section-usage"
266
+ >
267
+ <UsagePanel />
268
+ </SettingSection>
401
269
  )}
402
-
403
- {section === 'general' && (
404
- <>
405
- {settingsChrome('appearance') && (
406
- <section className="space-y-2" data-testid="settings-section-appearance">
407
- <h2 className="flex items-center gap-1.5 text-xs font-semibold text-agent-foreground">
408
- <LuMonitor className="h-3.5 w-3.5 text-agent-muted-foreground" />
409
- {t('Interface')}
410
- </h2>
411
- <AppearanceSettingsPanel />
412
- </section>
413
- )}
414
-
415
- <section className="space-y-2" data-testid="settings-section-orchestration">
416
- <h2 className="flex items-center gap-1.5 text-xs font-semibold text-agent-foreground">
417
- <LuSettings className="h-3.5 w-3.5 text-agent-muted-foreground" />
418
- {t('Orchestration')}
419
- </h2>
420
- <OrchestrationSettingsPanel />
421
- </section>
422
-
423
- {settingsChrome('llm') && (
424
- <section className="space-y-2" data-testid="settings-section-llm">
425
- <h2 className="flex items-center gap-1.5 text-xs font-semibold text-agent-foreground">
426
- <LuSettings className="h-3.5 w-3.5 text-agent-muted-foreground" />
427
- {t('Local model settings')}
428
- </h2>
429
- <LlmSettingsPanel
430
- ref={llmPanelRef}
431
- showFooterSave={false}
432
- onSaveUiChange={setLlmSaveUi}
433
- />
434
- </section>
435
- )}
436
-
437
- {settingsChrome('web-search') && (
438
- <section className="space-y-2" data-testid="settings-section-web-search">
439
- <h2 className="flex items-center gap-1.5 text-xs font-semibold text-agent-foreground">
440
- <LuSearch className="h-3.5 w-3.5 text-agent-muted-foreground" />
441
- {t('Web search')}
442
- </h2>
443
- <WebSearchSettingsPanel />
444
- </section>
445
- )}
446
-
447
- {settingsChrome('usage') && (
448
- <section className="space-y-2" data-testid="settings-section-usage">
449
- <h2 className="flex items-center gap-1.5 text-xs font-semibold text-agent-foreground">
450
- <LuChartBar className="h-3.5 w-3.5 text-agent-muted-foreground" />
451
- {t('Usage and cost')}
452
- </h2>
453
- <UsagePanel />
454
- </section>
455
- )}
456
-
457
- {settingsChrome('diagnose') && (
458
- <section className="space-y-2" data-testid="settings-section-diagnose">
459
- <h2 className="flex items-center gap-1.5 text-xs font-semibold text-agent-foreground">
460
- <LuNetwork className="h-3.5 w-3.5 text-agent-muted-foreground" />
461
- {t('Connection diagnostics')}
462
- </h2>
463
- <DiagnoseSettingsPanel />
464
- </section>
465
- )}
466
-
467
- {settingsChrome('security') && (
468
- <section className="space-y-2" data-testid="settings-section-security">
469
- <h2 className="flex items-center gap-1.5 text-xs font-semibold text-agent-foreground">
470
- <LuShieldCheck className="h-3.5 w-3.5 text-agent-muted-foreground" />
471
- {t('Security')}
472
- </h2>
473
- <SecuritySettingsPanel />
474
- </section>
475
- )}
476
-
477
- <section className="space-y-2" data-testid="settings-section-memory">
478
- <h2 className="flex items-center gap-1.5 text-xs font-semibold text-agent-foreground">
479
- <LuBookOpen className="h-3.5 w-3.5 text-agent-muted-foreground" />
480
- {t('Memory')}
481
- </h2>
482
- <MemorySettingsPanel />
483
- </section>
484
-
485
- {settingsChrome('insights') && (
486
- <section className="space-y-2" data-testid="settings-section-insights">
487
- <h2 className="flex items-center gap-1.5 text-xs font-semibold text-agent-foreground">
488
- <LuChartBar className="h-3.5 w-3.5 text-agent-muted-foreground" />
489
- {t('Help improve the product')}
490
- </h2>
491
- <InsightsSettingsPanel />
492
- </section>
493
- )}
494
-
495
- {settingsChrome('telemetry') && (
496
- <section className="space-y-2" data-testid="settings-section-telemetry">
497
- <h2 className="flex items-center gap-1.5 text-xs font-semibold text-agent-foreground">
498
- <LuActivity className="h-3.5 w-3.5 text-agent-muted-foreground" />
499
- {t('Telemetry (OTLP)')}
500
- </h2>
501
- <TelemetrySettingsPanel />
502
- </section>
503
- )}
504
-
505
- {/* 场景包设置面板(1.2 起由包渲染层贡献)。
506
- 包经 packs/registry 注册,未激活 flavor 的产物里没有包组件。 */}
507
- {getPackSettingsPanels().map((panel) => (
508
- <section
509
- key={panel.panelId}
510
- className="space-y-2"
511
- data-testid={`settings-section-${panel.panelId}`}
512
- >
513
- <h2 className="flex items-center gap-1.5 text-xs font-semibold text-agent-foreground">
514
- {panel.Icon ? (
515
- <panel.Icon className="h-3.5 w-3.5 text-agent-muted-foreground" />
516
- ) : null}
517
- {t(panel.title)}
518
- </h2>
519
- <panel.Component />
520
- </section>
521
- ))}
522
-
523
- {isPortableEnabled() && (
524
- <section className="space-y-2" data-testid="settings-section-portable">
525
- <h2 className="flex items-center gap-1.5 text-xs font-semibold text-agent-foreground">
526
- <LuDownload className="h-3.5 w-3.5 text-agent-muted-foreground" />
527
- {t('Backup and migration')}
528
- </h2>
529
- <PortableSettingsPanel />
530
- </section>
531
- )}
532
-
533
- <PythonRunnerSettingsPanel />
534
- <AppUpdateSettingsPanel />
535
- </>
270
+ {settingsChrome('diagnose') && (
271
+ <SettingSection
272
+ id="diagnose"
273
+ title={t('Connection diagnostics')}
274
+ divided={false}
275
+ testId="settings-section-diagnose"
276
+ >
277
+ <DiagnoseSettingsPanel />
278
+ </SettingSection>
279
+ )}
280
+ </SettingPageShell>
281
+ );
282
+
283
+ case 'security':
284
+ return (
285
+ <SettingPageShell
286
+ title={t('Security & privacy')}
287
+ description={t(
288
+ 'Review process sandbox isolation, data sharing consent, and OTLP telemetry.',
289
+ )}
290
+ banner={previewBanner}
291
+ testId="settings-page-security"
292
+ >
293
+ {settingsChrome('security') && (
294
+ <SettingSection
295
+ title={t('Sidecar process sandbox')}
296
+ divided={false}
297
+ testId="settings-section-security"
298
+ >
299
+ <SecuritySettingsPanel />
300
+ </SettingSection>
301
+ )}
302
+ {settingsChrome('insights') && (
303
+ <SettingSection
304
+ id="insights"
305
+ title={t('Help improve the product')}
306
+ divided={false}
307
+ testId="settings-section-insights"
308
+ >
309
+ <InsightsSettingsPanel />
310
+ </SettingSection>
311
+ )}
312
+ {settingsChrome('telemetry') && (
313
+ <SettingDisclosure
314
+ id="telemetry"
315
+ title={t('Telemetry (OTLP)')}
316
+ summary="OTLP/HTTP"
317
+ defaultOpen={anchorId === 'telemetry'}
318
+ testId="settings-section-telemetry"
319
+ >
320
+ <TelemetrySettingsPanel />
321
+ </SettingDisclosure>
322
+ )}
323
+ </SettingPageShell>
324
+ );
325
+
326
+ case 'portable':
327
+ return (
328
+ <SettingPageShell
329
+ title={t('Data & migration')}
330
+ description={t('Export or import configuration bundles and conversation archives.')}
331
+ banner={previewBanner}
332
+ testId="settings-section-portable"
333
+ >
334
+ <PortableSettingsPanel />
335
+ </SettingPageShell>
336
+ );
337
+
338
+ case 'about':
339
+ return (
340
+ <SettingPageShell
341
+ title={t('About')}
342
+ description={t('Check application version, release notes, and software updates.')}
343
+ banner={previewBanner}
344
+ testId="settings-section-about"
345
+ >
346
+ <AppUpdateSettingsPanel showFallbackBrand />
347
+ </SettingPageShell>
348
+ );
349
+
350
+ case 'general':
351
+ default:
352
+ return (
353
+ <SettingPageShell
354
+ title={t('General')}
355
+ description={t(
356
+ 'Manage language, zoom level, thinking display, and multi-agent collaboration.',
536
357
  )}
358
+ banner={previewBanner}
359
+ testId="settings-page-general"
360
+ >
361
+ {settingsChrome('appearance') && (
362
+ <div id="appearance" data-testid="settings-section-appearance">
363
+ <AppearanceSettingsPanel />
364
+ </div>
365
+ )}
366
+ <div id="orchestration" data-testid="settings-section-orchestration">
367
+ <OrchestrationSettingsPanel />
537
368
  </div>
538
- </div>
539
- </div>
540
- </div>
541
- );
369
+ {hasHostBridge() && (
370
+ <div id="python-runner">
371
+ <PythonRunnerSettingsPanel />
372
+ </div>
373
+ )}
374
+ </SettingPageShell>
375
+ );
376
+ }
377
+ })();
378
+
379
+ return withMobileChrome(pageBody);
542
380
  }