mux-sesh 1.9.4 → 1.9.5
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 +27 -9
- package/package.json +4 -2
- package/src/agents/session-name.ts +11 -2
- package/src/app/commands.ts +8 -8
- package/src/app/controller.ts +16 -4
- package/src/app/controls.ts +11 -9
- package/src/app/core-state.ts +5 -1
- package/src/app/data.ts +40 -5
- package/src/app/derived.ts +3 -3
- package/src/app/effects.ts +132 -15
- package/src/app/handlers.ts +42 -18
- package/src/app/keyboard.ts +3 -3
- package/src/app/modals.ts +8 -8
- package/src/app/runtime.ts +4 -1
- package/src/app/screen.tsx +11 -3
- package/src/app/state.ts +24 -4
- package/src/app/view.ts +17 -6
- package/src/config/index.ts +10 -0
- package/src/handlers/action-helpers.ts +22 -7
- package/src/handlers/actions.ts +51 -42
- package/src/handlers/keyboard/agents.ts +36 -14
- package/src/handlers/keyboard/new-session.ts +1 -1
- package/src/handlers/keyboard/normal.ts +8 -8
- package/src/handlers/keyboard/search.ts +6 -6
- package/src/handlers/keyboard/shared.ts +3 -3
- package/src/herdr/backend.ts +357 -0
- package/src/herdr/protocol.ts +268 -0
- package/src/items/order.ts +3 -7
- package/src/multiplexer/backend.ts +43 -0
- package/src/multiplexer/command.ts +48 -0
- package/src/multiplexer/index.ts +21 -0
- package/src/multiplexer/items.ts +66 -0
- package/src/multiplexer/resolve.ts +106 -0
- package/src/multiplexer/tmux-backend.ts +87 -0
- package/src/multiplexer/types.ts +93 -0
- package/src/opencode/session-name.ts +4 -2
- package/src/preview/project.ts +13 -11
- package/src/projects/session-links.ts +22 -4
- package/src/settings.ts +19 -0
- package/src/tmux/workflows.ts +5 -1
- package/src/types/index.ts +13 -1
- package/src/ui/AgentSessionGroup.tsx +25 -10
- package/src/ui/CommandsModal.tsx +15 -7
- package/src/ui/ItemList.tsx +3 -2
- package/src/ui/SessionDetailsPanel.tsx +68 -34
- package/src/ui/SessionList.tsx +23 -7
- package/src/ui/item-icon.ts +20 -7
- package/src/ui/session-meta.ts +10 -0
package/src/app/effects.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, type Dispatch, type MutableRefObject, type SetStateAction } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { isOpencodeSessionItem } from '../opencode/session-name'
|
|
3
3
|
import { checkAndUpdate, updateEvents } from '../update'
|
|
4
4
|
import { showTemporaryToast } from './notifications'
|
|
5
5
|
import { clearMatchIndices, filterAndSortItems } from '../search'
|
|
@@ -7,10 +7,15 @@ import { combineFileSearchResults, searchFilesAndDirectories, warmFileSearch } f
|
|
|
7
7
|
import { annotateProjectItemsWithSessionLinks } from '../projects/session-links'
|
|
8
8
|
import {
|
|
9
9
|
getProjectSelectionIndex,
|
|
10
|
+
getAgentSelectionIndex,
|
|
10
11
|
getSessionSelectionIndex,
|
|
11
12
|
loadSessionCandidateItems,
|
|
13
|
+
loadSessionItems,
|
|
14
|
+
reuseSessionItemIdentities,
|
|
12
15
|
} from './data'
|
|
13
16
|
import { AppMode, ViewMode, type Config, type Item } from '../types'
|
|
17
|
+
import type { MultiplexerBackend } from '../multiplexer'
|
|
18
|
+
import { getItemKey } from '../multiplexer/items'
|
|
14
19
|
import { clampCursorIndex } from '../ui/list-window'
|
|
15
20
|
import { isGitHubURL } from '../util/github'
|
|
16
21
|
import { measure } from '../util/perf'
|
|
@@ -120,6 +125,7 @@ export function useNewSessionProjectCursor(
|
|
|
120
125
|
export function useSessionCandidateLoader(
|
|
121
126
|
appMode: AppMode,
|
|
122
127
|
config: Config | null,
|
|
128
|
+
backend: MultiplexerBackend | null,
|
|
123
129
|
lastProjectSelectionRef: MutableRefObject<string | null>,
|
|
124
130
|
setSessionCandidateItems: Dispatch<SetStateAction<Item[]>>,
|
|
125
131
|
setAllItems: Dispatch<SetStateAction<Item[]>>,
|
|
@@ -127,15 +133,16 @@ export function useSessionCandidateLoader(
|
|
|
127
133
|
setCursor: Dispatch<SetStateAction<number>>
|
|
128
134
|
) {
|
|
129
135
|
useEffect(() => {
|
|
130
|
-
if (appMode !== AppMode.NewSession || !config) {
|
|
136
|
+
if (appMode !== AppMode.NewSession || !config || !backend) {
|
|
131
137
|
return
|
|
132
138
|
}
|
|
133
139
|
|
|
134
140
|
const nextConfig = config
|
|
141
|
+
const activeBackend = backend
|
|
135
142
|
let cancelled = false
|
|
136
143
|
|
|
137
144
|
async function loadCandidates() {
|
|
138
|
-
const linkedCandidates = await loadSessionCandidateItems(nextConfig, measure)
|
|
145
|
+
const linkedCandidates = await loadSessionCandidateItems(nextConfig, measure, activeBackend)
|
|
139
146
|
if (cancelled) {
|
|
140
147
|
return
|
|
141
148
|
}
|
|
@@ -153,6 +160,7 @@ export function useSessionCandidateLoader(
|
|
|
153
160
|
}
|
|
154
161
|
}, [
|
|
155
162
|
appMode,
|
|
163
|
+
backend,
|
|
156
164
|
config,
|
|
157
165
|
lastProjectSelectionRef,
|
|
158
166
|
setAllItems,
|
|
@@ -203,7 +211,7 @@ export function useSelectionMemory(
|
|
|
203
211
|
}
|
|
204
212
|
|
|
205
213
|
if (viewMode === ViewMode.Sessions && appMode === AppMode.Normal) {
|
|
206
|
-
lastSessionSelectionRef.current = selectedItem
|
|
214
|
+
lastSessionSelectionRef.current = getItemKey(selectedItem)
|
|
207
215
|
}
|
|
208
216
|
}, [
|
|
209
217
|
appMode,
|
|
@@ -231,14 +239,14 @@ export function usePendingKillReset(
|
|
|
231
239
|
return
|
|
232
240
|
}
|
|
233
241
|
|
|
234
|
-
const
|
|
242
|
+
const selectedSession =
|
|
235
243
|
appMode === AppMode.AgentsManage
|
|
236
|
-
? agentSessions[agentCursor]
|
|
244
|
+
? agentSessions[agentCursor]
|
|
237
245
|
: viewMode === ViewMode.Sessions
|
|
238
|
-
? regularSessions[cursor]
|
|
246
|
+
? regularSessions[cursor]
|
|
239
247
|
: undefined
|
|
240
248
|
|
|
241
|
-
if (
|
|
249
|
+
if (!selectedSession || getItemKey(selectedSession) !== pendingKillSessionName) {
|
|
242
250
|
setPendingKillSessionName(null)
|
|
243
251
|
}
|
|
244
252
|
}, [
|
|
@@ -334,33 +342,125 @@ export function useNewSessionFileSearch(
|
|
|
334
342
|
}
|
|
335
343
|
|
|
336
344
|
export function useOpencodeStatsPolling(
|
|
337
|
-
|
|
345
|
+
selectedAgentSession: Item | undefined,
|
|
338
346
|
loadOpencodeStatsForSession: (sessionName: string) => Promise<unknown>
|
|
339
347
|
) {
|
|
340
348
|
const loadStatsRef = useRef(loadOpencodeStatsForSession)
|
|
341
349
|
loadStatsRef.current = loadOpencodeStatsForSession
|
|
350
|
+
const selectedSessionName =
|
|
351
|
+
selectedAgentSession && isOpencodeSessionItem(selectedAgentSession)
|
|
352
|
+
? selectedAgentSession.title
|
|
353
|
+
: undefined
|
|
342
354
|
|
|
343
355
|
useEffect(() => {
|
|
344
|
-
if (!
|
|
356
|
+
if (!selectedSessionName) {
|
|
345
357
|
return
|
|
346
358
|
}
|
|
347
359
|
|
|
348
|
-
void loadStatsRef.current(
|
|
360
|
+
void loadStatsRef.current(selectedSessionName)
|
|
349
361
|
|
|
350
362
|
const interval = setInterval(() => {
|
|
351
|
-
void loadStatsRef.current(
|
|
363
|
+
void loadStatsRef.current(selectedSessionName)
|
|
352
364
|
}, 2000)
|
|
353
365
|
|
|
354
366
|
return () => {
|
|
355
367
|
clearInterval(interval)
|
|
356
368
|
}
|
|
357
|
-
}, [
|
|
369
|
+
}, [selectedSessionName])
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export function useHerdrAgentPolling(
|
|
373
|
+
appMode: AppMode,
|
|
374
|
+
viewMode: ViewMode,
|
|
375
|
+
config: Config | null,
|
|
376
|
+
backend: MultiplexerBackend | null,
|
|
377
|
+
selectedAgentSession: Item | undefined,
|
|
378
|
+
agentCursor: number,
|
|
379
|
+
setSessionItems: Dispatch<SetStateAction<Item[]>>,
|
|
380
|
+
setAllItems: Dispatch<SetStateAction<Item[]>>,
|
|
381
|
+
setItems: Dispatch<SetStateAction<Item[]>>,
|
|
382
|
+
setAgentCursor: Dispatch<SetStateAction<number>>,
|
|
383
|
+
setMessage: Dispatch<SetStateAction<string>>
|
|
384
|
+
) {
|
|
385
|
+
const selectedKeyRef = useRef<string | undefined>(undefined)
|
|
386
|
+
const agentCursorRef = useRef(agentCursor)
|
|
387
|
+
selectedKeyRef.current = selectedAgentSession ? getItemKey(selectedAgentSession) : undefined
|
|
388
|
+
agentCursorRef.current = agentCursor
|
|
389
|
+
|
|
390
|
+
useEffect(() => {
|
|
391
|
+
if (
|
|
392
|
+
appMode !== AppMode.AgentsManage ||
|
|
393
|
+
viewMode !== ViewMode.Sessions ||
|
|
394
|
+
!config ||
|
|
395
|
+
backend?.kind !== 'herdr'
|
|
396
|
+
) {
|
|
397
|
+
return
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
let cancelled = false
|
|
401
|
+
let polling = false
|
|
402
|
+
let reportedError: string | undefined
|
|
403
|
+
|
|
404
|
+
const poll = async () => {
|
|
405
|
+
if (polling) {
|
|
406
|
+
return
|
|
407
|
+
}
|
|
408
|
+
polling = true
|
|
409
|
+
try {
|
|
410
|
+
const { sessionItems } = await loadSessionItems(config, measure, backend, 'agents-poll')
|
|
411
|
+
if (cancelled) {
|
|
412
|
+
return
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
setSessionItems(current => reuseSessionItemIdentities(current, sessionItems))
|
|
416
|
+
setAllItems(current => reuseSessionItemIdentities(current, sessionItems))
|
|
417
|
+
setItems(current => reuseSessionItemIdentities(current, sessionItems))
|
|
418
|
+
setAgentCursor(
|
|
419
|
+
getAgentSelectionIndex(sessionItems, selectedKeyRef.current, agentCursorRef.current)
|
|
420
|
+
)
|
|
421
|
+
if (reportedError) {
|
|
422
|
+
const recoveredError = reportedError
|
|
423
|
+
setMessage(current => (current === recoveredError ? '' : current))
|
|
424
|
+
reportedError = undefined
|
|
425
|
+
}
|
|
426
|
+
} catch (error) {
|
|
427
|
+
if (!cancelled && !reportedError) {
|
|
428
|
+
reportedError = error instanceof Error ? error.message : 'Failed to refresh Herdr agents'
|
|
429
|
+
setMessage(reportedError)
|
|
430
|
+
}
|
|
431
|
+
} finally {
|
|
432
|
+
polling = false
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
void poll()
|
|
437
|
+
const interval = setInterval(() => void poll(), 2000)
|
|
438
|
+
return () => {
|
|
439
|
+
cancelled = true
|
|
440
|
+
clearInterval(interval)
|
|
441
|
+
if (reportedError) {
|
|
442
|
+
const abandonedError = reportedError
|
|
443
|
+
setMessage(current => (current === abandonedError ? '' : current))
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}, [
|
|
447
|
+
appMode,
|
|
448
|
+
backend,
|
|
449
|
+
config,
|
|
450
|
+
setAgentCursor,
|
|
451
|
+
setAllItems,
|
|
452
|
+
setItems,
|
|
453
|
+
setMessage,
|
|
454
|
+
setSessionItems,
|
|
455
|
+
viewMode,
|
|
456
|
+
])
|
|
358
457
|
}
|
|
359
458
|
|
|
360
459
|
interface UseAppBehaviorsOptions {
|
|
361
460
|
appMode: AppMode
|
|
362
461
|
viewMode: ViewMode
|
|
363
462
|
config: Config | null
|
|
463
|
+
backend: MultiplexerBackend | null
|
|
364
464
|
sessionItems: Item[]
|
|
365
465
|
projectSourceItems: Item[]
|
|
366
466
|
sessionCandidateItems: Item[]
|
|
@@ -368,7 +468,10 @@ interface UseAppBehaviorsOptions {
|
|
|
368
468
|
lastProjectSelectionRef: MutableRefObject<string | null>
|
|
369
469
|
setAllItems: Dispatch<SetStateAction<Item[]>>
|
|
370
470
|
setItems: Dispatch<SetStateAction<Item[]>>
|
|
471
|
+
setSessionItems: Dispatch<SetStateAction<Item[]>>
|
|
371
472
|
setCursor: Dispatch<SetStateAction<number>>
|
|
473
|
+
setAgentCursor: Dispatch<SetStateAction<number>>
|
|
474
|
+
setMessage: Dispatch<SetStateAction<string>>
|
|
372
475
|
setSessionCandidateItems: Dispatch<SetStateAction<Item[]>>
|
|
373
476
|
filteredCommandEntriesLength: number
|
|
374
477
|
setCommandsCursor: Dispatch<SetStateAction<number>>
|
|
@@ -387,7 +490,7 @@ interface UseAppBehaviorsOptions {
|
|
|
387
490
|
setPendingKillSessionName: Dispatch<SetStateAction<string | null>>
|
|
388
491
|
searchQuery: string
|
|
389
492
|
allItems: Item[]
|
|
390
|
-
|
|
493
|
+
selectedAgentSession: Item | undefined
|
|
391
494
|
loadOpencodeStatsForSession: (sessionName: string) => Promise<unknown>
|
|
392
495
|
setUpdatedVersion: Dispatch<SetStateAction<string | null>>
|
|
393
496
|
setToastMessage: Dispatch<SetStateAction<string>>
|
|
@@ -416,6 +519,7 @@ export function useAppBehaviors(options: UseAppBehaviorsOptions) {
|
|
|
416
519
|
useSessionCandidateLoader(
|
|
417
520
|
options.appMode,
|
|
418
521
|
options.config,
|
|
522
|
+
options.backend,
|
|
419
523
|
options.lastProjectSelectionRef,
|
|
420
524
|
options.setSessionCandidateItems,
|
|
421
525
|
options.setAllItems,
|
|
@@ -460,5 +564,18 @@ export function useAppBehaviors(options: UseAppBehaviorsOptions) {
|
|
|
460
564
|
options.setItems,
|
|
461
565
|
options.setCursor
|
|
462
566
|
)
|
|
463
|
-
useOpencodeStatsPolling(options.
|
|
567
|
+
useOpencodeStatsPolling(options.selectedAgentSession, options.loadOpencodeStatsForSession)
|
|
568
|
+
useHerdrAgentPolling(
|
|
569
|
+
options.appMode,
|
|
570
|
+
options.viewMode,
|
|
571
|
+
options.config,
|
|
572
|
+
options.backend,
|
|
573
|
+
options.selectedAgentSession,
|
|
574
|
+
options.agentCursor,
|
|
575
|
+
options.setSessionItems,
|
|
576
|
+
options.setAllItems,
|
|
577
|
+
options.setItems,
|
|
578
|
+
options.setAgentCursor,
|
|
579
|
+
options.setMessage
|
|
580
|
+
)
|
|
464
581
|
}
|
package/src/app/handlers.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { executeCommand as runCommand } from './commands'
|
|
|
2
2
|
import { persistConfigUpdate, runWithErrorMessage } from './operations'
|
|
3
3
|
import { AppMode, type Config, type Item, type OpencodeSessionStats, type ViewMode } from '../types'
|
|
4
4
|
import type { SettingsFieldId } from '../settings'
|
|
5
|
+
import type { MultiplexerBackend } from '../multiplexer'
|
|
5
6
|
import { applyEditorSetting, applyOptionSetting, getSettingEditorTitle } from '../settings'
|
|
6
7
|
import {
|
|
7
8
|
handleEditTarget as actionHandleEditTarget,
|
|
@@ -16,6 +17,7 @@ import {
|
|
|
16
17
|
type ShowMessage = (message: string, timeout?: number) => void
|
|
17
18
|
|
|
18
19
|
interface SharedHandlerOptions {
|
|
20
|
+
backend: MultiplexerBackend | null
|
|
19
21
|
config: Config | null
|
|
20
22
|
items: Item[]
|
|
21
23
|
sessionItems: Item[]
|
|
@@ -41,25 +43,33 @@ interface SettingsHandlerOptions {
|
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
export async function handleKillSessionWithFeedback(
|
|
44
|
-
|
|
46
|
+
item: Item,
|
|
45
47
|
options: KillHandlerOptions
|
|
46
48
|
): Promise<void> {
|
|
47
49
|
options.setPendingKillSessionName(null)
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
if (!options.backend) return
|
|
52
|
+
await actionHandleKillSession(item, options.backend, {
|
|
50
53
|
onSuccess: msg => options.showMessage(msg),
|
|
51
54
|
onError: msg => options.showMessage(msg, 3000),
|
|
52
55
|
refreshItems: () => options.refreshItems(),
|
|
53
56
|
})
|
|
54
57
|
}
|
|
55
58
|
|
|
56
|
-
export async function handleSelectItem(
|
|
57
|
-
|
|
59
|
+
export async function handleSelectItem(
|
|
60
|
+
item: Item,
|
|
61
|
+
config: Config | null,
|
|
62
|
+
backend: MultiplexerBackend | null
|
|
63
|
+
): Promise<void> {
|
|
64
|
+
if (!backend) return
|
|
65
|
+
await actionHandleSelect(item, config, backend)
|
|
58
66
|
}
|
|
59
67
|
|
|
60
68
|
export async function handleLastSessionWithFeedback(options: SharedHandlerOptions): Promise<void> {
|
|
69
|
+
if (!options.backend) return
|
|
70
|
+
const backend = options.backend
|
|
61
71
|
await runWithErrorMessage(
|
|
62
|
-
() => actionHandleLastSession(options.sessionItems),
|
|
72
|
+
() => actionHandleLastSession(options.sessionItems, backend),
|
|
63
73
|
'Failed to switch to the previous session',
|
|
64
74
|
options.showMessage
|
|
65
75
|
)
|
|
@@ -69,8 +79,10 @@ export async function handleRootSessionWithFeedback(
|
|
|
69
79
|
item: Item | undefined,
|
|
70
80
|
options: SharedHandlerOptions
|
|
71
81
|
): Promise<void> {
|
|
82
|
+
if (!options.backend) return
|
|
83
|
+
const backend = options.backend
|
|
72
84
|
await runWithErrorMessage(
|
|
73
|
-
() => actionHandleRootSession(item, options.config),
|
|
85
|
+
() => actionHandleRootSession(item, options.config, backend),
|
|
74
86
|
'Failed to open the root session',
|
|
75
87
|
options.showMessage
|
|
76
88
|
)
|
|
@@ -80,21 +92,23 @@ export async function handleEditTargetWithFeedback(
|
|
|
80
92
|
item: Item | undefined,
|
|
81
93
|
options: SharedHandlerOptions
|
|
82
94
|
): Promise<void> {
|
|
95
|
+
if (!options.backend) return
|
|
96
|
+
const backend = options.backend
|
|
83
97
|
await runWithErrorMessage(
|
|
84
|
-
() => actionHandleEditTarget(item, options.config),
|
|
98
|
+
() => actionHandleEditTarget(item, options.config, backend),
|
|
85
99
|
'Failed to edit target',
|
|
86
100
|
options.showMessage
|
|
87
101
|
)
|
|
88
102
|
}
|
|
89
103
|
|
|
90
104
|
export async function handleRenameSubmitWithFeedback(
|
|
91
|
-
renameTarget:
|
|
105
|
+
renameTarget: Item | null,
|
|
92
106
|
newName: string,
|
|
93
107
|
closeModal: () => void,
|
|
94
|
-
options: Pick<SharedHandlerOptions, 'showMessage' | 'refreshItems'>
|
|
108
|
+
options: Pick<SharedHandlerOptions, 'backend' | 'showMessage' | 'refreshItems'>
|
|
95
109
|
): Promise<void> {
|
|
96
|
-
if (newName && newName !== renameTarget) {
|
|
97
|
-
await actionHandleRenameSubmit(renameTarget, newName, {
|
|
110
|
+
if (renameTarget && newName && newName !== renameTarget.title && options.backend) {
|
|
111
|
+
await actionHandleRenameSubmit(renameTarget, newName, options.backend, {
|
|
98
112
|
onSuccess: msg => options.showMessage(msg),
|
|
99
113
|
onError: msg => options.showMessage(msg, 3000),
|
|
100
114
|
refreshItems: () => options.refreshItems(),
|
|
@@ -111,9 +125,18 @@ export async function handleNewSessionSubmitWithSearch(
|
|
|
111
125
|
if (!searchTerm) {
|
|
112
126
|
return
|
|
113
127
|
}
|
|
128
|
+
if (!options.backend) return
|
|
129
|
+
const backend = options.backend
|
|
114
130
|
|
|
115
131
|
await runWithErrorMessage(
|
|
116
|
-
() =>
|
|
132
|
+
() =>
|
|
133
|
+
actionHandleNewSessionSubmit(
|
|
134
|
+
searchTerm,
|
|
135
|
+
options.config,
|
|
136
|
+
options.items,
|
|
137
|
+
options.cursor,
|
|
138
|
+
backend
|
|
139
|
+
),
|
|
117
140
|
'Failed to create session',
|
|
118
141
|
options.showMessage
|
|
119
142
|
)
|
|
@@ -217,9 +240,9 @@ interface CreateAppHandlersOptions extends SharedHandlerOptions {
|
|
|
217
240
|
sessionCandidateItems: Item[]
|
|
218
241
|
projectSourceItems: Item[]
|
|
219
242
|
closeModal: () => void
|
|
220
|
-
openRenameModal: (
|
|
243
|
+
openRenameModal: (item: Item) => void
|
|
221
244
|
openSettingsModal: () => void
|
|
222
|
-
requestKillSession: (
|
|
245
|
+
requestKillSession: (item: Item) => void
|
|
223
246
|
setAppMode: (mode: AppMode) => void
|
|
224
247
|
setViewMode: (mode: ViewMode) => void
|
|
225
248
|
setAllItems: (items: Item[]) => void
|
|
@@ -233,7 +256,7 @@ interface CreateAppHandlersOptions extends SharedHandlerOptions {
|
|
|
233
256
|
setSettingEditorError: (message: string) => void
|
|
234
257
|
settingEditorValue: string
|
|
235
258
|
settingEditorPlainText?: string
|
|
236
|
-
renameTarget:
|
|
259
|
+
renameTarget: Item | null
|
|
237
260
|
renamedValue: string
|
|
238
261
|
searchTerm: string
|
|
239
262
|
loadOpencodeStatsForSession: (sessionName: string) => Promise<OpencodeSessionStats | null>
|
|
@@ -241,6 +264,7 @@ interface CreateAppHandlersOptions extends SharedHandlerOptions {
|
|
|
241
264
|
|
|
242
265
|
export function createAppHandlers(options: CreateAppHandlersOptions) {
|
|
243
266
|
const sharedOptions: SharedHandlerOptions = {
|
|
267
|
+
backend: options.backend,
|
|
244
268
|
config: options.config,
|
|
245
269
|
items: options.items,
|
|
246
270
|
sessionItems: options.sessionItems,
|
|
@@ -249,15 +273,15 @@ export function createAppHandlers(options: CreateAppHandlersOptions) {
|
|
|
249
273
|
refreshItems: options.refreshItems,
|
|
250
274
|
}
|
|
251
275
|
|
|
252
|
-
async function handleKillSessionWrapper(
|
|
253
|
-
await handleKillSessionWithFeedback(
|
|
276
|
+
async function handleKillSessionWrapper(item: Item) {
|
|
277
|
+
await handleKillSessionWithFeedback(item, {
|
|
254
278
|
...sharedOptions,
|
|
255
279
|
setPendingKillSessionName: options.setPendingKillSessionName,
|
|
256
280
|
})
|
|
257
281
|
}
|
|
258
282
|
|
|
259
283
|
async function handleSelectWrapper(item: Item) {
|
|
260
|
-
await handleSelectItem(item, options.config)
|
|
284
|
+
await handleSelectItem(item, options.config, options.backend)
|
|
261
285
|
}
|
|
262
286
|
|
|
263
287
|
async function handleLastSessionWrapper() {
|
package/src/app/keyboard.ts
CHANGED
|
@@ -51,14 +51,14 @@ interface UseAppKeyboardOptions {
|
|
|
51
51
|
openSettingEditor: (field: SettingsFieldId) => void
|
|
52
52
|
closeModal: () => void
|
|
53
53
|
clearPendingKill: () => void
|
|
54
|
-
requestKillSession: (
|
|
54
|
+
requestKillSession: (item: Item) => void
|
|
55
55
|
togglePinnedSession: (sessionName: string) => Promise<void>
|
|
56
|
-
openRenameModal: (
|
|
56
|
+
openRenameModal: (item: Item) => void
|
|
57
57
|
openCommandsModal: () => void
|
|
58
58
|
openSettingsModal: () => void
|
|
59
59
|
refreshItems: (forceViewMode?: ViewMode, nextConfig?: Config | null) => Promise<void>
|
|
60
60
|
handleSelect: (item: Item) => Promise<void>
|
|
61
|
-
handleKillSession: (
|
|
61
|
+
handleKillSession: (item: Item) => Promise<void>
|
|
62
62
|
handleLastSession: () => Promise<void>
|
|
63
63
|
handleRootSession: (item?: Item) => Promise<void>
|
|
64
64
|
handleEditTarget: (item?: Item) => Promise<void>
|
package/src/app/modals.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Dispatch, SetStateAction } from 'react'
|
|
2
2
|
import { getSettingEditorValue, type SettingsFieldId } from '../settings'
|
|
3
|
-
import type { Config } from '../types'
|
|
3
|
+
import type { Config, Item } from '../types'
|
|
4
4
|
|
|
5
5
|
export type ModalState =
|
|
6
6
|
| { type: 'rename'; target: string }
|
|
@@ -21,20 +21,20 @@ interface ModalSetters {
|
|
|
21
21
|
setSettingOptionsCursor: Dispatch<SetStateAction<number>>
|
|
22
22
|
setSettingEditorValue: Dispatch<SetStateAction<string>>
|
|
23
23
|
setSettingEditorError: Dispatch<SetStateAction<string>>
|
|
24
|
-
setRenameTarget: Dispatch<SetStateAction<
|
|
24
|
+
setRenameTarget: Dispatch<SetStateAction<Item | null>>
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export function openRenameModal(
|
|
28
|
-
|
|
28
|
+
item: Item,
|
|
29
29
|
clearPendingKill: () => void,
|
|
30
|
-
setRenameTarget: Dispatch<SetStateAction<
|
|
30
|
+
setRenameTarget: Dispatch<SetStateAction<Item | null>>,
|
|
31
31
|
setModalInputValue: Dispatch<SetStateAction<string>>,
|
|
32
32
|
setModalState: Dispatch<SetStateAction<ModalState>>
|
|
33
33
|
) {
|
|
34
34
|
clearPendingKill()
|
|
35
|
-
setRenameTarget(
|
|
36
|
-
setModalInputValue(
|
|
37
|
-
setModalState({ type: 'rename', target:
|
|
35
|
+
setRenameTarget(item)
|
|
36
|
+
setModalInputValue(item.title)
|
|
37
|
+
setModalState({ type: 'rename', target: item.title })
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export function openCommandsModal(
|
|
@@ -104,5 +104,5 @@ export function closeModal(setters: ModalSetters) {
|
|
|
104
104
|
setters.setSettingOptionsSearchQuery('')
|
|
105
105
|
setters.setSettingEditorValue('')
|
|
106
106
|
setters.setSettingEditorError('')
|
|
107
|
-
setters.setRenameTarget(
|
|
107
|
+
setters.setRenameTarget(null)
|
|
108
108
|
}
|
package/src/app/runtime.ts
CHANGED
|
@@ -4,9 +4,11 @@ import { applyOpencodeState, loadOpencodeSessionStats } from './opencode'
|
|
|
4
4
|
import { applyRefreshedViewState, loadRefreshedViewState } from './state'
|
|
5
5
|
import type { Measure } from './data'
|
|
6
6
|
import type { Config, Item, OpencodeSessionStats, OpencodeStatsState, ViewMode } from '../types'
|
|
7
|
+
import type { MultiplexerBackend } from '../multiplexer'
|
|
7
8
|
|
|
8
9
|
interface AppRuntimeOptions {
|
|
9
10
|
config: Config | null
|
|
11
|
+
backend: MultiplexerBackend | null
|
|
10
12
|
viewMode: ViewMode
|
|
11
13
|
measure: Measure
|
|
12
14
|
lastSessionSelectionRef: MutableRefObject<string | null>
|
|
@@ -36,7 +38,7 @@ export function createAppRuntime(options: AppRuntimeOptions) {
|
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
async function refreshItems(forceViewMode?: ViewMode, nextConfig = options.config) {
|
|
39
|
-
if (!nextConfig) {
|
|
41
|
+
if (!nextConfig || !options.backend) {
|
|
40
42
|
return
|
|
41
43
|
}
|
|
42
44
|
|
|
@@ -45,6 +47,7 @@ export function createAppRuntime(options: AppRuntimeOptions) {
|
|
|
45
47
|
targetMode,
|
|
46
48
|
nextConfig,
|
|
47
49
|
options.measure,
|
|
50
|
+
options.backend,
|
|
48
51
|
options.lastSessionSelectionRef.current,
|
|
49
52
|
options.lastProjectSelectionRef.current
|
|
50
53
|
)
|
package/src/app/screen.tsx
CHANGED
|
@@ -21,12 +21,14 @@ import SessionDetailsPanel from '../ui/SessionDetailsPanel'
|
|
|
21
21
|
import Toast from '../ui/Toast'
|
|
22
22
|
import VersionBadge, { formatVersionBadge } from '../ui/VersionBadge'
|
|
23
23
|
import { CURRENT_VERSION } from '../update/version'
|
|
24
|
+
import type { MultiplexerBackend } from '../multiplexer'
|
|
24
25
|
|
|
25
26
|
interface Props {
|
|
26
27
|
theme: ThemeColors
|
|
27
28
|
appMode: AppMode
|
|
28
29
|
viewMode: ViewMode
|
|
29
30
|
config: Config | null
|
|
31
|
+
backend: MultiplexerBackend | null
|
|
30
32
|
items: Item[]
|
|
31
33
|
regularSessions: Item[]
|
|
32
34
|
agentSessions: Item[]
|
|
@@ -53,6 +55,7 @@ export function AppScreen({
|
|
|
53
55
|
appMode,
|
|
54
56
|
viewMode,
|
|
55
57
|
config,
|
|
58
|
+
backend,
|
|
56
59
|
items,
|
|
57
60
|
regularSessions,
|
|
58
61
|
agentSessions,
|
|
@@ -73,7 +76,7 @@ export function AppScreen({
|
|
|
73
76
|
toastVisible,
|
|
74
77
|
updatedVersion,
|
|
75
78
|
}: Props) {
|
|
76
|
-
const title = getAppTitle(appMode, viewMode)
|
|
79
|
+
const title = getAppTitle(appMode, viewMode, backend?.kind)
|
|
77
80
|
const listStyle = getListStyle(theme, appMode)
|
|
78
81
|
const totalSessions = sessionItems.filter(item => item.isSession).length
|
|
79
82
|
const activeSessions = items.filter(item => item.isSession && item.isAttached).length
|
|
@@ -85,7 +88,7 @@ export function AppScreen({
|
|
|
85
88
|
appMode === AppMode.AgentsManage &&
|
|
86
89
|
selectedAgentSession !== undefined &&
|
|
87
90
|
isOpencodeSessionItem(selectedAgentSession)
|
|
88
|
-
const footerHint = getFooterHint(appMode, config?.prefixKey)
|
|
91
|
+
const footerHint = getFooterHint(appMode, config?.prefixKey, selectedPrimaryItem)
|
|
89
92
|
|
|
90
93
|
return (
|
|
91
94
|
<>
|
|
@@ -166,6 +169,7 @@ export function AppScreen({
|
|
|
166
169
|
sessions={agentSessions}
|
|
167
170
|
appMode={appMode}
|
|
168
171
|
cursor={agentCursor}
|
|
172
|
+
maxItems={maxVisibleItems}
|
|
169
173
|
icons={config?.icons}
|
|
170
174
|
pendingKillSessionName={pendingKillSessionName}
|
|
171
175
|
/>
|
|
@@ -188,7 +192,11 @@ export function AppScreen({
|
|
|
188
192
|
(showOpencodeStats ? (
|
|
189
193
|
<OpencodeStatsPanel selectedItem={selectedAgentSession} />
|
|
190
194
|
) : (
|
|
191
|
-
<SessionDetailsPanel
|
|
195
|
+
<SessionDetailsPanel
|
|
196
|
+
selectedItem={selectedPrimaryItem}
|
|
197
|
+
config={config}
|
|
198
|
+
backend={backend}
|
|
199
|
+
/>
|
|
192
200
|
))}
|
|
193
201
|
</box>
|
|
194
202
|
|
package/src/app/state.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useEffect, type Dispatch, type MutableRefObject, type SetStateAction } from 'react'
|
|
2
2
|
import { loadConfig } from '../config'
|
|
3
3
|
import { AppMode, ViewMode, type Config, type Item } from '../types'
|
|
4
|
+
import { resolveMultiplexerBackend, type MultiplexerBackend } from '../multiplexer'
|
|
4
5
|
import {
|
|
5
6
|
getProjectSelectionIndex,
|
|
6
7
|
getSessionSelectionIndex,
|
|
@@ -21,11 +22,12 @@ export async function loadRefreshedViewState(
|
|
|
21
22
|
targetMode: ViewMode,
|
|
22
23
|
config: Config,
|
|
23
24
|
measure: Measure,
|
|
25
|
+
backend: MultiplexerBackend,
|
|
24
26
|
lastSessionSelection?: string | null,
|
|
25
27
|
lastProjectSelection?: string | null
|
|
26
28
|
): Promise<RefreshedViewState> {
|
|
27
29
|
if (targetMode === ViewMode.Sessions) {
|
|
28
|
-
const { sessionItems } = await loadSessionItems(config, measure, 'refresh')
|
|
30
|
+
const { sessionItems } = await loadSessionItems(config, measure, backend, 'refresh')
|
|
29
31
|
return {
|
|
30
32
|
items: sessionItems,
|
|
31
33
|
sessionItems,
|
|
@@ -33,7 +35,7 @@ export async function loadRefreshedViewState(
|
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
const { visibleSessions } = await loadSessionItems(config, measure, 'refresh-projects')
|
|
38
|
+
const { visibleSessions } = await loadSessionItems(config, measure, backend, 'refresh-projects')
|
|
37
39
|
const { projectSourceItems, projectItems } = await loadProjectItemsWithLinks(
|
|
38
40
|
config,
|
|
39
41
|
visibleSessions,
|
|
@@ -74,6 +76,8 @@ export function useAppStartup(
|
|
|
74
76
|
lastProjectSelectionRef: MutableRefObject<string | null>,
|
|
75
77
|
mark: (label: string) => void,
|
|
76
78
|
setConfig: Dispatch<SetStateAction<Config | null>>,
|
|
79
|
+
setBackend: Dispatch<SetStateAction<MultiplexerBackend | null>>,
|
|
80
|
+
setMessage: Dispatch<SetStateAction<string>>,
|
|
77
81
|
setAppMode: Dispatch<SetStateAction<AppMode>>,
|
|
78
82
|
setViewMode: Dispatch<SetStateAction<ViewMode>>,
|
|
79
83
|
setSessionItems: Dispatch<SetStateAction<Item[]>>,
|
|
@@ -93,10 +97,20 @@ export function useAppStartup(
|
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
const startupAppMode = config.keybindMode === 'standard' ? AppMode.Search : AppMode.Normal
|
|
100
|
+
const backend = await measure('resolveBackend', () =>
|
|
101
|
+
resolveMultiplexerBackend({ preference: config.backend })
|
|
102
|
+
)
|
|
103
|
+
if (cancelled) return
|
|
96
104
|
setConfig(config)
|
|
105
|
+
setBackend(backend)
|
|
97
106
|
setAppMode(startupAppMode)
|
|
98
107
|
|
|
99
|
-
const { visibleSessions, sessionItems } = await loadSessionItems(
|
|
108
|
+
const { visibleSessions, sessionItems } = await loadSessionItems(
|
|
109
|
+
config,
|
|
110
|
+
measure,
|
|
111
|
+
backend,
|
|
112
|
+
'startup'
|
|
113
|
+
)
|
|
100
114
|
if (cancelled) {
|
|
101
115
|
return
|
|
102
116
|
}
|
|
@@ -136,7 +150,11 @@ export function useAppStartup(
|
|
|
136
150
|
mark('startup complete')
|
|
137
151
|
}
|
|
138
152
|
|
|
139
|
-
void init()
|
|
153
|
+
void init().catch(error => {
|
|
154
|
+
if (!cancelled) {
|
|
155
|
+
setMessage(error instanceof Error ? error.message : 'Failed to start mux-sesh')
|
|
156
|
+
}
|
|
157
|
+
})
|
|
140
158
|
|
|
141
159
|
return () => {
|
|
142
160
|
cancelled = true
|
|
@@ -149,6 +167,8 @@ export function useAppStartup(
|
|
|
149
167
|
setAllItems,
|
|
150
168
|
setAppMode,
|
|
151
169
|
setConfig,
|
|
170
|
+
setBackend,
|
|
171
|
+
setMessage,
|
|
152
172
|
setCursor,
|
|
153
173
|
setItems,
|
|
154
174
|
setProjectSourceItems,
|