mux-sesh 1.5.0 → 1.6.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/package.json +1 -1
- package/src/app.tsx +606 -175
- package/src/components/KeybindHelp.tsx +156 -135
- package/src/config/index.ts +208 -2
- package/src/handlers/keyboard.ts +204 -34
- package/src/settings.ts +425 -0
- package/src/styles/opencode-themes-a.ts +1 -0
- package/src/styles/opencode-themes-b.ts +1 -0
- package/src/styles/theme.tsx +441 -0
- package/src/types/index.ts +65 -0
- package/src/ui/CommandsModal.tsx +145 -0
- package/src/ui/HighlightedText.tsx +6 -3
- package/src/ui/ItemList.tsx +34 -35
- package/src/ui/Modal.tsx +41 -0
- package/src/ui/OpencodeSessionGroup.tsx +26 -28
- package/src/ui/OpencodeStatsPanel.tsx +34 -39
- package/src/ui/RenameModal.tsx +42 -0
- package/src/ui/SearchInput.tsx +3 -1
- package/src/ui/SessionDetailsPanel.tsx +68 -106
- package/src/ui/SessionList.tsx +33 -42
- package/src/ui/SessionStats.tsx +5 -3
- package/src/ui/SettingEditorModal.tsx +49 -0
- package/src/ui/SettingOptionsModal.tsx +77 -0
- package/src/ui/SettingsModal.tsx +96 -0
- package/src/ui/Toast.tsx +8 -9
- package/src/ui/item-icon.ts +13 -12
- package/src/styles/theme.ts +0 -50
package/src/config/index.ts
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
import { join } from 'path'
|
|
2
2
|
import { mkdir } from 'fs/promises'
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
Config,
|
|
5
|
+
IconConfig,
|
|
6
|
+
KeybindMode,
|
|
7
|
+
ProjectProfile,
|
|
8
|
+
ProjectWildcard,
|
|
9
|
+
SessionDefaults,
|
|
10
|
+
SortOrder,
|
|
11
|
+
ThemeColorScheme,
|
|
12
|
+
ThemeDefinition,
|
|
13
|
+
ThemePalette,
|
|
14
|
+
ThemeVariant,
|
|
15
|
+
ZoxideMode,
|
|
16
|
+
} from '../types'
|
|
4
17
|
|
|
5
18
|
const DEFAULT_EDITOR = 'nvim'
|
|
19
|
+
const DEFAULT_THEME = 'rosepine'
|
|
20
|
+
const DEFAULT_COLOR_SCHEME: ThemeColorScheme = 'system'
|
|
21
|
+
const DEFAULT_PREFIX_KEY = 'ctrl+x'
|
|
6
22
|
const DEFAULT_EDITOR_COMMAND =
|
|
7
23
|
"nvim -c \"lua vim.defer_fn(function() if pcall(require, 'telescope') then vim.cmd('Telescope find_files') end end, 100)\""
|
|
8
24
|
const DEFAULT_ICONS: IconConfig = {
|
|
@@ -11,6 +27,7 @@ const DEFAULT_ICONS: IconConfig = {
|
|
|
11
27
|
project: '',
|
|
12
28
|
opencode: '',
|
|
13
29
|
}
|
|
30
|
+
const OPTIONAL_THEME_PALETTE_KEYS = ['accent', 'interactive', 'diffAdd', 'diffDelete'] as const
|
|
14
31
|
|
|
15
32
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
16
33
|
return typeof value === 'object' && value !== null
|
|
@@ -47,6 +64,10 @@ function asSortOrder(value: unknown): SortOrder | undefined {
|
|
|
47
64
|
: undefined
|
|
48
65
|
}
|
|
49
66
|
|
|
67
|
+
function asThemeColorScheme(value: unknown): ThemeColorScheme | undefined {
|
|
68
|
+
return value === 'light' || value === 'dark' || value === 'system' ? value : undefined
|
|
69
|
+
}
|
|
70
|
+
|
|
50
71
|
function asPositiveInteger(value: unknown): number | undefined {
|
|
51
72
|
return typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : undefined
|
|
52
73
|
}
|
|
@@ -90,6 +111,103 @@ function normalizeIcons(value: unknown): IconConfig | undefined {
|
|
|
90
111
|
}
|
|
91
112
|
}
|
|
92
113
|
|
|
114
|
+
function normalizeThemePalette(value: unknown): ThemePalette | undefined {
|
|
115
|
+
if (!isRecord(value)) {
|
|
116
|
+
return undefined
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const neutral = asString(value.neutral)
|
|
120
|
+
const ink = asString(value.ink)
|
|
121
|
+
const primary = asString(value.primary)
|
|
122
|
+
const success = asString(value.success)
|
|
123
|
+
const warning = asString(value.warning)
|
|
124
|
+
const error = asString(value.error)
|
|
125
|
+
const info = asString(value.info)
|
|
126
|
+
|
|
127
|
+
if (!neutral || !ink || !primary || !success || !warning || !error || !info) {
|
|
128
|
+
return undefined
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const normalized: ThemePalette = {
|
|
132
|
+
neutral,
|
|
133
|
+
ink,
|
|
134
|
+
primary,
|
|
135
|
+
success,
|
|
136
|
+
warning,
|
|
137
|
+
error,
|
|
138
|
+
info,
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
for (const key of OPTIONAL_THEME_PALETTE_KEYS) {
|
|
142
|
+
const color = asString(value[key])
|
|
143
|
+
if (color) {
|
|
144
|
+
normalized[key] = color
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return normalized
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function normalizeThemeVariant(value: unknown): ThemeVariant | undefined {
|
|
152
|
+
if (!isRecord(value)) {
|
|
153
|
+
return undefined
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const palette = normalizeThemePalette(value.palette)
|
|
157
|
+
if (!palette) {
|
|
158
|
+
return undefined
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const overrides = isRecord(value.overrides)
|
|
162
|
+
? Object.fromEntries(
|
|
163
|
+
Object.entries(value.overrides)
|
|
164
|
+
.map(([key, override]) => [key, asString(override)])
|
|
165
|
+
.filter((entry): entry is [string, string] => typeof entry[1] === 'string')
|
|
166
|
+
)
|
|
167
|
+
: undefined
|
|
168
|
+
|
|
169
|
+
return {
|
|
170
|
+
palette,
|
|
171
|
+
overrides: overrides && Object.keys(overrides).length > 0 ? overrides : undefined,
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function normalizeThemeDefinition(value: unknown, id: string): ThemeDefinition | undefined {
|
|
176
|
+
if (!isRecord(value)) {
|
|
177
|
+
return undefined
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const light = normalizeThemeVariant(value.light)
|
|
181
|
+
const dark = normalizeThemeVariant(value.dark)
|
|
182
|
+
|
|
183
|
+
if (!light || !dark) {
|
|
184
|
+
return undefined
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
name: asString(value.name) ?? id,
|
|
189
|
+
light,
|
|
190
|
+
dark,
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function normalizeThemes(value: unknown): Record<string, ThemeDefinition> | undefined {
|
|
195
|
+
if (!isRecord(value)) {
|
|
196
|
+
return undefined
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const entries = Object.entries(value).flatMap(([name, definition]) => {
|
|
200
|
+
const normalizedDefinition = normalizeThemeDefinition(definition, name)
|
|
201
|
+
if (!normalizedDefinition) {
|
|
202
|
+
return []
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return [[name, normalizedDefinition] as const]
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
return entries.length > 0 ? Object.fromEntries(entries) : undefined
|
|
209
|
+
}
|
|
210
|
+
|
|
93
211
|
function normalizeProjectProfiles(value: unknown, homeDir: string): ProjectProfile[] | undefined {
|
|
94
212
|
if (!Array.isArray(value)) {
|
|
95
213
|
return undefined
|
|
@@ -151,6 +269,15 @@ function normalizeWildcards(value: unknown, homeDir: string): ProjectWildcard[]
|
|
|
151
269
|
export function normalizeConfig(rawConfig: unknown, homeDir = process.env.HOME || '~'): Config {
|
|
152
270
|
const raw = isRecord(rawConfig) ? rawConfig : {}
|
|
153
271
|
const defaultConfig = getDefaultConfig(homeDir)
|
|
272
|
+
const requestedTheme = asString(raw.theme)
|
|
273
|
+
const normalizedTheme =
|
|
274
|
+
requestedTheme === 'rose-pine'
|
|
275
|
+
? 'rosepine'
|
|
276
|
+
: requestedTheme === 'opencode-dark' || requestedTheme === 'opencode-light'
|
|
277
|
+
? 'opencode'
|
|
278
|
+
: requestedTheme
|
|
279
|
+
const implicitColorScheme =
|
|
280
|
+
requestedTheme === 'opencode-light' ? 'light' : requestedTheme === 'opencode-dark' ? 'dark' : undefined
|
|
154
281
|
|
|
155
282
|
const projectPaths = (asStringArray(raw.project_paths) ?? asStringArray(raw.projectPaths) ?? defaultConfig.projectPaths).map(
|
|
156
283
|
projectPath => expandHomePath(projectPath, homeDir)
|
|
@@ -162,8 +289,16 @@ export function normalizeConfig(rawConfig: unknown, homeDir = process.env.HOME |
|
|
|
162
289
|
const editor = asString(raw.editor) ?? defaultConfig.editor
|
|
163
290
|
const editorCmd = asString(raw.editor_cmd) ?? asString(raw.editorCmd) ?? defaultConfig.editorCmd
|
|
164
291
|
const keybindMode = asKeybindMode(raw.keybind_mode) ?? asKeybindMode(raw.keybindMode) ?? defaultConfig.keybindMode
|
|
292
|
+
const prefixKey = asString(raw.prefix_key) ?? asString(raw.prefixKey) ?? defaultConfig.prefixKey
|
|
165
293
|
const zoxideMode = asZoxideMode(raw.zoxide_mode) ?? asZoxideMode(raw.zoxideMode) ?? defaultConfig.zoxideMode
|
|
166
294
|
const sortOrder = asSortOrder(raw.sort_order) ?? asSortOrder(raw.sortOrder) ?? defaultConfig.sortOrder
|
|
295
|
+
const theme = normalizedTheme ?? defaultConfig.theme
|
|
296
|
+
const colorScheme =
|
|
297
|
+
asThemeColorScheme(raw.color_scheme) ??
|
|
298
|
+
asThemeColorScheme(raw.colorScheme) ??
|
|
299
|
+
implicitColorScheme ??
|
|
300
|
+
defaultConfig.colorScheme
|
|
301
|
+
const themes = normalizeThemes(raw.themes) ?? defaultConfig.themes
|
|
167
302
|
const autoUpdate = asBoolean(raw.auto_update) ?? asBoolean(raw.autoUpdate) ?? defaultConfig.autoUpdate
|
|
168
303
|
const dirLength = asPositiveInteger(raw.dir_length) ?? asPositiveInteger(raw.dirLength) ?? defaultConfig.dirLength
|
|
169
304
|
const hiddenSessions = asStringArray(raw.hidden_sessions) ?? asStringArray(raw.hiddenSessions) ?? defaultConfig.hiddenSessions
|
|
@@ -180,8 +315,12 @@ export function normalizeConfig(rawConfig: unknown, homeDir = process.env.HOME |
|
|
|
180
315
|
editor,
|
|
181
316
|
editorCmd,
|
|
182
317
|
keybindMode,
|
|
318
|
+
prefixKey,
|
|
183
319
|
zoxideMode,
|
|
184
320
|
sortOrder,
|
|
321
|
+
theme,
|
|
322
|
+
colorScheme,
|
|
323
|
+
themes,
|
|
185
324
|
autoUpdate,
|
|
186
325
|
dirLength,
|
|
187
326
|
hiddenSessions,
|
|
@@ -199,8 +338,12 @@ export function getDefaultConfig(homeDir = process.env.HOME || '~'): Config {
|
|
|
199
338
|
editor: DEFAULT_EDITOR,
|
|
200
339
|
editorCmd: DEFAULT_EDITOR_COMMAND,
|
|
201
340
|
keybindMode: 'vim',
|
|
341
|
+
prefixKey: DEFAULT_PREFIX_KEY,
|
|
202
342
|
zoxideMode: 'off',
|
|
203
343
|
sortOrder: 'live-first',
|
|
344
|
+
theme: DEFAULT_THEME,
|
|
345
|
+
colorScheme: DEFAULT_COLOR_SCHEME,
|
|
346
|
+
themes: {},
|
|
204
347
|
autoUpdate: true,
|
|
205
348
|
dirLength: 1,
|
|
206
349
|
hiddenSessions: [],
|
|
@@ -213,6 +356,69 @@ export function getDefaultConfig(homeDir = process.env.HOME || '~'): Config {
|
|
|
213
356
|
}
|
|
214
357
|
}
|
|
215
358
|
|
|
359
|
+
function serializeThemeVariant(variant: ThemeVariant) {
|
|
360
|
+
return variant.overrides && Object.keys(variant.overrides).length > 0
|
|
361
|
+
? {
|
|
362
|
+
palette: variant.palette,
|
|
363
|
+
overrides: variant.overrides,
|
|
364
|
+
}
|
|
365
|
+
: {
|
|
366
|
+
palette: variant.palette,
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export function serializeConfig(config: Config): Record<string, unknown> {
|
|
371
|
+
return {
|
|
372
|
+
project_paths: config.projectPaths,
|
|
373
|
+
repos_path: config.reposPath,
|
|
374
|
+
editor: config.editor,
|
|
375
|
+
editor_cmd: config.editorCmd,
|
|
376
|
+
keybind_mode: config.keybindMode,
|
|
377
|
+
prefix_key: config.prefixKey,
|
|
378
|
+
zoxide_mode: config.zoxideMode,
|
|
379
|
+
sort_order: config.sortOrder,
|
|
380
|
+
theme: config.theme,
|
|
381
|
+
color_scheme: config.colorScheme,
|
|
382
|
+
auto_update: config.autoUpdate,
|
|
383
|
+
dir_length: config.dirLength,
|
|
384
|
+
hidden_sessions: config.hiddenSessions,
|
|
385
|
+
icons: config.icons,
|
|
386
|
+
default_session: config.defaultSession
|
|
387
|
+
? {
|
|
388
|
+
startup_command: config.defaultSession.startupCommand,
|
|
389
|
+
preview_command: config.defaultSession.previewCommand,
|
|
390
|
+
}
|
|
391
|
+
: undefined,
|
|
392
|
+
themes: config.themes
|
|
393
|
+
? Object.fromEntries(
|
|
394
|
+
Object.entries(config.themes).map(([id, theme]) => [
|
|
395
|
+
id,
|
|
396
|
+
{
|
|
397
|
+
name: theme.name,
|
|
398
|
+
light: serializeThemeVariant(theme.light),
|
|
399
|
+
dark: serializeThemeVariant(theme.dark),
|
|
400
|
+
},
|
|
401
|
+
])
|
|
402
|
+
)
|
|
403
|
+
: undefined,
|
|
404
|
+
projects: config.projects?.map(project => ({
|
|
405
|
+
path: project.path,
|
|
406
|
+
session_name: project.sessionName,
|
|
407
|
+
startup_command: project.startupCommand,
|
|
408
|
+
preview_command: project.previewCommand,
|
|
409
|
+
listed: project.listed,
|
|
410
|
+
icon: project.icon,
|
|
411
|
+
})),
|
|
412
|
+
wildcards: config.wildcards?.map(wildcard => ({
|
|
413
|
+
pattern: wildcard.pattern,
|
|
414
|
+
session_name: wildcard.sessionName,
|
|
415
|
+
startup_command: wildcard.startupCommand,
|
|
416
|
+
preview_command: wildcard.previewCommand,
|
|
417
|
+
})),
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
|
|
216
422
|
export async function loadConfig(): Promise<Config> {
|
|
217
423
|
const configDir = join(process.env.HOME!, '.config', 'mux-sesh')
|
|
218
424
|
const configPath = join(configDir, 'config.json')
|
|
@@ -233,7 +439,7 @@ export async function saveConfig(config: Config): Promise<void> {
|
|
|
233
439
|
const configPath = join(configDir, 'config.json')
|
|
234
440
|
|
|
235
441
|
await mkdir(configDir, { recursive: true })
|
|
236
|
-
await Bun.write(configPath, JSON.stringify(config, null, 2))
|
|
442
|
+
await Bun.write(configPath, JSON.stringify(serializeConfig(config), null, 2))
|
|
237
443
|
}
|
|
238
444
|
|
|
239
445
|
export function getConfigPath(): string {
|