mux-sesh 1.6.4 → 1.7.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.
Files changed (78) hide show
  1. package/README.md +90 -59
  2. package/package.json +7 -5
  3. package/src/app/commands.ts +120 -0
  4. package/src/app/controller.ts +397 -0
  5. package/src/app/controls.ts +121 -0
  6. package/src/app/core-state.ts +71 -0
  7. package/src/app/data.ts +90 -0
  8. package/src/app/derived.ts +77 -0
  9. package/src/app/effects.ts +392 -0
  10. package/src/app/handlers.ts +325 -0
  11. package/src/app/keyboard.ts +161 -0
  12. package/src/app/modal-keyboard.ts +118 -0
  13. package/src/app/modal-state.ts +50 -0
  14. package/src/app/modals-layer.tsx +159 -0
  15. package/src/app/modals.ts +108 -0
  16. package/src/app/notifications.ts +21 -0
  17. package/src/app/opencode.ts +49 -0
  18. package/src/app/operations.ts +31 -0
  19. package/src/app/runtime.ts +76 -0
  20. package/src/app/screen.tsx +217 -0
  21. package/src/app/state.ts +166 -0
  22. package/src/app/textarea.ts +16 -0
  23. package/src/app/view.ts +89 -0
  24. package/src/app.tsx +7 -1136
  25. package/src/config/index.ts +36 -42
  26. package/src/config/paths.ts +13 -0
  27. package/src/config/session-rules.ts +6 -2
  28. package/src/config/store.ts +26 -0
  29. package/src/handlers/action-helpers.ts +50 -0
  30. package/src/handlers/actions.ts +34 -65
  31. package/src/handlers/keyboard/index.ts +5 -0
  32. package/src/handlers/keyboard/new-session.ts +57 -0
  33. package/src/handlers/keyboard/normal.ts +201 -0
  34. package/src/handlers/keyboard/opencode.ts +104 -0
  35. package/src/handlers/keyboard/search.ts +113 -0
  36. package/src/handlers/keyboard/shared.ts +116 -0
  37. package/src/opencode/sqlite.ts +21 -6
  38. package/src/preview/project.ts +41 -15
  39. package/src/search/index.ts +4 -1
  40. package/src/settings.ts +294 -297
  41. package/src/styles/opencode-themes-a.ts +1442 -1
  42. package/src/styles/opencode-themes-b.ts +1212 -1
  43. package/src/styles/opencode-tui-colors.ts +1784 -1
  44. package/src/styles/theme.tsx +2 -1
  45. package/src/tmux/actions.ts +103 -0
  46. package/src/tmux/details.ts +123 -0
  47. package/src/tmux/helpers.ts +35 -0
  48. package/src/tmux/index.ts +10 -288
  49. package/src/tmux/list.ts +31 -0
  50. package/src/tmux/project-discovery.ts +113 -0
  51. package/src/tmux/project-loader.ts +74 -0
  52. package/src/tmux/project-zoxide.ts +128 -0
  53. package/src/tmux/projects.ts +23 -262
  54. package/src/types/index.ts +0 -1
  55. package/src/ui/CommandsModal.tsx +87 -22
  56. package/src/ui/HighlightedText.tsx +1 -5
  57. package/src/ui/ItemList.tsx +14 -4
  58. package/src/ui/Modal.tsx +8 -1
  59. package/src/ui/OpencodeSessionGroup.tsx +20 -9
  60. package/src/ui/OpencodeStatsPanel.tsx +48 -15
  61. package/src/ui/RenameModal.tsx +17 -17
  62. package/src/ui/SearchInput.tsx +1 -20
  63. package/src/ui/SessionDetailsPanel.tsx +43 -15
  64. package/src/ui/SessionList.tsx +23 -6
  65. package/src/ui/SettingEditorModal.tsx +15 -9
  66. package/src/ui/SettingOptionsModal.tsx +30 -12
  67. package/src/ui/SettingsModal.tsx +20 -14
  68. package/src/ui/VersionBadge.tsx +3 -1
  69. package/src/ui/item-icon.ts +5 -1
  70. package/src/ui/list-window.ts +5 -1
  71. package/src/ui/use-textarea-focus.ts +26 -0
  72. package/src/update/index.ts +10 -2
  73. package/src/update/installation.ts +6 -2
  74. package/src/util/ansi.ts +3 -0
  75. package/src/util/glob.ts +5 -1
  76. package/src/components/KeybindHelp.tsx +0 -289
  77. package/src/handlers/keyboard.ts +0 -654
  78. package/src/ui/SessionStats.tsx +0 -32
@@ -59,7 +59,8 @@ function readableText(background: string) {
59
59
  return luminance(background) > 150 ? '#171717' : '#f5f5f5'
60
60
  }
61
61
 
62
- const EXACT_TUI_THEME_COLORS: Partial<Record<string, Record<'light' | 'dark', ThemeColors>>> = TUI_THEME_COLORS
62
+ const EXACT_TUI_THEME_COLORS: Partial<Record<string, Record<'light' | 'dark', ThemeColors>>> =
63
+ TUI_THEME_COLORS
63
64
 
64
65
  function mix(colorA: string, colorB: string, ratio: number) {
65
66
  const from = hexToRgb(colorA)
@@ -0,0 +1,103 @@
1
+ import { spawn } from 'bun'
2
+ import { sanitizeTmuxSessionName } from './helpers'
3
+
4
+ export interface CreateTmuxSessionOptions {
5
+ startupCommand?: string
6
+ }
7
+
8
+ async function isTmuxRunning(): Promise<boolean> {
9
+ const proc = spawn(['pgrep', 'tmux'])
10
+ await proc.exited
11
+ return proc.exitCode === 0
12
+ }
13
+
14
+ async function tmuxSessionExists(sessionName: string): Promise<boolean> {
15
+ const proc = spawn(['tmux', 'has-session', `-t=${sessionName}`])
16
+ await proc.exited
17
+ return proc.exitCode === 0
18
+ }
19
+
20
+ async function switchClient(sessionName: string): Promise<void> {
21
+ const proc = spawn(['tmux', 'switch-client', '-t', sessionName])
22
+ await proc.exited
23
+ }
24
+
25
+ export async function createTmuxSession(
26
+ name: string,
27
+ path: string,
28
+ options: CreateTmuxSessionOptions = {}
29
+ ): Promise<void> {
30
+ const sessionName = sanitizeTmuxSessionName(name)
31
+ const insideTmux = !!process.env.TMUX
32
+
33
+ if (!insideTmux && !(await isTmuxRunning())) {
34
+ const command = ['tmux', 'new-session', '-s', sessionName, '-c', path]
35
+ if (options.startupCommand) {
36
+ command.push(options.startupCommand)
37
+ }
38
+
39
+ const proc = spawn(command, {
40
+ stdin: 'inherit',
41
+ stdout: 'inherit',
42
+ stderr: 'inherit',
43
+ })
44
+ await proc.exited
45
+ return
46
+ }
47
+
48
+ if (!(await tmuxSessionExists(sessionName))) {
49
+ const createProc = spawn(['tmux', 'new-session', '-d', '-s', sessionName, '-c', path])
50
+ await createProc.exited
51
+
52
+ if (options.startupCommand) {
53
+ const startupProc = spawn([
54
+ 'tmux',
55
+ 'send-keys',
56
+ '-t',
57
+ sessionName,
58
+ options.startupCommand,
59
+ 'Enter',
60
+ ])
61
+ await startupProc.exited
62
+ }
63
+ }
64
+
65
+ await switchClient(sessionName)
66
+ }
67
+
68
+ export async function createNamedTmuxSession(name: string): Promise<void> {
69
+ const sessionName = sanitizeTmuxSessionName(name)
70
+ const insideTmux = !!process.env.TMUX
71
+
72
+ if (!insideTmux && !(await isTmuxRunning())) {
73
+ const proc = spawn(['tmux', 'new-session', '-s', sessionName], {
74
+ stdin: 'inherit',
75
+ stdout: 'inherit',
76
+ stderr: 'inherit',
77
+ })
78
+ await proc.exited
79
+ return
80
+ }
81
+
82
+ if (!(await tmuxSessionExists(sessionName))) {
83
+ const createProc = spawn(['tmux', 'new-session', '-d', '-s', sessionName])
84
+ await createProc.exited
85
+ }
86
+
87
+ await switchClient(sessionName)
88
+ }
89
+
90
+ export async function switchTmuxSession(name: string): Promise<void> {
91
+ await switchClient(name)
92
+ }
93
+
94
+ export async function killTmuxSession(name: string): Promise<void> {
95
+ const proc = spawn(['tmux', 'kill-session', '-t', name])
96
+ await proc.exited
97
+ }
98
+
99
+ export async function renameTmuxSession(oldName: string, newName: string): Promise<void> {
100
+ const sanitizedName = sanitizeTmuxSessionName(newName)
101
+ const proc = spawn(['tmux', 'rename-session', '-t', oldName, sanitizedName])
102
+ await proc.exited
103
+ }
@@ -0,0 +1,123 @@
1
+ import { spawn } from 'bun'
2
+ import type { SessionDetails, WindowInfo } from '../types'
3
+ import { formatPanePreview, formatWindowCommand, readTmuxValue } from './helpers'
4
+
5
+ const SESSION_DETAILS_CACHE_TTL_MS = 4000
6
+ const sessionDetailsCache = new Map<string, { details: SessionDetails; expiresAt: number }>()
7
+
8
+ export async function getCurrentTmuxSessionName(): Promise<string> {
9
+ return readTmuxValue(
10
+ ['tmux', 'display-message', '-p', '#S'],
11
+ 'Failed to resolve the current tmux session name'
12
+ )
13
+ }
14
+
15
+ export async function getTmuxSessionDirectory(sessionName: string): Promise<string> {
16
+ return readTmuxValue(
17
+ ['tmux', 'display-message', '-t', sessionName, '-p', '#{pane_current_path}'],
18
+ `Failed to resolve tmux directory for session '${sessionName}'`
19
+ )
20
+ }
21
+
22
+ export async function getSessionDetails(sessionName: string): Promise<SessionDetails> {
23
+ const cached = sessionDetailsCache.get(sessionName)
24
+ if (cached && cached.expiresAt > Date.now()) {
25
+ return cached.details
26
+ }
27
+
28
+ const statusProc = spawn([
29
+ 'tmux',
30
+ 'list-sessions',
31
+ '-F',
32
+ '#{session_name}:#{session_attached}:#{session_windows}',
33
+ '-f',
34
+ `#{==:#{session_name},${sessionName}}`,
35
+ ])
36
+ const statusOutput = await new Response(statusProc.stdout).text()
37
+ const [, attached, windowCount] = statusOutput.trim().split(':')
38
+
39
+ const windowsProc = spawn([
40
+ 'tmux',
41
+ 'list-windows',
42
+ '-t',
43
+ sessionName,
44
+ '-F',
45
+ '#{window_index}:#{window_name}',
46
+ ])
47
+ const windowsOutput = await new Response(windowsProc.stdout).text()
48
+ const windowLines = windowsOutput.trim().split('\n').filter(Boolean)
49
+
50
+ const windows: WindowInfo[] = []
51
+
52
+ for (const line of windowLines) {
53
+ const [index, name] = line.split(':')
54
+
55
+ const dirProc = spawn([
56
+ 'tmux',
57
+ 'display-message',
58
+ '-t',
59
+ `${sessionName}:${index}`,
60
+ '-p',
61
+ '#{pane_current_path}',
62
+ ])
63
+ const currentPath = (await new Response(dirProc.stdout).text()).trim()
64
+
65
+ const cmdProc = spawn([
66
+ 'tmux',
67
+ 'display-message',
68
+ '-t',
69
+ `${sessionName}:${index}`,
70
+ '-p',
71
+ '#{pane_current_command}',
72
+ ])
73
+ const currentCommand = (await new Response(cmdProc.stdout).text()).trim()
74
+
75
+ windows.push({
76
+ index,
77
+ name,
78
+ currentPath: currentPath.replace(process.env.HOME || '', '~'),
79
+ currentCommand: formatWindowCommand(currentCommand),
80
+ })
81
+ }
82
+
83
+ const activeWindowProc = spawn([
84
+ 'tmux',
85
+ 'display-message',
86
+ '-t',
87
+ sessionName,
88
+ '-p',
89
+ '#{window_index}',
90
+ ])
91
+ const activeWindowIndex = (await new Response(activeWindowProc.stdout).text()).trim()
92
+
93
+ let panePreviewLines: string[] | undefined
94
+ if (activeWindowIndex.length > 0) {
95
+ const paneProc = spawn([
96
+ 'tmux',
97
+ 'capture-pane',
98
+ '-p',
99
+ '-t',
100
+ `${sessionName}:${activeWindowIndex}`,
101
+ '-S',
102
+ '-16',
103
+ ])
104
+ const paneOutput = await new Response(paneProc.stdout).text()
105
+ const formatted = formatPanePreview(paneOutput)
106
+ panePreviewLines = formatted.length > 0 ? formatted : undefined
107
+ }
108
+
109
+ const details = {
110
+ name: sessionName,
111
+ isAttached: attached === '1',
112
+ windowCount,
113
+ windows,
114
+ panePreviewLines,
115
+ }
116
+
117
+ sessionDetailsCache.set(sessionName, {
118
+ details,
119
+ expiresAt: Date.now() + SESSION_DETAILS_CACHE_TTL_MS,
120
+ })
121
+
122
+ return details
123
+ }
@@ -0,0 +1,35 @@
1
+ import { stripAnsi } from '../util/ansi'
2
+
3
+ export function formatPanePreview(output: string): string[] {
4
+ return stripAnsi(output)
5
+ .replace(/\r/g, '')
6
+ .split('\n')
7
+ .map(line => line.trimEnd())
8
+ .filter(line => line.length > 0)
9
+ .slice(-8)
10
+ }
11
+
12
+ export function sanitizeTmuxSessionName(name: string): string {
13
+ return name.replace(/\./g, '_').replace(/ /g, '_')
14
+ }
15
+
16
+ export async function readTmuxValue(args: string[], errorMessage: string): Promise<string> {
17
+ const proc = Bun.spawn(args)
18
+ const output = await new Response(proc.stdout).text()
19
+ await proc.exited
20
+
21
+ if (proc.exitCode !== 0) {
22
+ throw new Error(errorMessage)
23
+ }
24
+
25
+ const value = output.trim()
26
+ if (!value) {
27
+ throw new Error(errorMessage)
28
+ }
29
+
30
+ return value
31
+ }
32
+
33
+ export function formatWindowCommand(currentCommand: string): string {
34
+ return ['bash', 'zsh', 'fish'].includes(currentCommand) ? '' : currentCommand
35
+ }
package/src/tmux/index.ts CHANGED
@@ -1,288 +1,10 @@
1
- import { spawn } from 'bun'
2
- import type { Item, SessionDetails, WindowInfo } from '../types'
3
- import { getLiveSessionGroupLabel } from '../util/path-display'
4
-
5
- const SESSION_DETAILS_CACHE_TTL_MS = 4000
6
- const sessionDetailsCache = new Map<string, { details: SessionDetails; expiresAt: number }>()
7
-
8
- function stripAnsi(value: string): string {
9
- return value.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, '')
10
- }
11
-
12
- function formatPanePreview(output: string): string[] {
13
- return stripAnsi(output)
14
- .replace(/\r/g, '')
15
- .split('\n')
16
- .map(line => line.trimEnd())
17
- .filter(line => line.length > 0)
18
- .slice(-8)
19
- }
20
-
21
- export interface CreateTmuxSessionOptions {
22
- startupCommand?: string
23
- }
24
-
25
- function sanitizeSessionName(name: string): string {
26
- return name.replace(/\./g, '_').replace(/ /g, '_')
27
- }
28
-
29
- async function readTmuxValue(args: string[], errorMessage: string): Promise<string> {
30
- const proc = spawn(args)
31
- const output = await new Response(proc.stdout).text()
32
- await proc.exited
33
-
34
- if (proc.exitCode !== 0) {
35
- throw new Error(errorMessage)
36
- }
37
-
38
- const value = output.trim()
39
- if (!value) {
40
- throw new Error(errorMessage)
41
- }
42
-
43
- return value
44
- }
45
-
46
- export async function listTmuxSessions(): Promise<Item[]> {
47
- const proc = spawn([
48
- 'tmux',
49
- 'list-sessions',
50
- '-F',
51
- '#{session_name}\t#{session_attached}\t#{session_windows}\t#{session_created}\t#{session_activity}\t#{session_path}',
52
- ])
53
-
54
- const output = await new Response(proc.stdout).text()
55
- const lines = output.trim().split('\n').filter(Boolean)
56
-
57
- const sessions = lines.map(line => {
58
- const [name, attached, windows, created, activity, sessionPath = ''] = line.split('\t')
59
-
60
- return {
61
- title: name,
62
- path: sessionPath,
63
- desc: getLiveSessionGroupLabel(sessionPath),
64
- isSession: true,
65
- itemKind: 'tmux' as const,
66
- isAttached: attached === '1',
67
- windowCount: windows,
68
- createdAt: parseInt(created, 10),
69
- lastActivity: parseInt(activity, 10),
70
- }
71
- })
72
-
73
- return sessions
74
- }
75
-
76
- export async function createTmuxSession(
77
- name: string,
78
- path: string,
79
- options: CreateTmuxSessionOptions = {}
80
- ): Promise<void> {
81
- const sessionName = sanitizeSessionName(name)
82
- const insideTmux = !!process.env.TMUX
83
-
84
- // Check if tmux is running
85
- const tmuxRunning = spawn(['pgrep', 'tmux'])
86
- await tmuxRunning.exited
87
- const isTmuxRunning = tmuxRunning.exitCode === 0
88
-
89
- if (!insideTmux && !isTmuxRunning) {
90
- const command = ['tmux', 'new-session', '-s', sessionName, '-c', path]
91
- if (options.startupCommand) {
92
- command.push(options.startupCommand)
93
- }
94
-
95
- const proc = spawn(command, {
96
- stdin: 'inherit',
97
- stdout: 'inherit',
98
- stderr: 'inherit',
99
- })
100
- await proc.exited
101
- return
102
- }
103
-
104
- const hasSession = spawn(['tmux', 'has-session', `-t=${sessionName}`])
105
- await hasSession.exited
106
-
107
- if (hasSession.exitCode !== 0) {
108
- const createProc = spawn(['tmux', 'new-session', '-d', '-s', sessionName, '-c', path])
109
- await createProc.exited
110
-
111
- if (options.startupCommand) {
112
- const startupProc = spawn(['tmux', 'send-keys', '-t', sessionName, options.startupCommand, 'Enter'])
113
- await startupProc.exited
114
- }
115
- }
116
-
117
- const switchProc = spawn(['tmux', 'switch-client', '-t', sessionName])
118
- await switchProc.exited
119
- }
120
-
121
- export async function createNamedTmuxSession(name: string): Promise<void> {
122
- const sessionName = sanitizeSessionName(name)
123
- const insideTmux = !!process.env.TMUX
124
-
125
- const tmuxRunning = spawn(['pgrep', 'tmux'])
126
- await tmuxRunning.exited
127
- const isTmuxRunning = tmuxRunning.exitCode === 0
128
-
129
- if (!insideTmux && !isTmuxRunning) {
130
- const proc = spawn(['tmux', 'new-session', '-s', sessionName], {
131
- stdin: 'inherit',
132
- stdout: 'inherit',
133
- stderr: 'inherit',
134
- })
135
- await proc.exited
136
- return
137
- }
138
-
139
- const hasSession = spawn(['tmux', 'has-session', `-t=${sessionName}`])
140
- await hasSession.exited
141
-
142
- if (hasSession.exitCode !== 0) {
143
- const createProc = spawn(['tmux', 'new-session', '-d', '-s', sessionName])
144
- await createProc.exited
145
- }
146
-
147
- const switchProc = spawn(['tmux', 'switch-client', '-t', sessionName])
148
- await switchProc.exited
149
- }
150
-
151
- export async function switchTmuxSession(name: string): Promise<void> {
152
- const proc = spawn(['tmux', 'switch-client', '-t', name])
153
- await proc.exited
154
- }
155
-
156
- export async function getCurrentTmuxSessionName(): Promise<string> {
157
- return readTmuxValue(
158
- ['tmux', 'display-message', '-p', '#S'],
159
- 'Failed to resolve the current tmux session name'
160
- )
161
- }
162
-
163
- export async function getTmuxSessionDirectory(sessionName: string): Promise<string> {
164
- return readTmuxValue(
165
- ['tmux', 'display-message', '-t', sessionName, '-p', '#{pane_current_path}'],
166
- `Failed to resolve tmux directory for session '${sessionName}'`
167
- )
168
- }
169
-
170
- export async function killTmuxSession(name: string): Promise<void> {
171
- const proc = spawn(['tmux', 'kill-session', '-t', name])
172
- await proc.exited
173
- }
174
-
175
- export async function renameTmuxSession(oldName: string, newName: string): Promise<void> {
176
- const sanitizedName = sanitizeSessionName(newName)
177
- const proc = spawn(['tmux', 'rename-session', '-t', oldName, sanitizedName])
178
- await proc.exited
179
- }
180
-
181
- export async function getSessionDetails(sessionName: string): Promise<SessionDetails> {
182
- const cached = sessionDetailsCache.get(sessionName)
183
- if (cached && cached.expiresAt > Date.now()) {
184
- return cached.details
185
- }
186
-
187
- // Get session status
188
- const statusProc = spawn([
189
- 'tmux',
190
- 'list-sessions',
191
- '-F',
192
- '#{session_name}:#{session_attached}:#{session_windows}',
193
- '-f',
194
- `#{==:#{session_name},${sessionName}}`,
195
- ])
196
- const statusOutput = await new Response(statusProc.stdout).text()
197
- const [, attached, windowCount] = statusOutput.trim().split(':')
198
-
199
- // Get windows
200
- const windowsProc = spawn([
201
- 'tmux',
202
- 'list-windows',
203
- '-t',
204
- sessionName,
205
- '-F',
206
- '#{window_index}:#{window_name}',
207
- ])
208
- const windowsOutput = await new Response(windowsProc.stdout).text()
209
- const windowLines = windowsOutput.trim().split('\n').filter(Boolean)
210
-
211
- const windows: WindowInfo[] = []
212
-
213
- for (const line of windowLines) {
214
- const [index, name] = line.split(':')
215
-
216
- // Get current directory
217
- const dirProc = spawn([
218
- 'tmux',
219
- 'display-message',
220
- '-t',
221
- `${sessionName}:${index}`,
222
- '-p',
223
- '#{pane_current_path}',
224
- ])
225
- const currentPath = (await new Response(dirProc.stdout).text()).trim()
226
-
227
- // Get current command
228
- const cmdProc = spawn([
229
- 'tmux',
230
- 'display-message',
231
- '-t',
232
- `${sessionName}:${index}`,
233
- '-p',
234
- '#{pane_current_command}',
235
- ])
236
- const currentCommand = (await new Response(cmdProc.stdout).text()).trim()
237
-
238
- const displayPath = currentPath.replace(process.env.HOME || '', '~')
239
-
240
- windows.push({
241
- index,
242
- name,
243
- currentPath: displayPath,
244
- currentCommand: ['bash', 'zsh', 'fish'].includes(currentCommand) ? '' : currentCommand,
245
- })
246
- }
247
-
248
- const activeWindowProc = spawn([
249
- 'tmux',
250
- 'display-message',
251
- '-t',
252
- sessionName,
253
- '-p',
254
- '#{window_index}',
255
- ])
256
- const activeWindowIndex = (await new Response(activeWindowProc.stdout).text()).trim()
257
-
258
- let panePreviewLines: string[] | undefined
259
- if (activeWindowIndex.length > 0) {
260
- const paneProc = spawn([
261
- 'tmux',
262
- 'capture-pane',
263
- '-p',
264
- '-t',
265
- `${sessionName}:${activeWindowIndex}`,
266
- '-S',
267
- '-16',
268
- ])
269
- const paneOutput = await new Response(paneProc.stdout).text()
270
- const formatted = formatPanePreview(paneOutput)
271
- panePreviewLines = formatted.length > 0 ? formatted : undefined
272
- }
273
-
274
- const details = {
275
- name: sessionName,
276
- isAttached: attached === '1',
277
- windowCount,
278
- windows,
279
- panePreviewLines,
280
- }
281
-
282
- sessionDetailsCache.set(sessionName, {
283
- details,
284
- expiresAt: Date.now() + SESSION_DETAILS_CACHE_TTL_MS,
285
- })
286
-
287
- return details
288
- }
1
+ export {
2
+ createNamedTmuxSession,
3
+ createTmuxSession,
4
+ killTmuxSession,
5
+ renameTmuxSession,
6
+ switchTmuxSession,
7
+ } from './actions'
8
+ export type { CreateTmuxSessionOptions } from './actions'
9
+ export { getCurrentTmuxSessionName, getSessionDetails, getTmuxSessionDirectory } from './details'
10
+ export { listTmuxSessions } from './list'
@@ -0,0 +1,31 @@
1
+ import { spawn } from 'bun'
2
+ import type { Item } from '../types'
3
+ import { getLiveSessionGroupLabel } from '../util/path-display'
4
+
5
+ export async function listTmuxSessions(): Promise<Item[]> {
6
+ const proc = spawn([
7
+ 'tmux',
8
+ 'list-sessions',
9
+ '-F',
10
+ '#{session_name}\t#{session_attached}\t#{session_windows}\t#{session_created}\t#{session_activity}\t#{session_path}',
11
+ ])
12
+
13
+ const output = await new Response(proc.stdout).text()
14
+ const lines = output.trim().split('\n').filter(Boolean)
15
+
16
+ return lines.map(line => {
17
+ const [name, attached, windows, created, activity, sessionPath = ''] = line.split('\t')
18
+
19
+ return {
20
+ title: name,
21
+ path: sessionPath,
22
+ desc: getLiveSessionGroupLabel(sessionPath),
23
+ isSession: true,
24
+ itemKind: 'tmux' as const,
25
+ isAttached: attached === '1',
26
+ windowCount: windows,
27
+ createdAt: parseInt(created, 10),
28
+ lastActivity: parseInt(activity, 10),
29
+ }
30
+ })
31
+ }