mux-sesh 1.10.0 → 2.0.1
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/README.md +133 -86
- package/bin/mux-sesh +45 -17
- package/bin/platform.sh +139 -0
- package/bin/postinstall +22 -0
- package/package.json +27 -38
- package/src/agents/index.ts +0 -1
- package/src/agents/session-name.ts +0 -24
- package/src/app/commands.ts +0 -138
- package/src/app/controller.ts +0 -437
- package/src/app/controls.ts +0 -123
- package/src/app/core-state.ts +0 -75
- package/src/app/data.ts +0 -130
- package/src/app/derived.ts +0 -77
- package/src/app/effects.ts +0 -650
- package/src/app/handlers.ts +0 -406
- package/src/app/keyboard.ts +0 -165
- package/src/app/modal-keyboard.ts +0 -137
- package/src/app/modal-state.ts +0 -53
- package/src/app/modals-layer.tsx +0 -159
- package/src/app/modals.ts +0 -108
- package/src/app/notifications.ts +0 -21
- package/src/app/opencode.ts +0 -49
- package/src/app/operations.ts +0 -31
- package/src/app/runtime.ts +0 -79
- package/src/app/screen.tsx +0 -240
- package/src/app/state.ts +0 -178
- package/src/app/textarea.ts +0 -16
- package/src/app/view.ts +0 -101
- package/src/app.tsx +0 -50
- package/src/config/index.ts +0 -475
- package/src/config/listed-sessions.ts +0 -33
- package/src/config/paths.ts +0 -13
- package/src/config/session-rules.ts +0 -100
- package/src/config/store.ts +0 -33
- package/src/files/target.ts +0 -96
- package/src/handlers/action-helpers.ts +0 -83
- package/src/handlers/actions.ts +0 -216
- package/src/handlers/keyboard/agents.ts +0 -134
- package/src/handlers/keyboard/index.ts +0 -5
- package/src/handlers/keyboard/new-session.ts +0 -58
- package/src/handlers/keyboard/normal.ts +0 -220
- package/src/handlers/keyboard/search.ts +0 -118
- package/src/handlers/keyboard/shared.ts +0 -117
- package/src/herdr/backend.ts +0 -357
- package/src/herdr/protocol.ts +0 -268
- package/src/index.tsx +0 -23
- package/src/items/order.ts +0 -95
- package/src/multiplexer/backend.ts +0 -43
- package/src/multiplexer/command.ts +0 -48
- package/src/multiplexer/index.ts +0 -21
- package/src/multiplexer/items.ts +0 -66
- package/src/multiplexer/resolve.ts +0 -109
- package/src/multiplexer/tmux-backend.ts +0 -87
- package/src/multiplexer/types.ts +0 -93
- package/src/opencode/constants.ts +0 -7
- package/src/opencode/index.ts +0 -20
- package/src/opencode/parser.ts +0 -45
- package/src/opencode/session-name.ts +0 -13
- package/src/opencode/session.ts +0 -146
- package/src/opencode/sqlite.ts +0 -447
- package/src/opencode/stats.ts +0 -26
- package/src/opencode/tokens.ts +0 -116
- package/src/opencode/types.ts +0 -33
- package/src/preview/project.ts +0 -362
- package/src/projects/session-links.ts +0 -52
- package/src/search/fff.ts +0 -224
- package/src/search/index.ts +0 -198
- package/src/settings.ts +0 -465
- package/src/styles/omarchy.ts +0 -295
- package/src/styles/opencode-themes-a.ts +0 -1442
- package/src/styles/opencode-themes-b.ts +0 -1212
- package/src/styles/opencode-tui-colors.ts +0 -1784
- package/src/styles/terminal-palette.ts +0 -156
- package/src/styles/theme-follow.ts +0 -94
- package/src/styles/theme.tsx +0 -311
- package/src/tmux/actions.ts +0 -145
- package/src/tmux/details.ts +0 -104
- package/src/tmux/helpers.ts +0 -35
- package/src/tmux/index.ts +0 -10
- package/src/tmux/list.ts +0 -31
- package/src/tmux/project-discovery.ts +0 -116
- package/src/tmux/project-loader.ts +0 -92
- package/src/tmux/project-zoxide.ts +0 -128
- package/src/tmux/projects.ts +0 -38
- package/src/tmux/workflows.ts +0 -26
- package/src/types/index.ts +0 -221
- package/src/ui/AgentSessionGroup.tsx +0 -93
- package/src/ui/CommandsModal.tsx +0 -246
- package/src/ui/ErrorScreen.tsx +0 -102
- package/src/ui/HighlightedText.tsx +0 -60
- package/src/ui/ItemList.tsx +0 -119
- package/src/ui/Modal.tsx +0 -48
- package/src/ui/OpencodeStatsPanel.tsx +0 -233
- package/src/ui/RenameModal.tsx +0 -42
- package/src/ui/SearchInput.tsx +0 -43
- package/src/ui/SessionDetailsPanel.tsx +0 -273
- package/src/ui/SessionList.tsx +0 -119
- package/src/ui/SettingEditorModal.tsx +0 -55
- package/src/ui/SettingOptionsModal.tsx +0 -95
- package/src/ui/SettingsModal.tsx +0 -102
- package/src/ui/Toast.tsx +0 -34
- package/src/ui/VersionBadge.tsx +0 -45
- package/src/ui/item-icon.ts +0 -110
- package/src/ui/list-window.ts +0 -35
- package/src/ui/session-meta.ts +0 -10
- package/src/ui/text-columns.ts +0 -17
- package/src/ui/use-textarea-focus.ts +0 -29
- package/src/update/events.ts +0 -28
- package/src/update/index.ts +0 -91
- package/src/update/installation.ts +0 -161
- package/src/update/version.ts +0 -33
- package/src/util/ansi.ts +0 -3
- package/src/util/browser.ts +0 -37
- package/src/util/clipboard.ts +0 -22
- package/src/util/errors.ts +0 -170
- package/src/util/github.ts +0 -100
- package/src/util/glob.ts +0 -51
- package/src/util/path-display.ts +0 -98
- package/src/util/perf.ts +0 -23
- package/src/util/shell.ts +0 -3
- package/src/util/shutdown.ts +0 -111
- package/src/util/terminal.ts +0 -28
- package/src/util/time.ts +0 -48
- package/tsconfig.json +0 -25
package/src/settings.ts
DELETED
|
@@ -1,465 +0,0 @@
|
|
|
1
|
-
import { normalizeConfig, serializeConfig } from './config'
|
|
2
|
-
import { BUILTIN_THEMES, DEFAULT_THEME_ID, SYSTEM_THEME_ID } from './styles/theme'
|
|
3
|
-
import type { Config, KeybindMode, SortOrder, ThemeColorScheme, ZoxideMode } from './types'
|
|
4
|
-
|
|
5
|
-
export type SettingsFieldId =
|
|
6
|
-
| 'backend'
|
|
7
|
-
| 'theme'
|
|
8
|
-
| 'colorScheme'
|
|
9
|
-
| 'keybindMode'
|
|
10
|
-
| 'prefixKey'
|
|
11
|
-
| 'sortOrder'
|
|
12
|
-
| 'zoxideMode'
|
|
13
|
-
| 'autoUpdate'
|
|
14
|
-
| 'dirLength'
|
|
15
|
-
| 'reposPath'
|
|
16
|
-
| 'editor'
|
|
17
|
-
| 'editorCmd'
|
|
18
|
-
| 'defaultStartupCommand'
|
|
19
|
-
| 'defaultPreviewCommand'
|
|
20
|
-
| 'projectPaths'
|
|
21
|
-
| 'hiddenSessions'
|
|
22
|
-
| 'pinnedSessions'
|
|
23
|
-
| 'icons'
|
|
24
|
-
| 'projects'
|
|
25
|
-
| 'wildcards'
|
|
26
|
-
|
|
27
|
-
export interface SettingsEntry {
|
|
28
|
-
id: SettingsFieldId
|
|
29
|
-
label: string
|
|
30
|
-
value: string
|
|
31
|
-
hint: string
|
|
32
|
-
kind: 'options' | 'number' | 'text' | 'json'
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface SettingsOption {
|
|
36
|
-
value: string
|
|
37
|
-
label: string
|
|
38
|
-
description?: string
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const COLOR_SCHEME_OPTIONS: ThemeColorScheme[] = ['system', 'dark', 'light']
|
|
42
|
-
const KEYBIND_OPTIONS: KeybindMode[] = ['vim', 'standard']
|
|
43
|
-
const PREFIX_OPTIONS = ['ctrl+x', 'ctrl+space', 'space', ',', ';'] as const
|
|
44
|
-
const SORT_ORDER_OPTIONS: SortOrder[] = [
|
|
45
|
-
'live-first',
|
|
46
|
-
'configured-first',
|
|
47
|
-
'zoxide-first',
|
|
48
|
-
'alphabetical',
|
|
49
|
-
]
|
|
50
|
-
const ZOXIDE_OPTIONS: ZoxideMode[] = ['off', 'rank', 'merge']
|
|
51
|
-
const BACKEND_OPTIONS = ['auto', 'tmux', 'herdr'] as const
|
|
52
|
-
|
|
53
|
-
type SettingsFieldKind = SettingsEntry['kind']
|
|
54
|
-
|
|
55
|
-
interface SettingsFieldDefinition {
|
|
56
|
-
id: SettingsFieldId
|
|
57
|
-
label: string
|
|
58
|
-
hint: string
|
|
59
|
-
kind: SettingsFieldKind
|
|
60
|
-
title?: string
|
|
61
|
-
getValue: (config: Config) => string
|
|
62
|
-
getEditorValue?: (config: Config) => string
|
|
63
|
-
getOptions?: (config: Config) => SettingsOption[]
|
|
64
|
-
applyOption?: (config: Config, value: string) => Config
|
|
65
|
-
applyEditor?: (raw: Record<string, unknown>, value: string) => void
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function formatJSON(value: unknown): string {
|
|
69
|
-
return JSON.stringify(value, null, 2)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function getThemeOptions(config?: Config): string[] {
|
|
73
|
-
const builtin = Object.keys(BUILTIN_THEMES).sort((left, right) => {
|
|
74
|
-
if (left === DEFAULT_THEME_ID) return -1
|
|
75
|
-
if (right === DEFAULT_THEME_ID) return 1
|
|
76
|
-
return left.localeCompare(right)
|
|
77
|
-
})
|
|
78
|
-
const custom = Object.keys(config?.themes ?? {}).sort((left, right) => left.localeCompare(right))
|
|
79
|
-
return [SYSTEM_THEME_ID, ...builtin, ...custom]
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function themeOptions(config: Config): SettingsOption[] {
|
|
83
|
-
return getThemeOptions(config).map(id => {
|
|
84
|
-
if (id === SYSTEM_THEME_ID) {
|
|
85
|
-
return {
|
|
86
|
-
value: id,
|
|
87
|
-
label: 'System',
|
|
88
|
-
description: 'Follow the desktop or terminal theme',
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return {
|
|
92
|
-
value: id,
|
|
93
|
-
label: config.themes?.[id]?.name ?? BUILTIN_THEMES[id]?.name ?? id,
|
|
94
|
-
description: id,
|
|
95
|
-
}
|
|
96
|
-
})
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function choiceOptions(
|
|
100
|
-
values: readonly string[],
|
|
101
|
-
descriptions?: Partial<Record<string, string>>
|
|
102
|
-
): SettingsOption[] {
|
|
103
|
-
return values.map(value => ({
|
|
104
|
-
value,
|
|
105
|
-
label: value,
|
|
106
|
-
description: descriptions?.[value],
|
|
107
|
-
}))
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const SETTINGS_FIELDS: readonly SettingsFieldDefinition[] = [
|
|
111
|
-
{
|
|
112
|
-
id: 'backend',
|
|
113
|
-
label: 'Backend',
|
|
114
|
-
hint: 'Multiplexer selection; applies next launch',
|
|
115
|
-
kind: 'options',
|
|
116
|
-
getValue: config => config.backend ?? 'auto',
|
|
117
|
-
getOptions: () =>
|
|
118
|
-
choiceOptions(BACKEND_OPTIONS, {
|
|
119
|
-
auto: 'Detect current or running multiplexer',
|
|
120
|
-
tmux: 'Require tmux',
|
|
121
|
-
herdr: 'Require a running Herdr server',
|
|
122
|
-
}),
|
|
123
|
-
applyOption: (config, value) => ({
|
|
124
|
-
...config,
|
|
125
|
-
backend: value === 'tmux' || value === 'herdr' ? value : undefined,
|
|
126
|
-
}),
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
id: 'theme',
|
|
130
|
-
label: 'Theme',
|
|
131
|
-
hint: 'Built-in, custom, or system',
|
|
132
|
-
kind: 'options',
|
|
133
|
-
getValue: config => config.theme ?? DEFAULT_THEME_ID,
|
|
134
|
-
getOptions: config => themeOptions(config),
|
|
135
|
-
applyOption: (config, value) => ({
|
|
136
|
-
...config,
|
|
137
|
-
theme: value,
|
|
138
|
-
}),
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
id: 'colorScheme',
|
|
142
|
-
label: 'Color Scheme',
|
|
143
|
-
hint: 'System, dark, or light',
|
|
144
|
-
kind: 'options',
|
|
145
|
-
getValue: config => config.colorScheme ?? 'system',
|
|
146
|
-
getOptions: () =>
|
|
147
|
-
choiceOptions(COLOR_SCHEME_OPTIONS, {
|
|
148
|
-
system: 'Follow the detected terminal theme',
|
|
149
|
-
dark: 'Force dark mode',
|
|
150
|
-
light: 'Force light mode',
|
|
151
|
-
}),
|
|
152
|
-
applyOption: (config, value) => ({
|
|
153
|
-
...config,
|
|
154
|
-
colorScheme: value as ThemeColorScheme,
|
|
155
|
-
}),
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
id: 'keybindMode',
|
|
159
|
-
label: 'Keybind Mode',
|
|
160
|
-
hint: 'Navigation style',
|
|
161
|
-
kind: 'options',
|
|
162
|
-
getValue: config => config.keybindMode ?? 'vim',
|
|
163
|
-
getOptions: () =>
|
|
164
|
-
choiceOptions(KEYBIND_OPTIONS, {
|
|
165
|
-
vim: 'Single-key navigation and actions',
|
|
166
|
-
standard: 'Arrow keys with prefixed commands',
|
|
167
|
-
}),
|
|
168
|
-
applyOption: (config, value) => ({
|
|
169
|
-
...config,
|
|
170
|
-
keybindMode: value as KeybindMode,
|
|
171
|
-
}),
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
id: 'prefixKey',
|
|
175
|
-
label: 'Prefix Key',
|
|
176
|
-
hint: 'Prefixed command trigger',
|
|
177
|
-
kind: 'options',
|
|
178
|
-
title: 'Prefix Key',
|
|
179
|
-
getValue: config => config.prefixKey ?? 'ctrl+x',
|
|
180
|
-
getEditorValue: config => config.prefixKey ?? 'ctrl+x',
|
|
181
|
-
getOptions: () =>
|
|
182
|
-
choiceOptions(PREFIX_OPTIONS, {
|
|
183
|
-
'ctrl+x': 'Default OpenCode-style prefix',
|
|
184
|
-
'ctrl+space': 'Control-space prefix',
|
|
185
|
-
space: 'Spacebar prefix',
|
|
186
|
-
',': 'Comma prefix',
|
|
187
|
-
';': 'Semicolon prefix',
|
|
188
|
-
}),
|
|
189
|
-
applyOption: (config, value) => ({
|
|
190
|
-
...config,
|
|
191
|
-
prefixKey: value,
|
|
192
|
-
}),
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
id: 'sortOrder',
|
|
196
|
-
label: 'Sort Order',
|
|
197
|
-
hint: 'List ordering',
|
|
198
|
-
kind: 'options',
|
|
199
|
-
getValue: config => config.sortOrder ?? 'live-first',
|
|
200
|
-
getOptions: () => choiceOptions(SORT_ORDER_OPTIONS),
|
|
201
|
-
applyOption: (config, value) => ({
|
|
202
|
-
...config,
|
|
203
|
-
sortOrder: value as SortOrder,
|
|
204
|
-
}),
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
id: 'zoxideMode',
|
|
208
|
-
label: 'Zoxide Mode',
|
|
209
|
-
hint: 'Project discovery weighting',
|
|
210
|
-
kind: 'options',
|
|
211
|
-
getValue: config => config.zoxideMode ?? 'off',
|
|
212
|
-
getOptions: () => choiceOptions(ZOXIDE_OPTIONS),
|
|
213
|
-
applyOption: (config, value) => ({
|
|
214
|
-
...config,
|
|
215
|
-
zoxideMode: value as ZoxideMode,
|
|
216
|
-
}),
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
id: 'autoUpdate',
|
|
220
|
-
label: 'Auto Update',
|
|
221
|
-
hint: 'Background update checks',
|
|
222
|
-
kind: 'options',
|
|
223
|
-
getValue: config => (config.autoUpdate ? 'on' : 'off'),
|
|
224
|
-
getOptions: () => [
|
|
225
|
-
{ value: 'true', label: 'on', description: 'Check for updates automatically' },
|
|
226
|
-
{ value: 'false', label: 'off', description: 'Disable automatic update checks' },
|
|
227
|
-
],
|
|
228
|
-
applyOption: (config, value) => ({
|
|
229
|
-
...config,
|
|
230
|
-
autoUpdate: value === 'true',
|
|
231
|
-
}),
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
id: 'dirLength',
|
|
235
|
-
label: 'Dir Length',
|
|
236
|
-
hint: 'Session naming depth',
|
|
237
|
-
kind: 'number',
|
|
238
|
-
getValue: config => String(config.dirLength ?? 1),
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
id: 'reposPath',
|
|
242
|
-
label: 'Repos Path',
|
|
243
|
-
hint: 'Git clone destination',
|
|
244
|
-
kind: 'text',
|
|
245
|
-
title: 'Repos Path',
|
|
246
|
-
getValue: config => config.reposPath,
|
|
247
|
-
getEditorValue: config => config.reposPath,
|
|
248
|
-
applyEditor: (raw, value) => {
|
|
249
|
-
raw.repos_path = value.trim()
|
|
250
|
-
},
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
id: 'editor',
|
|
254
|
-
label: 'Editor',
|
|
255
|
-
hint: 'Short editor name',
|
|
256
|
-
kind: 'text',
|
|
257
|
-
title: 'Editor',
|
|
258
|
-
getValue: config => config.editor,
|
|
259
|
-
getEditorValue: config => config.editor,
|
|
260
|
-
applyEditor: (raw, value) => {
|
|
261
|
-
raw.editor = value.trim()
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
id: 'editorCmd',
|
|
266
|
-
label: 'Editor Command',
|
|
267
|
-
hint: 'Launch command',
|
|
268
|
-
kind: 'text',
|
|
269
|
-
title: 'Editor Command',
|
|
270
|
-
getValue: config => config.editorCmd,
|
|
271
|
-
getEditorValue: config => config.editorCmd,
|
|
272
|
-
applyEditor: (raw, value) => {
|
|
273
|
-
raw.editor_cmd = value
|
|
274
|
-
},
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
id: 'defaultStartupCommand',
|
|
278
|
-
label: 'Default Startup',
|
|
279
|
-
hint: 'Fallback project startup command',
|
|
280
|
-
kind: 'text',
|
|
281
|
-
title: 'Default Startup Command',
|
|
282
|
-
getValue: config => config.defaultSession?.startupCommand ?? '',
|
|
283
|
-
getEditorValue: config => config.defaultSession?.startupCommand ?? '',
|
|
284
|
-
applyEditor: (raw, value) => {
|
|
285
|
-
raw.default_session = {
|
|
286
|
-
...(typeof raw.default_session === 'object' && raw.default_session
|
|
287
|
-
? raw.default_session
|
|
288
|
-
: {}),
|
|
289
|
-
startup_command: value,
|
|
290
|
-
}
|
|
291
|
-
},
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
id: 'defaultPreviewCommand',
|
|
295
|
-
label: 'Default Preview',
|
|
296
|
-
hint: 'Fallback preview command',
|
|
297
|
-
kind: 'text',
|
|
298
|
-
title: 'Default Preview Command',
|
|
299
|
-
getValue: config => config.defaultSession?.previewCommand ?? '',
|
|
300
|
-
getEditorValue: config => config.defaultSession?.previewCommand ?? '',
|
|
301
|
-
applyEditor: (raw, value) => {
|
|
302
|
-
const trimmed = value.trim()
|
|
303
|
-
raw.default_session = {
|
|
304
|
-
...(typeof raw.default_session === 'object' && raw.default_session
|
|
305
|
-
? raw.default_session
|
|
306
|
-
: {}),
|
|
307
|
-
preview_command: trimmed.length > 0 ? value : undefined,
|
|
308
|
-
}
|
|
309
|
-
},
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
id: 'projectPaths',
|
|
313
|
-
label: 'Project Paths',
|
|
314
|
-
hint: 'JSON array of roots',
|
|
315
|
-
kind: 'json',
|
|
316
|
-
title: 'Project Paths',
|
|
317
|
-
getValue: config => `${config.projectPaths.length} entries`,
|
|
318
|
-
getEditorValue: config => formatJSON(config.projectPaths),
|
|
319
|
-
applyEditor: (raw, value) => {
|
|
320
|
-
raw.project_paths = JSON.parse(value) as unknown
|
|
321
|
-
},
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
id: 'hiddenSessions',
|
|
325
|
-
label: 'Hidden Sessions',
|
|
326
|
-
hint: 'JSON array of filters',
|
|
327
|
-
kind: 'json',
|
|
328
|
-
title: 'Hidden Sessions',
|
|
329
|
-
getValue: config => `${config.hiddenSessions?.length ?? 0} patterns`,
|
|
330
|
-
getEditorValue: config => formatJSON(config.hiddenSessions ?? []),
|
|
331
|
-
applyEditor: (raw, value) => {
|
|
332
|
-
raw.hidden_sessions = JSON.parse(value) as unknown
|
|
333
|
-
},
|
|
334
|
-
},
|
|
335
|
-
{
|
|
336
|
-
id: 'pinnedSessions',
|
|
337
|
-
label: 'Pinned Sessions',
|
|
338
|
-
hint: 'JSON array of session names',
|
|
339
|
-
kind: 'json',
|
|
340
|
-
title: 'Pinned Sessions',
|
|
341
|
-
getValue: config => `${config.pinnedSessions?.length ?? 0} pinned`,
|
|
342
|
-
getEditorValue: config => formatJSON(config.pinnedSessions ?? []),
|
|
343
|
-
applyEditor: (raw, value) => {
|
|
344
|
-
raw.pinned_sessions = JSON.parse(value) as unknown
|
|
345
|
-
},
|
|
346
|
-
},
|
|
347
|
-
{
|
|
348
|
-
id: 'icons',
|
|
349
|
-
label: 'Icons',
|
|
350
|
-
hint: 'JSON object',
|
|
351
|
-
kind: 'json',
|
|
352
|
-
title: 'Icons',
|
|
353
|
-
getValue: () => 'customize glyphs',
|
|
354
|
-
getEditorValue: config => formatJSON(config.icons ?? {}),
|
|
355
|
-
applyEditor: (raw, value) => {
|
|
356
|
-
raw.icons = JSON.parse(value) as unknown
|
|
357
|
-
},
|
|
358
|
-
},
|
|
359
|
-
{
|
|
360
|
-
id: 'projects',
|
|
361
|
-
label: 'Projects',
|
|
362
|
-
hint: 'JSON array of exact rules',
|
|
363
|
-
kind: 'json',
|
|
364
|
-
title: 'Projects',
|
|
365
|
-
getValue: config => `${config.projects?.length ?? 0} rules`,
|
|
366
|
-
getEditorValue: config => formatJSON(config.projects ?? []),
|
|
367
|
-
applyEditor: (raw, value) => {
|
|
368
|
-
raw.projects = JSON.parse(value) as unknown
|
|
369
|
-
},
|
|
370
|
-
},
|
|
371
|
-
{
|
|
372
|
-
id: 'wildcards',
|
|
373
|
-
label: 'Wildcards',
|
|
374
|
-
hint: 'JSON array of wildcard rules',
|
|
375
|
-
kind: 'json',
|
|
376
|
-
title: 'Wildcards',
|
|
377
|
-
getValue: config => `${config.wildcards?.length ?? 0} rules`,
|
|
378
|
-
getEditorValue: config => formatJSON(config.wildcards ?? []),
|
|
379
|
-
applyEditor: (raw, value) => {
|
|
380
|
-
raw.wildcards = JSON.parse(value) as unknown
|
|
381
|
-
},
|
|
382
|
-
},
|
|
383
|
-
]
|
|
384
|
-
|
|
385
|
-
const SETTINGS_FIELD_MAP = Object.fromEntries(
|
|
386
|
-
SETTINGS_FIELDS.map(field => [field.id, field])
|
|
387
|
-
) as Record<SettingsFieldId, SettingsFieldDefinition>
|
|
388
|
-
|
|
389
|
-
function getSettingsField(field: SettingsFieldId): SettingsFieldDefinition {
|
|
390
|
-
return SETTINGS_FIELD_MAP[field]
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
export function getSettingsEntries(config: Config): SettingsEntry[] {
|
|
394
|
-
return SETTINGS_FIELDS.map(field => ({
|
|
395
|
-
id: field.id,
|
|
396
|
-
label: field.label,
|
|
397
|
-
value: field.getValue(config),
|
|
398
|
-
hint: field.hint,
|
|
399
|
-
kind: field.kind,
|
|
400
|
-
}))
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
export function getSettingEditorValue(config: Config, field: SettingsFieldId): string {
|
|
404
|
-
return getSettingsField(field).getEditorValue?.(config) ?? ''
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
export function getSettingOptions(config: Config, field: SettingsFieldId): SettingsOption[] {
|
|
408
|
-
return getSettingsField(field).getOptions?.(config) ?? []
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
export function isOptionSetting(field: SettingsFieldId): boolean {
|
|
412
|
-
return getSettingsField(field).kind === 'options'
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
export function applyOptionSetting(config: Config, field: SettingsFieldId, value: string): Config {
|
|
416
|
-
return getSettingsField(field).applyOption?.(config, value) ?? config
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
export function applyEditorSetting(
|
|
420
|
-
config: Config,
|
|
421
|
-
field: SettingsFieldId,
|
|
422
|
-
value: string,
|
|
423
|
-
homeDir: string
|
|
424
|
-
): Config {
|
|
425
|
-
const raw = serializeConfig(config)
|
|
426
|
-
const applyEditor = getSettingsField(field).applyEditor
|
|
427
|
-
if (!applyEditor) {
|
|
428
|
-
return config
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
applyEditor(raw, value)
|
|
432
|
-
|
|
433
|
-
return normalizeConfig(raw, homeDir)
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
export function getSettingEditorTitle(field: SettingsFieldId): string {
|
|
437
|
-
const setting = getSettingsField(field)
|
|
438
|
-
return setting.title ?? setting.label
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
export function filterSettingsEntries(entries: SettingsEntry[], query: string): SettingsEntry[] {
|
|
442
|
-
const normalizedQuery = query.trim().toLowerCase()
|
|
443
|
-
|
|
444
|
-
if (!normalizedQuery) {
|
|
445
|
-
return entries
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
return entries.filter(entry => {
|
|
449
|
-
const haystack = `${entry.label} ${entry.value} ${entry.hint}`.toLowerCase()
|
|
450
|
-
return haystack.includes(normalizedQuery)
|
|
451
|
-
})
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
export function filterSettingsOptions(options: SettingsOption[], query: string): SettingsOption[] {
|
|
455
|
-
const normalizedQuery = query.trim().toLowerCase()
|
|
456
|
-
|
|
457
|
-
if (!normalizedQuery) {
|
|
458
|
-
return options
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
return options.filter(option => {
|
|
462
|
-
const haystack = `${option.label} ${option.value} ${option.description ?? ''}`.toLowerCase()
|
|
463
|
-
return haystack.includes(normalizedQuery)
|
|
464
|
-
})
|
|
465
|
-
}
|