mux-sesh 1.1.2 → 1.1.4
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 +24 -5
- package/package.json +1 -1
- package/src/app.tsx +30 -8
- package/src/styles/theme.ts +10 -6
- package/src/tmux/index.ts +1 -1
- package/src/ui/OpencodeStatsPanel.tsx +8 -1
- package/src/ui/SessionDetailsPanel.tsx +11 -4
- package/src/util/terminal.ts +42 -0
package/README.md
CHANGED
|
@@ -113,15 +113,34 @@ Configuration is stored at `~/.config/mux-sesh/config.json`:
|
|
|
113
113
|
}
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
-
|
|
117
116
|
### Configuration Options
|
|
118
117
|
|
|
119
|
-
- **`
|
|
120
|
-
- **`
|
|
118
|
+
- **`project_paths`** - Array of directories to scan for projects
|
|
119
|
+
- **`repos_path`** - Directory where GitHub repositories will be cloned
|
|
121
120
|
- **`editor`** - Default editor to use
|
|
122
|
-
- **`
|
|
121
|
+
- **`editor_cmd`** - Command to run when opening editor
|
|
123
122
|
- **`keybind_mode`** - alternative keybinds for those who do not want vim like binds
|
|
124
|
-
- **`start_in_search_mode`** -
|
|
123
|
+
- **`start_in_search_mode`** - Start in search mode by default
|
|
124
|
+
|
|
125
|
+
### tmux Integration
|
|
126
|
+
|
|
127
|
+
For the best experience, bind mux-sesh to a global tmux keybinding. Add this to your `~/.tmux.conf`:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Open mux-sesh in a popup with Alt+w (no prefix required)
|
|
131
|
+
bind-key -n M-w popup -E -w 62% -h 70% "mux-sesh"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
After adding the binding, reload your tmux config:
|
|
135
|
+
```bash
|
|
136
|
+
tmux source-file ~/.tmux.conf
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Now you can press `Alt+w` from anywhere in tmux (including inside nvim) to launch mux-sesh.
|
|
140
|
+
|
|
141
|
+
**Alternative Integration:**
|
|
142
|
+
- **From Neovim**: Use [mux-manager](https://github.com/quiet-ghost/mux-manager) - a Telescope-based tmux session manager that integrates directly into Neovim
|
|
143
|
+
- **With prefix**: Use `bind-key f popup -E -w 80% -h 80% "mux-sesh"` if you prefer requiring the tmux prefix key first
|
|
125
144
|
|
|
126
145
|
## Usage Examples
|
|
127
146
|
|
package/package.json
CHANGED
package/src/app.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import { isGitHubURL } from './util/github'
|
|
|
9
9
|
import { getOpencodeSessionStats } from './opencode'
|
|
10
10
|
import { formatSessionAge } from './util/time'
|
|
11
11
|
import { colors, sessionListStyle, sessionListStyleFull } from './styles/theme'
|
|
12
|
+
import { useTerminalSize, shouldShowDetailPanel } from './util/terminal'
|
|
12
13
|
import KeybindHelp from './components/KeybindHelp'
|
|
13
14
|
import OpencodeStatsPanel from './ui/OpencodeStatsPanel'
|
|
14
15
|
import SessionDetailsPanel from './ui/SessionDetailsPanel'
|
|
@@ -49,6 +50,7 @@ export function App() {
|
|
|
49
50
|
const textareaRef = useRef<any>(null)
|
|
50
51
|
const statsCache = useRef<Map<string, OpencodeSessionStats>>(new Map())
|
|
51
52
|
const [loadingStats, setLoadingStats] = useState(false)
|
|
53
|
+
const { columns } = useTerminalSize()
|
|
52
54
|
|
|
53
55
|
useEffect(() => {
|
|
54
56
|
async function init() {
|
|
@@ -276,16 +278,28 @@ export function App() {
|
|
|
276
278
|
|
|
277
279
|
const title =
|
|
278
280
|
appMode === AppMode.Search
|
|
279
|
-
? '
|
|
281
|
+
? ' Search Sessions'
|
|
280
282
|
: appMode === AppMode.NewSession
|
|
281
|
-
? '
|
|
283
|
+
? ' New Session'
|
|
282
284
|
: appMode === AppMode.Rename
|
|
283
285
|
? ' Rename Session'
|
|
284
286
|
: appMode === AppMode.OpencodeManage
|
|
285
|
-
? '
|
|
286
|
-
: '
|
|
287
|
-
|
|
288
|
-
const listStyle =
|
|
287
|
+
? ' Opencode Sessions'
|
|
288
|
+
: ' Tmux Session Manager'
|
|
289
|
+
|
|
290
|
+
const listStyle =
|
|
291
|
+
appMode === AppMode.NewSession
|
|
292
|
+
? {
|
|
293
|
+
...sessionListStyleFull,
|
|
294
|
+
flexGrow: 1,
|
|
295
|
+
flexShrink: 1,
|
|
296
|
+
}
|
|
297
|
+
: {
|
|
298
|
+
...sessionListStyle,
|
|
299
|
+
flexGrow: 1,
|
|
300
|
+
flexShrink: 1,
|
|
301
|
+
minWidth: 40,
|
|
302
|
+
}
|
|
289
303
|
|
|
290
304
|
const totalSessions =
|
|
291
305
|
viewMode === ViewMode.Sessions && appMode === AppMode.Normal ? items.length : 0
|
|
@@ -307,10 +321,11 @@ export function App() {
|
|
|
307
321
|
<box
|
|
308
322
|
style={{
|
|
309
323
|
flexDirection: 'row',
|
|
310
|
-
alignItems: '
|
|
324
|
+
alignItems: 'stretch',
|
|
311
325
|
justifyContent: 'center',
|
|
312
326
|
width: '100%',
|
|
313
327
|
height: '100%',
|
|
328
|
+
gap: 1,
|
|
314
329
|
}}
|
|
315
330
|
>
|
|
316
331
|
{/* Left panel - Session/Project list */}
|
|
@@ -389,6 +404,13 @@ export function App() {
|
|
|
389
404
|
{/* Message */}
|
|
390
405
|
{message && <text style={{ fg: colors.action, marginTop: 1 }}>{message}</text>}
|
|
391
406
|
|
|
407
|
+
{/* Terminal size warning */}
|
|
408
|
+
{columns < 80 && appMode !== AppMode.NewSession && (
|
|
409
|
+
<text style={{ fg: colors.inactive, marginTop: 1 }}>
|
|
410
|
+
Terminal too small. Resize for full view.
|
|
411
|
+
</text>
|
|
412
|
+
)}
|
|
413
|
+
|
|
392
414
|
{/* Keybind help */}
|
|
393
415
|
<box style={{ marginTop: 1, flexDirection: 'column' }}>
|
|
394
416
|
<KeybindHelp appMode={appMode} keybindMode={config?.keybindMode} />
|
|
@@ -396,7 +418,7 @@ export function App() {
|
|
|
396
418
|
</box>
|
|
397
419
|
|
|
398
420
|
{/* Right panel - Detail panel (only in non-new-session modes) */}
|
|
399
|
-
{appMode
|
|
421
|
+
{shouldShowDetailPanel(columns, appMode === AppMode.NewSession) && (
|
|
400
422
|
<>
|
|
401
423
|
{viewMode === ViewMode.Sessions && appMode === AppMode.OpencodeManage ? (
|
|
402
424
|
<OpencodeStatsPanel selectedItem={opencodeSessions[opencodeCursor]} />
|
package/src/styles/theme.ts
CHANGED
|
@@ -18,13 +18,17 @@ export const sessionListStyle = {
|
|
|
18
18
|
borderStyle: 'rounded' as const,
|
|
19
19
|
borderColor: colors.border,
|
|
20
20
|
padding: 0.3,
|
|
21
|
-
width:
|
|
22
|
-
height:
|
|
21
|
+
width: '50%' as const,
|
|
22
|
+
height: '100%' as const,
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export const sessionListStyleFull = {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
border: true,
|
|
27
|
+
borderStyle: 'rounded' as const,
|
|
28
|
+
borderColor: colors.border,
|
|
29
|
+
padding: 0.3,
|
|
30
|
+
width: '100%' as const,
|
|
31
|
+
height: '100%' as const,
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
export const detailPanelStyle = {
|
|
@@ -32,8 +36,8 @@ export const detailPanelStyle = {
|
|
|
32
36
|
borderStyle: 'rounded' as const,
|
|
33
37
|
borderColor: colors.border,
|
|
34
38
|
padding: 0.3,
|
|
35
|
-
width:
|
|
36
|
-
height:
|
|
39
|
+
width: '50%' as const,
|
|
40
|
+
height: '100%' as const,
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
export const selectedStyle = {
|
package/src/tmux/index.ts
CHANGED
|
@@ -144,7 +144,7 @@ export async function getSessionDetails(sessionName: string): Promise<SessionDet
|
|
|
144
144
|
const windows: WindowInfo[] = []
|
|
145
145
|
|
|
146
146
|
for (const line of windowLines) {
|
|
147
|
-
const [index, name] = line.split(':
|
|
147
|
+
const [index, name] = line.split(':')
|
|
148
148
|
|
|
149
149
|
// Get current directory
|
|
150
150
|
const dirProc = spawn([
|
|
@@ -29,8 +29,15 @@ export default function OpencodeStatsPanel({ selectedItem }: Props) {
|
|
|
29
29
|
: 0
|
|
30
30
|
const sessionCost = sessionStats?.sessionTotalCost || 0
|
|
31
31
|
|
|
32
|
+
const panelStyle = {
|
|
33
|
+
...detailPanelStyle,
|
|
34
|
+
flexGrow: 1,
|
|
35
|
+
flexShrink: 1,
|
|
36
|
+
minWidth: 40,
|
|
37
|
+
}
|
|
38
|
+
|
|
32
39
|
return (
|
|
33
|
-
<box style={
|
|
40
|
+
<box style={panelStyle}>
|
|
34
41
|
{/* Header */}
|
|
35
42
|
<box style={{ alignItems: 'center', justifyContent: 'center', marginBottom: 2 }}>
|
|
36
43
|
<text style={{ fg: colors.primary, marginBottom: 1 }}> OpenCode Stats</text>
|
|
@@ -23,9 +23,16 @@ export default function SessionDetailsPanel({ selectedItem }: Props) {
|
|
|
23
23
|
}
|
|
24
24
|
}, [selectedItem])
|
|
25
25
|
|
|
26
|
+
const panelStyle = {
|
|
27
|
+
...detailPanelStyle,
|
|
28
|
+
flexGrow: 1,
|
|
29
|
+
flexShrink: 1,
|
|
30
|
+
minWidth: 40,
|
|
31
|
+
}
|
|
32
|
+
|
|
26
33
|
if (!selectedItem?.isSession) {
|
|
27
34
|
return (
|
|
28
|
-
<box style={
|
|
35
|
+
<box style={panelStyle}>
|
|
29
36
|
<text style={{ fg: colors.primary, marginBottom: 1 }}>Details</text>
|
|
30
37
|
<text style={{ fg: colors.inactive }}>No session selected</text>
|
|
31
38
|
</box>
|
|
@@ -34,7 +41,7 @@ export default function SessionDetailsPanel({ selectedItem }: Props) {
|
|
|
34
41
|
|
|
35
42
|
if (loading) {
|
|
36
43
|
return (
|
|
37
|
-
<box style={
|
|
44
|
+
<box style={panelStyle}>
|
|
38
45
|
<text style={{ fg: colors.primary, marginBottom: 1 }}>{selectedItem.title}</text>
|
|
39
46
|
<text style={{ fg: colors.inactive }}>Loading...</text>
|
|
40
47
|
</box>
|
|
@@ -43,7 +50,7 @@ export default function SessionDetailsPanel({ selectedItem }: Props) {
|
|
|
43
50
|
|
|
44
51
|
if (!details) {
|
|
45
52
|
return (
|
|
46
|
-
<box style={
|
|
53
|
+
<box style={panelStyle}>
|
|
47
54
|
<text style={{ fg: colors.primary, marginBottom: 1 }}>{selectedItem.title}</text>
|
|
48
55
|
<text style={{ fg: colors.inactive }}>Unable to load session details</text>
|
|
49
56
|
</box>
|
|
@@ -51,7 +58,7 @@ export default function SessionDetailsPanel({ selectedItem }: Props) {
|
|
|
51
58
|
}
|
|
52
59
|
|
|
53
60
|
return (
|
|
54
|
-
<box style={
|
|
61
|
+
<box style={panelStyle}>
|
|
55
62
|
<box style={{ alignItems: 'center', justifyContent: 'center' }}>
|
|
56
63
|
<text style={{ fg: colors.primary, marginBottom: 1 }}>{details.name}</text>
|
|
57
64
|
</box>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
export interface TerminalSize {
|
|
4
|
+
columns: number
|
|
5
|
+
rows: number
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type LayoutMode = 'compact' | 'normal' | 'wide'
|
|
9
|
+
|
|
10
|
+
export function useTerminalSize(): TerminalSize {
|
|
11
|
+
const [size, setSize] = useState<TerminalSize>({
|
|
12
|
+
columns: process.stdout.columns || 80,
|
|
13
|
+
rows: process.stdout.rows || 24,
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const handler = () => {
|
|
18
|
+
setSize({
|
|
19
|
+
columns: process.stdout.columns || 80,
|
|
20
|
+
rows: process.stdout.rows || 24,
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
process.stdout.on('resize', handler)
|
|
25
|
+
return () => {
|
|
26
|
+
process.stdout.off('resize', handler)
|
|
27
|
+
}
|
|
28
|
+
}, [])
|
|
29
|
+
|
|
30
|
+
return size
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function getLayoutMode(columns: number): LayoutMode {
|
|
34
|
+
if (columns < 100) return 'compact'
|
|
35
|
+
if (columns < 150) return 'normal'
|
|
36
|
+
return 'wide'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function shouldShowDetailPanel(columns: number, isNewSessionMode: boolean): boolean {
|
|
40
|
+
if (isNewSessionMode) return false
|
|
41
|
+
return columns >= 80
|
|
42
|
+
}
|