mux-sesh 1.9.3 → 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/index.ts +1 -0
- package/src/agents/session-name.ts +24 -0
- package/src/app/commands.ts +20 -16
- package/src/app/controller.ts +30 -18
- package/src/app/controls.ts +11 -9
- package/src/app/core-state.ts +8 -4
- package/src/app/data.ts +42 -7
- package/src/app/derived.ts +11 -11
- package/src/app/effects.ts +141 -23
- package/src/app/handlers.ts +48 -24
- package/src/app/keyboard.ts +12 -12
- package/src/app/modals.ts +8 -8
- package/src/app/runtime.ts +4 -1
- package/src/app/screen.tsx +30 -15
- package/src/app/state.ts +24 -4
- package/src/app/view.ts +24 -13
- 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 +134 -0
- package/src/handlers/keyboard/index.ts +1 -1
- package/src/handlers/keyboard/new-session.ts +1 -1
- package/src/handlers/keyboard/normal.ts +12 -8
- package/src/handlers/keyboard/search.ts +10 -6
- package/src/handlers/keyboard/shared.ts +6 -6
- package/src/herdr/backend.ts +357 -0
- package/src/herdr/protocol.ts +268 -0
- package/src/items/order.ts +7 -11
- 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 +5 -4
- 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 +14 -2
- package/src/ui/{OpencodeSessionGroup.tsx → AgentSessionGroup.tsx} +27 -12
- package/src/ui/CommandsModal.tsx +18 -10
- 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 +24 -12
- package/src/ui/session-meta.ts +10 -0
- package/src/handlers/keyboard/opencode.ts +0 -105
package/src/app/effects.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, type Dispatch, type MutableRefObject, type SetStateAction } from 'react'
|
|
2
|
+
import { isOpencodeSessionItem } from '../opencode/session-name'
|
|
2
3
|
import { checkAndUpdate, updateEvents } from '../update'
|
|
3
4
|
import { showTemporaryToast } from './notifications'
|
|
4
5
|
import { clearMatchIndices, filterAndSortItems } from '../search'
|
|
@@ -6,10 +7,15 @@ import { combineFileSearchResults, searchFilesAndDirectories, warmFileSearch } f
|
|
|
6
7
|
import { annotateProjectItemsWithSessionLinks } from '../projects/session-links'
|
|
7
8
|
import {
|
|
8
9
|
getProjectSelectionIndex,
|
|
10
|
+
getAgentSelectionIndex,
|
|
9
11
|
getSessionSelectionIndex,
|
|
10
12
|
loadSessionCandidateItems,
|
|
13
|
+
loadSessionItems,
|
|
14
|
+
reuseSessionItemIdentities,
|
|
11
15
|
} from './data'
|
|
12
16
|
import { AppMode, ViewMode, type Config, type Item } from '../types'
|
|
17
|
+
import type { MultiplexerBackend } from '../multiplexer'
|
|
18
|
+
import { getItemKey } from '../multiplexer/items'
|
|
13
19
|
import { clampCursorIndex } from '../ui/list-window'
|
|
14
20
|
import { isGitHubURL } from '../util/github'
|
|
15
21
|
import { measure } from '../util/perf'
|
|
@@ -119,6 +125,7 @@ export function useNewSessionProjectCursor(
|
|
|
119
125
|
export function useSessionCandidateLoader(
|
|
120
126
|
appMode: AppMode,
|
|
121
127
|
config: Config | null,
|
|
128
|
+
backend: MultiplexerBackend | null,
|
|
122
129
|
lastProjectSelectionRef: MutableRefObject<string | null>,
|
|
123
130
|
setSessionCandidateItems: Dispatch<SetStateAction<Item[]>>,
|
|
124
131
|
setAllItems: Dispatch<SetStateAction<Item[]>>,
|
|
@@ -126,15 +133,16 @@ export function useSessionCandidateLoader(
|
|
|
126
133
|
setCursor: Dispatch<SetStateAction<number>>
|
|
127
134
|
) {
|
|
128
135
|
useEffect(() => {
|
|
129
|
-
if (appMode !== AppMode.NewSession || !config) {
|
|
136
|
+
if (appMode !== AppMode.NewSession || !config || !backend) {
|
|
130
137
|
return
|
|
131
138
|
}
|
|
132
139
|
|
|
133
140
|
const nextConfig = config
|
|
141
|
+
const activeBackend = backend
|
|
134
142
|
let cancelled = false
|
|
135
143
|
|
|
136
144
|
async function loadCandidates() {
|
|
137
|
-
const linkedCandidates = await loadSessionCandidateItems(nextConfig, measure)
|
|
145
|
+
const linkedCandidates = await loadSessionCandidateItems(nextConfig, measure, activeBackend)
|
|
138
146
|
if (cancelled) {
|
|
139
147
|
return
|
|
140
148
|
}
|
|
@@ -152,6 +160,7 @@ export function useSessionCandidateLoader(
|
|
|
152
160
|
}
|
|
153
161
|
}, [
|
|
154
162
|
appMode,
|
|
163
|
+
backend,
|
|
155
164
|
config,
|
|
156
165
|
lastProjectSelectionRef,
|
|
157
166
|
setAllItems,
|
|
@@ -202,7 +211,7 @@ export function useSelectionMemory(
|
|
|
202
211
|
}
|
|
203
212
|
|
|
204
213
|
if (viewMode === ViewMode.Sessions && appMode === AppMode.Normal) {
|
|
205
|
-
lastSessionSelectionRef.current = selectedItem
|
|
214
|
+
lastSessionSelectionRef.current = getItemKey(selectedItem)
|
|
206
215
|
}
|
|
207
216
|
}, [
|
|
208
217
|
appMode,
|
|
@@ -219,8 +228,8 @@ export function usePendingKillReset(
|
|
|
219
228
|
pendingKillSessionName: string | null,
|
|
220
229
|
appMode: AppMode,
|
|
221
230
|
viewMode: ViewMode,
|
|
222
|
-
|
|
223
|
-
|
|
231
|
+
agentSessions: Item[],
|
|
232
|
+
agentCursor: number,
|
|
224
233
|
regularSessions: Item[],
|
|
225
234
|
cursor: number,
|
|
226
235
|
setPendingKillSessionName: Dispatch<SetStateAction<string | null>>
|
|
@@ -230,21 +239,21 @@ export function usePendingKillReset(
|
|
|
230
239
|
return
|
|
231
240
|
}
|
|
232
241
|
|
|
233
|
-
const
|
|
234
|
-
appMode === AppMode.
|
|
235
|
-
?
|
|
242
|
+
const selectedSession =
|
|
243
|
+
appMode === AppMode.AgentsManage
|
|
244
|
+
? agentSessions[agentCursor]
|
|
236
245
|
: viewMode === ViewMode.Sessions
|
|
237
|
-
? regularSessions[cursor]
|
|
246
|
+
? regularSessions[cursor]
|
|
238
247
|
: undefined
|
|
239
248
|
|
|
240
|
-
if (
|
|
249
|
+
if (!selectedSession || getItemKey(selectedSession) !== pendingKillSessionName) {
|
|
241
250
|
setPendingKillSessionName(null)
|
|
242
251
|
}
|
|
243
252
|
}, [
|
|
244
253
|
appMode,
|
|
245
254
|
cursor,
|
|
246
|
-
|
|
247
|
-
|
|
255
|
+
agentCursor,
|
|
256
|
+
agentSessions,
|
|
248
257
|
pendingKillSessionName,
|
|
249
258
|
regularSessions,
|
|
250
259
|
setPendingKillSessionName,
|
|
@@ -333,33 +342,125 @@ export function useNewSessionFileSearch(
|
|
|
333
342
|
}
|
|
334
343
|
|
|
335
344
|
export function useOpencodeStatsPolling(
|
|
336
|
-
|
|
345
|
+
selectedAgentSession: Item | undefined,
|
|
337
346
|
loadOpencodeStatsForSession: (sessionName: string) => Promise<unknown>
|
|
338
347
|
) {
|
|
339
348
|
const loadStatsRef = useRef(loadOpencodeStatsForSession)
|
|
340
349
|
loadStatsRef.current = loadOpencodeStatsForSession
|
|
350
|
+
const selectedSessionName =
|
|
351
|
+
selectedAgentSession && isOpencodeSessionItem(selectedAgentSession)
|
|
352
|
+
? selectedAgentSession.title
|
|
353
|
+
: undefined
|
|
341
354
|
|
|
342
355
|
useEffect(() => {
|
|
343
|
-
if (!
|
|
356
|
+
if (!selectedSessionName) {
|
|
344
357
|
return
|
|
345
358
|
}
|
|
346
359
|
|
|
347
|
-
void loadStatsRef.current(
|
|
360
|
+
void loadStatsRef.current(selectedSessionName)
|
|
348
361
|
|
|
349
362
|
const interval = setInterval(() => {
|
|
350
|
-
void loadStatsRef.current(
|
|
363
|
+
void loadStatsRef.current(selectedSessionName)
|
|
351
364
|
}, 2000)
|
|
352
365
|
|
|
353
366
|
return () => {
|
|
354
367
|
clearInterval(interval)
|
|
355
368
|
}
|
|
356
|
-
}, [
|
|
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
|
+
])
|
|
357
457
|
}
|
|
358
458
|
|
|
359
459
|
interface UseAppBehaviorsOptions {
|
|
360
460
|
appMode: AppMode
|
|
361
461
|
viewMode: ViewMode
|
|
362
462
|
config: Config | null
|
|
463
|
+
backend: MultiplexerBackend | null
|
|
363
464
|
sessionItems: Item[]
|
|
364
465
|
projectSourceItems: Item[]
|
|
365
466
|
sessionCandidateItems: Item[]
|
|
@@ -367,7 +468,10 @@ interface UseAppBehaviorsOptions {
|
|
|
367
468
|
lastProjectSelectionRef: MutableRefObject<string | null>
|
|
368
469
|
setAllItems: Dispatch<SetStateAction<Item[]>>
|
|
369
470
|
setItems: Dispatch<SetStateAction<Item[]>>
|
|
471
|
+
setSessionItems: Dispatch<SetStateAction<Item[]>>
|
|
370
472
|
setCursor: Dispatch<SetStateAction<number>>
|
|
473
|
+
setAgentCursor: Dispatch<SetStateAction<number>>
|
|
474
|
+
setMessage: Dispatch<SetStateAction<string>>
|
|
371
475
|
setSessionCandidateItems: Dispatch<SetStateAction<Item[]>>
|
|
372
476
|
filteredCommandEntriesLength: number
|
|
373
477
|
setCommandsCursor: Dispatch<SetStateAction<number>>
|
|
@@ -380,13 +484,13 @@ interface UseAppBehaviorsOptions {
|
|
|
380
484
|
items: Item[]
|
|
381
485
|
selectedPrimaryItem: Item | undefined
|
|
382
486
|
pendingKillSessionName: string | null
|
|
383
|
-
|
|
384
|
-
|
|
487
|
+
agentSessions: Item[]
|
|
488
|
+
agentCursor: number
|
|
385
489
|
regularSessions: Item[]
|
|
386
490
|
setPendingKillSessionName: Dispatch<SetStateAction<string | null>>
|
|
387
491
|
searchQuery: string
|
|
388
492
|
allItems: Item[]
|
|
389
|
-
|
|
493
|
+
selectedAgentSession: Item | undefined
|
|
390
494
|
loadOpencodeStatsForSession: (sessionName: string) => Promise<unknown>
|
|
391
495
|
setUpdatedVersion: Dispatch<SetStateAction<string | null>>
|
|
392
496
|
setToastMessage: Dispatch<SetStateAction<string>>
|
|
@@ -415,6 +519,7 @@ export function useAppBehaviors(options: UseAppBehaviorsOptions) {
|
|
|
415
519
|
useSessionCandidateLoader(
|
|
416
520
|
options.appMode,
|
|
417
521
|
options.config,
|
|
522
|
+
options.backend,
|
|
418
523
|
options.lastProjectSelectionRef,
|
|
419
524
|
options.setSessionCandidateItems,
|
|
420
525
|
options.setAllItems,
|
|
@@ -438,8 +543,8 @@ export function useAppBehaviors(options: UseAppBehaviorsOptions) {
|
|
|
438
543
|
options.pendingKillSessionName,
|
|
439
544
|
options.appMode,
|
|
440
545
|
options.viewMode,
|
|
441
|
-
options.
|
|
442
|
-
options.
|
|
546
|
+
options.agentSessions,
|
|
547
|
+
options.agentCursor,
|
|
443
548
|
options.regularSessions,
|
|
444
549
|
options.cursor,
|
|
445
550
|
options.setPendingKillSessionName
|
|
@@ -459,5 +564,18 @@ export function useAppBehaviors(options: UseAppBehaviorsOptions) {
|
|
|
459
564
|
options.setItems,
|
|
460
565
|
options.setCursor
|
|
461
566
|
)
|
|
462
|
-
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
|
+
)
|
|
463
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
|
)
|
|
@@ -210,30 +233,30 @@ export async function executeAppCommand(
|
|
|
210
233
|
interface CreateAppHandlersOptions extends SharedHandlerOptions {
|
|
211
234
|
appMode: AppMode
|
|
212
235
|
viewMode: ViewMode
|
|
213
|
-
|
|
236
|
+
agentCursor: number
|
|
214
237
|
regularSessions: Item[]
|
|
215
|
-
|
|
238
|
+
agentSessions: Item[]
|
|
216
239
|
selectedPrimaryItem?: Item
|
|
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
|
|
226
249
|
setItems: (items: Item[]) => void
|
|
227
250
|
setCursor: (cursor: number) => void
|
|
228
251
|
setSearchQuery: (value: string) => void
|
|
229
|
-
|
|
252
|
+
setAgentCursor: (cursor: number) => void
|
|
230
253
|
setPendingKillSessionName: (sessionName: string | null) => void
|
|
231
254
|
saveConfig: (config: Config) => Promise<void>
|
|
232
255
|
setConfig: (config: Config) => void
|
|
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() {
|
|
@@ -330,9 +354,9 @@ export function createAppHandlers(options: CreateAppHandlersOptions) {
|
|
|
330
354
|
appMode: options.appMode,
|
|
331
355
|
viewMode: options.viewMode,
|
|
332
356
|
cursor: options.cursor,
|
|
333
|
-
|
|
357
|
+
agentCursor: options.agentCursor,
|
|
334
358
|
regularSessions: options.regularSessions,
|
|
335
|
-
|
|
359
|
+
agentSessions: options.agentSessions,
|
|
336
360
|
selectedPrimaryItem: options.selectedPrimaryItem,
|
|
337
361
|
sessionCandidateItems: options.sessionCandidateItems,
|
|
338
362
|
projectSourceItems: options.projectSourceItems,
|
|
@@ -347,7 +371,7 @@ export function createAppHandlers(options: CreateAppHandlersOptions) {
|
|
|
347
371
|
setItems: options.setItems,
|
|
348
372
|
setCursor: options.setCursor,
|
|
349
373
|
setSearchQuery: options.setSearchQuery,
|
|
350
|
-
|
|
374
|
+
setAgentCursor: options.setAgentCursor,
|
|
351
375
|
refreshItems: forceViewMode => options.refreshItems(forceViewMode),
|
|
352
376
|
handleLastSession: handleLastSessionWrapper,
|
|
353
377
|
handleRootSession: handleRootSessionWrapper,
|
package/src/app/keyboard.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { ModalState } from './modals'
|
|
|
5
5
|
import {
|
|
6
6
|
handleNewSessionMode,
|
|
7
7
|
handleNormalMode,
|
|
8
|
-
|
|
8
|
+
handleAgentsManageMode,
|
|
9
9
|
handleSearchMode,
|
|
10
10
|
type KeyboardHandlerContext,
|
|
11
11
|
} from '../handlers/keyboard'
|
|
@@ -20,12 +20,12 @@ interface UseAppKeyboardOptions {
|
|
|
20
20
|
config: Config | null
|
|
21
21
|
items: Item[]
|
|
22
22
|
regularSessions: Item[]
|
|
23
|
-
|
|
23
|
+
agentSessions: Item[]
|
|
24
24
|
sessionItems: Item[]
|
|
25
25
|
sessionCandidateItems: Item[]
|
|
26
26
|
projectSourceItems: Item[]
|
|
27
27
|
cursor: number
|
|
28
|
-
|
|
28
|
+
agentCursor: number
|
|
29
29
|
searchQuery: string
|
|
30
30
|
prefixActive: boolean
|
|
31
31
|
prefixTimeoutRef: MutableRefObject<NodeJS.Timeout | null>
|
|
@@ -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>
|
|
@@ -66,7 +66,7 @@ interface UseAppKeyboardOptions {
|
|
|
66
66
|
setAppMode: Dispatch<SetStateAction<AppMode>>
|
|
67
67
|
setViewMode: Dispatch<SetStateAction<ViewMode>>
|
|
68
68
|
setCursor: Dispatch<SetStateAction<number>>
|
|
69
|
-
|
|
69
|
+
setAgentCursor: Dispatch<SetStateAction<number>>
|
|
70
70
|
setSearchQuery: Dispatch<SetStateAction<string>>
|
|
71
71
|
setAllItems: Dispatch<SetStateAction<Item[]>>
|
|
72
72
|
setItems: Dispatch<SetStateAction<Item[]>>
|
|
@@ -80,9 +80,9 @@ export function useAppKeyboard(options: UseAppKeyboardOptions) {
|
|
|
80
80
|
viewMode: options.viewMode,
|
|
81
81
|
items: options.items,
|
|
82
82
|
regularSessions: options.regularSessions,
|
|
83
|
-
|
|
83
|
+
agentSessions: options.agentSessions,
|
|
84
84
|
cursor: options.cursor,
|
|
85
|
-
|
|
85
|
+
agentCursor: options.agentCursor,
|
|
86
86
|
searchQuery: options.searchQuery,
|
|
87
87
|
prefixKey: options.config?.prefixKey,
|
|
88
88
|
projectItems:
|
|
@@ -95,7 +95,7 @@ export function useAppKeyboard(options: UseAppKeyboardOptions) {
|
|
|
95
95
|
setAppMode: options.setAppMode,
|
|
96
96
|
setViewMode: options.setViewMode,
|
|
97
97
|
setCursor: options.setCursor,
|
|
98
|
-
|
|
98
|
+
setAgentCursor: options.setAgentCursor,
|
|
99
99
|
setSearchQuery: options.setSearchQuery,
|
|
100
100
|
setAllItems: options.setAllItems,
|
|
101
101
|
setItems: options.setItems,
|
|
@@ -156,8 +156,8 @@ export function useAppKeyboard(options: UseAppKeyboardOptions) {
|
|
|
156
156
|
} else {
|
|
157
157
|
handleNewSessionMode(key, keyboardContext, keybindMode)
|
|
158
158
|
}
|
|
159
|
-
} else if (options.appMode === AppMode.
|
|
160
|
-
|
|
159
|
+
} else if (options.appMode === AppMode.AgentsManage) {
|
|
160
|
+
handleAgentsManageMode(key, keyboardContext, keybindMode)
|
|
161
161
|
}
|
|
162
162
|
})
|
|
163
163
|
}
|
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
|
)
|