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/app.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import type { TextareaRenderable } from '@opentui/core'
|
|
|
2
2
|
import { useKeyboard } from '@opentui/react'
|
|
3
3
|
import { useState, useEffect, useRef } from 'react'
|
|
4
4
|
import { AppMode, ViewMode, type Item, type Config, type OpencodeStatsState } from './types'
|
|
5
|
-
import { loadConfig } from './config'
|
|
5
|
+
import { getConfigPath, loadConfig, saveConfig } from './config'
|
|
6
6
|
import { getListedSessionItems, mergeSessionItems } from './config/listed-sessions'
|
|
7
7
|
import { orderProjectItems, orderSessionItems } from './items/order'
|
|
8
8
|
import { annotateProjectItemsWithSessionLinks } from './projects/session-links'
|
|
@@ -12,26 +12,39 @@ import { getProjectItems } from './tmux/projects'
|
|
|
12
12
|
import { filterAndSortItems, clearMatchIndices } from './search'
|
|
13
13
|
import { isGitHubURL } from './util/github'
|
|
14
14
|
import { getOpencodeSessionStats } from './opencode'
|
|
15
|
-
import {
|
|
16
|
-
import { colors, sessionListStyle, sessionListStyleFull } from './styles/theme'
|
|
15
|
+
import { ThemeProvider, getPanelStyle, resolveTheme } from './styles/theme'
|
|
17
16
|
import { useTerminalSize, shouldShowDetailPanel } from './util/terminal'
|
|
18
17
|
import Toast from './ui/Toast'
|
|
19
18
|
import { checkAndUpdate, updateEvents } from './update'
|
|
20
|
-
import KeybindHelp from './components/KeybindHelp'
|
|
21
19
|
import OpencodeStatsPanel from './ui/OpencodeStatsPanel'
|
|
22
20
|
import SessionDetailsPanel from './ui/SessionDetailsPanel'
|
|
23
21
|
import SessionList from './ui/SessionList'
|
|
24
22
|
import OpencodeSessionGroup from './ui/OpencodeSessionGroup'
|
|
25
23
|
import SearchInput from './ui/SearchInput'
|
|
26
|
-
import SessionStats from './ui/SessionStats'
|
|
27
24
|
import ItemList from './ui/ItemList'
|
|
25
|
+
import RenameModal from './ui/RenameModal'
|
|
26
|
+
import CommandsModal, { filterCommandEntries, getCommandEntries, type CommandId } from './ui/CommandsModal'
|
|
27
|
+
import SettingsModal from './ui/SettingsModal'
|
|
28
|
+
import SettingOptionsModal from './ui/SettingOptionsModal'
|
|
29
|
+
import SettingEditorModal from './ui/SettingEditorModal'
|
|
30
|
+
import {
|
|
31
|
+
applyEditorSetting,
|
|
32
|
+
applyOptionSetting,
|
|
33
|
+
filterSettingsEntries,
|
|
34
|
+
filterSettingsOptions,
|
|
35
|
+
getSettingEditorTitle,
|
|
36
|
+
getSettingEditorValue,
|
|
37
|
+
getSettingsEntries,
|
|
38
|
+
getSettingOptions,
|
|
39
|
+
isOptionSetting,
|
|
40
|
+
type SettingsFieldId,
|
|
41
|
+
} from './settings'
|
|
28
42
|
import {
|
|
29
43
|
type KeyboardHandlerContext,
|
|
30
44
|
handleNormalMode,
|
|
31
45
|
handleOpencodeManageMode,
|
|
32
46
|
handleSearchMode,
|
|
33
47
|
handleNewSessionMode,
|
|
34
|
-
handleRenameMode,
|
|
35
48
|
} from './handlers/keyboard'
|
|
36
49
|
import {
|
|
37
50
|
handleSelect as actionHandleSelect,
|
|
@@ -43,6 +56,14 @@ import {
|
|
|
43
56
|
handleEditTarget as actionHandleEditTarget,
|
|
44
57
|
} from './handlers/actions'
|
|
45
58
|
|
|
59
|
+
type ModalState =
|
|
60
|
+
| { type: 'rename'; target: string }
|
|
61
|
+
| { type: 'commands' }
|
|
62
|
+
| { type: 'settings' }
|
|
63
|
+
| { type: 'setting-options'; field: SettingsFieldId }
|
|
64
|
+
| { type: 'setting-editor'; field: SettingsFieldId }
|
|
65
|
+
| null
|
|
66
|
+
|
|
46
67
|
export function App() {
|
|
47
68
|
const [appMode, setAppMode] = useState(AppMode.Normal)
|
|
48
69
|
const [viewMode, setViewMode] = useState(ViewMode.Sessions)
|
|
@@ -56,14 +77,38 @@ export function App() {
|
|
|
56
77
|
const [message, setMessage] = useState('')
|
|
57
78
|
const [renameTarget, setRenameTarget] = useState('')
|
|
58
79
|
const [config, setConfig] = useState<Config | null>(null)
|
|
80
|
+
const [modalState, setModalState] = useState<ModalState>(null)
|
|
81
|
+
const [modalInputValue, setModalInputValue] = useState('')
|
|
82
|
+
const [commandsCursor, setCommandsCursor] = useState(0)
|
|
83
|
+
const [commandsSearchQuery, setCommandsSearchQuery] = useState('')
|
|
84
|
+
const [settingsCursor, setSettingsCursor] = useState(0)
|
|
85
|
+
const [settingsSearchQuery, setSettingsSearchQuery] = useState('')
|
|
86
|
+
const [settingOptionsCursor, setSettingOptionsCursor] = useState(0)
|
|
87
|
+
const [settingOptionsSearchQuery, setSettingOptionsSearchQuery] = useState('')
|
|
88
|
+
const [settingEditorValue, setSettingEditorValue] = useState('')
|
|
89
|
+
const [settingEditorError, setSettingEditorError] = useState('')
|
|
90
|
+
const [pendingKillSessionName, setPendingKillSessionName] = useState<string | null>(null)
|
|
59
91
|
const [prefixActive, setPrefixActive] = useState(false)
|
|
60
92
|
const prefixTimeoutRef = useRef<NodeJS.Timeout | null>(null)
|
|
61
93
|
const textareaRef = useRef<TextareaRenderable | null>(null)
|
|
94
|
+
const modalTextareaRef = useRef<TextareaRenderable | null>(null)
|
|
95
|
+
const commandsSearchTextareaRef = useRef<TextareaRenderable | null>(null)
|
|
96
|
+
const settingsSearchTextareaRef = useRef<TextareaRenderable | null>(null)
|
|
97
|
+
const settingOptionsSearchTextareaRef = useRef<TextareaRenderable | null>(null)
|
|
98
|
+
const settingEditorTextareaRef = useRef<TextareaRenderable | null>(null)
|
|
62
99
|
const lastSessionSelectionRef = useRef<string | null>(null)
|
|
63
100
|
const lastProjectSelectionRef = useRef<string | null>(null)
|
|
64
101
|
const { columns, rows } = useTerminalSize()
|
|
65
102
|
const [toastMessage, setToastMessage] = useState('')
|
|
66
103
|
const [toastVisible, setToastVisible] = useState(false)
|
|
104
|
+
const configPath = getConfigPath()
|
|
105
|
+
const resolvedTheme = resolveTheme(config?.theme, config?.themes, config?.colorScheme)
|
|
106
|
+
const theme = resolvedTheme.colors
|
|
107
|
+
const settingsEntries = config ? getSettingsEntries(config) : []
|
|
108
|
+
const filteredSettingsEntries = filterSettingsEntries(settingsEntries, settingsSearchQuery)
|
|
109
|
+
const currentOptionField = modalState?.type === 'setting-options' ? modalState.field : undefined
|
|
110
|
+
const settingOptions = config && currentOptionField ? getSettingOptions(config, currentOptionField) : []
|
|
111
|
+
const filteredSettingOptions = filterSettingsOptions(settingOptions, settingOptionsSearchQuery)
|
|
67
112
|
|
|
68
113
|
function getSessionSelectionIndex(nextItems: Item[]): number {
|
|
69
114
|
const regularItems = nextItems.filter(item => !(item.isSession && item.title.startsWith('opencode-')))
|
|
@@ -115,16 +160,9 @@ export function App() {
|
|
|
115
160
|
setAppMode(AppMode.Search)
|
|
116
161
|
}
|
|
117
162
|
|
|
118
|
-
const sessions = await listTmuxSessions()
|
|
163
|
+
const [sessions, listedSessions] = await Promise.all([listTmuxSessions(), getListedSessionItems(cfg)])
|
|
119
164
|
const visibleSessions = filterHiddenSessions(sessions, cfg.hiddenSessions)
|
|
120
|
-
const listedSessions = await getListedSessionItems(cfg)
|
|
121
165
|
const combinedSessions = orderSessionItems(mergeSessionItems(visibleSessions, listedSessions), cfg.sortOrder)
|
|
122
|
-
const projects = orderProjectItems(
|
|
123
|
-
await annotateProjectItemsWithSessionLinks(await getProjectItems(cfg), visibleSessions, cfg),
|
|
124
|
-
cfg.sortOrder
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
setProjectItems(projects)
|
|
128
166
|
|
|
129
167
|
if (combinedSessions.length > 0) {
|
|
130
168
|
setViewMode(ViewMode.Sessions)
|
|
@@ -132,12 +170,23 @@ export function App() {
|
|
|
132
170
|
setAllItems(combinedSessions)
|
|
133
171
|
setItems(combinedSessions)
|
|
134
172
|
setCursor(getSessionSelectionIndex(combinedSessions))
|
|
135
|
-
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const rawProjects = await getProjectItems(cfg)
|
|
176
|
+
const projects = orderProjectItems(
|
|
177
|
+
await annotateProjectItemsWithSessionLinks(rawProjects, visibleSessions, cfg),
|
|
178
|
+
cfg.sortOrder
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
setProjectItems(projects)
|
|
182
|
+
|
|
183
|
+
if (combinedSessions.length === 0) {
|
|
136
184
|
setViewMode(ViewMode.Projects)
|
|
137
185
|
setAllItems(projects)
|
|
138
186
|
setItems(projects)
|
|
139
187
|
setCursor(getProjectSelectionIndex(projects))
|
|
140
188
|
}
|
|
189
|
+
|
|
141
190
|
checkAndUpdate(cfg).catch(error => {
|
|
142
191
|
console.error('Auto-update check failed:', error)
|
|
143
192
|
})
|
|
@@ -145,21 +194,21 @@ export function App() {
|
|
|
145
194
|
init()
|
|
146
195
|
}, [])
|
|
147
196
|
|
|
148
|
-
async function refreshItems(forceViewMode?: ViewMode) {
|
|
149
|
-
if (!
|
|
197
|
+
async function refreshItems(forceViewMode?: ViewMode, nextConfig = config) {
|
|
198
|
+
if (!nextConfig) return
|
|
150
199
|
|
|
151
200
|
const targetMode = forceViewMode ?? viewMode
|
|
152
201
|
|
|
153
202
|
if (targetMode === ViewMode.Sessions) {
|
|
154
203
|
const sessions = await listTmuxSessions()
|
|
155
|
-
const visibleSessions = filterHiddenSessions(sessions,
|
|
156
|
-
const listedSessions = await getListedSessionItems(
|
|
204
|
+
const visibleSessions = filterHiddenSessions(sessions, nextConfig.hiddenSessions)
|
|
205
|
+
const listedSessions = await getListedSessionItems(nextConfig)
|
|
157
206
|
const cleanSessions = clearMatchIndices(
|
|
158
|
-
orderSessionItems(mergeSessionItems(visibleSessions, listedSessions),
|
|
207
|
+
orderSessionItems(mergeSessionItems(visibleSessions, listedSessions), nextConfig.sortOrder)
|
|
159
208
|
)
|
|
160
209
|
const linkedProjects = orderProjectItems(
|
|
161
|
-
await annotateProjectItemsWithSessionLinks(projectItems, visibleSessions,
|
|
162
|
-
|
|
210
|
+
await annotateProjectItemsWithSessionLinks(projectItems, visibleSessions, nextConfig),
|
|
211
|
+
nextConfig.sortOrder
|
|
163
212
|
)
|
|
164
213
|
setSessionItems(cleanSessions)
|
|
165
214
|
setProjectItems(linkedProjects)
|
|
@@ -168,10 +217,10 @@ export function App() {
|
|
|
168
217
|
setCursor(getSessionSelectionIndex(cleanSessions))
|
|
169
218
|
} else {
|
|
170
219
|
const sessions = await listTmuxSessions()
|
|
171
|
-
const visibleSessions = filterHiddenSessions(sessions,
|
|
220
|
+
const visibleSessions = filterHiddenSessions(sessions, nextConfig.hiddenSessions)
|
|
172
221
|
const projects = orderProjectItems(
|
|
173
|
-
await annotateProjectItemsWithSessionLinks(await getProjectItems(
|
|
174
|
-
|
|
222
|
+
await annotateProjectItemsWithSessionLinks(await getProjectItems(nextConfig), visibleSessions, nextConfig),
|
|
223
|
+
nextConfig.sortOrder
|
|
175
224
|
)
|
|
176
225
|
const cleanProjects = clearMatchIndices(projects)
|
|
177
226
|
setProjectItems(cleanProjects)
|
|
@@ -221,8 +270,12 @@ export function App() {
|
|
|
221
270
|
appMode === AppMode.OpencodeManage ? opencodeSessions[opencodeCursor]?.title : undefined
|
|
222
271
|
const selectedPrimaryItem =
|
|
223
272
|
viewMode === ViewMode.Sessions && appMode === AppMode.Normal ? regularSessions[cursor] : items[cursor]
|
|
273
|
+
const commandEntries = getCommandEntries(appMode, config?.keybindMode, config?.prefixKey, selectedPrimaryItem)
|
|
274
|
+
const filteredCommandEntries = filterCommandEntries(commandEntries, commandsSearchQuery)
|
|
224
275
|
|
|
225
276
|
async function handleKillSessionWrapper(sessionName: string) {
|
|
277
|
+
setPendingKillSessionName(null)
|
|
278
|
+
|
|
226
279
|
await actionKillSession(sessionName, {
|
|
227
280
|
onSuccess: msg => {
|
|
228
281
|
setMessage(msg)
|
|
@@ -270,8 +323,75 @@ export function App() {
|
|
|
270
323
|
}
|
|
271
324
|
}
|
|
272
325
|
|
|
326
|
+
function clearPendingKill() {
|
|
327
|
+
setPendingKillSessionName(null)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function requestKillSession(sessionName: string) {
|
|
331
|
+
if (pendingKillSessionName === sessionName) {
|
|
332
|
+
void handleKillSessionWrapper(sessionName)
|
|
333
|
+
return
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
setPendingKillSessionName(sessionName)
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function openRenameModal(sessionName: string) {
|
|
340
|
+
clearPendingKill()
|
|
341
|
+
setRenameTarget(sessionName)
|
|
342
|
+
setModalInputValue(sessionName)
|
|
343
|
+
setModalState({ type: 'rename', target: sessionName })
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function openCommandsModal() {
|
|
347
|
+
clearPendingKill()
|
|
348
|
+
setCommandsSearchQuery('')
|
|
349
|
+
setCommandsCursor(0)
|
|
350
|
+
setModalState({ type: 'commands' })
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function openSettingsModal() {
|
|
354
|
+
if (!config) {
|
|
355
|
+
return
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
clearPendingKill()
|
|
359
|
+
setSettingEditorError('')
|
|
360
|
+
setSettingsSearchQuery('')
|
|
361
|
+
setSettingsCursor(0)
|
|
362
|
+
setModalState({ type: 'settings' })
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function openSettingOptions(field: SettingsFieldId) {
|
|
366
|
+
setSettingOptionsSearchQuery('')
|
|
367
|
+
setSettingOptionsCursor(0)
|
|
368
|
+
setModalState({ type: 'setting-options', field })
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function openSettingEditor(field: SettingsFieldId) {
|
|
372
|
+
if (!config) {
|
|
373
|
+
return
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
setSettingEditorError('')
|
|
377
|
+
setSettingEditorValue(getSettingEditorValue(config, field))
|
|
378
|
+
setModalState({ type: 'setting-editor', field })
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function closeModal() {
|
|
382
|
+
setModalState(null)
|
|
383
|
+
setModalInputValue('')
|
|
384
|
+
setCommandsSearchQuery('')
|
|
385
|
+
setCommandsCursor(0)
|
|
386
|
+
setSettingsSearchQuery('')
|
|
387
|
+
setSettingOptionsSearchQuery('')
|
|
388
|
+
setSettingEditorValue('')
|
|
389
|
+
setSettingEditorError('')
|
|
390
|
+
setRenameTarget('')
|
|
391
|
+
}
|
|
392
|
+
|
|
273
393
|
async function handleRenameSubmit() {
|
|
274
|
-
const newName =
|
|
394
|
+
const newName = (modalTextareaRef.current?.plainText ?? modalInputValue).trim()
|
|
275
395
|
if (newName && newName !== renameTarget) {
|
|
276
396
|
await actionRenameSubmit(renameTarget, newName, {
|
|
277
397
|
onSuccess: msg => {
|
|
@@ -285,9 +405,8 @@ export function App() {
|
|
|
285
405
|
refreshItems,
|
|
286
406
|
})
|
|
287
407
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
setRenameTarget('')
|
|
408
|
+
|
|
409
|
+
closeModal()
|
|
291
410
|
}
|
|
292
411
|
|
|
293
412
|
async function handleNewSessionSubmit() {
|
|
@@ -303,6 +422,120 @@ export function App() {
|
|
|
303
422
|
}
|
|
304
423
|
}
|
|
305
424
|
|
|
425
|
+
async function executeCommand(commandID: CommandId) {
|
|
426
|
+
switch (commandID) {
|
|
427
|
+
case 'search':
|
|
428
|
+
closeModal()
|
|
429
|
+
setAppMode(AppMode.Search)
|
|
430
|
+
setSearchQuery('')
|
|
431
|
+
return
|
|
432
|
+
case 'new-session':
|
|
433
|
+
closeModal()
|
|
434
|
+
setAppMode(AppMode.NewSession)
|
|
435
|
+
setViewMode(ViewMode.Projects)
|
|
436
|
+
setAllItems(projectItems)
|
|
437
|
+
setItems(projectItems)
|
|
438
|
+
setCursor(Math.max(0, projectItems.length - 1))
|
|
439
|
+
setSearchQuery('')
|
|
440
|
+
return
|
|
441
|
+
case 'open-settings':
|
|
442
|
+
openSettingsModal()
|
|
443
|
+
return
|
|
444
|
+
case 'view-projects':
|
|
445
|
+
closeModal()
|
|
446
|
+
setViewMode(ViewMode.Projects)
|
|
447
|
+
await refreshItems(ViewMode.Projects)
|
|
448
|
+
return
|
|
449
|
+
case 'view-sessions':
|
|
450
|
+
closeModal()
|
|
451
|
+
setViewMode(ViewMode.Sessions)
|
|
452
|
+
await refreshItems(ViewMode.Sessions)
|
|
453
|
+
return
|
|
454
|
+
case 'rename-session': {
|
|
455
|
+
const target =
|
|
456
|
+
appMode === AppMode.OpencodeManage ? opencodeSessions[opencodeCursor] : viewMode === ViewMode.Sessions ? regularSessions[cursor] : undefined
|
|
457
|
+
if (target?.isSession) {
|
|
458
|
+
openRenameModal(target.title)
|
|
459
|
+
}
|
|
460
|
+
return
|
|
461
|
+
}
|
|
462
|
+
case 'kill-session': {
|
|
463
|
+
const target =
|
|
464
|
+
appMode === AppMode.OpencodeManage ? opencodeSessions[opencodeCursor] : viewMode === ViewMode.Sessions ? regularSessions[cursor] : undefined
|
|
465
|
+
if (target?.isSession) {
|
|
466
|
+
closeModal()
|
|
467
|
+
requestKillSession(target.title)
|
|
468
|
+
}
|
|
469
|
+
return
|
|
470
|
+
}
|
|
471
|
+
case 'last-session':
|
|
472
|
+
closeModal()
|
|
473
|
+
await handleLastSessionWrapper()
|
|
474
|
+
return
|
|
475
|
+
case 'root-session':
|
|
476
|
+
closeModal()
|
|
477
|
+
await handleRootSessionWrapper(selectedPrimaryItem)
|
|
478
|
+
return
|
|
479
|
+
case 'edit-target':
|
|
480
|
+
closeModal()
|
|
481
|
+
await handleEditTargetWrapper(selectedPrimaryItem)
|
|
482
|
+
return
|
|
483
|
+
case 'open-opencode':
|
|
484
|
+
closeModal()
|
|
485
|
+
if (viewMode === ViewMode.Sessions && opencodeSessions.length > 0) {
|
|
486
|
+
setAppMode(AppMode.OpencodeManage)
|
|
487
|
+
setOpencodeCursor(0)
|
|
488
|
+
await loadOpencodeStatsForSession(opencodeSessions[0].title)
|
|
489
|
+
}
|
|
490
|
+
return
|
|
491
|
+
case 'refresh':
|
|
492
|
+
closeModal()
|
|
493
|
+
await refreshItems()
|
|
494
|
+
setMessage('Refreshed')
|
|
495
|
+
setTimeout(() => setMessage(''), 2000)
|
|
496
|
+
return
|
|
497
|
+
case 'back':
|
|
498
|
+
closeModal()
|
|
499
|
+
setAppMode(AppMode.Normal)
|
|
500
|
+
return
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
async function applyAndPersistConfig(nextConfig: Config, successMessage: string) {
|
|
505
|
+
await saveConfig(nextConfig)
|
|
506
|
+
setConfig(nextConfig)
|
|
507
|
+
await refreshItems(undefined, nextConfig)
|
|
508
|
+
setMessage(successMessage)
|
|
509
|
+
setTimeout(() => setMessage(''), 2000)
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
async function handleSettingsEditorSubmit(field: SettingsFieldId) {
|
|
513
|
+
if (!config) {
|
|
514
|
+
return
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
try {
|
|
518
|
+
const rawText = settingEditorTextareaRef.current?.plainText ?? settingEditorValue
|
|
519
|
+
const nextConfig = applyEditorSetting(config, field, rawText, process.env.HOME || '~')
|
|
520
|
+
|
|
521
|
+
setSettingEditorError('')
|
|
522
|
+
await applyAndPersistConfig(nextConfig, `${getSettingEditorTitle(field)} updated`)
|
|
523
|
+
openSettingsModal()
|
|
524
|
+
} catch (error) {
|
|
525
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to save settings'
|
|
526
|
+
setSettingEditorError(errorMessage)
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
async function handleSettingOptionSubmit(field: SettingsFieldId, value: string) {
|
|
531
|
+
if (!config) {
|
|
532
|
+
return
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
const nextConfig = applyOptionSetting(config, field, value)
|
|
536
|
+
await applyAndPersistConfig(nextConfig, `${getSettingEditorTitle(field)} updated`)
|
|
537
|
+
}
|
|
538
|
+
|
|
306
539
|
const keyboardContext: KeyboardHandlerContext = {
|
|
307
540
|
appMode,
|
|
308
541
|
viewMode,
|
|
@@ -313,6 +546,7 @@ export function App() {
|
|
|
313
546
|
opencodeCursor,
|
|
314
547
|
searchQuery,
|
|
315
548
|
renameTarget,
|
|
549
|
+
prefixKey: config?.prefixKey,
|
|
316
550
|
projectItems,
|
|
317
551
|
sessionItems,
|
|
318
552
|
prefixActive,
|
|
@@ -328,33 +562,114 @@ export function App() {
|
|
|
328
562
|
setItems,
|
|
329
563
|
setPrefixActive,
|
|
330
564
|
refreshItems,
|
|
565
|
+
requestKillSession,
|
|
566
|
+
clearPendingKill,
|
|
331
567
|
handleSelect: handleSelectWrapper,
|
|
332
568
|
handleKillSession: handleKillSessionWrapper,
|
|
333
569
|
handleLastSession: handleLastSessionWrapper,
|
|
334
570
|
handleRootSession: handleRootSessionWrapper,
|
|
335
571
|
handleEditTarget: handleEditTargetWrapper,
|
|
572
|
+
openRenameModal,
|
|
573
|
+
openCommandsModal,
|
|
574
|
+
openSettingsModal,
|
|
336
575
|
loadOpencodeStatsForSession,
|
|
337
576
|
setMessage,
|
|
338
577
|
}
|
|
339
578
|
|
|
340
579
|
useKeyboard(key => {
|
|
341
580
|
const keybindMode = config?.keybindMode || 'vim'
|
|
581
|
+
|
|
582
|
+
if (modalState?.type === 'rename') {
|
|
583
|
+
if (key.name === 'return') {
|
|
584
|
+
void handleRenameSubmit()
|
|
585
|
+
} else if (key.name === 'escape') {
|
|
586
|
+
closeModal()
|
|
587
|
+
}
|
|
588
|
+
return
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
if (modalState?.type === 'commands') {
|
|
592
|
+
if (key.name === 'escape' || key.name === 'q') {
|
|
593
|
+
closeModal()
|
|
594
|
+
} else if (key.name === 'down' || key.name === 'j') {
|
|
595
|
+
setCommandsCursor(current => Math.min(current + 1, filteredCommandEntries.length - 1))
|
|
596
|
+
} else if (key.name === 'up' || key.name === 'k') {
|
|
597
|
+
setCommandsCursor(current => Math.max(current - 1, 0))
|
|
598
|
+
} else if (key.name === 'return') {
|
|
599
|
+
const command = filteredCommandEntries[commandsCursor]
|
|
600
|
+
if (!command) {
|
|
601
|
+
return
|
|
602
|
+
}
|
|
603
|
+
void executeCommand(command.id)
|
|
604
|
+
}
|
|
605
|
+
return
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
if (modalState?.type === 'settings') {
|
|
609
|
+
if (key.name === 'escape') {
|
|
610
|
+
closeModal()
|
|
611
|
+
} else if (key.name === 'down' || key.name === 'j') {
|
|
612
|
+
setSettingsCursor(current => Math.min(current + 1, filteredSettingsEntries.length - 1))
|
|
613
|
+
} else if (key.name === 'up' || key.name === 'k') {
|
|
614
|
+
setSettingsCursor(current => Math.max(current - 1, 0))
|
|
615
|
+
} else if (key.name === 'return') {
|
|
616
|
+
const entry = filteredSettingsEntries[settingsCursor]
|
|
617
|
+
if (!entry) {
|
|
618
|
+
return
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
if (isOptionSetting(entry.id)) {
|
|
622
|
+
openSettingOptions(entry.id)
|
|
623
|
+
} else {
|
|
624
|
+
openSettingEditor(entry.id)
|
|
625
|
+
}
|
|
626
|
+
} else if (key.name === 'e') {
|
|
627
|
+
const entry = filteredSettingsEntries[settingsCursor]
|
|
628
|
+
if (!entry) return
|
|
629
|
+
if (isOptionSetting(entry.id)) {
|
|
630
|
+
openSettingOptions(entry.id)
|
|
631
|
+
} else {
|
|
632
|
+
openSettingEditor(entry.id)
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
return
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
if (modalState?.type === 'setting-options') {
|
|
639
|
+
if (key.name === 'escape') {
|
|
640
|
+
setModalState({ type: 'settings' })
|
|
641
|
+
} else if (key.name === 'down' || key.name === 'j') {
|
|
642
|
+
setSettingOptionsCursor(current => Math.min(current + 1, filteredSettingOptions.length - 1))
|
|
643
|
+
} else if (key.name === 'up' || key.name === 'k') {
|
|
644
|
+
setSettingOptionsCursor(current => Math.max(current - 1, 0))
|
|
645
|
+
} else if (key.name === 'return') {
|
|
646
|
+
const option = filteredSettingOptions[settingOptionsCursor]
|
|
647
|
+
if (!option) return
|
|
648
|
+
void handleSettingOptionSubmit(modalState.field, option.value)
|
|
649
|
+
}
|
|
650
|
+
return
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
if (modalState?.type === 'setting-editor') {
|
|
654
|
+
if (key.name === 'escape') {
|
|
655
|
+
setModalState({ type: 'settings' })
|
|
656
|
+
setSettingEditorError('')
|
|
657
|
+
} else if (key.name === 'return') {
|
|
658
|
+
void handleSettingsEditorSubmit(modalState.field)
|
|
659
|
+
}
|
|
660
|
+
return
|
|
661
|
+
}
|
|
662
|
+
|
|
342
663
|
if (appMode === AppMode.Normal) {
|
|
343
664
|
handleNormalMode(key, keyboardContext, keybindMode)
|
|
344
665
|
} else if (appMode === AppMode.Search) {
|
|
345
666
|
handleSearchMode(key, keyboardContext, keybindMode)
|
|
346
667
|
} else if (appMode === AppMode.NewSession) {
|
|
347
668
|
if (key.name === 'return') {
|
|
348
|
-
handleNewSessionSubmit()
|
|
669
|
+
void handleNewSessionSubmit()
|
|
349
670
|
} else {
|
|
350
671
|
handleNewSessionMode(key, keyboardContext, keybindMode)
|
|
351
672
|
}
|
|
352
|
-
} else if (appMode === AppMode.Rename) {
|
|
353
|
-
if (key.name === 'return') {
|
|
354
|
-
handleRenameSubmit()
|
|
355
|
-
} else {
|
|
356
|
-
handleRenameMode(key, keyboardContext, keybindMode)
|
|
357
|
-
}
|
|
358
673
|
} else if (appMode === AppMode.OpencodeManage) {
|
|
359
674
|
handleOpencodeManageMode(key, keyboardContext, keybindMode)
|
|
360
675
|
}
|
|
@@ -362,7 +677,7 @@ export function App() {
|
|
|
362
677
|
|
|
363
678
|
useEffect(() => {
|
|
364
679
|
const unsubscribe = updateEvents.on(event => {
|
|
365
|
-
setToastMessage(`
|
|
680
|
+
setToastMessage(`Update ready ${event.version}`)
|
|
366
681
|
setToastVisible(true)
|
|
367
682
|
setTimeout(() => {
|
|
368
683
|
setToastVisible(false)
|
|
@@ -393,6 +708,37 @@ export function App() {
|
|
|
393
708
|
}
|
|
394
709
|
}, [appMode, viewMode, projectItems])
|
|
395
710
|
|
|
711
|
+
useEffect(() => {
|
|
712
|
+
if (filteredCommandEntries.length === 0) {
|
|
713
|
+
setCommandsCursor(0)
|
|
714
|
+
return
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
setCommandsCursor(current => Math.min(current, filteredCommandEntries.length - 1))
|
|
718
|
+
}, [filteredCommandEntries.length])
|
|
719
|
+
|
|
720
|
+
useEffect(() => {
|
|
721
|
+
setCommandsCursor(0)
|
|
722
|
+
}, [commandsSearchQuery])
|
|
723
|
+
|
|
724
|
+
useEffect(() => {
|
|
725
|
+
if (filteredSettingsEntries.length === 0) {
|
|
726
|
+
setSettingsCursor(0)
|
|
727
|
+
return
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
setSettingsCursor(current => Math.min(current, filteredSettingsEntries.length - 1))
|
|
731
|
+
}, [filteredSettingsEntries.length])
|
|
732
|
+
|
|
733
|
+
useEffect(() => {
|
|
734
|
+
if (filteredSettingOptions.length === 0) {
|
|
735
|
+
setSettingOptionsCursor(0)
|
|
736
|
+
return
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
setSettingOptionsCursor(current => Math.min(current, filteredSettingOptions.length - 1))
|
|
740
|
+
}, [filteredSettingOptions.length])
|
|
741
|
+
|
|
396
742
|
useEffect(() => {
|
|
397
743
|
const selectedItem = appMode === AppMode.NewSession ? items[cursor] : selectedPrimaryItem
|
|
398
744
|
|
|
@@ -412,6 +758,23 @@ export function App() {
|
|
|
412
758
|
}
|
|
413
759
|
}, [appMode, viewMode, cursor, items, selectedPrimaryItem])
|
|
414
760
|
|
|
761
|
+
useEffect(() => {
|
|
762
|
+
if (!pendingKillSessionName) {
|
|
763
|
+
return
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
const selectedSessionName =
|
|
767
|
+
appMode === AppMode.OpencodeManage
|
|
768
|
+
? opencodeSessions[opencodeCursor]?.title
|
|
769
|
+
: viewMode === ViewMode.Sessions
|
|
770
|
+
? regularSessions[cursor]?.title
|
|
771
|
+
: undefined
|
|
772
|
+
|
|
773
|
+
if (selectedSessionName !== pendingKillSessionName) {
|
|
774
|
+
setPendingKillSessionName(null)
|
|
775
|
+
}
|
|
776
|
+
}, [appMode, cursor, opencodeCursor, opencodeSessions, pendingKillSessionName, regularSessions, viewMode])
|
|
777
|
+
|
|
415
778
|
useEffect(() => {
|
|
416
779
|
if (appMode === AppMode.Search || appMode === AppMode.NewSession) {
|
|
417
780
|
if (searchQuery.trim()) {
|
|
@@ -443,176 +806,244 @@ export function App() {
|
|
|
443
806
|
|
|
444
807
|
const title =
|
|
445
808
|
appMode === AppMode.Search
|
|
446
|
-
? '
|
|
809
|
+
? 'Search'
|
|
447
810
|
: appMode === AppMode.NewSession
|
|
448
|
-
? '
|
|
449
|
-
: appMode === AppMode.
|
|
450
|
-
? '
|
|
451
|
-
:
|
|
452
|
-
? '
|
|
453
|
-
: '
|
|
811
|
+
? 'New Session'
|
|
812
|
+
: appMode === AppMode.OpencodeManage
|
|
813
|
+
? 'OpenCode Sessions'
|
|
814
|
+
: viewMode === ViewMode.Projects
|
|
815
|
+
? 'Projects'
|
|
816
|
+
: 'Sessions'
|
|
454
817
|
|
|
455
818
|
const listStyle =
|
|
456
819
|
appMode === AppMode.NewSession
|
|
457
820
|
? {
|
|
458
|
-
...
|
|
821
|
+
...getPanelStyle(theme, 'full'),
|
|
459
822
|
flexGrow: 1,
|
|
460
823
|
flexShrink: 1,
|
|
461
824
|
}
|
|
462
825
|
: {
|
|
463
|
-
...
|
|
826
|
+
...getPanelStyle(theme, 'split'),
|
|
464
827
|
flexGrow: 1,
|
|
465
828
|
flexShrink: 1,
|
|
466
829
|
minWidth: 40,
|
|
467
830
|
}
|
|
468
831
|
|
|
469
|
-
const totalSessions =
|
|
470
|
-
viewMode === ViewMode.Sessions && appMode === AppMode.Normal
|
|
471
|
-
? items.filter(item => item.isSession).length
|
|
472
|
-
: 0
|
|
832
|
+
const totalSessions = sessionItems.filter(item => item.isSession).length
|
|
473
833
|
const activeSessions = items.filter(item => item.isSession && item.isAttached).length
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
const
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
? formatSessionAge(sessionsWithAges[sessionsWithAges.length - 1].createdAt!)
|
|
485
|
-
: 'N/A'
|
|
486
|
-
const maxVisibleItems = Math.max(8, rows - (appMode === AppMode.NewSession ? 10 : 16))
|
|
834
|
+
const maxVisibleItems = Math.max(8, rows - (appMode === AppMode.NewSession ? 10 : 12))
|
|
835
|
+
const prefixLabel = config?.prefixKey ? `${config.prefixKey} ...` : 'direct keys'
|
|
836
|
+
const footerHint =
|
|
837
|
+
appMode === AppMode.OpencodeManage
|
|
838
|
+
? `o back d kill ctrl+p commands ${prefixLabel}`
|
|
839
|
+
: appMode === AppMode.NewSession
|
|
840
|
+
? 'enter create esc cancel'
|
|
841
|
+
: appMode === AppMode.Search
|
|
842
|
+
? 'enter select esc cancel'
|
|
843
|
+
: `enter select i search n new o opencode d kill ctrl+p commands ${prefixLabel}`
|
|
487
844
|
|
|
488
845
|
return (
|
|
489
|
-
<
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
<box style={
|
|
502
|
-
<
|
|
503
|
-
|
|
846
|
+
<ThemeProvider theme={theme}>
|
|
847
|
+
<box
|
|
848
|
+
style={{
|
|
849
|
+
flexDirection: 'row',
|
|
850
|
+
alignItems: 'stretch',
|
|
851
|
+
justifyContent: 'center',
|
|
852
|
+
width: '100%',
|
|
853
|
+
height: '100%',
|
|
854
|
+
gap: 1,
|
|
855
|
+
backgroundColor: theme.background,
|
|
856
|
+
}}
|
|
857
|
+
>
|
|
858
|
+
<box style={listStyle}>
|
|
859
|
+
<box style={{ justifyContent: 'space-between', marginBottom: 1 }}>
|
|
860
|
+
<box style={{ flexDirection: 'column' }}>
|
|
861
|
+
<text style={{ fg: theme.text }}>mux-sesh</text>
|
|
862
|
+
<text style={{ fg: theme.textSubtle }}>{title}</text>
|
|
863
|
+
</box>
|
|
864
|
+
<box style={{ flexDirection: 'column', alignItems: 'flex-end' }}>
|
|
865
|
+
<text style={{ fg: theme.textMuted }}>
|
|
866
|
+
{viewMode === ViewMode.Sessions ? `${activeSessions}/${totalSessions} active` : `${projectItems.length} projects`}
|
|
867
|
+
</text>
|
|
868
|
+
<text style={{ fg: theme.textSubtle }}>{`${resolvedTheme.name} · ${resolvedTheme.mode}`}</text>
|
|
869
|
+
</box>
|
|
870
|
+
</box>
|
|
504
871
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
872
|
+
{(appMode === AppMode.Search || appMode === AppMode.NewSession) && (
|
|
873
|
+
<SearchInput
|
|
874
|
+
key={appMode}
|
|
875
|
+
appMode={appMode}
|
|
876
|
+
searchQuery={searchQuery}
|
|
877
|
+
textareaRef={textareaRef}
|
|
878
|
+
prefixActive={prefixActive}
|
|
879
|
+
onContentChange={() => {
|
|
880
|
+
if (textareaRef.current && textareaRef.current.plainText !== undefined) {
|
|
881
|
+
setSearchQuery(textareaRef.current.plainText)
|
|
882
|
+
}
|
|
883
|
+
}}
|
|
884
|
+
/>
|
|
885
|
+
)}
|
|
886
|
+
|
|
887
|
+
<box
|
|
888
|
+
style={{
|
|
889
|
+
alignSelf: 'auto',
|
|
890
|
+
flexDirection: 'column',
|
|
891
|
+
flexGrow: 0,
|
|
892
|
+
flexShrink: 0,
|
|
893
|
+
marginTop:
|
|
894
|
+
viewMode === ViewMode.Sessions && (appMode === AppMode.Normal || appMode === AppMode.OpencodeManage)
|
|
895
|
+
? 1
|
|
896
|
+
: 0,
|
|
519
897
|
}}
|
|
520
|
-
|
|
521
|
-
|
|
898
|
+
>
|
|
899
|
+
{items.length === 0 ? (
|
|
900
|
+
<text style={{ fg: theme.inactive }}>
|
|
901
|
+
{appMode === AppMode.NewSession && searchQuery && isGitHubURL(searchQuery)
|
|
902
|
+
? 'Clone & create session'
|
|
903
|
+
: appMode === AppMode.NewSession && searchQuery
|
|
904
|
+
? `Create session: ${searchQuery}`
|
|
905
|
+
: 'No items found'}
|
|
906
|
+
</text>
|
|
907
|
+
) : viewMode === ViewMode.Sessions && (appMode === AppMode.Normal || appMode === AppMode.OpencodeManage) ? (
|
|
908
|
+
<>
|
|
909
|
+
<SessionList
|
|
910
|
+
items={regularSessions}
|
|
911
|
+
cursor={cursor}
|
|
912
|
+
searchQuery={searchQuery}
|
|
913
|
+
maxItems={maxVisibleItems}
|
|
914
|
+
icons={config?.icons}
|
|
915
|
+
pendingKillSessionName={pendingKillSessionName}
|
|
916
|
+
/>
|
|
522
917
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
: 0,
|
|
535
|
-
}}
|
|
536
|
-
>
|
|
537
|
-
{items.length === 0 ? (
|
|
538
|
-
<text style={{ fg: colors.inactive }}>
|
|
539
|
-
{appMode === AppMode.NewSession && searchQuery && isGitHubURL(searchQuery)
|
|
540
|
-
? `Clone & create session`
|
|
541
|
-
: appMode === AppMode.NewSession && searchQuery
|
|
542
|
-
? `Create session: ${searchQuery}`
|
|
543
|
-
: 'No items found'}
|
|
544
|
-
</text>
|
|
545
|
-
) : viewMode === ViewMode.Sessions &&
|
|
546
|
-
(appMode === AppMode.Normal || appMode === AppMode.OpencodeManage) ? (
|
|
547
|
-
<>
|
|
548
|
-
{/* Regular sessions */}
|
|
549
|
-
<SessionList
|
|
550
|
-
items={regularSessions}
|
|
918
|
+
<OpencodeSessionGroup
|
|
919
|
+
sessions={opencodeSessions}
|
|
920
|
+
appMode={appMode}
|
|
921
|
+
cursor={opencodeCursor}
|
|
922
|
+
icons={config?.icons}
|
|
923
|
+
pendingKillSessionName={pendingKillSessionName}
|
|
924
|
+
/>
|
|
925
|
+
</>
|
|
926
|
+
) : (
|
|
927
|
+
<ItemList
|
|
928
|
+
items={items}
|
|
551
929
|
cursor={cursor}
|
|
930
|
+
appMode={appMode}
|
|
552
931
|
searchQuery={searchQuery}
|
|
553
932
|
maxItems={maxVisibleItems}
|
|
554
933
|
icons={config?.icons}
|
|
934
|
+
pendingKillSessionName={pendingKillSessionName}
|
|
555
935
|
/>
|
|
936
|
+
)}
|
|
937
|
+
</box>
|
|
556
938
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
{/* Session statistics */}
|
|
566
|
-
<SessionStats
|
|
567
|
-
totalSessions={totalSessions}
|
|
568
|
-
activeSessions={activeSessions}
|
|
569
|
-
idleSessions={idleSessions}
|
|
570
|
-
oldestSession={oldestSession}
|
|
571
|
-
newestSession={newestSession}
|
|
572
|
-
/>
|
|
573
|
-
</>
|
|
574
|
-
) : (
|
|
575
|
-
<ItemList
|
|
576
|
-
items={items}
|
|
577
|
-
cursor={cursor}
|
|
578
|
-
appMode={appMode}
|
|
579
|
-
searchQuery={searchQuery}
|
|
580
|
-
maxItems={maxVisibleItems}
|
|
581
|
-
icons={config?.icons}
|
|
582
|
-
/>
|
|
939
|
+
{(message || columns < 80 || footerHint) && (
|
|
940
|
+
<box style={{ flexDirection: 'column', marginTop: 1 }}>
|
|
941
|
+
{message && <text style={{ fg: theme.action }}>{message}</text>}
|
|
942
|
+
{columns < 80 && appMode !== AppMode.NewSession && (
|
|
943
|
+
<text style={{ fg: theme.textSubtle }}>Resize for the detail pane.</text>
|
|
944
|
+
)}
|
|
945
|
+
<text style={{ fg: theme.textSubtle }}>{footerHint}</text>
|
|
946
|
+
</box>
|
|
583
947
|
)}
|
|
584
948
|
</box>
|
|
585
949
|
|
|
586
|
-
{
|
|
587
|
-
|
|
950
|
+
{shouldShowDetailPanel(columns, appMode === AppMode.NewSession) && (
|
|
951
|
+
<>
|
|
952
|
+
{viewMode === ViewMode.Sessions && appMode === AppMode.OpencodeManage ? (
|
|
953
|
+
<OpencodeStatsPanel selectedItem={opencodeSessions[opencodeCursor]} />
|
|
954
|
+
) : (
|
|
955
|
+
<SessionDetailsPanel selectedItem={selectedPrimaryItem} config={config} />
|
|
956
|
+
)}
|
|
957
|
+
</>
|
|
958
|
+
)}
|
|
588
959
|
|
|
589
|
-
{
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
960
|
+
{modalState?.type === 'rename' && (
|
|
961
|
+
<RenameModal
|
|
962
|
+
target={modalState.target}
|
|
963
|
+
initialValue={modalInputValue}
|
|
964
|
+
columns={columns}
|
|
965
|
+
textareaRef={modalTextareaRef}
|
|
966
|
+
onContentChange={() => {
|
|
967
|
+
if (modalTextareaRef.current?.plainText !== undefined) {
|
|
968
|
+
setModalInputValue(modalTextareaRef.current.plainText)
|
|
969
|
+
}
|
|
970
|
+
}}
|
|
971
|
+
/>
|
|
594
972
|
)}
|
|
595
973
|
|
|
596
|
-
{
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
974
|
+
{modalState?.type === 'commands' && (
|
|
975
|
+
<CommandsModal
|
|
976
|
+
columns={columns}
|
|
977
|
+
themeId={resolvedTheme.id}
|
|
978
|
+
entries={filteredCommandEntries}
|
|
979
|
+
cursor={commandsCursor}
|
|
980
|
+
searchQuery={commandsSearchQuery}
|
|
981
|
+
textareaRef={commandsSearchTextareaRef}
|
|
982
|
+
onContentChange={() => {
|
|
983
|
+
if (commandsSearchTextareaRef.current?.plainText !== undefined) {
|
|
984
|
+
setCommandsSearchQuery(commandsSearchTextareaRef.current.plainText)
|
|
985
|
+
setCommandsCursor(0)
|
|
986
|
+
}
|
|
987
|
+
}}
|
|
988
|
+
/>
|
|
989
|
+
)}
|
|
601
990
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
991
|
+
{modalState?.type === 'settings' && config && (
|
|
992
|
+
<SettingsModal
|
|
993
|
+
configPath={configPath}
|
|
994
|
+
themeName={resolvedTheme.name}
|
|
995
|
+
colorMode={resolvedTheme.mode}
|
|
996
|
+
columns={columns}
|
|
997
|
+
entries={filteredSettingsEntries}
|
|
998
|
+
cursor={settingsCursor}
|
|
999
|
+
searchQuery={settingsSearchQuery}
|
|
1000
|
+
textareaRef={settingsSearchTextareaRef}
|
|
1001
|
+
onContentChange={() => {
|
|
1002
|
+
if (settingsSearchTextareaRef.current?.plainText !== undefined) {
|
|
1003
|
+
setSettingsSearchQuery(settingsSearchTextareaRef.current.plainText)
|
|
1004
|
+
setSettingsCursor(0)
|
|
1005
|
+
}
|
|
1006
|
+
}}
|
|
1007
|
+
/>
|
|
1008
|
+
)}
|
|
1009
|
+
|
|
1010
|
+
{modalState?.type === 'setting-options' && (
|
|
1011
|
+
<SettingOptionsModal
|
|
1012
|
+
title={getSettingEditorTitle(modalState.field)}
|
|
1013
|
+
description='Select an option to apply it immediately'
|
|
1014
|
+
columns={columns}
|
|
1015
|
+
options={filteredSettingOptions}
|
|
1016
|
+
cursor={settingOptionsCursor}
|
|
1017
|
+
searchQuery={settingOptionsSearchQuery}
|
|
1018
|
+
textareaRef={settingOptionsSearchTextareaRef}
|
|
1019
|
+
onContentChange={() => {
|
|
1020
|
+
if (settingOptionsSearchTextareaRef.current?.plainText !== undefined) {
|
|
1021
|
+
setSettingOptionsSearchQuery(settingOptionsSearchTextareaRef.current.plainText)
|
|
1022
|
+
setSettingOptionsCursor(0)
|
|
1023
|
+
}
|
|
1024
|
+
}}
|
|
1025
|
+
/>
|
|
1026
|
+
)}
|
|
1027
|
+
|
|
1028
|
+
{modalState?.type === 'setting-editor' && (
|
|
1029
|
+
<SettingEditorModal
|
|
1030
|
+
title={getSettingEditorTitle(modalState.field)}
|
|
1031
|
+
description='Edit value and press Enter to apply immediately'
|
|
1032
|
+
value={settingEditorValue}
|
|
1033
|
+
error={settingEditorError}
|
|
1034
|
+
columns={columns}
|
|
1035
|
+
rows={rows}
|
|
1036
|
+
textareaRef={settingEditorTextareaRef}
|
|
1037
|
+
onContentChange={() => {
|
|
1038
|
+
if (settingEditorTextareaRef.current?.plainText !== undefined) {
|
|
1039
|
+
setSettingEditorValue(settingEditorTextareaRef.current.plainText)
|
|
1040
|
+
}
|
|
1041
|
+
}}
|
|
1042
|
+
/>
|
|
1043
|
+
)}
|
|
1044
|
+
|
|
1045
|
+
<Toast message={toastMessage} visible={toastVisible} />
|
|
1046
|
+
</box>
|
|
1047
|
+
</ThemeProvider>
|
|
617
1048
|
)
|
|
618
1049
|
}
|