@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
@@ -6,7 +6,11 @@
6
6
 
7
7
  import { t } from '@/i18n';
8
8
  import { formatElapsedCompact } from './elapsed';
9
- import { deriveActionStatusInfo } from './executed-actions-model';
9
+ import {
10
+ deriveActionStatusInfo,
11
+ parseImageAction,
12
+ resolveActionCard,
13
+ } from './executed-actions-model';
10
14
  import {
11
15
  countProcessReasoning,
12
16
  countProcessTools,
@@ -141,6 +145,109 @@ export function processStatusLabel(input: {
141
145
  return parts.join(' · ');
142
146
  }
143
147
 
148
+ type HistoryStageCategory = 'skill' | 'edit' | 'explore' | 'run' | 'image' | 'web';
149
+
150
+ function classifyHistoryStageAction(raw: unknown): HistoryStageCategory | null {
151
+ if (!raw || typeof raw !== 'object') return null;
152
+ const candidate = raw as {
153
+ tool?: unknown;
154
+ arguments?: unknown;
155
+ result?: unknown;
156
+ view?: { card?: 'generic' | 'terminal' | 'diff' | 'search' | 'read' | 'web'; declared?: boolean };
157
+ };
158
+ if (typeof candidate.tool !== 'string') return null;
159
+ const tool = candidate.tool;
160
+ if (tool === 'load_skill' || tool === 'read_skill' || tool === 'activate_skill') {
161
+ return 'skill';
162
+ }
163
+ if (candidate.arguments && typeof candidate.arguments === 'object') {
164
+ const pathArg = (candidate.arguments as { path?: unknown; file_path?: unknown }).path
165
+ ?? (candidate.arguments as { file_path?: unknown }).file_path;
166
+ if (typeof pathArg === 'string' && /(?:^|[/\\])SKILL\.md$/i.test(pathArg)) {
167
+ return 'skill';
168
+ }
169
+ }
170
+ if (
171
+ tool === 'view_image' ||
172
+ tool === 'render_office_preview' ||
173
+ parseImageAction({ tool, arguments: candidate.arguments, result: candidate.result }) !== null
174
+ ) {
175
+ return 'image';
176
+ }
177
+ const info = deriveActionStatusInfo({
178
+ tool,
179
+ arguments: candidate.arguments,
180
+ result: candidate.result,
181
+ });
182
+ if (info.classifiedShell) {
183
+ if (
184
+ info.classifiedShell.kind === 'search' ||
185
+ info.classifiedShell.kind === 'list' ||
186
+ info.classifiedShell.kind === 'read'
187
+ ) {
188
+ return 'explore';
189
+ }
190
+ return 'run';
191
+ }
192
+ const card = resolveActionCard({ tool, view: candidate.view });
193
+ if (card === 'diff') return 'edit';
194
+ if (card === 'read' || card === 'search') return 'explore';
195
+ if (card === 'web') return 'web';
196
+ if (
197
+ card === 'terminal' ||
198
+ tool === 'run_code' ||
199
+ tool.includes('exec') ||
200
+ tool.includes('shell') ||
201
+ tool.includes('snippet')
202
+ ) {
203
+ return 'run';
204
+ }
205
+ return null;
206
+ }
207
+
208
+ function categoryLabel(category: HistoryStageCategory): string {
209
+ switch (category) {
210
+ case 'skill':
211
+ return t('used skills');
212
+ case 'edit':
213
+ return t('edited files');
214
+ case 'explore':
215
+ return t('explored files');
216
+ case 'run':
217
+ return t('ran commands');
218
+ case 'image':
219
+ return t('viewed images');
220
+ case 'web':
221
+ return t('searched the web');
222
+ }
223
+ }
224
+
225
+ function summarizeHistoryStageCategories(
226
+ process: ReadonlyArray<ProcessTimelineBlock<unknown>>,
227
+ ): string | null {
228
+ const counts = new Map<HistoryStageCategory, { count: number; order: number }>();
229
+ let order = 0;
230
+ for (const block of process) {
231
+ if (block.type !== 'tools') continue;
232
+ for (const raw of block.actions) {
233
+ const cat = classifyHistoryStageAction(raw);
234
+ if (!cat) continue;
235
+ const prev = counts.get(cat);
236
+ if (prev) {
237
+ prev.count += 1;
238
+ } else {
239
+ counts.set(cat, { count: 1, order: order++ });
240
+ }
241
+ }
242
+ }
243
+ if (counts.size === 0) return null;
244
+ const top = [...counts.entries()]
245
+ .sort((a, b) => b[1].count - a[1].count || a[1].order - b[1].order)
246
+ .slice(0, 2)
247
+ .map(([cat]) => categoryLabel(cat));
248
+ return top.join(t(', '));
249
+ }
250
+
144
251
  /**
145
252
  * Single-line summary for folded prior process steps so only the latest stage
146
253
  * (`thinking` / `output` / latest single tool) remains directly visible.
@@ -152,10 +259,13 @@ export function completedHistoryLabel(
152
259
  const tools = countProcessTools(process);
153
260
  const failedCount = options?.showFailedCount ? countFailedProcessTools(process) : 0;
154
261
  const steps = tools > 0 ? tools : countHistoryStages(process);
262
+ const stageSummary = steps >= 3 ? summarizeHistoryStageCategories(process) : null;
155
263
  const base =
156
264
  steps === 1
157
265
  ? t('Completed 1 step')
158
- : t('Completed {count} steps', { count: steps });
266
+ : stageSummary
267
+ ? t('Completed {count} steps · {summary}', { count: steps, summary: stageSummary })
268
+ : t('Completed {count} steps', { count: steps });
159
269
  return failedCount > 0 ? `${base} · ${t('{count} failed', { count: failedCount })}` : base;
160
270
  }
161
271
 
@@ -141,11 +141,59 @@ function actionsFromTimeline(blocks: TurnBlock[] | undefined): ExecutedAction[]
141
141
  return actions;
142
142
  }
143
143
 
144
+ export interface ResolveTurnTodosInput {
145
+ /** Assistant message IDs belonging to this `ConversationTurn` in chronological order. */
146
+ assistantMessageIds: readonly string[];
147
+ /** True when this turn is the newest turn in the conversation (eligible for live tail actions). */
148
+ isLatestTurn: boolean;
149
+ executedActionsByMessageId?: Record<string, ExecutedAction[]>;
150
+ timelineByMessageId?: Record<string, TurnBlock[]>;
151
+ currentTurnActions?: ExecutedAction[];
152
+ currentTurnTimeline?: TurnBlock[];
153
+ }
154
+
155
+ /**
156
+ * Extract the latest `todo_write` snapshot strictly within a single `ConversationTurn`.
157
+ * Never walks backwards into earlier turns so unfinished items from an older turn
158
+ * cannot leak onto a subsequent unrelated prompt.
159
+ */
160
+ export function resolveTurnTodos(input: ResolveTurnTodosInput): SessionTodo[] | null {
161
+ if (input.isLatestTurn) {
162
+ const live =
163
+ latestTodosFromActions(input.currentTurnActions) ??
164
+ latestTodosFromActions(actionsFromTimeline(input.currentTurnTimeline));
165
+ if (live) return live;
166
+ }
167
+
168
+ for (let i = input.assistantMessageIds.length - 1; i >= 0; i -= 1) {
169
+ const id = input.assistantMessageIds[i]!;
170
+ const turnScoped =
171
+ latestTodosFromActions(input.executedActionsByMessageId?.[id]) ??
172
+ latestTodosFromActions(actionsFromTimeline(input.timelineByMessageId?.[id]));
173
+ if (turnScoped) return turnScoped;
174
+ }
175
+ return null;
176
+ }
177
+
178
+ /**
179
+ * Sticky turn-strip visibility:
180
+ * - Only rendered on the latest conversation turn so historical turns stay compact;
181
+ * - Visible throughout streaming (including the brief moment after `n/n` completes);
182
+ * - Auto-hides once streaming finishes and all items are completed, while keeping
183
+ * an interrupted/incomplete strip collapsed beneath the prompt until resumed or superseded.
184
+ */
185
+ export function shouldShowTurnTodoStrip(
186
+ todos: SessionTodo[] | null | undefined,
187
+ options: { isLatestTurn: boolean; isTurnStreaming: boolean },
188
+ ): todos is SessionTodo[] {
189
+ if (!todos || todos.length === 0) return false;
190
+ if (!options.isLatestTurn) return false;
191
+ if (options.isTurnStreaming) return true;
192
+ return todos.some((todo) => todo.status !== 'completed');
193
+ }
194
+
144
195
  /**
145
- * Composer meta-row visibility: keep active or incomplete task lists visible,
146
- * and keep newly completed lists visible while the turn is still streaming;
147
- * once the turn settles (`!isStreaming`), hide an all-completed list so stale
148
- * finished checklists do not linger above the next prompt.
196
+ * Composer meta-row visibility (legacy helper retained for pure model tests).
149
197
  */
150
198
  export function shouldShowComposerTodos(
151
199
  todos: SessionTodo[] | null | undefined,
@@ -214,15 +214,15 @@ export function AgentsSettingsPanel({
214
214
  };
215
215
 
216
216
  return (
217
- <div className="space-y-3">
218
- <p className="text-[11px] text-agent-muted-foreground">
217
+ <div className="space-y-4">
218
+ <p className="text-xs leading-relaxed text-agent-muted-foreground">
219
219
  {t(
220
220
  'Custom agents appear in the expert picker above the input box. The role prompt opens the conversation as its persona, and the checked skills and tool permissions apply on every turn. Built-in agents can have their text and capabilities edited, but cannot be deleted.',
221
221
  )}
222
222
  </p>
223
223
 
224
224
  {formOpen ? (
225
- <div className="space-y-2 rounded-agent-md border border-agent-border/60 bg-agent-muted/30 p-2.5">
225
+ <div className="space-y-3 rounded-agent-md border border-agent-border bg-agent-canvas p-4">
226
226
  <h4 className="text-xs font-semibold text-agent-foreground">
227
227
  {editingId ? t('Edit agent') : t('New agent')}
228
228
  </h4>
@@ -1,60 +1,70 @@
1
1
  import { LuInfo } from 'react-icons/lu';
2
+ import { BRAND_NAME } from '@/brand';
2
3
  import { useAppRelease } from '@/components/SidebarRelease';
3
4
  import { t } from '@/i18n';
5
+ import { SettingRow, SettingSection } from './primitives';
4
6
 
5
7
  /**
6
- * 综合设置里的版本与更新。侧栏只显示版本号;检查、下载和安装在这里。
7
- * 没有桌面更新通道时不渲染。
8
+ * 版本与更新面板:
9
+ * - 独立挂载(未传 showFallbackBrand)且无桌面版本信息时保持返回 null,兼容存量单测;
10
+ * - 在「关于」子页(showFallbackBrand=true)常驻展示应用名称与当前版本号,不额外渲染冗余二级标题。
8
11
  */
9
- export function AppUpdateSettingsPanel() {
12
+ export function AppUpdateSettingsPanel({
13
+ showFallbackBrand = false,
14
+ }: {
15
+ showFallbackBrand?: boolean;
16
+ } = {}) {
10
17
  const release = useAppRelease();
11
- if (!release.version) return null;
18
+ if (!release.version && !showFallbackBrand) return null;
19
+
12
20
  const detail =
13
21
  release.actionTitle && release.actionTitle !== release.actionLabel
14
22
  ? release.actionTitle
15
23
  : null;
16
24
 
17
- return (
18
- <section className="space-y-2" data-testid="settings-section-update">
19
- <h2 className="flex items-center gap-1.5 text-xs font-semibold text-agent-foreground">
20
- <LuInfo className="h-3.5 w-3.5 text-agent-muted-foreground" />
21
- {t('About')}
22
- </h2>
23
- <div className="flex items-center gap-3 rounded-agent-md border border-agent-border bg-agent-card p-2.5">
24
- <div className="min-w-0 flex-1">
25
- <p className="text-xs font-medium text-agent-foreground">{t('Current version')}</p>
26
- <p
27
- className="mt-1 text-xs tabular-nums text-agent-muted-foreground"
28
- data-testid="settings-app-version"
29
- >
30
- v{release.version}
31
- </p>
32
- {detail ? (
33
- <p className="mt-1 text-xs leading-relaxed text-agent-muted-foreground">{detail}</p>
34
- ) : null}
35
- </div>
36
- {release.actionLabel ? (
37
- <button
38
- type="button"
39
- className={[
40
- 'flex h-7 shrink-0 items-center rounded-full px-3 text-xs transition-colors',
41
- release.emphasize
42
- ? 'bg-agent-foreground font-medium text-agent-canvas hover:opacity-90'
43
- : 'border border-agent-border text-agent-foreground hover:bg-agent-foreground/5',
44
- release.clickable ? '' : 'cursor-default opacity-60',
45
- ].join(' ')}
46
- data-testid="settings-app-update"
47
- title={release.actionTitle}
48
- disabled={!release.clickable}
49
- onClick={release.run}
50
- >
51
- {release.actionLabel}
52
- </button>
53
- ) : null}
54
- </div>
25
+ const body = (
26
+ <div className="space-y-4">
27
+ <SettingSection>
28
+ <SettingRow
29
+ title={release.version ? t('Current version') : BRAND_NAME}
30
+ description={
31
+ <>
32
+ {release.version ? (
33
+ <span className="tabular-nums" data-testid="settings-app-version">
34
+ v{release.version}
35
+ </span>
36
+ ) : (
37
+ <span data-testid="settings-app-version">{t('Web client')}</span>
38
+ )}
39
+ {detail ? <span className="mt-1 block">{detail}</span> : null}
40
+ </>
41
+ }
42
+ control={
43
+ release.actionLabel ? (
44
+ <button
45
+ type="button"
46
+ className={[
47
+ 'flex h-7 shrink-0 items-center rounded-full px-3 text-xs transition-colors',
48
+ release.emphasize
49
+ ? 'bg-agent-foreground font-medium text-agent-canvas hover:opacity-90'
50
+ : 'border border-agent-border text-agent-foreground hover:bg-agent-foreground/5',
51
+ release.clickable ? '' : 'cursor-default opacity-60',
52
+ ].join(' ')}
53
+ data-testid="settings-app-update"
54
+ title={release.actionTitle}
55
+ disabled={!release.clickable}
56
+ onClick={release.run}
57
+ >
58
+ {release.actionLabel}
59
+ </button>
60
+ ) : null
61
+ }
62
+ />
63
+ </SettingSection>
64
+
55
65
  {release.releaseNotes ? (
56
66
  <div
57
- className="rounded-agent-md border border-agent-border bg-agent-card p-2.5 text-xs"
67
+ className="rounded-lg border border-agent-border/70 bg-agent-muted/20 p-3.5 text-xs"
58
68
  data-testid="settings-app-release-notes"
59
69
  >
60
70
  <p className="font-medium text-agent-foreground">
@@ -67,6 +77,20 @@ export function AppUpdateSettingsPanel() {
67
77
  </div>
68
78
  </div>
69
79
  ) : null}
80
+ </div>
81
+ );
82
+
83
+ if (showFallbackBrand) {
84
+ return body;
85
+ }
86
+
87
+ return (
88
+ <section className="space-y-2" data-testid="settings-section-update">
89
+ <h2 className="flex items-center gap-1.5 text-xs font-semibold text-agent-foreground">
90
+ <LuInfo className="h-3.5 w-3.5 text-agent-muted-foreground" />
91
+ {t('About')}
92
+ </h2>
93
+ {body}
70
94
  </section>
71
95
  );
72
96
  }
@@ -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
  }