@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.
Files changed (37) hide show
  1. package/package.json +4 -4
  2. package/src/components/AgentSidebar.tsx +6 -2
  3. package/src/components/ChatHeader.tsx +17 -2
  4. package/src/components/chat/AssistantMessage.tsx +60 -1
  5. package/src/components/chat/ChatInput.tsx +16 -4
  6. package/src/components/chat/LocalChatPanel.tsx +32 -1
  7. package/src/components/chat/MemorySaveNoticeBar.tsx +24 -3
  8. package/src/components/chat/MessageList.tsx +6 -0
  9. package/src/components/settings/AgentsSettingsPanel.tsx +3 -3
  10. package/src/components/settings/AppUpdateSettingsPanel.tsx +67 -43
  11. package/src/components/settings/AppearanceSettingsPanel.tsx +101 -134
  12. package/src/components/settings/CliInstallSettingsPanel.tsx +25 -23
  13. package/src/components/settings/DiagnoseSettingsPanel.tsx +3 -3
  14. package/src/components/settings/InsightsSettingsPanel.tsx +5 -7
  15. package/src/components/settings/LlmSettingsPanel.tsx +22 -2
  16. package/src/components/settings/McpSettingsPanel.tsx +4 -5
  17. package/src/components/settings/MemorySettingsPanel.tsx +302 -169
  18. package/src/components/settings/OrchestrationSettingsPanel.tsx +79 -121
  19. package/src/components/settings/PortableSettingsPanel.tsx +62 -49
  20. package/src/components/settings/PythonRunnerSettingsPanel.tsx +2 -4
  21. package/src/components/settings/SecuritySettingsPanel.tsx +91 -70
  22. package/src/components/settings/SettingsSidebar.tsx +238 -0
  23. package/src/components/settings/SkillsSettingsPanel.tsx +3 -4
  24. package/src/components/settings/TelemetrySettingsPanel.tsx +2 -7
  25. package/src/components/settings/UsagePanel.tsx +27 -35
  26. package/src/components/settings/WebSearchSettingsPanel.tsx +89 -88
  27. package/src/components/settings/primitives.tsx +302 -0
  28. package/src/components/settings/settings-registry.ts +371 -0
  29. package/src/layouts/AgentLayout.tsx +106 -6
  30. package/src/lib/chat-draft-store.ts +43 -0
  31. package/src/lib/chat-mode-store.ts +27 -0
  32. package/src/lib/chat-title.ts +13 -0
  33. package/src/lib/local-api.ts +35 -0
  34. package/src/packs/registry.ts +2 -0
  35. package/src/pages/AgentPage.tsx +333 -3
  36. package/src/pages/SettingsPage.tsx +337 -487
  37. package/src/styles/index.css +6 -0
@@ -3,9 +3,11 @@ import {
3
3
  THINKING_DISPLAY_OPTIONS,
4
4
  persistThinkingDisplay,
5
5
  useThinkingDisplay,
6
+ type ThinkingDisplayMode,
6
7
  } from '@/lib/show-thinking-content';
7
8
  import { getHostBridge } from '@/lib/host-bridge';
8
9
  import { localeEndonym, supportedLocales, useI18n } from '@/i18n';
10
+ import { SettingRow, SettingSection, SettingSegmented } from './primitives';
9
11
 
10
12
  function stepZoom(scale: number, direction: -1 | 1): number {
11
13
  const snapped = Math.round(scale * 10) / 10;
@@ -36,153 +38,118 @@ function InterfaceZoomRow() {
36
38
  if (!available || scale == null) return null;
37
39
  const percent = Math.round(scale * 100);
38
40
  return (
39
- <div
40
- className="flex items-center justify-between gap-3 rounded-agent-md border border-agent-border bg-agent-card p-2.5"
41
- data-testid="interface-zoom"
42
- >
43
- <div>
44
- <p className="text-xs font-medium text-agent-foreground">{t('Interface zoom')}</p>
45
- <p className="mt-1 text-xs text-agent-muted-foreground" data-testid="interface-zoom-level">
46
- {percent}%
47
- </p>
48
- </div>
49
- <div className="flex items-center gap-1">
50
- <button
51
- type="button"
52
- className="h-7 w-7 rounded-full border border-agent-border text-sm text-agent-foreground disabled:opacity-30"
53
- aria-label={t('Zoom out')}
54
- data-testid="interface-zoom-out"
55
- disabled={percent <= 80}
56
- onClick={() => {
57
- const next = stepZoom(scale, -1);
58
- setScale(next);
59
- void getHostBridge()?.setZoom?.(next);
60
- }}
61
- >
62
- −
63
- </button>
64
- <button
65
- type="button"
66
- className="h-7 w-7 rounded-full border border-agent-border text-sm text-agent-foreground disabled:opacity-30"
67
- aria-label={t('Zoom in')}
68
- data-testid="interface-zoom-in"
69
- disabled={percent >= 200}
70
- onClick={() => {
71
- const next = stepZoom(scale, 1);
72
- setScale(next);
73
- void getHostBridge()?.setZoom?.(next);
74
- }}
75
- >
76
- +
77
- </button>
78
- <button
79
- type="button"
80
- className="h-7 rounded-full border border-agent-border px-2 text-xs text-agent-foreground"
81
- data-testid="interface-zoom-reset"
82
- onClick={() => {
83
- setScale(1);
84
- void getHostBridge()?.setZoom?.(1);
85
- }}
86
- >
87
- {t('Reset')}
88
- </button>
89
- </div>
90
- </div>
41
+ <SettingRow
42
+ testId="interface-zoom"
43
+ title={t('Interface zoom')}
44
+ description={t('Adjust overall text size and control scale across the app.')}
45
+ control={
46
+ <div className="flex items-center gap-1.5">
47
+ <button
48
+ type="button"
49
+ className="flex h-7 w-7 items-center justify-center rounded-md border border-agent-border bg-agent-canvas text-sm text-agent-foreground transition-colors hover:bg-agent-muted/60 disabled:opacity-30"
50
+ aria-label={t('Zoom out')}
51
+ data-testid="interface-zoom-out"
52
+ disabled={percent <= 80}
53
+ onClick={() => {
54
+ const next = stepZoom(scale, -1);
55
+ setScale(next);
56
+ void getHostBridge()?.setZoom?.(next);
57
+ }}
58
+ >
59
+ −
60
+ </button>
61
+ <span
62
+ className="min-w-[3.25rem] text-center font-mono text-xs tabular-nums text-agent-foreground"
63
+ data-testid="interface-zoom-level"
64
+ >
65
+ {percent}%
66
+ </span>
67
+ <button
68
+ type="button"
69
+ className="flex h-7 w-7 items-center justify-center rounded-md border border-agent-border bg-agent-canvas text-sm text-agent-foreground transition-colors hover:bg-agent-muted/60 disabled:opacity-30"
70
+ aria-label={t('Zoom in')}
71
+ data-testid="interface-zoom-in"
72
+ disabled={percent >= 200}
73
+ onClick={() => {
74
+ const next = stepZoom(scale, 1);
75
+ setScale(next);
76
+ void getHostBridge()?.setZoom?.(next);
77
+ }}
78
+ >
79
+ +
80
+ </button>
81
+ <button
82
+ type="button"
83
+ className="h-7 rounded-md border border-agent-border bg-agent-canvas px-2.5 text-xs text-agent-muted-foreground transition-colors hover:bg-agent-muted/60 hover:text-agent-foreground"
84
+ data-testid="interface-zoom-reset"
85
+ onClick={() => {
86
+ setScale(1);
87
+ void getHostBridge()?.setZoom?.(1);
88
+ }}
89
+ >
90
+ {t('Reset')}
91
+ </button>
92
+ </div>
93
+ }
94
+ />
91
95
  );
92
96
  }
93
97
 
94
98
  /**
95
- * 界面偏好:思考过程正文按「隐藏 / 显示5行 / 完整显示」三档。
96
- * 产品声明了多于一种语言时,在这里切换。立即写入 localStorage。
99
+ * 界面偏好(Codex 式细分割线行):
100
+ * - 语言切换(多语言产品时显示,右侧紧凑分段器);
101
+ * - 桌面客户端界面缩放;
102
+ * - 思考过程正文展示档位(隐藏 / 显示5行 / 完整显示),立即写入 localStorage。
97
103
  */
98
104
  export function AppearanceSettingsPanel() {
99
105
  const { t, locale, setLocale } = useI18n();
100
106
  const mode = useThinkingDisplay();
101
- const current = THINKING_DISPLAY_OPTIONS.find((item) => item.mode === mode);
102
107
  const locales = supportedLocales();
103
108
 
104
109
  return (
105
- <div className="space-y-2">
110
+ <SettingSection title={t('Interface')}>
106
111
  {locales.length > 1 ? (
107
- <div
108
- className="space-y-2 rounded-agent-md border border-agent-border bg-agent-card p-2.5"
109
- data-testid="locale-settings"
110
- >
111
- <p className="text-xs font-medium text-agent-foreground">{t('Language')}</p>
112
- <div
113
- className="flex w-full rounded-full border border-agent-border bg-agent-canvas p-0.5"
114
- role="radiogroup"
115
- aria-label={t('Language')}
116
- data-testid="locale-toggle"
117
- >
118
- {locales.map((item) => {
119
- const selected = locale === item;
120
- return (
121
- <button
122
- key={item}
123
- type="button"
124
- role="radio"
125
- aria-checked={selected}
126
- data-testid={`locale-option-${item}`}
127
- onClick={() => setLocale(item)}
128
- className={[
129
- 'h-7 flex-1 rounded-full px-2 text-xs transition-colors',
130
- selected
131
- ? 'bg-agent-foreground/10 text-agent-foreground'
132
- : 'text-agent-muted-foreground hover:text-agent-foreground',
133
- ].join(' ')}
134
- >
135
- {localeEndonym(item)}
136
- </button>
137
- );
138
- })}
139
- </div>
140
- </div>
112
+ <SettingRow
113
+ testId="locale-settings"
114
+ title={t('Language')}
115
+ description={t('Display language for the application interface.')}
116
+ control={
117
+ <SettingSegmented
118
+ value={locale}
119
+ ariaLabel={t('Language')}
120
+ testId="locale-toggle"
121
+ onChange={setLocale}
122
+ options={locales.map((item) => ({
123
+ value: item,
124
+ label: localeEndonym(item),
125
+ testId: `locale-option-${item}`,
126
+ }))}
127
+ />
128
+ }
129
+ />
141
130
  ) : null}
142
- <div
143
- className="space-y-2 rounded-agent-md border border-agent-border bg-agent-card p-2.5"
144
- data-testid="appearance-settings-panel"
145
- >
146
- <div>
147
- <p className="text-xs font-medium text-agent-foreground">{t('Show thinking')}</p>
148
- <p className="mt-1 text-xs leading-relaxed text-agent-muted-foreground">
149
- {current ? t(current.hint) : null}{' '}
150
- {t(
151
- 'These options only control the thinking text. Tool cards and work rows stay as they are. A work row shows "Working", or the count and elapsed time after it finishes.',
152
- )}
153
- </p>
154
- </div>
155
- <div
156
- className="flex w-full rounded-full border border-agent-border bg-agent-canvas p-0.5"
157
- role="radiogroup"
158
- aria-label={t('Show thinking')}
159
- data-testid="thinking-display-toggle"
160
- >
161
- {THINKING_DISPLAY_OPTIONS.map((item) => {
162
- const selected = mode === item.mode;
163
- return (
164
- <button
165
- key={item.mode}
166
- type="button"
167
- role="radio"
168
- aria-checked={selected}
169
- aria-label={t(item.label)}
170
- data-testid={`thinking-display-${item.mode}`}
171
- onClick={() => persistThinkingDisplay(item.mode)}
172
- className={[
173
- 'h-7 flex-1 rounded-full px-2 text-xs transition-colors',
174
- selected
175
- ? 'bg-agent-foreground/10 text-agent-foreground'
176
- : 'text-agent-muted-foreground hover:text-agent-foreground',
177
- ].join(' ')}
178
- >
179
- {t(item.label)}
180
- </button>
181
- );
182
- })}
183
- </div>
184
- </div>
185
131
  <InterfaceZoomRow />
186
- </div>
132
+ <SettingRow
133
+ testId="appearance-settings-panel"
134
+ title={t('Show thinking')}
135
+ description={t(
136
+ 'Control how much thinking text is shown during the current turn. Collapses automatically once the turn ends.',
137
+ )}
138
+ control={
139
+ <SettingSegmented<ThinkingDisplayMode>
140
+ value={mode}
141
+ ariaLabel={t('Show thinking')}
142
+ testId="thinking-display-toggle"
143
+ onChange={persistThinkingDisplay}
144
+ options={THINKING_DISPLAY_OPTIONS.map((item) => ({
145
+ value: item.mode,
146
+ label: t(item.label),
147
+ ariaLabel: t(item.label),
148
+ testId: `thinking-display-${item.mode}`,
149
+ }))}
150
+ />
151
+ }
152
+ />
153
+ </SettingSection>
187
154
  );
188
155
  }
@@ -29,29 +29,31 @@ export function CliInstallSettingsPanel(props: {
29
29
  };
30
30
 
31
31
  return (
32
- <div className="space-y-2 rounded-agent-md border border-agent-border bg-agent-card p-2.5" data-testid="cli-install-settings">
33
- <p className="text-xs text-agent-muted-foreground">
34
- {t('Install the command-line tool on your PATH so you can run it from a terminal.')}
35
- </p>
36
- <button
37
- type="button"
38
- data-testid="cli-install-button"
39
- onClick={() => void onClick()}
40
- disabled={running}
41
- className="inline-flex items-center gap-1.5 rounded-agent-md bg-agent-primary px-3 py-1.5 text-xs font-medium text-agent-primary-foreground transition hover:bg-agent-primary/90 disabled:opacity-50"
42
- >
43
- {running ? (
44
- <>
45
- <LuLoader className="h-3.5 w-3.5 animate-spin" />
46
- {t('Installing…')}
47
- </>
48
- ) : (
49
- <>
50
- <LuTerminal className="h-3.5 w-3.5" />
51
- {t('Install command-line tool')}
52
- </>
53
- )}
54
- </button>
32
+ <div className="space-y-3 border-t border-b border-agent-border/60 py-3.5" data-testid="cli-install-settings">
33
+ <div className="flex items-center justify-between gap-6">
34
+ <p className="text-xs leading-relaxed text-agent-muted-foreground">
35
+ {t('Install the command-line tool on your PATH so you can run it from a terminal.')}
36
+ </p>
37
+ <button
38
+ type="button"
39
+ data-testid="cli-install-button"
40
+ onClick={() => void onClick()}
41
+ disabled={running}
42
+ className="inline-flex h-8 shrink-0 items-center gap-1.5 rounded-full bg-agent-foreground px-3.5 text-xs font-medium text-agent-canvas transition hover:opacity-90 disabled:opacity-50"
43
+ >
44
+ {running ? (
45
+ <>
46
+ <LuLoader className="h-3.5 w-3.5 animate-spin" />
47
+ {t('Installing…')}
48
+ </>
49
+ ) : (
50
+ <>
51
+ <LuTerminal className="h-3.5 w-3.5" />
52
+ {t('Install command-line tool')}
53
+ </>
54
+ )}
55
+ </button>
56
+ </div>
55
57
  {message && (
56
58
  <p data-testid="cli-install-message" className="text-xs text-agent-foreground">
57
59
  {message}
@@ -139,8 +139,8 @@ export function DiagnoseSettingsPanel() {
139
139
  };
140
140
 
141
141
  return (
142
- <div className="space-y-2 rounded-agent-md border border-agent-border bg-agent-card p-2.5">
143
- <p className="text-xs text-agent-muted-foreground">
142
+ <div className="space-y-3 border-t border-agent-border/60 pt-3">
143
+ <p className="text-xs leading-relaxed text-agent-muted-foreground">
144
144
  {t(
145
145
  'Diagnose network connectivity to the current model service, including DNS resolution, TCP connection, TLS handshake, the HTTP endpoint, and chat completion.',
146
146
  )}{' '}
@@ -153,7 +153,7 @@ export function DiagnoseSettingsPanel() {
153
153
  type="button"
154
154
  onClick={() => void run()}
155
155
  disabled={running}
156
- className="inline-flex items-center gap-1.5 rounded-agent-md bg-agent-primary px-3 py-1.5 text-xs font-medium text-agent-primary-foreground transition hover:bg-agent-primary/90 disabled:opacity-50"
156
+ className="inline-flex h-8 items-center gap-1.5 rounded-full bg-agent-foreground px-3.5 text-xs font-medium text-agent-canvas transition hover:opacity-90 disabled:opacity-50"
157
157
  >
158
158
  {running ? (
159
159
  <>
@@ -1,5 +1,4 @@
1
1
  import { useCallback, useEffect, useState } from 'react';
2
- import { LuChartBar } from 'react-icons/lu';
3
2
  import { BRAND_NAME } from '@/brand';
4
3
  import { t } from '@/i18n';
5
4
  import { getHostBridge, hasHostBridge } from '@/lib/host-bridge';
@@ -203,13 +202,12 @@ export function InsightsSettingsPanel() {
203
202
  const stats = data.stats ?? empty.stats!;
204
203
 
205
204
  return (
206
- <div className="space-y-3" data-testid="insights-settings-panel">
207
- <div className="rounded-agent-md border border-agent-border/60 bg-agent-muted/30 p-2.5 space-y-2">
208
- <h4 className="flex items-center gap-1.5 text-xs font-semibold text-agent-foreground">
209
- <LuChartBar className="h-3.5 w-3.5 text-agent-muted-foreground" />
205
+ <div className="space-y-3 border-t border-agent-border/60 pt-3" data-testid="insights-settings-panel">
206
+ <div className="space-y-3">
207
+ <p className="sr-only">
210
208
  {t('Help improve the product (behavior / conversations / user info are confirmed separately)')}
211
- </h4>
212
- <p className="text-[11px] text-agent-muted-foreground">
209
+ </p>
210
+ <p className="text-xs leading-relaxed text-agent-muted-foreground">
213
211
  {t(
214
212
  'Even if the user does not agree to upload, records stay on this device. You can export JSON and send it to the product team, or click "Upload now" once.',
215
213
  )}
@@ -32,6 +32,7 @@ import { ModelCapabilityChips } from '@/components/settings/ModelCapabilityChips
32
32
  import { modelCapabilityChips } from '@/components/settings/model-capabilities';
33
33
  import { ModelIdCombobox } from '@/components/settings/ModelIdCombobox';
34
34
  import { SettingsSaveButton } from '@/components/settings/SettingsSaveButton';
35
+ import { SettingDisclosure } from '@/components/settings/primitives';
35
36
  import { t } from '@/i18n';
36
37
  import { hasHostBridge } from '@/lib/host-bridge';
37
38
  import {
@@ -69,6 +70,8 @@ interface LlmSettingsPanelProps {
69
70
  onSaved?: (settings: LlmSettings) => void;
70
71
  onSaveUiChange?: (ui: LlmSaveUi) => void;
71
72
  showFooterSave?: boolean;
73
+ /** 在设置页子页面内默认将预制/兼容旗标/预算/超时折叠进高级区,保持首屏清爽。 */
74
+ collapseAdvanced?: boolean;
72
75
  }
73
76
 
74
77
  // ─── 厂商参数预制(框架 llm.presets)────────────────────────────────────────
@@ -78,12 +81,12 @@ interface LlmSettingsPanelProps {
78
81
  /**
79
82
  * LlmSettingsPanel — 本地模型设置表单(服务商 / URL / Key / 模型 / 预制 / 超时)。
80
83
  *
81
- * 两处复用:设置页「设置」分区,以及输入区齿轮打开的 LocalLlmSettingsModal。
84
+ * 两处复用:设置页「模型服务」子页,以及输入区齿轮打开的 LocalLlmSettingsModal。
82
85
  * 挂载时自取当前配置;保存走 local-api `setLlmSettings`。
83
86
  */
84
87
  export const LlmSettingsPanel = forwardRef<LlmSettingsPanelHandle, LlmSettingsPanelProps>(
85
88
  function LlmSettingsPanel(
86
- { onSaved, onSaveUiChange, showFooterSave = true },
89
+ { onSaved, onSaveUiChange, showFooterSave = true, collapseAdvanced = false },
87
90
  ref,
88
91
  ) {
89
92
  const [settings, setSettings] = useState<LlmSettings>({
@@ -613,6 +616,9 @@ export const LlmSettingsPanel = forwardRef<LlmSettingsPanelHandle, LlmSettingsPa
613
616
  </p>
614
617
  </div>
615
618
 
619
+ {(() => {
620
+ const advancedBody = (
621
+ <div className="space-y-4">
616
622
  {usesOpenAiCompatExtras(settings.provider) && (
617
623
  <div className="rounded-agent-md border border-agent-border/60 p-3 space-y-3">
618
624
  <div>
@@ -889,6 +895,20 @@ export const LlmSettingsPanel = forwardRef<LlmSettingsPanelHandle, LlmSettingsPa
889
895
  </div>
890
896
 
891
897
  </div>
898
+ </div>
899
+ );
900
+ if (!collapseAdvanced) return advancedBody;
901
+ return (
902
+ <SettingDisclosure
903
+ title={t('Advanced parameters & compatibility')}
904
+ summary={`${t('Token budget limit')}: ${(settings.maxTotalTokens ?? 60000).toLocaleString()}`}
905
+ defaultOpen={false}
906
+ testId="llm-advanced-disclosure"
907
+ >
908
+ {advancedBody}
909
+ </SettingDisclosure>
910
+ );
911
+ })()}
892
912
  </>
893
913
  )}
894
914
 
@@ -281,11 +281,10 @@ export function McpSettingsPanel() {
281
281
  };
282
282
 
283
283
  return (
284
- <div className="space-y-3">
284
+ <div className="space-y-5">
285
285
  {/* JSON 导入 */}
286
- <div className="bg-agent-muted/30 border border-agent-border/60 rounded-agent-md p-2.5 space-y-2">
287
- <h4 className="text-xs font-semibold text-agent-foreground flex items-center gap-1.5">
288
- <LuPlug className="h-3.5 w-3.5 text-agent-muted-foreground" />
286
+ <div className="space-y-2.5 border-t border-b border-agent-border/60 py-4">
287
+ <h4 className="text-xs font-medium text-agent-foreground">
289
288
  {t('Paste JSON to import (Claude Desktop format)')}
290
289
  </h4>
291
290
  <textarea
@@ -322,7 +321,7 @@ export function McpSettingsPanel() {
322
321
 
323
322
  {/* 手动添加 / 编辑表单 */}
324
323
  {mcpFormOpen ? (
325
- <div className="bg-agent-muted/30 border border-agent-border/60 rounded-agent-md p-2.5 space-y-2.5">
324
+ <div className="space-y-3 rounded-agent-md border border-agent-border bg-agent-canvas p-4">
326
325
  <h4 className="text-xs font-semibold text-agent-foreground">
327
326
  {mcpEditingId ? t('Edit MCP server') : t('Add MCP server manually')}
328
327
  </h4>