-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings_registry.dart
More file actions
393 lines (382 loc) · 13.4 KB
/
Copy pathsettings_registry.dart
File metadata and controls
393 lines (382 loc) · 13.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
/// The single source of truth for the desktop settings taxonomy: an ordered
/// list of all 8 sections plus a search index over their items.
///
/// Wave 2 agents add real controls by editing the relevant `sections/*.dart`
/// body widget (and declaring items here for search) — the shell and prefs
/// store do not change. Adding a whole new section is the only reason to edit
/// the [kSettingsSections] list.
library;
import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
import '../sections/about_section.dart';
import '../sections/advanced_section.dart';
import '../sections/agents_chat_section.dart';
import '../sections/appearance_section.dart';
import '../sections/general_section.dart';
import '../sections/notifications_section.dart';
import '../sections/server_devices_section.dart';
import '../sections/shortcuts_section.dart';
import '../../../store/models.dart';
import '../../../ui/home/repo_monogram.dart';
import '../repository_settings_page.dart';
import 'settings_item.dart';
import 'settings_section.dart';
/// All settings sections, in taxonomy order (SPEC-13 §"Section taxonomy").
final List<SettingsSection> kSettingsSections = [
SettingsSection(
id: 'general',
title: 'General',
icon: PhosphorIconsLight.slidersHorizontal,
builder: (_) => const GeneralSection(),
items: const [
SettingsItem(
id: 'general.startup',
title: 'Startup',
help: 'Launch at login and restore the last window or session.',
keywords: ['launch', 'login', 'restore', 'boot'],
availability: SettingsAvailability.comingSoon,
),
SettingsItem(
id: 'general.language',
title: 'Language & region',
help: 'Interface language and regional formats.',
keywords: ['locale', 'i18n', 'region'],
availability: SettingsAvailability.comingSoon,
),
SettingsItem(
id: 'general.update',
title: 'Software update',
help: 'Update channel and check for updates.',
keywords: ['upgrade', 'channel', 'version'],
availability: SettingsAvailability.comingSoon,
),
],
),
SettingsSection(
id: 'appearance',
title: 'Appearance',
icon: PhosphorIconsLight.palette,
builder: (_) => const AppearanceSection(),
items: const [
SettingsItem(
id: 'appearance.theme',
title: 'Theme',
help: 'System, Light, or Dark appearance.',
keywords: ['dark', 'light', 'system', 'mode', 'color scheme'],
),
SettingsItem(
id: 'appearance.accent',
title: 'Accent color',
help: 'The single accent hue used for active and selected states.',
keywords: ['color', 'highlight', 'green'],
availability: SettingsAvailability.comingSoon,
),
SettingsItem(
id: 'appearance.text_code',
title: 'Text & code',
help: 'UI text scale; monospace code font (coming soon).',
keywords: ['font', 'scale', 'size', 'monospace', 'text'],
),
SettingsItem(
id: 'appearance.layout',
title: 'Layout',
help: 'Default sidebar width and start collapsed.',
keywords: ['sidebar', 'width', 'collapsed', 'fold'],
),
SettingsItem(
id: 'appearance.chat_rendering',
title: 'Chat rendering',
help: 'Markdown, code highlight theme, and timestamps.',
keywords: ['markdown', 'highlight', 'timestamps'],
availability: SettingsAvailability.comingSoon,
),
],
),
SettingsSection(
id: 'agents_chat',
title: 'Agents & Chat',
icon: PhosphorIconsLight.robot,
builder: (_) => const AgentsChatSection(),
items: const [
SettingsItem(
id: 'agents_chat.default_agent',
title: 'Default agent & model',
help: 'The agent and model used for new sessions.',
keywords: ['model', 'llm', 'default'],
availability: SettingsAvailability.comingSoon,
),
SettingsItem(
id: 'agents_chat.per_agent',
title: 'Per-agent config',
help: 'Binary path and API-key location per agent.',
keywords: ['binary', 'api key', 'path'],
availability: SettingsAvailability.comingSoon,
),
SettingsItem(
id: 'agents_chat.approvals',
title: 'Approval & permissions policy',
help: 'How agent tool calls are approved.',
keywords: ['permissions', 'approval', 'policy'],
availability: SettingsAvailability.comingSoon,
),
SettingsItem(
id: 'agents_chat.composer',
title: 'Composer',
help: 'Send on Enter vs ⌘-Enter.',
keywords: ['enter', 'send', 'shortcut'],
availability: SettingsAvailability.comingSoon,
),
SettingsItem(
id: 'agents_chat.pr_actions',
title: 'PR actions',
help:
'Editable canned prompts for the composer\'s PR actions '
'(Create PR, Fix PR, Resolve comments).',
keywords: [
'pr',
'pull request',
'prompt',
'create pr',
'fix pr',
'resolve comments',
'github',
],
),
],
),
SettingsSection(
id: 'server_devices',
title: 'Server & Devices',
icon: PhosphorIconsLight.hardDrives,
builder: (_) => const ServerDevicesSection(),
items: const [
SettingsItem(
id: 'server_devices.endpoint',
title: 'Endpoint',
help: 'The host and port the daemon binds and the client connects to.',
keywords: ['host', 'port', 'connection'],
),
SettingsItem(
id: 'server_devices.lifecycle',
title: 'Lifecycle',
help: 'Start, stop, restart, and autostart the daemon.',
keywords: ['start', 'stop', 'restart', 'daemon', 'autostart'],
),
SettingsItem(
id: 'server_devices.cli',
title: 'CLI',
help: 'Resolved makit CLI path and install command.',
keywords: ['install', 'path', 'command line'],
),
SettingsItem(
id: 'server_devices.paired',
title: 'Paired devices',
help: 'List and revoke paired devices.',
keywords: ['devices', 'revoke', 'pairing'],
),
SettingsItem(
id: 'server_devices.pair',
title: 'Pair new device',
help: 'Pair a new device via QR code.',
keywords: ['qr', 'pair', 'add device'],
),
SettingsItem(
id: 'server_devices.sessions',
title: 'Running sessions',
help: 'Active sessions (idle/exited hidden); history and cleanup.',
keywords: ['sessions', 'running', 'history'],
),
SettingsItem(
id: 'server_devices.fingerprint',
title: 'Fingerprint / TLS trust',
help: 'Certificate fingerprint and TLS trust.',
keywords: ['tls', 'certificate', 'fingerprint', 'trust'],
),
SettingsItem(
id: 'server_devices.unpair',
title: 'Unpair this device',
help: 'Remove this device\'s pairing (danger).',
keywords: ['unpair', 'remove', 'danger'],
),
],
),
SettingsSection(
id: 'notifications',
title: 'Notifications',
icon: PhosphorIconsLight.bell,
builder: (_) => const NotificationsSection(),
items: const [
SettingsItem(
id: 'notifications.local',
title: 'Local notifications',
help: 'Local notifications, background wake, and reminder delay.',
keywords: ['alerts', 'background', 'wake', 'reminder', 'delay'],
),
SettingsItem(
id: 'notifications.per_type',
title: 'Per-type mute & approval reminders',
help: 'Mute specific notification types; approval reminders.',
keywords: ['mute', 'reminders', 'approval'],
availability: SettingsAvailability.comingSoon,
),
],
),
SettingsSection(
id: 'shortcuts',
title: 'Shortcuts',
icon: PhosphorIconsLight.keyboard,
builder: (_) => const ShortcutsSection(),
items: const [
SettingsItem(
id: 'shortcuts.chat',
title: 'Chat scope shortcuts',
help: 'Shortcuts active while the message field is focused.',
keywords: ['keyboard', 'chord', 'rebind', 'composer'],
),
SettingsItem(
id: 'shortcuts.window',
title: 'Window scope shortcuts',
help: 'Shortcuts active anywhere in the window.',
keywords: ['keyboard', 'chord', 'rebind', 'global'],
),
],
),
SettingsSection(
id: 'advanced',
title: 'Advanced',
icon: PhosphorIconsLight.wrench,
builder: (_) => const AdvancedSection(),
items: const [
SettingsItem(
id: 'advanced.developer',
title: 'Developer',
help: 'Fake server toggle, logs, and diagnostics.',
keywords: ['fake', 'logs', 'diagnostics', 'debug'],
),
SettingsItem(
id: 'advanced.status',
title: 'Status',
help: 'Process id, uptime, and protocol version.',
keywords: ['pid', 'uptime', 'protocol', 'version'],
),
SettingsItem(
id: 'advanced.telemetry',
title: 'Telemetry',
help: 'Anonymous usage telemetry.',
keywords: ['analytics', 'usage'],
availability: SettingsAvailability.comingSoon,
),
SettingsItem(
id: 'advanced.reset_all',
title: 'Reset all settings',
help: 'Clear every changed preference and return to defaults.',
keywords: ['reset', 'defaults', 'clear'],
),
],
),
SettingsSection(
id: 'about',
title: 'About',
icon: PhosphorIconsLight.info,
builder: (_) => const AboutSection(),
items: const [
SettingsItem(
id: 'about.version',
title: 'Version & links',
help: 'App version, protocol version, and links.',
keywords: ['version', 'protocol', 'links', 'about'],
),
],
),
];
/// A single search hit: the matching [item] and the id of the section that
/// owns it (for deep-linking / navigation).
class SettingsSearchResult {
/// Creates a result.
const SettingsSearchResult({required this.sectionId, required this.item});
/// The id of the owning section.
final String sectionId;
/// The matching item.
final SettingsItem item;
}
/// The section list for a given set of repositories: the fixed app sections, then
/// one per repository under a REPOSITORIES group.
///
/// Only **pinned** repos get a section. That is what bounds the sidebar: a pinned
/// project is one the user added (`manager.ts:215`), where an unpinned one is
/// merely something makit noticed (`:287`). Without the filter the settings
/// sidebar would grow into a file browser.
///
/// Section ids are `repo:<projectId>` — keyed off the persisted id, never the
/// path, so a repo that moves keeps its section and its deep links.
List<SettingsSection> sectionsFor(List<RepoInfo> repos) {
final pinned = repos.where((r) => r.pinned).toList();
return [
...kSettingsSections,
for (final repo in pinned)
SettingsSection(
id: repoSectionId(repo.id),
title: repo.name,
icon: PhosphorIconsLight.folder,
// The repo's own mark, so the sidebar rows are distinguishable — which is
// the place the "two repos look identical" problem actually bites, and the
// place the user looks to confirm a chosen colour took effect (D15/D14′).
// `icon` stays as the fallback for any renderer that ignores `leading`.
leading: RepoMonogram(
name: repo.name,
hue: repo.settings?.logoHue,
size: 20,
),
builder: (_) => RepositorySettingsPage(repoId: repo.id),
// Generated per repo so the existing search field reaches these rows too;
// without them "worktree root" would find nothing.
items: [
SettingsItem(
id: '${repoSectionId(repo.id)}.identity',
title: 'Identity',
help:
'Logo, root path, git provider and default branch for ${repo.name}.',
keywords: const ['logo', 'path', 'provider', 'forge', 'branch'],
),
SettingsItem(
id: '${repoSectionId(repo.id)}.worktrees',
title: 'Worktrees',
help: 'Where new worktrees for ${repo.name} are created.',
keywords: const ['worktree', 'worktree root', 'directory'],
),
],
),
];
}
/// The section id for a repo. One function, so the window, the nav pane and any
/// deep link cannot disagree about the format.
String repoSectionId(String projectId) => 'repo:$projectId';
/// True when [sectionId] addresses a repository section.
bool isRepoSection(String sectionId) => sectionId.startsWith('repo:');
/// A reusable search over an arbitrary list of sections. Defaults to the
/// app-wide [kSettingsSections]. Returns items whose title, keywords, or help
/// contain [query] (case-insensitive); an empty/whitespace query returns no
/// results.
List<SettingsSearchResult> searchSettings(
String query, {
List<SettingsSection>? sections,
}) {
final q = query.trim().toLowerCase();
if (q.isEmpty) return const [];
final results = <SettingsSearchResult>[];
for (final section in sections ?? kSettingsSections) {
for (final item in section.items) {
if (_matches(item, q)) {
results.add(SettingsSearchResult(sectionId: section.id, item: item));
}
}
}
return results;
}
bool _matches(SettingsItem item, String q) {
if (item.title.toLowerCase().contains(q)) return true;
if (item.help.toLowerCase().contains(q)) return true;
for (final keyword in item.keywords) {
if (keyword.toLowerCase().contains(q)) return true;
}
return false;
}