@steerable/agent-shell-web 0.14.5 → 0.14.7
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 +6 -2
- package/src/components/ChatHeader.tsx +17 -2
- package/src/components/chat/AssistantMessage.tsx +60 -1
- package/src/components/chat/ChatInput.tsx +16 -4
- package/src/components/chat/LocalChatPanel.tsx +32 -1
- package/src/components/chat/MemorySaveNoticeBar.tsx +24 -3
- package/src/components/chat/MessageList.tsx +6 -0
- package/src/components/settings/AgentsSettingsPanel.tsx +3 -3
- package/src/components/settings/AppUpdateSettingsPanel.tsx +67 -43
- package/src/components/settings/AppearanceSettingsPanel.tsx +101 -134
- package/src/components/settings/CliInstallSettingsPanel.tsx +25 -23
- package/src/components/settings/DiagnoseSettingsPanel.tsx +3 -3
- package/src/components/settings/InsightsSettingsPanel.tsx +5 -7
- package/src/components/settings/LlmSettingsPanel.tsx +22 -2
- package/src/components/settings/McpSettingsPanel.tsx +4 -5
- package/src/components/settings/MemorySettingsPanel.tsx +302 -169
- package/src/components/settings/OrchestrationSettingsPanel.tsx +79 -121
- package/src/components/settings/PortableSettingsPanel.tsx +62 -49
- package/src/components/settings/PythonRunnerSettingsPanel.tsx +2 -4
- package/src/components/settings/SecuritySettingsPanel.tsx +91 -70
- package/src/components/settings/SettingsSidebar.tsx +238 -0
- package/src/components/settings/SkillsSettingsPanel.tsx +3 -4
- package/src/components/settings/TelemetrySettingsPanel.tsx +2 -7
- package/src/components/settings/UsagePanel.tsx +27 -35
- package/src/components/settings/WebSearchSettingsPanel.tsx +89 -88
- package/src/components/settings/primitives.tsx +302 -0
- package/src/components/settings/settings-registry.ts +371 -0
- package/src/layouts/AgentLayout.tsx +106 -6
- package/src/lib/chat-draft-store.ts +43 -0
- package/src/lib/chat-mode-store.ts +27 -0
- package/src/lib/chat-title.ts +13 -0
- package/src/lib/local-api.ts +35 -0
- package/src/packs/registry.ts +2 -0
- package/src/pages/AgentPage.tsx +333 -3
- package/src/pages/SettingsPage.tsx +337 -487
- package/src/styles/index.css +6 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { useState, type ReactNode } from 'react';
|
|
2
|
+
import { LuChevronRight } from 'react-icons/lu';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Codex × WorkBuddy 风格设置页基础排版原语:
|
|
6
|
+
* - SettingPageShell:右侧单页居中画布(单层标题 + 一句副标题 + 右上角就地动作);
|
|
7
|
+
* - SettingSection + SettingRow:无厚重套盒,采用细分割线 divide-y 左文右控行;
|
|
8
|
+
* - SettingSwitch / SettingSegmented / SettingDisclosure:统一开关、紧凑分段与渐进披露。
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export function SettingPageShell({
|
|
12
|
+
title,
|
|
13
|
+
description,
|
|
14
|
+
width = 'default',
|
|
15
|
+
headerAction,
|
|
16
|
+
banner,
|
|
17
|
+
testId,
|
|
18
|
+
children,
|
|
19
|
+
}: {
|
|
20
|
+
title: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
width?: 'default' | 'wide';
|
|
23
|
+
headerAction?: ReactNode;
|
|
24
|
+
banner?: ReactNode;
|
|
25
|
+
testId?: string;
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
}) {
|
|
28
|
+
const maxWidthClass = width === 'wide' ? 'max-w-3xl' : 'max-w-2xl';
|
|
29
|
+
return (
|
|
30
|
+
<div
|
|
31
|
+
data-testid={testId}
|
|
32
|
+
className="h-full w-full overflow-y-auto px-6 py-6"
|
|
33
|
+
>
|
|
34
|
+
<div className={`mx-auto w-full ${maxWidthClass} space-y-6 pb-8`}>
|
|
35
|
+
{banner}
|
|
36
|
+
<header className="flex items-start justify-between gap-4 border-b border-agent-border/60 pb-4">
|
|
37
|
+
<div className="min-w-0">
|
|
38
|
+
<h1 className="text-base font-semibold tracking-tight text-agent-foreground">
|
|
39
|
+
{title}
|
|
40
|
+
</h1>
|
|
41
|
+
{description ? (
|
|
42
|
+
<p className="mt-1 text-xs leading-relaxed text-agent-muted-foreground">
|
|
43
|
+
{description}
|
|
44
|
+
</p>
|
|
45
|
+
) : null}
|
|
46
|
+
</div>
|
|
47
|
+
{headerAction ? <div className="shrink-0">{headerAction}</div> : null}
|
|
48
|
+
</header>
|
|
49
|
+
<div className="space-y-6">{children}</div>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function SettingSection({
|
|
56
|
+
title,
|
|
57
|
+
description,
|
|
58
|
+
action,
|
|
59
|
+
id,
|
|
60
|
+
testId,
|
|
61
|
+
divided = true,
|
|
62
|
+
children,
|
|
63
|
+
}: {
|
|
64
|
+
title?: string;
|
|
65
|
+
description?: string;
|
|
66
|
+
action?: ReactNode;
|
|
67
|
+
id?: string;
|
|
68
|
+
testId?: string;
|
|
69
|
+
divided?: boolean;
|
|
70
|
+
children: ReactNode;
|
|
71
|
+
}) {
|
|
72
|
+
return (
|
|
73
|
+
<section id={id} data-testid={testId} className="space-y-2">
|
|
74
|
+
{title || description || action ? (
|
|
75
|
+
<div className="flex items-center justify-between gap-3">
|
|
76
|
+
<div className="min-w-0">
|
|
77
|
+
{title ? (
|
|
78
|
+
<h2 className="text-xs font-semibold text-agent-foreground">{title}</h2>
|
|
79
|
+
) : null}
|
|
80
|
+
{description ? (
|
|
81
|
+
<p className="mt-0.5 text-xs leading-relaxed text-agent-muted-foreground">
|
|
82
|
+
{description}
|
|
83
|
+
</p>
|
|
84
|
+
) : null}
|
|
85
|
+
</div>
|
|
86
|
+
{action ? <div className="shrink-0">{action}</div> : null}
|
|
87
|
+
</div>
|
|
88
|
+
) : null}
|
|
89
|
+
<div
|
|
90
|
+
className={
|
|
91
|
+
divided
|
|
92
|
+
? 'divide-y divide-agent-border/60 border-t border-b border-agent-border/60'
|
|
93
|
+
: 'space-y-3'
|
|
94
|
+
}
|
|
95
|
+
>
|
|
96
|
+
{children}
|
|
97
|
+
</div>
|
|
98
|
+
</section>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function SettingRow({
|
|
103
|
+
title,
|
|
104
|
+
badge,
|
|
105
|
+
description,
|
|
106
|
+
control,
|
|
107
|
+
align = 'center',
|
|
108
|
+
testId,
|
|
109
|
+
children,
|
|
110
|
+
}: {
|
|
111
|
+
title: ReactNode;
|
|
112
|
+
badge?: ReactNode;
|
|
113
|
+
description?: ReactNode;
|
|
114
|
+
control?: ReactNode;
|
|
115
|
+
align?: 'center' | 'start';
|
|
116
|
+
testId?: string;
|
|
117
|
+
children?: ReactNode;
|
|
118
|
+
}) {
|
|
119
|
+
return (
|
|
120
|
+
<div data-testid={testId} className="py-3.5">
|
|
121
|
+
<div
|
|
122
|
+
className={`flex justify-between gap-6 ${
|
|
123
|
+
align === 'start' ? 'items-start' : 'items-center'
|
|
124
|
+
}`}
|
|
125
|
+
>
|
|
126
|
+
<div className="min-w-0 flex-1">
|
|
127
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
128
|
+
<span className="text-xs font-medium text-agent-foreground">{title}</span>
|
|
129
|
+
{badge}
|
|
130
|
+
</div>
|
|
131
|
+
{description ? (
|
|
132
|
+
<div className="mt-1 text-xs leading-relaxed text-agent-muted-foreground">
|
|
133
|
+
{description}
|
|
134
|
+
</div>
|
|
135
|
+
) : null}
|
|
136
|
+
</div>
|
|
137
|
+
{control ? <div className="shrink-0">{control}</div> : null}
|
|
138
|
+
</div>
|
|
139
|
+
{children ? <div className="mt-3">{children}</div> : null}
|
|
140
|
+
</div>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function SettingSwitch({
|
|
145
|
+
checked,
|
|
146
|
+
onChange,
|
|
147
|
+
disabled = false,
|
|
148
|
+
label,
|
|
149
|
+
testId,
|
|
150
|
+
}: {
|
|
151
|
+
checked: boolean;
|
|
152
|
+
onChange: (next: boolean) => void;
|
|
153
|
+
disabled?: boolean;
|
|
154
|
+
label: string;
|
|
155
|
+
testId?: string;
|
|
156
|
+
}) {
|
|
157
|
+
return (
|
|
158
|
+
<button
|
|
159
|
+
type="button"
|
|
160
|
+
role="switch"
|
|
161
|
+
aria-checked={checked}
|
|
162
|
+
aria-label={label}
|
|
163
|
+
disabled={disabled}
|
|
164
|
+
data-testid={testId}
|
|
165
|
+
onClick={() => onChange(!checked)}
|
|
166
|
+
className={[
|
|
167
|
+
'relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-agent-foreground/30 disabled:cursor-not-allowed disabled:opacity-50',
|
|
168
|
+
checked ? 'bg-agent-foreground' : 'bg-agent-border',
|
|
169
|
+
].join(' ')}
|
|
170
|
+
>
|
|
171
|
+
<span
|
|
172
|
+
aria-hidden="true"
|
|
173
|
+
className={[
|
|
174
|
+
'pointer-events-none inline-block h-4 w-4 rounded-full bg-agent-canvas shadow-2xs transition-transform',
|
|
175
|
+
checked ? 'translate-x-4' : 'translate-x-0.5',
|
|
176
|
+
].join(' ')}
|
|
177
|
+
/>
|
|
178
|
+
</button>
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface SegmentedOption<T extends string> {
|
|
183
|
+
readonly value: T;
|
|
184
|
+
readonly label: string;
|
|
185
|
+
readonly ariaLabel?: string;
|
|
186
|
+
readonly testId?: string;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export function SettingSegmented<T extends string>({
|
|
190
|
+
value,
|
|
191
|
+
options,
|
|
192
|
+
onChange,
|
|
193
|
+
ariaLabel,
|
|
194
|
+
testId,
|
|
195
|
+
}: {
|
|
196
|
+
value: T;
|
|
197
|
+
options: readonly SegmentedOption<T>[];
|
|
198
|
+
onChange: (next: T) => void;
|
|
199
|
+
ariaLabel: string;
|
|
200
|
+
testId?: string;
|
|
201
|
+
}) {
|
|
202
|
+
return (
|
|
203
|
+
<div
|
|
204
|
+
role="radiogroup"
|
|
205
|
+
aria-label={ariaLabel}
|
|
206
|
+
data-testid={testId}
|
|
207
|
+
className="inline-flex items-center rounded-lg border border-agent-border/70 bg-agent-muted/50 p-0.5"
|
|
208
|
+
>
|
|
209
|
+
{options.map((opt) => {
|
|
210
|
+
const selected = opt.value === value;
|
|
211
|
+
return (
|
|
212
|
+
<button
|
|
213
|
+
key={opt.value}
|
|
214
|
+
type="button"
|
|
215
|
+
role="radio"
|
|
216
|
+
aria-checked={selected}
|
|
217
|
+
aria-label={opt.ariaLabel ?? opt.label}
|
|
218
|
+
data-testid={opt.testId}
|
|
219
|
+
onClick={() => onChange(opt.value)}
|
|
220
|
+
className={[
|
|
221
|
+
'h-6 rounded-md px-2.5 text-xs transition-colors whitespace-nowrap',
|
|
222
|
+
selected
|
|
223
|
+
? 'bg-agent-canvas font-medium text-agent-foreground shadow-2xs'
|
|
224
|
+
: 'text-agent-muted-foreground hover:text-agent-foreground',
|
|
225
|
+
].join(' ')}
|
|
226
|
+
>
|
|
227
|
+
{opt.label}
|
|
228
|
+
</button>
|
|
229
|
+
);
|
|
230
|
+
})}
|
|
231
|
+
</div>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export function SettingStatusBadge({
|
|
236
|
+
tone,
|
|
237
|
+
children,
|
|
238
|
+
testId,
|
|
239
|
+
}: {
|
|
240
|
+
tone: 'success' | 'warning' | 'danger' | 'neutral';
|
|
241
|
+
children: ReactNode;
|
|
242
|
+
testId?: string;
|
|
243
|
+
}) {
|
|
244
|
+
const toneClass =
|
|
245
|
+
tone === 'success'
|
|
246
|
+
? 'bg-emerald-500/12 text-emerald-700 dark:text-emerald-300 border-emerald-500/25'
|
|
247
|
+
: tone === 'warning'
|
|
248
|
+
? 'bg-amber-500/12 text-amber-700 dark:text-amber-300 border-amber-500/25'
|
|
249
|
+
: tone === 'danger'
|
|
250
|
+
? 'bg-agent-destructive/10 text-agent-destructive border-agent-destructive/25'
|
|
251
|
+
: 'bg-agent-muted text-agent-muted-foreground border-agent-border';
|
|
252
|
+
return (
|
|
253
|
+
<span
|
|
254
|
+
data-testid={testId}
|
|
255
|
+
className={`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium ${toneClass}`}
|
|
256
|
+
>
|
|
257
|
+
{children}
|
|
258
|
+
</span>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export function SettingDisclosure({
|
|
263
|
+
title,
|
|
264
|
+
summary,
|
|
265
|
+
defaultOpen = false,
|
|
266
|
+
id,
|
|
267
|
+
testId,
|
|
268
|
+
children,
|
|
269
|
+
}: {
|
|
270
|
+
title: string;
|
|
271
|
+
summary?: string;
|
|
272
|
+
defaultOpen?: boolean;
|
|
273
|
+
id?: string;
|
|
274
|
+
testId?: string;
|
|
275
|
+
children: ReactNode;
|
|
276
|
+
}) {
|
|
277
|
+
const [open, setOpen] = useState(defaultOpen);
|
|
278
|
+
return (
|
|
279
|
+
<div id={id} data-testid={testId} className="border-t border-agent-border/60 pt-3">
|
|
280
|
+
<button
|
|
281
|
+
type="button"
|
|
282
|
+
aria-expanded={open}
|
|
283
|
+
data-testid={testId ? `${testId}-toggle` : undefined}
|
|
284
|
+
onClick={() => setOpen((prev) => !prev)}
|
|
285
|
+
className="flex w-full items-center justify-between gap-3 py-1 text-left transition-colors hover:text-agent-foreground"
|
|
286
|
+
>
|
|
287
|
+
<span className="flex min-w-0 items-center gap-1.5 text-xs font-medium text-agent-foreground">
|
|
288
|
+
<LuChevronRight
|
|
289
|
+
className={`h-3.5 w-3.5 shrink-0 text-agent-muted-foreground transition-transform ${
|
|
290
|
+
open ? 'rotate-90' : ''
|
|
291
|
+
}`}
|
|
292
|
+
/>
|
|
293
|
+
<span>{title}</span>
|
|
294
|
+
</span>
|
|
295
|
+
{!open && summary ? (
|
|
296
|
+
<span className="truncate text-[11px] text-agent-muted-foreground">{summary}</span>
|
|
297
|
+
) : null}
|
|
298
|
+
</button>
|
|
299
|
+
{open ? <div className="mt-3 space-y-4 pl-5">{children}</div> : null}
|
|
300
|
+
</div>
|
|
301
|
+
);
|
|
302
|
+
}
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
LuBlocks,
|
|
4
|
+
LuBookOpen,
|
|
5
|
+
LuBot,
|
|
6
|
+
LuChartBar,
|
|
7
|
+
LuCpu,
|
|
8
|
+
LuDownload,
|
|
9
|
+
LuInfo,
|
|
10
|
+
LuPlug,
|
|
11
|
+
LuSearch,
|
|
12
|
+
LuSettings,
|
|
13
|
+
LuShieldCheck,
|
|
14
|
+
LuSlidersHorizontal,
|
|
15
|
+
} from 'react-icons/lu';
|
|
16
|
+
import { t } from '@/i18n';
|
|
17
|
+
import { settingsChrome } from '@/lib/host-tools';
|
|
18
|
+
import { isPortableEnabled } from '@/lib/portable';
|
|
19
|
+
import {
|
|
20
|
+
getPackSettingsPanels,
|
|
21
|
+
type PackSettingsPanelContribution,
|
|
22
|
+
type SettingsNavGroup,
|
|
23
|
+
} from '@/packs/registry';
|
|
24
|
+
|
|
25
|
+
export interface SettingsNavEntry {
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly group: SettingsNavGroup;
|
|
28
|
+
readonly label: string;
|
|
29
|
+
readonly description?: string;
|
|
30
|
+
readonly badge?: string;
|
|
31
|
+
readonly keywords: readonly string[];
|
|
32
|
+
readonly matchHint?: string;
|
|
33
|
+
readonly Icon: ComponentType<{ className?: string }>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface SettingsNavSection {
|
|
37
|
+
readonly group: SettingsNavGroup;
|
|
38
|
+
readonly title: string;
|
|
39
|
+
readonly items: readonly SettingsNavEntry[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ResolvedSettingsRoute {
|
|
43
|
+
readonly tabId: string;
|
|
44
|
+
readonly anchorId: string | null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const PLUGIN_PRIORITY_IDS = ['agents', 'skills', 'mcp', 'web-search'] as const;
|
|
48
|
+
|
|
49
|
+
const LEGACY_SECTION_ALIASES: Record<string, { tabId: string; anchorId: string | null }> = {
|
|
50
|
+
appearance: { tabId: 'general', anchorId: 'appearance' },
|
|
51
|
+
orchestration: { tabId: 'general', anchorId: 'orchestration' },
|
|
52
|
+
'python-runner': { tabId: 'general', anchorId: 'python-runner' },
|
|
53
|
+
diagnose: { tabId: 'usage', anchorId: 'diagnose' },
|
|
54
|
+
insights: { tabId: 'security', anchorId: 'insights' },
|
|
55
|
+
telemetry: { tabId: 'security', anchorId: 'telemetry' },
|
|
56
|
+
update: { tabId: 'about', anchorId: null },
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export function settingsGroupTitle(group: SettingsNavGroup): string {
|
|
60
|
+
switch (group) {
|
|
61
|
+
case 'app':
|
|
62
|
+
return t('App');
|
|
63
|
+
case 'capabilities':
|
|
64
|
+
return t('Capabilities');
|
|
65
|
+
case 'data-security':
|
|
66
|
+
return t('Data & privacy');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface BuildSettingsNavOptions {
|
|
71
|
+
readonly hiddenNavItems?: readonly string[];
|
|
72
|
+
readonly releaseVersion?: string | null;
|
|
73
|
+
readonly packPanels?: readonly PackSettingsPanelContribution[];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function buildSettingsNavEntries(
|
|
77
|
+
options: BuildSettingsNavOptions = {},
|
|
78
|
+
): SettingsNavEntry[] {
|
|
79
|
+
const hiddenSet = new Set(options.hiddenNavItems ?? []);
|
|
80
|
+
const packs = options.packPanels ?? getPackSettingsPanels();
|
|
81
|
+
const entries: SettingsNavEntry[] = [];
|
|
82
|
+
|
|
83
|
+
const pushPackPanels = (targetGroup: SettingsNavGroup) => {
|
|
84
|
+
for (const panel of packs) {
|
|
85
|
+
const group = panel.group ?? 'capabilities';
|
|
86
|
+
if (group !== targetGroup) continue;
|
|
87
|
+
if (hiddenSet.has(panel.panelId)) continue;
|
|
88
|
+
entries.push({
|
|
89
|
+
id: panel.panelId,
|
|
90
|
+
group,
|
|
91
|
+
label: t(panel.title),
|
|
92
|
+
description: panel.description ? t(panel.description) : undefined,
|
|
93
|
+
keywords: (panel.keywords ?? []).map((kw) => t(kw)),
|
|
94
|
+
Icon: panel.Icon ?? LuSettings,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// ── 1. App ──────────────────────────────────────────────────────────
|
|
100
|
+
entries.push({
|
|
101
|
+
id: 'general',
|
|
102
|
+
group: 'app',
|
|
103
|
+
label: t('General'),
|
|
104
|
+
description: t(
|
|
105
|
+
'Manage language, zoom level, thinking display, and multi-agent collaboration.',
|
|
106
|
+
),
|
|
107
|
+
keywords: [
|
|
108
|
+
t('Interface'),
|
|
109
|
+
t('Language'),
|
|
110
|
+
t('Interface zoom'),
|
|
111
|
+
t('Show thinking'),
|
|
112
|
+
t('Orchestration'),
|
|
113
|
+
t('Multi-agent orchestration (Fork-Join)'),
|
|
114
|
+
t('Python code runner'),
|
|
115
|
+
'locale',
|
|
116
|
+
'zoom',
|
|
117
|
+
'thinking',
|
|
118
|
+
'python',
|
|
119
|
+
],
|
|
120
|
+
Icon: LuSlidersHorizontal,
|
|
121
|
+
});
|
|
122
|
+
pushPackPanels('app');
|
|
123
|
+
|
|
124
|
+
// ── 2. Capabilities ─────────────────────────────────────────────────
|
|
125
|
+
if (!hiddenSet.has('llm') && settingsChrome('llm')) {
|
|
126
|
+
entries.push({
|
|
127
|
+
id: 'llm',
|
|
128
|
+
group: 'capabilities',
|
|
129
|
+
label: t('Models'),
|
|
130
|
+
description: t('Configure model provider, gateway URL, API key, and advanced parameters.'),
|
|
131
|
+
keywords: [
|
|
132
|
+
t('Local model settings'),
|
|
133
|
+
t('Provider'),
|
|
134
|
+
'API Key',
|
|
135
|
+
'Base URL',
|
|
136
|
+
'Temperature',
|
|
137
|
+
t('Vendor parameter presets'),
|
|
138
|
+
t('Advanced compatibility flags (optional)'),
|
|
139
|
+
t('Token budget limit'),
|
|
140
|
+
t('Timeouts'),
|
|
141
|
+
],
|
|
142
|
+
Icon: LuCpu,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
if (!hiddenSet.has('agents') && settingsChrome('agents')) {
|
|
146
|
+
entries.push({
|
|
147
|
+
id: 'agents',
|
|
148
|
+
group: 'capabilities',
|
|
149
|
+
label: t('Agents'),
|
|
150
|
+
description: t('Create and customize role prompts, skills, and tool permissions.'),
|
|
151
|
+
keywords: [t('New agent'), t('Existing agents'), t('Tool permissions'), 'prompt'],
|
|
152
|
+
Icon: LuBot,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
if (!hiddenSet.has('skills') && settingsChrome('skills')) {
|
|
156
|
+
entries.push({
|
|
157
|
+
id: 'skills',
|
|
158
|
+
group: 'capabilities',
|
|
159
|
+
label: 'Skills',
|
|
160
|
+
description: t('Import local skill folders and inspect loaded workspace skills.'),
|
|
161
|
+
keywords: [t('Skills'), t('Local skills'), t('Loaded skills'), t('Import local skill directory')],
|
|
162
|
+
Icon: LuBlocks,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if (!hiddenSet.has('mcp') && settingsChrome('mcp')) {
|
|
166
|
+
entries.push({
|
|
167
|
+
id: 'mcp',
|
|
168
|
+
group: 'capabilities',
|
|
169
|
+
label: t('MCP servers'),
|
|
170
|
+
description: t('Connect local stdio or remote Streamable HTTP MCP tool servers.'),
|
|
171
|
+
keywords: ['MCP', t('Add MCP server manually'), 'stdio', 'Streamable HTTP', 'Claude Desktop'],
|
|
172
|
+
Icon: LuPlug,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
if (!hiddenSet.has('web-search') && settingsChrome('web-search')) {
|
|
176
|
+
entries.push({
|
|
177
|
+
id: 'web-search',
|
|
178
|
+
group: 'capabilities',
|
|
179
|
+
label: t('Web search'),
|
|
180
|
+
description: t('Choose free DuckDuckGo search or configure a Tavily API key.'),
|
|
181
|
+
keywords: [t('Search backend'), 'DuckDuckGo', 'Tavily', t('Free')],
|
|
182
|
+
Icon: LuSearch,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
if (!hiddenSet.has('memory')) {
|
|
186
|
+
entries.push({
|
|
187
|
+
id: 'memory',
|
|
188
|
+
group: 'capabilities',
|
|
189
|
+
label: t('Memory'),
|
|
190
|
+
description: t('Manage automatic memory mode, personal notes, and project rules.'),
|
|
191
|
+
keywords: [t('Personal memory'), t('Project memory'), 'MEMORY.md'],
|
|
192
|
+
Icon: LuBookOpen,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
pushPackPanels('capabilities');
|
|
196
|
+
|
|
197
|
+
// ── 3. Data & privacy ───────────────────────────────────────────────
|
|
198
|
+
if (
|
|
199
|
+
(!hiddenSet.has('usage') && settingsChrome('usage')) ||
|
|
200
|
+
(!hiddenSet.has('diagnose') && settingsChrome('diagnose'))
|
|
201
|
+
) {
|
|
202
|
+
entries.push({
|
|
203
|
+
id: 'usage',
|
|
204
|
+
group: 'data-security',
|
|
205
|
+
label: t('Usage & diagnostics'),
|
|
206
|
+
description: t('Inspect token consumption, estimated cost, and gateway connectivity.'),
|
|
207
|
+
keywords: [
|
|
208
|
+
t('Usage and cost'),
|
|
209
|
+
t('Connection diagnostics'),
|
|
210
|
+
t('Total tokens'),
|
|
211
|
+
t('Estimated cost'),
|
|
212
|
+
t('Detected proxy settings'),
|
|
213
|
+
'proxy',
|
|
214
|
+
'DNS',
|
|
215
|
+
'TLS',
|
|
216
|
+
],
|
|
217
|
+
Icon: LuChartBar,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
if (
|
|
221
|
+
(!hiddenSet.has('security') && settingsChrome('security')) ||
|
|
222
|
+
(!hiddenSet.has('insights') && settingsChrome('insights')) ||
|
|
223
|
+
(!hiddenSet.has('telemetry') && settingsChrome('telemetry'))
|
|
224
|
+
) {
|
|
225
|
+
entries.push({
|
|
226
|
+
id: 'security',
|
|
227
|
+
group: 'data-security',
|
|
228
|
+
label: t('Security & privacy'),
|
|
229
|
+
description: t('Review process sandbox isolation, data sharing consent, and OTLP telemetry.'),
|
|
230
|
+
keywords: [
|
|
231
|
+
t('Security'),
|
|
232
|
+
t('Sidecar process sandbox'),
|
|
233
|
+
t('Help improve the product'),
|
|
234
|
+
t('Telemetry (OTLP)'),
|
|
235
|
+
'sandbox',
|
|
236
|
+
'seatbelt',
|
|
237
|
+
'egress',
|
|
238
|
+
'privacy',
|
|
239
|
+
'otlp',
|
|
240
|
+
],
|
|
241
|
+
Icon: LuShieldCheck,
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
if (!hiddenSet.has('portable') && isPortableEnabled()) {
|
|
245
|
+
entries.push({
|
|
246
|
+
id: 'portable',
|
|
247
|
+
group: 'data-security',
|
|
248
|
+
label: t('Data & migration'),
|
|
249
|
+
description: t('Export or import configuration bundles and conversation archives.'),
|
|
250
|
+
keywords: [
|
|
251
|
+
t('Backup and migration'),
|
|
252
|
+
t('Export config'),
|
|
253
|
+
t('Import config'),
|
|
254
|
+
t('Export chats'),
|
|
255
|
+
t('Import chats'),
|
|
256
|
+
],
|
|
257
|
+
Icon: LuDownload,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
pushPackPanels('data-security');
|
|
261
|
+
|
|
262
|
+
entries.push({
|
|
263
|
+
id: 'about',
|
|
264
|
+
group: 'data-security',
|
|
265
|
+
label: t('About'),
|
|
266
|
+
description: t('Check application version, release notes, and software updates.'),
|
|
267
|
+
badge: options.releaseVersion ? `v${options.releaseVersion}` : undefined,
|
|
268
|
+
keywords: [t('Software update'), t('Current version'), 'version', 'update'],
|
|
269
|
+
Icon: LuInfo,
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
return entries;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export function groupSettingsNavEntries(
|
|
276
|
+
entries: readonly SettingsNavEntry[],
|
|
277
|
+
): SettingsNavSection[] {
|
|
278
|
+
const order: SettingsNavGroup[] = ['app', 'capabilities', 'data-security'];
|
|
279
|
+
const sections: SettingsNavSection[] = [];
|
|
280
|
+
for (const group of order) {
|
|
281
|
+
const items = entries.filter((item) => item.group === group);
|
|
282
|
+
if (items.length > 0) {
|
|
283
|
+
sections.push({
|
|
284
|
+
group,
|
|
285
|
+
title: settingsGroupTitle(group),
|
|
286
|
+
items,
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return sections;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* 统一解析 `/settings` 的 `?tab=` 与存量 `?section=` 深链。
|
|
295
|
+
*/
|
|
296
|
+
export function resolveSettingsRoute(
|
|
297
|
+
searchParams: URLSearchParams,
|
|
298
|
+
availableIds: readonly string[],
|
|
299
|
+
): ResolvedSettingsRoute {
|
|
300
|
+
const fallbackTab = availableIds[0] ?? 'general';
|
|
301
|
+
if (availableIds.length === 0) {
|
|
302
|
+
return { tabId: 'general', anchorId: null };
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const hasId = (id: string) => availableIds.includes(id);
|
|
306
|
+
|
|
307
|
+
const tryResolveToken = (raw: string | null): ResolvedSettingsRoute | null => {
|
|
308
|
+
if (!raw) return null;
|
|
309
|
+
const alias = LEGACY_SECTION_ALIASES[raw];
|
|
310
|
+
if (alias && hasId(alias.tabId)) {
|
|
311
|
+
return alias;
|
|
312
|
+
}
|
|
313
|
+
if (hasId(raw)) {
|
|
314
|
+
return { tabId: raw, anchorId: null };
|
|
315
|
+
}
|
|
316
|
+
return null;
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
const rawTab = searchParams.get('tab');
|
|
320
|
+
const rawSection = searchParams.get('section');
|
|
321
|
+
|
|
322
|
+
// 1. 显式 ?tab=<id> 最高优先(同时覆盖 ?section=plugins&tab=skills)
|
|
323
|
+
const fromTab = tryResolveToken(rawTab);
|
|
324
|
+
if (fromTab) return fromTab;
|
|
325
|
+
|
|
326
|
+
// 2. ?section=plugins(无有效 tab):定位至首个已启用的扩展能力页
|
|
327
|
+
if (rawSection === 'plugins') {
|
|
328
|
+
const firstPlugin = PLUGIN_PRIORITY_IDS.find((id) => hasId(id));
|
|
329
|
+
if (firstPlugin) {
|
|
330
|
+
return { tabId: firstPlugin, anchorId: null };
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// 3. 存量单段 ?section=<id>(如 ?section=skills / ?section=llm / ?section=diagnose)
|
|
335
|
+
const fromSection = tryResolveToken(rawSection);
|
|
336
|
+
if (fromSection) return fromSection;
|
|
337
|
+
|
|
338
|
+
// 4. 缺省或未知参数:安全落到 general(或首个可用页)
|
|
339
|
+
return {
|
|
340
|
+
tabId: hasId('general') ? 'general' : fallbackTab,
|
|
341
|
+
anchorId: null,
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* 按关键字实时筛选左侧设置子页;若命中隐藏关键词则返回带 `matchHint` 的条目。
|
|
347
|
+
*/
|
|
348
|
+
export function filterSettingsEntries(
|
|
349
|
+
entries: readonly SettingsNavEntry[],
|
|
350
|
+
rawQuery: string,
|
|
351
|
+
): SettingsNavEntry[] {
|
|
352
|
+
const query = rawQuery.trim().toLowerCase();
|
|
353
|
+
if (!query) return [...entries];
|
|
354
|
+
|
|
355
|
+
const matched: SettingsNavEntry[] = [];
|
|
356
|
+
for (const entry of entries) {
|
|
357
|
+
if (entry.label.toLowerCase().includes(query)) {
|
|
358
|
+
matched.push(entry);
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
const matchedKeyword = entry.keywords.find((kw) => kw.toLowerCase().includes(query));
|
|
362
|
+
if (matchedKeyword) {
|
|
363
|
+
matched.push({ ...entry, matchHint: matchedKeyword });
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
if (entry.description?.toLowerCase().includes(query)) {
|
|
367
|
+
matched.push({ ...entry, matchHint: entry.description });
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return matched;
|
|
371
|
+
}
|