mux-sesh 1.6.4 → 1.7.0
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 +90 -59
- package/package.json +7 -5
- package/src/app/commands.ts +120 -0
- package/src/app/controller.ts +397 -0
- package/src/app/controls.ts +121 -0
- package/src/app/core-state.ts +71 -0
- package/src/app/data.ts +90 -0
- package/src/app/derived.ts +77 -0
- package/src/app/effects.ts +392 -0
- package/src/app/handlers.ts +325 -0
- package/src/app/keyboard.ts +161 -0
- package/src/app/modal-keyboard.ts +118 -0
- package/src/app/modal-state.ts +50 -0
- package/src/app/modals-layer.tsx +159 -0
- package/src/app/modals.ts +108 -0
- package/src/app/notifications.ts +21 -0
- package/src/app/opencode.ts +49 -0
- package/src/app/operations.ts +31 -0
- package/src/app/runtime.ts +76 -0
- package/src/app/screen.tsx +217 -0
- package/src/app/state.ts +166 -0
- package/src/app/textarea.ts +16 -0
- package/src/app/view.ts +89 -0
- package/src/app.tsx +7 -1136
- package/src/config/index.ts +36 -42
- package/src/config/paths.ts +13 -0
- package/src/config/session-rules.ts +6 -2
- package/src/config/store.ts +26 -0
- package/src/handlers/action-helpers.ts +50 -0
- package/src/handlers/actions.ts +34 -65
- package/src/handlers/keyboard/index.ts +5 -0
- package/src/handlers/keyboard/new-session.ts +57 -0
- package/src/handlers/keyboard/normal.ts +201 -0
- package/src/handlers/keyboard/opencode.ts +104 -0
- package/src/handlers/keyboard/search.ts +113 -0
- package/src/handlers/keyboard/shared.ts +116 -0
- package/src/opencode/sqlite.ts +21 -6
- package/src/preview/project.ts +41 -15
- package/src/search/index.ts +4 -1
- package/src/settings.ts +294 -297
- package/src/styles/opencode-themes-a.ts +1442 -1
- package/src/styles/opencode-themes-b.ts +1212 -1
- package/src/styles/opencode-tui-colors.ts +1784 -1
- package/src/styles/theme.tsx +2 -1
- package/src/tmux/actions.ts +103 -0
- package/src/tmux/details.ts +123 -0
- package/src/tmux/helpers.ts +35 -0
- package/src/tmux/index.ts +10 -288
- package/src/tmux/list.ts +31 -0
- package/src/tmux/project-discovery.ts +113 -0
- package/src/tmux/project-loader.ts +74 -0
- package/src/tmux/project-zoxide.ts +128 -0
- package/src/tmux/projects.ts +23 -262
- package/src/types/index.ts +0 -1
- package/src/ui/CommandsModal.tsx +87 -22
- package/src/ui/HighlightedText.tsx +1 -5
- package/src/ui/ItemList.tsx +14 -4
- package/src/ui/Modal.tsx +8 -1
- package/src/ui/OpencodeSessionGroup.tsx +20 -9
- package/src/ui/OpencodeStatsPanel.tsx +48 -15
- package/src/ui/RenameModal.tsx +17 -17
- package/src/ui/SearchInput.tsx +1 -20
- package/src/ui/SessionDetailsPanel.tsx +43 -15
- package/src/ui/SessionList.tsx +23 -6
- package/src/ui/SettingEditorModal.tsx +15 -9
- package/src/ui/SettingOptionsModal.tsx +30 -12
- package/src/ui/SettingsModal.tsx +20 -14
- package/src/ui/VersionBadge.tsx +3 -1
- package/src/ui/item-icon.ts +5 -1
- package/src/ui/list-window.ts +5 -1
- package/src/ui/use-textarea-focus.ts +26 -0
- package/src/update/index.ts +10 -2
- package/src/update/installation.ts +6 -2
- package/src/util/ansi.ts +3 -0
- package/src/util/glob.ts +5 -1
- package/src/components/KeybindHelp.tsx +0 -289
- package/src/handlers/keyboard.ts +0 -654
- package/src/ui/SessionStats.tsx +0 -32
package/src/settings.ts
CHANGED
|
@@ -39,9 +39,29 @@ export interface SettingsOption {
|
|
|
39
39
|
const COLOR_SCHEME_OPTIONS: ThemeColorScheme[] = ['system', 'dark', 'light']
|
|
40
40
|
const KEYBIND_OPTIONS: KeybindMode[] = ['vim', 'standard']
|
|
41
41
|
const PREFIX_OPTIONS = ['ctrl+x', 'ctrl+space', 'space', ',', ';'] as const
|
|
42
|
-
const SORT_ORDER_OPTIONS: SortOrder[] = [
|
|
42
|
+
const SORT_ORDER_OPTIONS: SortOrder[] = [
|
|
43
|
+
'live-first',
|
|
44
|
+
'configured-first',
|
|
45
|
+
'zoxide-first',
|
|
46
|
+
'alphabetical',
|
|
47
|
+
]
|
|
43
48
|
const ZOXIDE_OPTIONS: ZoxideMode[] = ['off', 'rank', 'merge']
|
|
44
49
|
|
|
50
|
+
type SettingsFieldKind = SettingsEntry['kind']
|
|
51
|
+
|
|
52
|
+
interface SettingsFieldDefinition {
|
|
53
|
+
id: SettingsFieldId
|
|
54
|
+
label: string
|
|
55
|
+
hint: string
|
|
56
|
+
kind: SettingsFieldKind
|
|
57
|
+
title?: string
|
|
58
|
+
getValue: (config: Config) => string
|
|
59
|
+
getEditorValue?: (config: Config) => string
|
|
60
|
+
getOptions?: (config: Config) => SettingsOption[]
|
|
61
|
+
applyOption?: (config: Config, value: string) => Config
|
|
62
|
+
applyEditor?: (raw: Record<string, unknown>, value: string) => void
|
|
63
|
+
}
|
|
64
|
+
|
|
45
65
|
function formatJSON(value: unknown): string {
|
|
46
66
|
return JSON.stringify(value, null, 2)
|
|
47
67
|
}
|
|
@@ -62,7 +82,10 @@ function themeOptions(): SettingsOption[] {
|
|
|
62
82
|
}))
|
|
63
83
|
}
|
|
64
84
|
|
|
65
|
-
function choiceOptions(
|
|
85
|
+
function choiceOptions(
|
|
86
|
+
values: readonly string[],
|
|
87
|
+
descriptions?: Partial<Record<string, string>>
|
|
88
|
+
): SettingsOption[] {
|
|
66
89
|
return values.map(value => ({
|
|
67
90
|
value,
|
|
68
91
|
label: value,
|
|
@@ -70,332 +93,306 @@ function choiceOptions(values: readonly string[], descriptions?: Partial<Record<
|
|
|
70
93
|
}))
|
|
71
94
|
}
|
|
72
95
|
|
|
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
|
-
|
|
96
|
+
const SETTINGS_FIELDS: readonly SettingsFieldDefinition[] = [
|
|
97
|
+
{
|
|
98
|
+
id: 'theme',
|
|
99
|
+
label: 'Theme',
|
|
100
|
+
hint: 'Built-in theme catalog',
|
|
101
|
+
kind: 'options',
|
|
102
|
+
getValue: config => config.theme ?? 'rosepine',
|
|
103
|
+
getOptions: () => themeOptions(),
|
|
104
|
+
applyOption: (config, value) => ({
|
|
105
|
+
...config,
|
|
106
|
+
theme: value,
|
|
107
|
+
}),
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: 'colorScheme',
|
|
111
|
+
label: 'Color Scheme',
|
|
112
|
+
hint: 'System, dark, or light',
|
|
113
|
+
kind: 'options',
|
|
114
|
+
getValue: config => config.colorScheme ?? 'system',
|
|
115
|
+
getOptions: () =>
|
|
116
|
+
choiceOptions(COLOR_SCHEME_OPTIONS, {
|
|
117
|
+
system: 'Follow the detected terminal theme',
|
|
118
|
+
dark: 'Force dark mode',
|
|
119
|
+
light: 'Force light mode',
|
|
120
|
+
}),
|
|
121
|
+
applyOption: (config, value) => ({
|
|
122
|
+
...config,
|
|
123
|
+
colorScheme: value as ThemeColorScheme,
|
|
124
|
+
}),
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
id: 'keybindMode',
|
|
128
|
+
label: 'Keybind Mode',
|
|
129
|
+
hint: 'Navigation style',
|
|
130
|
+
kind: 'options',
|
|
131
|
+
getValue: config => config.keybindMode ?? 'vim',
|
|
132
|
+
getOptions: () =>
|
|
133
|
+
choiceOptions(KEYBIND_OPTIONS, {
|
|
134
|
+
vim: 'Single-key navigation and actions',
|
|
135
|
+
standard: 'Arrow keys with prefixed commands',
|
|
136
|
+
}),
|
|
137
|
+
applyOption: (config, value) => ({
|
|
138
|
+
...config,
|
|
139
|
+
keybindMode: value as KeybindMode,
|
|
140
|
+
}),
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
id: 'prefixKey',
|
|
144
|
+
label: 'Prefix Key',
|
|
145
|
+
hint: 'Prefixed command trigger',
|
|
146
|
+
kind: 'options',
|
|
147
|
+
title: 'Prefix Key',
|
|
148
|
+
getValue: config => config.prefixKey ?? 'ctrl+x',
|
|
149
|
+
getEditorValue: config => config.prefixKey ?? 'ctrl+x',
|
|
150
|
+
getOptions: () =>
|
|
151
|
+
choiceOptions(PREFIX_OPTIONS, {
|
|
152
|
+
'ctrl+x': 'Default OpenCode-style prefix',
|
|
153
|
+
'ctrl+space': 'Control-space prefix',
|
|
154
|
+
space: 'Spacebar prefix',
|
|
155
|
+
',': 'Comma prefix',
|
|
156
|
+
';': 'Semicolon prefix',
|
|
157
|
+
}),
|
|
158
|
+
applyOption: (config, value) => ({
|
|
159
|
+
...config,
|
|
160
|
+
prefixKey: value,
|
|
161
|
+
}),
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
id: 'sortOrder',
|
|
165
|
+
label: 'Sort Order',
|
|
166
|
+
hint: 'List ordering',
|
|
167
|
+
kind: 'options',
|
|
168
|
+
getValue: config => config.sortOrder ?? 'live-first',
|
|
169
|
+
getOptions: () => choiceOptions(SORT_ORDER_OPTIONS),
|
|
170
|
+
applyOption: (config, value) => ({
|
|
171
|
+
...config,
|
|
172
|
+
sortOrder: value as SortOrder,
|
|
173
|
+
}),
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
id: 'zoxideMode',
|
|
177
|
+
label: 'Zoxide Mode',
|
|
178
|
+
hint: 'Project discovery weighting',
|
|
179
|
+
kind: 'options',
|
|
180
|
+
getValue: config => config.zoxideMode ?? 'off',
|
|
181
|
+
getOptions: () => choiceOptions(ZOXIDE_OPTIONS),
|
|
182
|
+
applyOption: (config, value) => ({
|
|
183
|
+
...config,
|
|
184
|
+
zoxideMode: value as ZoxideMode,
|
|
185
|
+
}),
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
id: 'autoUpdate',
|
|
189
|
+
label: 'Auto Update',
|
|
190
|
+
hint: 'Background update checks',
|
|
191
|
+
kind: 'options',
|
|
192
|
+
getValue: config => (config.autoUpdate ? 'on' : 'off'),
|
|
193
|
+
getOptions: () => [
|
|
194
|
+
{ value: 'true', label: 'on', description: 'Check for updates automatically' },
|
|
195
|
+
{ value: 'false', label: 'off', description: 'Disable automatic update checks' },
|
|
196
|
+
],
|
|
197
|
+
applyOption: (config, value) => ({
|
|
198
|
+
...config,
|
|
199
|
+
autoUpdate: value === 'true',
|
|
200
|
+
}),
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
id: 'dirLength',
|
|
204
|
+
label: 'Dir Length',
|
|
205
|
+
hint: 'Session naming depth',
|
|
206
|
+
kind: 'number',
|
|
207
|
+
getValue: config => String(config.dirLength ?? 1),
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
id: 'reposPath',
|
|
211
|
+
label: 'Repos Path',
|
|
212
|
+
hint: 'Git clone destination',
|
|
213
|
+
kind: 'text',
|
|
214
|
+
title: 'Repos Path',
|
|
215
|
+
getValue: config => config.reposPath,
|
|
216
|
+
getEditorValue: config => config.reposPath,
|
|
217
|
+
applyEditor: (raw, value) => {
|
|
218
|
+
raw.repos_path = value.trim()
|
|
137
219
|
},
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
id: 'editor',
|
|
223
|
+
label: 'Editor',
|
|
224
|
+
hint: 'Short editor name',
|
|
225
|
+
kind: 'text',
|
|
226
|
+
title: 'Editor',
|
|
227
|
+
getValue: config => config.editor,
|
|
228
|
+
getEditorValue: config => config.editor,
|
|
229
|
+
applyEditor: (raw, value) => {
|
|
230
|
+
raw.editor = value.trim()
|
|
144
231
|
},
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
id: 'editorCmd',
|
|
235
|
+
label: 'Editor Command',
|
|
236
|
+
hint: 'Launch command',
|
|
237
|
+
kind: 'text',
|
|
238
|
+
title: 'Editor Command',
|
|
239
|
+
getValue: config => config.editorCmd,
|
|
240
|
+
getEditorValue: config => config.editorCmd,
|
|
241
|
+
applyEditor: (raw, value) => {
|
|
242
|
+
raw.editor_cmd = value
|
|
151
243
|
},
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
id: 'defaultStartupCommand',
|
|
247
|
+
label: 'Default Startup',
|
|
248
|
+
hint: 'Fallback project startup command',
|
|
249
|
+
kind: 'text',
|
|
250
|
+
title: 'Default Startup Command',
|
|
251
|
+
getValue: config => config.defaultSession?.startupCommand ?? '',
|
|
252
|
+
getEditorValue: config => config.defaultSession?.startupCommand ?? '',
|
|
253
|
+
applyEditor: (raw, value) => {
|
|
254
|
+
raw.default_session = {
|
|
255
|
+
...(typeof raw.default_session === 'object' && raw.default_session
|
|
256
|
+
? raw.default_session
|
|
257
|
+
: {}),
|
|
258
|
+
startup_command: value,
|
|
259
|
+
}
|
|
158
260
|
},
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
id: 'defaultPreviewCommand',
|
|
264
|
+
label: 'Default Preview',
|
|
265
|
+
hint: 'Fallback preview command',
|
|
266
|
+
kind: 'text',
|
|
267
|
+
title: 'Default Preview Command',
|
|
268
|
+
getValue: config => config.defaultSession?.previewCommand ?? '',
|
|
269
|
+
getEditorValue: config => config.defaultSession?.previewCommand ?? '',
|
|
270
|
+
applyEditor: (raw, value) => {
|
|
271
|
+
const trimmed = value.trim()
|
|
272
|
+
raw.default_session = {
|
|
273
|
+
...(typeof raw.default_session === 'object' && raw.default_session
|
|
274
|
+
? raw.default_session
|
|
275
|
+
: {}),
|
|
276
|
+
preview_command: trimmed.length > 0 ? value : undefined,
|
|
277
|
+
}
|
|
165
278
|
},
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
id: 'projectPaths',
|
|
282
|
+
label: 'Project Paths',
|
|
283
|
+
hint: 'JSON array of roots',
|
|
284
|
+
kind: 'json',
|
|
285
|
+
title: 'Project Paths',
|
|
286
|
+
getValue: config => `${config.projectPaths.length} entries`,
|
|
287
|
+
getEditorValue: config => formatJSON(config.projectPaths),
|
|
288
|
+
applyEditor: (raw, value) => {
|
|
289
|
+
raw.project_paths = JSON.parse(value) as unknown
|
|
172
290
|
},
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
id: 'hiddenSessions',
|
|
294
|
+
label: 'Hidden Sessions',
|
|
295
|
+
hint: 'JSON array of filters',
|
|
296
|
+
kind: 'json',
|
|
297
|
+
title: 'Hidden Sessions',
|
|
298
|
+
getValue: config => `${config.hiddenSessions?.length ?? 0} patterns`,
|
|
299
|
+
getEditorValue: config => formatJSON(config.hiddenSessions ?? []),
|
|
300
|
+
applyEditor: (raw, value) => {
|
|
301
|
+
raw.hidden_sessions = JSON.parse(value) as unknown
|
|
179
302
|
},
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
id: 'icons',
|
|
306
|
+
label: 'Icons',
|
|
307
|
+
hint: 'JSON object',
|
|
308
|
+
kind: 'json',
|
|
309
|
+
title: 'Icons',
|
|
310
|
+
getValue: () => 'customize glyphs',
|
|
311
|
+
getEditorValue: config => formatJSON(config.icons ?? {}),
|
|
312
|
+
applyEditor: (raw, value) => {
|
|
313
|
+
raw.icons = JSON.parse(value) as unknown
|
|
186
314
|
},
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
id: 'projects',
|
|
318
|
+
label: 'Projects',
|
|
319
|
+
hint: 'JSON array of exact rules',
|
|
320
|
+
kind: 'json',
|
|
321
|
+
title: 'Projects',
|
|
322
|
+
getValue: config => `${config.projects?.length ?? 0} rules`,
|
|
323
|
+
getEditorValue: config => formatJSON(config.projects ?? []),
|
|
324
|
+
applyEditor: (raw, value) => {
|
|
325
|
+
raw.projects = JSON.parse(value) as unknown
|
|
193
326
|
},
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
id: 'wildcards',
|
|
330
|
+
label: 'Wildcards',
|
|
331
|
+
hint: 'JSON array of wildcard rules',
|
|
332
|
+
kind: 'json',
|
|
333
|
+
title: 'Wildcards',
|
|
334
|
+
getValue: config => `${config.wildcards?.length ?? 0} rules`,
|
|
335
|
+
getEditorValue: config => formatJSON(config.wildcards ?? []),
|
|
336
|
+
applyEditor: (raw, value) => {
|
|
337
|
+
raw.wildcards = JSON.parse(value) as unknown
|
|
200
338
|
},
|
|
201
|
-
|
|
339
|
+
},
|
|
340
|
+
]
|
|
341
|
+
|
|
342
|
+
const SETTINGS_FIELD_MAP = Object.fromEntries(
|
|
343
|
+
SETTINGS_FIELDS.map(field => [field.id, field])
|
|
344
|
+
) as Record<SettingsFieldId, SettingsFieldDefinition>
|
|
345
|
+
|
|
346
|
+
function getSettingsField(field: SettingsFieldId): SettingsFieldDefinition {
|
|
347
|
+
return SETTINGS_FIELD_MAP[field]
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export function getSettingsEntries(config: Config): SettingsEntry[] {
|
|
351
|
+
return SETTINGS_FIELDS.map(field => ({
|
|
352
|
+
id: field.id,
|
|
353
|
+
label: field.label,
|
|
354
|
+
value: field.getValue(config),
|
|
355
|
+
hint: field.hint,
|
|
356
|
+
kind: field.kind,
|
|
357
|
+
}))
|
|
202
358
|
}
|
|
203
359
|
|
|
204
360
|
export function getSettingEditorValue(config: Config, field: SettingsFieldId): string {
|
|
205
|
-
|
|
206
|
-
case 'prefixKey':
|
|
207
|
-
return config.prefixKey ?? 'ctrl+x'
|
|
208
|
-
case 'reposPath':
|
|
209
|
-
return config.reposPath
|
|
210
|
-
case 'editor':
|
|
211
|
-
return config.editor
|
|
212
|
-
case 'editorCmd':
|
|
213
|
-
return config.editorCmd
|
|
214
|
-
case 'defaultStartupCommand':
|
|
215
|
-
return config.defaultSession?.startupCommand ?? ''
|
|
216
|
-
case 'defaultPreviewCommand':
|
|
217
|
-
return config.defaultSession?.previewCommand ?? ''
|
|
218
|
-
case 'projectPaths':
|
|
219
|
-
return formatJSON(config.projectPaths)
|
|
220
|
-
case 'hiddenSessions':
|
|
221
|
-
return formatJSON(config.hiddenSessions ?? [])
|
|
222
|
-
case 'icons':
|
|
223
|
-
return formatJSON(config.icons ?? {})
|
|
224
|
-
case 'projects':
|
|
225
|
-
return formatJSON(config.projects ?? [])
|
|
226
|
-
case 'wildcards':
|
|
227
|
-
return formatJSON(config.wildcards ?? [])
|
|
228
|
-
default:
|
|
229
|
-
return ''
|
|
230
|
-
}
|
|
361
|
+
return getSettingsField(field).getEditorValue?.(config) ?? ''
|
|
231
362
|
}
|
|
232
363
|
|
|
233
364
|
export function getSettingOptions(config: Config, field: SettingsFieldId): SettingsOption[] {
|
|
234
|
-
|
|
235
|
-
case 'theme':
|
|
236
|
-
return themeOptions()
|
|
237
|
-
case 'colorScheme':
|
|
238
|
-
return choiceOptions(COLOR_SCHEME_OPTIONS, {
|
|
239
|
-
system: 'Follow the detected terminal theme',
|
|
240
|
-
dark: 'Force dark mode',
|
|
241
|
-
light: 'Force light mode',
|
|
242
|
-
})
|
|
243
|
-
case 'keybindMode':
|
|
244
|
-
return choiceOptions(KEYBIND_OPTIONS, {
|
|
245
|
-
vim: 'Single-key navigation and actions',
|
|
246
|
-
standard: 'Arrow keys with prefixed commands',
|
|
247
|
-
})
|
|
248
|
-
case 'prefixKey':
|
|
249
|
-
return choiceOptions(PREFIX_OPTIONS, {
|
|
250
|
-
'ctrl+x': 'Default OpenCode-style prefix',
|
|
251
|
-
'ctrl+space': 'Control-space prefix',
|
|
252
|
-
space: 'Spacebar prefix',
|
|
253
|
-
',': 'Comma prefix',
|
|
254
|
-
';': 'Semicolon prefix',
|
|
255
|
-
})
|
|
256
|
-
case 'sortOrder':
|
|
257
|
-
return choiceOptions(SORT_ORDER_OPTIONS)
|
|
258
|
-
case 'zoxideMode':
|
|
259
|
-
return choiceOptions(ZOXIDE_OPTIONS)
|
|
260
|
-
case 'autoUpdate':
|
|
261
|
-
return [
|
|
262
|
-
{ value: 'true', label: 'on', description: 'Check for updates automatically' },
|
|
263
|
-
{ value: 'false', label: 'off', description: 'Disable automatic update checks' },
|
|
264
|
-
]
|
|
265
|
-
default:
|
|
266
|
-
return []
|
|
267
|
-
}
|
|
365
|
+
return getSettingsField(field).getOptions?.(config) ?? []
|
|
268
366
|
}
|
|
269
367
|
|
|
270
368
|
export function isOptionSetting(field: SettingsFieldId): boolean {
|
|
271
|
-
return (
|
|
272
|
-
field === 'theme' ||
|
|
273
|
-
field === 'colorScheme' ||
|
|
274
|
-
field === 'keybindMode' ||
|
|
275
|
-
field === 'prefixKey' ||
|
|
276
|
-
field === 'sortOrder' ||
|
|
277
|
-
field === 'zoxideMode' ||
|
|
278
|
-
field === 'autoUpdate'
|
|
279
|
-
)
|
|
369
|
+
return getSettingsField(field).kind === 'options'
|
|
280
370
|
}
|
|
281
371
|
|
|
282
372
|
export function applyOptionSetting(config: Config, field: SettingsFieldId, value: string): Config {
|
|
283
|
-
|
|
284
|
-
case 'theme':
|
|
285
|
-
return {
|
|
286
|
-
...config,
|
|
287
|
-
theme: value,
|
|
288
|
-
}
|
|
289
|
-
case 'colorScheme':
|
|
290
|
-
return {
|
|
291
|
-
...config,
|
|
292
|
-
colorScheme: value as ThemeColorScheme,
|
|
293
|
-
}
|
|
294
|
-
case 'keybindMode':
|
|
295
|
-
return {
|
|
296
|
-
...config,
|
|
297
|
-
keybindMode: value as KeybindMode,
|
|
298
|
-
}
|
|
299
|
-
case 'prefixKey':
|
|
300
|
-
return {
|
|
301
|
-
...config,
|
|
302
|
-
prefixKey: value,
|
|
303
|
-
}
|
|
304
|
-
case 'sortOrder':
|
|
305
|
-
return {
|
|
306
|
-
...config,
|
|
307
|
-
sortOrder: value as SortOrder,
|
|
308
|
-
}
|
|
309
|
-
case 'zoxideMode':
|
|
310
|
-
return {
|
|
311
|
-
...config,
|
|
312
|
-
zoxideMode: value as ZoxideMode,
|
|
313
|
-
}
|
|
314
|
-
case 'autoUpdate':
|
|
315
|
-
return {
|
|
316
|
-
...config,
|
|
317
|
-
autoUpdate: value === 'true',
|
|
318
|
-
}
|
|
319
|
-
default:
|
|
320
|
-
return config
|
|
321
|
-
}
|
|
373
|
+
return getSettingsField(field).applyOption?.(config, value) ?? config
|
|
322
374
|
}
|
|
323
375
|
|
|
324
|
-
export function applyEditorSetting(
|
|
376
|
+
export function applyEditorSetting(
|
|
377
|
+
config: Config,
|
|
378
|
+
field: SettingsFieldId,
|
|
379
|
+
value: string,
|
|
380
|
+
homeDir: string
|
|
381
|
+
): Config {
|
|
325
382
|
const raw = serializeConfig(config)
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
case 'reposPath':
|
|
330
|
-
raw.repos_path = trimmed
|
|
331
|
-
break
|
|
332
|
-
case 'editor':
|
|
333
|
-
raw.editor = trimmed
|
|
334
|
-
break
|
|
335
|
-
case 'editorCmd':
|
|
336
|
-
raw.editor_cmd = value
|
|
337
|
-
break
|
|
338
|
-
case 'defaultStartupCommand':
|
|
339
|
-
raw.default_session = {
|
|
340
|
-
...(typeof raw.default_session === 'object' && raw.default_session ? raw.default_session : {}),
|
|
341
|
-
startup_command: value,
|
|
342
|
-
}
|
|
343
|
-
break
|
|
344
|
-
case 'defaultPreviewCommand':
|
|
345
|
-
raw.default_session = {
|
|
346
|
-
...(typeof raw.default_session === 'object' && raw.default_session ? raw.default_session : {}),
|
|
347
|
-
preview_command: trimmed.length > 0 ? value : undefined,
|
|
348
|
-
}
|
|
349
|
-
break
|
|
350
|
-
case 'projectPaths':
|
|
351
|
-
raw.project_paths = JSON.parse(value) as unknown
|
|
352
|
-
break
|
|
353
|
-
case 'hiddenSessions':
|
|
354
|
-
raw.hidden_sessions = JSON.parse(value) as unknown
|
|
355
|
-
break
|
|
356
|
-
case 'icons':
|
|
357
|
-
raw.icons = JSON.parse(value) as unknown
|
|
358
|
-
break
|
|
359
|
-
case 'projects':
|
|
360
|
-
raw.projects = JSON.parse(value) as unknown
|
|
361
|
-
break
|
|
362
|
-
case 'wildcards':
|
|
363
|
-
raw.wildcards = JSON.parse(value) as unknown
|
|
364
|
-
break
|
|
365
|
-
default:
|
|
366
|
-
return config
|
|
383
|
+
const applyEditor = getSettingsField(field).applyEditor
|
|
384
|
+
if (!applyEditor) {
|
|
385
|
+
return config
|
|
367
386
|
}
|
|
368
387
|
|
|
388
|
+
applyEditor(raw, value)
|
|
389
|
+
|
|
369
390
|
return normalizeConfig(raw, homeDir)
|
|
370
391
|
}
|
|
371
392
|
|
|
372
393
|
export function getSettingEditorTitle(field: SettingsFieldId): string {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
return 'Prefix Key'
|
|
376
|
-
case 'reposPath':
|
|
377
|
-
return 'Repos Path'
|
|
378
|
-
case 'editor':
|
|
379
|
-
return 'Editor'
|
|
380
|
-
case 'editorCmd':
|
|
381
|
-
return 'Editor Command'
|
|
382
|
-
case 'defaultStartupCommand':
|
|
383
|
-
return 'Default Startup Command'
|
|
384
|
-
case 'defaultPreviewCommand':
|
|
385
|
-
return 'Default Preview Command'
|
|
386
|
-
case 'projectPaths':
|
|
387
|
-
return 'Project Paths'
|
|
388
|
-
case 'hiddenSessions':
|
|
389
|
-
return 'Hidden Sessions'
|
|
390
|
-
case 'icons':
|
|
391
|
-
return 'Icons'
|
|
392
|
-
case 'projects':
|
|
393
|
-
return 'Projects'
|
|
394
|
-
case 'wildcards':
|
|
395
|
-
return 'Wildcards'
|
|
396
|
-
default:
|
|
397
|
-
return 'Setting'
|
|
398
|
-
}
|
|
394
|
+
const setting = getSettingsField(field)
|
|
395
|
+
return setting.title ?? setting.label
|
|
399
396
|
}
|
|
400
397
|
|
|
401
398
|
export function filterSettingsEntries(entries: SettingsEntry[], query: string): SettingsEntry[] {
|