mux-sesh 1.9.7 → 1.9.8
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "mux-sesh",
|
|
4
|
-
"version": "1.9.
|
|
4
|
+
"version": "1.9.8",
|
|
5
5
|
"description": "An OpenTUI manager for tmux sessions and Herdr workspaces with fuzzy project search",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"packageManager": "bun@1.3.14",
|
package/src/app/controller.ts
CHANGED
|
@@ -174,6 +174,10 @@ export function useAppController() {
|
|
|
174
174
|
showMessage,
|
|
175
175
|
refreshItems,
|
|
176
176
|
setPendingKillSessionName,
|
|
177
|
+
regularSessions,
|
|
178
|
+
rememberedSessions: (key: string | null) => {
|
|
179
|
+
lastSessionSelectionRef.current = key
|
|
180
|
+
},
|
|
177
181
|
}),
|
|
178
182
|
setPendingKillSessionName,
|
|
179
183
|
setRenameTarget,
|
|
@@ -213,6 +217,9 @@ export function useAppController() {
|
|
|
213
217
|
refreshItems,
|
|
214
218
|
agentCursor,
|
|
215
219
|
regularSessions,
|
|
220
|
+
rememberedSessions: (key: string | null) => {
|
|
221
|
+
lastSessionSelectionRef.current = key
|
|
222
|
+
},
|
|
216
223
|
agentSessions,
|
|
217
224
|
selectedPrimaryItem,
|
|
218
225
|
sessionCandidateItems,
|
package/src/app/handlers.ts
CHANGED
|
@@ -28,6 +28,8 @@ interface SharedHandlerOptions {
|
|
|
28
28
|
|
|
29
29
|
interface KillHandlerOptions extends SharedHandlerOptions {
|
|
30
30
|
setPendingKillSessionName: (sessionName: string | null) => void
|
|
31
|
+
regularSessions: Item[]
|
|
32
|
+
rememberedSessions: (key: string | null) => void
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
interface SettingsHandlerOptions {
|
|
@@ -53,6 +55,8 @@ export async function handleKillSessionWithFeedback(
|
|
|
53
55
|
onSuccess: msg => options.showMessage(msg),
|
|
54
56
|
onError: msg => options.showMessage(msg, 3000),
|
|
55
57
|
refreshItems: () => options.refreshItems(),
|
|
58
|
+
regularSessions: options.regularSessions,
|
|
59
|
+
rememberedSessions: options.rememberedSessions,
|
|
56
60
|
})
|
|
57
61
|
}
|
|
58
62
|
|
|
@@ -260,6 +264,7 @@ interface CreateAppHandlersOptions extends SharedHandlerOptions {
|
|
|
260
264
|
renamedValue: string
|
|
261
265
|
searchTerm: string
|
|
262
266
|
loadOpencodeStatsForSession: (sessionName: string) => Promise<OpencodeSessionStats | null>
|
|
267
|
+
rememberedSessions: (key: string | null) => void
|
|
263
268
|
}
|
|
264
269
|
|
|
265
270
|
export function createAppHandlers(options: CreateAppHandlersOptions) {
|
|
@@ -277,6 +282,8 @@ export function createAppHandlers(options: CreateAppHandlersOptions) {
|
|
|
277
282
|
await handleKillSessionWithFeedback(item, {
|
|
278
283
|
...sharedOptions,
|
|
279
284
|
setPendingKillSessionName: options.setPendingKillSessionName,
|
|
285
|
+
regularSessions: options.regularSessions,
|
|
286
|
+
rememberedSessions: options.rememberedSessions,
|
|
280
287
|
})
|
|
281
288
|
}
|
|
282
289
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dirname } from 'path'
|
|
2
2
|
import type { Config, Item } from '../types'
|
|
3
3
|
import type { MultiplexerBackend } from '../multiplexer'
|
|
4
|
-
import { getWorkspaceRef, isLiveSessionItem } from '../multiplexer/items'
|
|
4
|
+
import { getItemKey, getWorkspaceRef, isLiveSessionItem } from '../multiplexer/items'
|
|
5
5
|
import { getGitRoot, resolveProjectSession } from '../config/session-rules'
|
|
6
6
|
import { isFileItem, resolveFileSession } from '../files/target'
|
|
7
7
|
import { requestShutdown } from '../util/shutdown'
|
|
@@ -38,6 +38,14 @@ export function getNextSessionName(renameTarget: string, newName: string): strin
|
|
|
38
38
|
return trimmedName
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
export function getSessionSelectionAfterRemoval(
|
|
42
|
+
regularSessions: Item[],
|
|
43
|
+
removed: Item
|
|
44
|
+
): string | null {
|
|
45
|
+
const neighbor = regularSessions.find(session => session.title === removed.title)
|
|
46
|
+
return neighbor ? getItemKey(neighbor) : null
|
|
47
|
+
}
|
|
48
|
+
|
|
41
49
|
export async function openProjectSession(
|
|
42
50
|
projectPath: string,
|
|
43
51
|
config: Config,
|
package/src/handlers/actions.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spawn } from 'bun'
|
|
2
2
|
import type { Item, Config } from '../types'
|
|
3
3
|
import type { MultiplexerBackend } from '../multiplexer'
|
|
4
|
-
import { getWorkspaceRef, isLiveSessionItem } from '../multiplexer/items'
|
|
4
|
+
import { getItemKey, getWorkspaceRef, isLiveSessionItem } from '../multiplexer/items'
|
|
5
5
|
import { getLastSessionTarget } from '../tmux/workflows'
|
|
6
6
|
import { isFileItem, resolveTypedPathTarget } from '../files/target'
|
|
7
7
|
import { isGitHubURL, cloneGitHubRepo } from '../util/github'
|
|
@@ -31,6 +31,13 @@ export async function handleSelect(item: Item, config: Config | null, backend: M
|
|
|
31
31
|
await openProjectSession(item.path, requireConfig(config), backend)
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
function getKillNeighbor(item: Item, regularSessions: Item[]): Item | undefined {
|
|
35
|
+
const sessions = regularSessions.filter(isLiveSessionItem)
|
|
36
|
+
const index = sessions.findIndex(session => getItemKey(session) === getItemKey(item))
|
|
37
|
+
if (index < 0) return undefined
|
|
38
|
+
return sessions[index - 1] ?? sessions[index + 1]
|
|
39
|
+
}
|
|
40
|
+
|
|
34
41
|
export async function handleKillSession(
|
|
35
42
|
item: Item,
|
|
36
43
|
backend: MultiplexerBackend,
|
|
@@ -38,17 +45,47 @@ export async function handleKillSession(
|
|
|
38
45
|
onSuccess: (message: string) => void
|
|
39
46
|
onError: (message: string) => void
|
|
40
47
|
refreshItems: () => Promise<void>
|
|
48
|
+
regularSessions: Item[]
|
|
49
|
+
rememberedSessions: (key: string | null) => void
|
|
41
50
|
}
|
|
42
51
|
) {
|
|
52
|
+
let closed = false
|
|
53
|
+
|
|
43
54
|
try {
|
|
44
55
|
if (!isLiveSessionItem(item)) throw new Error('Select a live session to close')
|
|
45
|
-
|
|
56
|
+
|
|
57
|
+
const target = getWorkspaceRef(item)
|
|
58
|
+
const neighbor = getKillNeighbor(item, callbacks.regularSessions)
|
|
59
|
+
const prior = await backend.current().catch(() => undefined)
|
|
60
|
+
const wasCurrent = prior !== undefined && prior.id === target.id
|
|
61
|
+
|
|
62
|
+
await backend.close(target)
|
|
63
|
+
closed = true
|
|
64
|
+
|
|
65
|
+
callbacks.rememberedSessions(neighbor ? getItemKey(neighbor) : null)
|
|
66
|
+
|
|
67
|
+
if (!wasCurrent && prior) {
|
|
68
|
+
const now = await backend.current().catch(() => undefined)
|
|
69
|
+
if (!now || now.id !== prior.id) {
|
|
70
|
+
await backend.open(prior)
|
|
71
|
+
}
|
|
72
|
+
} else if (wasCurrent && neighbor && isLiveSessionItem(neighbor)) {
|
|
73
|
+
const preferred = getWorkspaceRef(neighbor)
|
|
74
|
+
const now = await backend.current().catch(() => undefined)
|
|
75
|
+
if (!now || now.id !== preferred.id) {
|
|
76
|
+
await backend.open(preferred)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
46
80
|
callbacks.onSuccess(
|
|
47
81
|
`${backend.kind === 'herdr' ? 'Workspace' : 'Session'} '${item.title}' closed`
|
|
48
82
|
)
|
|
49
|
-
await callbacks.refreshItems()
|
|
50
83
|
} catch (error) {
|
|
51
84
|
callbacks.onError(`Error killing session: ${error}`)
|
|
85
|
+
} finally {
|
|
86
|
+
if (closed) {
|
|
87
|
+
await callbacks.refreshItems().catch(() => {})
|
|
88
|
+
}
|
|
52
89
|
}
|
|
53
90
|
}
|
|
54
91
|
|