mux-sesh 1.4.1 → 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/README.md +123 -7
- package/package.json +3 -3
- package/src/app.tsx +746 -173
- package/src/components/KeybindHelp.tsx +178 -111
- package/src/config/index.ts +413 -20
- package/src/config/listed-sessions.ts +36 -0
- package/src/config/session-rules.ts +101 -0
- package/src/handlers/actions.ts +93 -6
- package/src/handlers/keyboard.ts +299 -79
- package/src/items/order.ts +50 -0
- package/src/opencode/session.ts +1 -17
- package/src/opencode/stats.ts +1 -1
- package/src/preview/project.ts +235 -0
- package/src/projects/session-links.ts +31 -0
- package/src/search/index.ts +83 -47
- 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/tmux/index.ts +58 -14
- package/src/tmux/projects.ts +151 -20
- package/src/tmux/workflows.ts +22 -0
- package/src/types/index.ts +114 -0
- package/src/ui/CommandsModal.tsx +145 -0
- package/src/ui/HighlightedText.tsx +6 -3
- package/src/ui/ItemList.tsx +47 -41
- package/src/ui/Modal.tsx +41 -0
- package/src/ui/OpencodeSessionGroup.tsx +50 -46
- 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 +168 -72
- package/src/ui/SessionList.tsx +59 -34
- 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 +78 -0
- package/src/ui/list-window.ts +22 -0
- package/src/update/installation.ts +4 -15
- package/src/update/version.ts +2 -1
- package/src/util/glob.ts +47 -0
- package/src/util/terminal.ts +6 -20
- package/src/styles/theme.ts +0 -50
package/src/handlers/actions.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { spawn } from 'bun'
|
|
2
2
|
import type { Item, Config } from '../types'
|
|
3
3
|
import {
|
|
4
4
|
switchTmuxSession,
|
|
@@ -6,16 +6,31 @@ import {
|
|
|
6
6
|
killTmuxSession,
|
|
7
7
|
renameTmuxSession,
|
|
8
8
|
createNamedTmuxSession,
|
|
9
|
+
getCurrentTmuxSessionName,
|
|
10
|
+
getTmuxSessionDirectory,
|
|
9
11
|
} from '../tmux/index'
|
|
12
|
+
import { getGitRoot, resolveProjectSession } from '../config/session-rules'
|
|
13
|
+
import { getLastSessionTarget } from '../tmux/workflows'
|
|
10
14
|
import { isGitHubURL, cloneGitHubRepo } from '../util/github'
|
|
11
15
|
import { requestShutdown } from '../util/shutdown'
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
function quoteShellArg(value: string): string {
|
|
18
|
+
return `'${value.replaceAll("'", "'\\''")}'`
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function handleSelect(item: Item, config: Config | null) {
|
|
14
22
|
if (item.isSession) {
|
|
15
23
|
await switchTmuxSession(item.title)
|
|
16
24
|
await requestShutdown(0)
|
|
17
25
|
} else {
|
|
18
|
-
|
|
26
|
+
if (!config) {
|
|
27
|
+
throw new Error('Config is not loaded yet')
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const resolvedSession = await resolveProjectSession(item.path, config)
|
|
31
|
+
await createTmuxSession(resolvedSession.sessionName, item.path, {
|
|
32
|
+
startupCommand: resolvedSession.startupCommand,
|
|
33
|
+
})
|
|
19
34
|
await requestShutdown(0)
|
|
20
35
|
}
|
|
21
36
|
}
|
|
@@ -70,18 +85,90 @@ export async function handleNewSessionSubmit(
|
|
|
70
85
|
try {
|
|
71
86
|
if (!config) return
|
|
72
87
|
const clonedPath = await cloneGitHubRepo(searchTerm, config)
|
|
73
|
-
const
|
|
74
|
-
await createTmuxSession(
|
|
88
|
+
const resolvedSession = await resolveProjectSession(clonedPath, config)
|
|
89
|
+
await createTmuxSession(resolvedSession.sessionName, clonedPath, {
|
|
90
|
+
startupCommand: resolvedSession.startupCommand,
|
|
91
|
+
})
|
|
75
92
|
await requestShutdown(0)
|
|
76
93
|
} catch (error) {
|
|
77
94
|
throw new Error(`Error cloning repository: ${error}`)
|
|
78
95
|
}
|
|
79
96
|
} else if (items.length > 0 && cursor < items.length) {
|
|
80
97
|
const selectedItem = items[cursor]
|
|
81
|
-
|
|
98
|
+
if (!config) {
|
|
99
|
+
throw new Error('Config is not loaded yet')
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const resolvedSession = await resolveProjectSession(selectedItem.path, config)
|
|
103
|
+
await createTmuxSession(resolvedSession.sessionName, selectedItem.path, {
|
|
104
|
+
startupCommand: resolvedSession.startupCommand,
|
|
105
|
+
})
|
|
82
106
|
await requestShutdown(0)
|
|
83
107
|
} else {
|
|
84
108
|
await createNamedTmuxSession(searchTerm)
|
|
85
109
|
await requestShutdown(0)
|
|
86
110
|
}
|
|
87
111
|
}
|
|
112
|
+
|
|
113
|
+
export async function handleLastSession(items: Item[]) {
|
|
114
|
+
const currentSessionName = await getCurrentTmuxSessionName().catch(() => undefined)
|
|
115
|
+
const target = getLastSessionTarget(items, currentSessionName)
|
|
116
|
+
|
|
117
|
+
if (!target) {
|
|
118
|
+
throw new Error('No previous tmux session is available')
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
await switchTmuxSession(target.title)
|
|
122
|
+
await requestShutdown(0)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export async function handleRootSession(item: Item | undefined, config: Config | null) {
|
|
126
|
+
if (!item) {
|
|
127
|
+
throw new Error('No session or project is selected')
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (!config) {
|
|
131
|
+
throw new Error('Config is not loaded yet')
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const itemPath = item.isSession ? await getTmuxSessionDirectory(item.title) : item.path
|
|
135
|
+
const rootPath = (await getGitRoot(itemPath)) ?? itemPath
|
|
136
|
+
const resolvedSession = await resolveProjectSession(rootPath, config)
|
|
137
|
+
|
|
138
|
+
await createTmuxSession(resolvedSession.sessionName, rootPath, {
|
|
139
|
+
startupCommand: resolvedSession.startupCommand,
|
|
140
|
+
})
|
|
141
|
+
await requestShutdown(0)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export async function handleEditTarget(item: Item | undefined, config: Config | null) {
|
|
145
|
+
if (!item || item.itemKind !== 'configured') {
|
|
146
|
+
throw new Error('Select a configured session to edit its target')
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (!config) {
|
|
150
|
+
throw new Error('Config is not loaded yet')
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const command = `${config.editor} ${quoteShellArg(item.path)}`
|
|
154
|
+
|
|
155
|
+
if (process.env.TMUX) {
|
|
156
|
+
const proc = spawn(['tmux', 'new-window', '-c', item.path, command], { stderr: 'pipe' })
|
|
157
|
+
await proc.exited
|
|
158
|
+
|
|
159
|
+
if (proc.exitCode !== 0) {
|
|
160
|
+
throw new Error(`Failed to open editor for '${item.title}'`)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
await requestShutdown(0)
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
spawn(['sh', '-lc', command], {
|
|
168
|
+
cwd: item.path,
|
|
169
|
+
stdin: 'inherit',
|
|
170
|
+
stdout: 'inherit',
|
|
171
|
+
stderr: 'inherit',
|
|
172
|
+
})
|
|
173
|
+
await requestShutdown(0)
|
|
174
|
+
}
|