mux-sesh 1.4.1 → 1.5.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 +176 -34
- package/src/components/KeybindHelp.tsx +48 -2
- package/src/config/index.ts +206 -19
- 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 +114 -64
- 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/tmux/index.ts +58 -14
- package/src/tmux/projects.ts +151 -20
- package/src/tmux/workflows.ts +22 -0
- package/src/types/index.ts +49 -0
- package/src/ui/ItemList.tsx +21 -14
- package/src/ui/OpencodeSessionGroup.tsx +48 -42
- package/src/ui/SessionDetailsPanel.tsx +179 -45
- package/src/ui/SessionList.tsx +67 -33
- package/src/ui/item-icon.ts +77 -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/README.md
CHANGED
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
- **Beautiful UI** - Catppuccin-themed interface
|
|
14
14
|
- **Vim keybindings** - Navigate with j/k or arrow keys
|
|
15
15
|
- **Project scanning** - Browse and create sessions from local directories
|
|
16
|
+
- **Config-driven sessions** - Exact project rules, wildcard rules, and listed config targets
|
|
17
|
+
- **Session-aware project picker** - See when a project will attach to an existing tmux session vs create a new one
|
|
18
|
+
- **Rich previews** - Preview commands with directory fallback and live tmux context for running projects
|
|
16
19
|
- **GitHub integration** - Clone repos directly from URLs
|
|
17
20
|
- **Quick select** - Use number keys (1-9) for instant switching
|
|
18
21
|
- **Session management** - Create, switch, kill, and rename sessions
|
|
@@ -76,11 +79,29 @@ cp dist/mux-sesh ~/.local/bin/
|
|
|
76
79
|
| `n` | Create new session |
|
|
77
80
|
| `d` | Kill selected session |
|
|
78
81
|
| `r` | Rename selected session |
|
|
82
|
+
| `l` | Jump to previous tmux session |
|
|
83
|
+
| `g` | Open the git-root session for the selected item |
|
|
84
|
+
| `e` | Edit configured session target |
|
|
79
85
|
| `R` | Refresh list |
|
|
80
86
|
| `s` | Switch to sessions view |
|
|
81
87
|
| `p` | Switch to projects view |
|
|
82
88
|
| `q` or `Esc` | Quit |
|
|
83
89
|
|
|
90
|
+
### Standard Mode
|
|
91
|
+
| Key | Action |
|
|
92
|
+
|-----|--------|
|
|
93
|
+
| `↑` / `↓` | Navigate |
|
|
94
|
+
| `Ctrl+I` | Search |
|
|
95
|
+
| `Ctrl+N` | New session |
|
|
96
|
+
| `Ctrl+D` | Kill selected live session |
|
|
97
|
+
| `Ctrl+R` | Rename selected live session |
|
|
98
|
+
| `Ctrl+L` | Jump to previous tmux session |
|
|
99
|
+
| `Ctrl+G` | Open the git-root session for the selected item |
|
|
100
|
+
| `Ctrl+E` | Edit configured session target |
|
|
101
|
+
| `Ctrl+Q` | Quit |
|
|
102
|
+
|
|
103
|
+
In search/new/rename mode, standard mode also supports `Ctrl+X` prefix commands for refresh, rename, kill, root, and opencode actions.
|
|
104
|
+
|
|
84
105
|
### Search Mode
|
|
85
106
|
| Key | Action |
|
|
86
107
|
|-----|--------|
|
|
@@ -104,12 +125,40 @@ Configuration is stored at `~/.config/mux-sesh/config.json`:
|
|
|
104
125
|
|
|
105
126
|
```json
|
|
106
127
|
{
|
|
107
|
-
"project_paths": ["~/dev", "~/personal", "~/work"],
|
|
128
|
+
"project_paths": ["~/dev", "~/personal", "~/work", "~/projects"],
|
|
108
129
|
"repos_path": "~/dev/repos",
|
|
109
130
|
"editor": "nvim",
|
|
110
131
|
"editor_cmd": "nvim -c \"lua vim.defer_fn(function() if pcall(require, 'telescope') then vim.cmd('Telescope find_files') end end, 100)\"",
|
|
111
|
-
"keybind_mode": "vim",
|
|
112
|
-
"
|
|
132
|
+
"keybind_mode": "vim",
|
|
133
|
+
"sort_order": "zoxide-first",
|
|
134
|
+
"zoxide_mode": "rank",
|
|
135
|
+
"dir_length": 2,
|
|
136
|
+
"hidden_sessions": ["scratch", "tmp*"],
|
|
137
|
+
"icons": {
|
|
138
|
+
"tmux": "",
|
|
139
|
+
"configured": "",
|
|
140
|
+
"project": "",
|
|
141
|
+
"opencode": ""
|
|
142
|
+
},
|
|
143
|
+
"default_session": {
|
|
144
|
+
"startup_command": "nvim",
|
|
145
|
+
"preview_command": "eza --all {}"
|
|
146
|
+
},
|
|
147
|
+
"projects": [
|
|
148
|
+
{
|
|
149
|
+
"path": "~/.dotfiles/hypr/.config/hypr",
|
|
150
|
+
"session_name": "hyprland",
|
|
151
|
+
"listed": true,
|
|
152
|
+
"icon": "",
|
|
153
|
+
"startup_command": "nvim"
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
"wildcards": [
|
|
157
|
+
{
|
|
158
|
+
"pattern": "~/work/**",
|
|
159
|
+
"startup_command": "bun run dev"
|
|
160
|
+
}
|
|
161
|
+
]
|
|
113
162
|
}
|
|
114
163
|
```
|
|
115
164
|
|
|
@@ -118,9 +167,66 @@ Configuration is stored at `~/.config/mux-sesh/config.json`:
|
|
|
118
167
|
- **`project_paths`** - Array of directories to scan for projects
|
|
119
168
|
- **`repos_path`** - Directory where GitHub repositories will be cloned
|
|
120
169
|
- **`editor`** - Default editor to use
|
|
121
|
-
- **`editor_cmd`** -
|
|
122
|
-
- **`keybind_mode`** -
|
|
123
|
-
- **`
|
|
170
|
+
- **`editor_cmd`** - Default startup command for new sessions unless overridden
|
|
171
|
+
- **`keybind_mode`** - `vim` or `standard`
|
|
172
|
+
- **`sort_order`** - Session/project ordering: `live-first`, `configured-first`, `zoxide-first`, or `alphabetical`
|
|
173
|
+
- **`zoxide_mode`** - `off`, `rank`, or `merge` for zoxide-aware project ordering
|
|
174
|
+
- **`dir_length`** - Number of path segments used when generating session names from git roots or project paths
|
|
175
|
+
- **`hidden_sessions`** - Glob patterns for live tmux sessions to hide from the list
|
|
176
|
+
- **`icons`** - Global icons for tmux, configured, project, and opencode rows
|
|
177
|
+
- **`default_session`** - Fallback startup and preview commands
|
|
178
|
+
- **`projects`** - Exact path rules with optional `session_name`, `startup_command`, `preview_command`, `listed`, and `icon`
|
|
179
|
+
- **`wildcards`** - Pattern-based defaults for matching projects
|
|
180
|
+
|
|
181
|
+
### Rule Resolution
|
|
182
|
+
|
|
183
|
+
When you select a project, mux-sesh resolves its behavior in this order:
|
|
184
|
+
|
|
185
|
+
1. Exact `projects[]` path match
|
|
186
|
+
2. First matching `wildcards[]` rule
|
|
187
|
+
3. `default_session`
|
|
188
|
+
|
|
189
|
+
Session names use the git root when available, then apply `dir_length` if you did not set an explicit `session_name`.
|
|
190
|
+
|
|
191
|
+
### Listed Sessions
|
|
192
|
+
|
|
193
|
+
Set `listed: true` on a project rule to keep that target visible in the Sessions view even when tmux has not started it yet. This works well for dotfiles, config folders, dashboards, and other “always useful” targets.
|
|
194
|
+
|
|
195
|
+
If a live tmux session already exists with the same title, the live session takes precedence.
|
|
196
|
+
|
|
197
|
+
### Sorting and Zoxide
|
|
198
|
+
|
|
199
|
+
- `zoxide_mode: off` - scan only
|
|
200
|
+
- `zoxide_mode: rank` - reorder discovered projects by zoxide score
|
|
201
|
+
- `zoxide_mode: merge` - include additional zoxide-ranked projects inside configured roots
|
|
202
|
+
- `sort_order: live-first` - live sessions before configured placeholders
|
|
203
|
+
- `sort_order: configured-first` - configured placeholders before live sessions
|
|
204
|
+
- `sort_order: zoxide-first` - preserve project discovery/zoxide ordering
|
|
205
|
+
- `sort_order: alphabetical` - alphabetical project and session ordering
|
|
206
|
+
|
|
207
|
+
### Preview Behavior
|
|
208
|
+
|
|
209
|
+
`preview_command` inherits from `default_session`, can be overridden per project rule, and supports `{}` interpolation for the selected path.
|
|
210
|
+
|
|
211
|
+
- if the preview command succeeds, mux-sesh renders its output in the detail panel
|
|
212
|
+
- if it fails or times out, mux-sesh falls back to a directory listing
|
|
213
|
+
- if a project already has a linked tmux session, the preview also includes live tmux window details
|
|
214
|
+
|
|
215
|
+
Example:
|
|
216
|
+
|
|
217
|
+
```json
|
|
218
|
+
{
|
|
219
|
+
"default_session": {
|
|
220
|
+
"preview_command": "eza --all {}"
|
|
221
|
+
},
|
|
222
|
+
"projects": [
|
|
223
|
+
{
|
|
224
|
+
"path": "~/dev/projects/mux-sesh",
|
|
225
|
+
"preview_command": "git -C {} status --short"
|
|
226
|
+
}
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
```
|
|
124
230
|
|
|
125
231
|
### tmux Integration
|
|
126
232
|
|
|
@@ -159,7 +265,17 @@ mux-sesh
|
|
|
159
265
|
|
|
160
266
|
# Press 'n' for new session
|
|
161
267
|
# Type project name to filter
|
|
162
|
-
#
|
|
268
|
+
# Rows show whether they will attach to an existing tmux session or create a new one
|
|
269
|
+
# Press Enter to create or attach
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Jump to Root / Last / Edit Target
|
|
273
|
+
```bash
|
|
274
|
+
mux-sesh
|
|
275
|
+
|
|
276
|
+
# Select a project or session, then press 'g' to jump to its git-root session
|
|
277
|
+
# Press 'l' to jump to the most recent non-current tmux session
|
|
278
|
+
# Select a configured session and press 'e' to open its target in your editor
|
|
163
279
|
```
|
|
164
280
|
|
|
165
281
|
### Clone from GitHub
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mux-sesh",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "A beautiful tmux session manager built with OpenTUI - fuzzy search sessions, manage projects, clone from GitHub",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"bun": ">=1.0.0"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@opentui/core": "
|
|
51
|
-
"@opentui/react": "
|
|
50
|
+
"@opentui/core": "0.1.60",
|
|
51
|
+
"@opentui/react": "0.1.60",
|
|
52
52
|
"react": "^19.2.2"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
package/src/app.tsx
CHANGED
|
@@ -3,7 +3,11 @@ import { useKeyboard } from '@opentui/react'
|
|
|
3
3
|
import { useState, useEffect, useRef } from 'react'
|
|
4
4
|
import { AppMode, ViewMode, type Item, type Config, type OpencodeStatsState } from './types'
|
|
5
5
|
import { loadConfig } from './config'
|
|
6
|
+
import { getListedSessionItems, mergeSessionItems } from './config/listed-sessions'
|
|
7
|
+
import { orderProjectItems, orderSessionItems } from './items/order'
|
|
8
|
+
import { annotateProjectItemsWithSessionLinks } from './projects/session-links'
|
|
6
9
|
import { listTmuxSessions } from './tmux'
|
|
10
|
+
import { filterHiddenSessions } from './tmux/workflows'
|
|
7
11
|
import { getProjectItems } from './tmux/projects'
|
|
8
12
|
import { filterAndSortItems, clearMatchIndices } from './search'
|
|
9
13
|
import { isGitHubURL } from './util/github'
|
|
@@ -22,6 +26,7 @@ import SearchInput from './ui/SearchInput'
|
|
|
22
26
|
import SessionStats from './ui/SessionStats'
|
|
23
27
|
import ItemList from './ui/ItemList'
|
|
24
28
|
import {
|
|
29
|
+
type KeyboardHandlerContext,
|
|
25
30
|
handleNormalMode,
|
|
26
31
|
handleOpencodeManageMode,
|
|
27
32
|
handleSearchMode,
|
|
@@ -29,10 +34,13 @@ import {
|
|
|
29
34
|
handleRenameMode,
|
|
30
35
|
} from './handlers/keyboard'
|
|
31
36
|
import {
|
|
32
|
-
handleSelect,
|
|
37
|
+
handleSelect as actionHandleSelect,
|
|
33
38
|
handleKillSession as actionKillSession,
|
|
39
|
+
handleLastSession as actionHandleLastSession,
|
|
34
40
|
handleRenameSubmit as actionRenameSubmit,
|
|
35
41
|
handleNewSessionSubmit as actionNewSessionSubmit,
|
|
42
|
+
handleRootSession as actionHandleRootSession,
|
|
43
|
+
handleEditTarget as actionHandleEditTarget,
|
|
36
44
|
} from './handlers/actions'
|
|
37
45
|
|
|
38
46
|
export function App() {
|
|
@@ -51,10 +59,41 @@ export function App() {
|
|
|
51
59
|
const [prefixActive, setPrefixActive] = useState(false)
|
|
52
60
|
const prefixTimeoutRef = useRef<NodeJS.Timeout | null>(null)
|
|
53
61
|
const textareaRef = useRef<TextareaRenderable | null>(null)
|
|
54
|
-
const
|
|
62
|
+
const lastSessionSelectionRef = useRef<string | null>(null)
|
|
63
|
+
const lastProjectSelectionRef = useRef<string | null>(null)
|
|
64
|
+
const { columns, rows } = useTerminalSize()
|
|
55
65
|
const [toastMessage, setToastMessage] = useState('')
|
|
56
66
|
const [toastVisible, setToastVisible] = useState(false)
|
|
57
67
|
|
|
68
|
+
function getSessionSelectionIndex(nextItems: Item[]): number {
|
|
69
|
+
const regularItems = nextItems.filter(item => !(item.isSession && item.title.startsWith('opencode-')))
|
|
70
|
+
if (regularItems.length === 0) {
|
|
71
|
+
return 0
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const selection = lastSessionSelectionRef.current
|
|
75
|
+
if (!selection) {
|
|
76
|
+
return 0
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const index = regularItems.findIndex(item => item.title === selection)
|
|
80
|
+
return index >= 0 ? index : 0
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function getProjectSelectionIndex(nextItems: Item[]): number {
|
|
84
|
+
if (nextItems.length === 0) {
|
|
85
|
+
return 0
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const selection = lastProjectSelectionRef.current
|
|
89
|
+
if (!selection) {
|
|
90
|
+
return 0
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const index = nextItems.findIndex(item => item.path === selection)
|
|
94
|
+
return index >= 0 ? index : 0
|
|
95
|
+
}
|
|
96
|
+
|
|
58
97
|
function updateOpencodeState(sessionName: string, nextState: OpencodeStatsState) {
|
|
59
98
|
const applyState = (existingItems: Item[]) =>
|
|
60
99
|
existingItems.map(item =>
|
|
@@ -77,19 +116,27 @@ export function App() {
|
|
|
77
116
|
}
|
|
78
117
|
|
|
79
118
|
const sessions = await listTmuxSessions()
|
|
80
|
-
const
|
|
119
|
+
const visibleSessions = filterHiddenSessions(sessions, cfg.hiddenSessions)
|
|
120
|
+
const listedSessions = await getListedSessionItems(cfg)
|
|
121
|
+
const combinedSessions = orderSessionItems(mergeSessionItems(visibleSessions, listedSessions), cfg.sortOrder)
|
|
122
|
+
const projects = orderProjectItems(
|
|
123
|
+
await annotateProjectItemsWithSessionLinks(await getProjectItems(cfg), visibleSessions, cfg),
|
|
124
|
+
cfg.sortOrder
|
|
125
|
+
)
|
|
81
126
|
|
|
82
127
|
setProjectItems(projects)
|
|
83
128
|
|
|
84
|
-
if (
|
|
129
|
+
if (combinedSessions.length > 0) {
|
|
85
130
|
setViewMode(ViewMode.Sessions)
|
|
86
|
-
setSessionItems(
|
|
87
|
-
setAllItems(
|
|
88
|
-
setItems(
|
|
131
|
+
setSessionItems(combinedSessions)
|
|
132
|
+
setAllItems(combinedSessions)
|
|
133
|
+
setItems(combinedSessions)
|
|
134
|
+
setCursor(getSessionSelectionIndex(combinedSessions))
|
|
89
135
|
} else {
|
|
90
136
|
setViewMode(ViewMode.Projects)
|
|
91
137
|
setAllItems(projects)
|
|
92
138
|
setItems(projects)
|
|
139
|
+
setCursor(getProjectSelectionIndex(projects))
|
|
93
140
|
}
|
|
94
141
|
checkAndUpdate(cfg).catch(error => {
|
|
95
142
|
console.error('Auto-update check failed:', error)
|
|
@@ -105,18 +152,33 @@ export function App() {
|
|
|
105
152
|
|
|
106
153
|
if (targetMode === ViewMode.Sessions) {
|
|
107
154
|
const sessions = await listTmuxSessions()
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
155
|
+
const visibleSessions = filterHiddenSessions(sessions, config.hiddenSessions)
|
|
156
|
+
const listedSessions = await getListedSessionItems(config)
|
|
157
|
+
const cleanSessions = clearMatchIndices(
|
|
158
|
+
orderSessionItems(mergeSessionItems(visibleSessions, listedSessions), config.sortOrder)
|
|
159
|
+
)
|
|
160
|
+
const linkedProjects = orderProjectItems(
|
|
161
|
+
await annotateProjectItemsWithSessionLinks(projectItems, visibleSessions, config),
|
|
162
|
+
config.sortOrder
|
|
163
|
+
)
|
|
164
|
+
setSessionItems(cleanSessions)
|
|
165
|
+
setProjectItems(linkedProjects)
|
|
166
|
+
setAllItems(cleanSessions)
|
|
167
|
+
setItems(cleanSessions)
|
|
168
|
+
setCursor(getSessionSelectionIndex(cleanSessions))
|
|
112
169
|
} else {
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
170
|
+
const sessions = await listTmuxSessions()
|
|
171
|
+
const visibleSessions = filterHiddenSessions(sessions, config.hiddenSessions)
|
|
172
|
+
const projects = orderProjectItems(
|
|
173
|
+
await annotateProjectItemsWithSessionLinks(await getProjectItems(config), visibleSessions, config),
|
|
174
|
+
config.sortOrder
|
|
175
|
+
)
|
|
176
|
+
const cleanProjects = clearMatchIndices(projects)
|
|
177
|
+
setProjectItems(cleanProjects)
|
|
178
|
+
setAllItems(cleanProjects)
|
|
179
|
+
setItems(cleanProjects)
|
|
180
|
+
setCursor(getProjectSelectionIndex(cleanProjects))
|
|
118
181
|
}
|
|
119
|
-
setCursor(0)
|
|
120
182
|
}
|
|
121
183
|
|
|
122
184
|
async function loadOpencodeStatsForSession(sessionName: string) {
|
|
@@ -147,7 +209,7 @@ export function App() {
|
|
|
147
209
|
const regularSessions =
|
|
148
210
|
viewMode === ViewMode.Sessions &&
|
|
149
211
|
(appMode === AppMode.Normal || appMode === AppMode.OpencodeManage)
|
|
150
|
-
? items.filter(item => item.isSession &&
|
|
212
|
+
? items.filter(item => !(item.isSession && item.title.startsWith('opencode-')))
|
|
151
213
|
: items
|
|
152
214
|
|
|
153
215
|
const opencodeSessions =
|
|
@@ -157,6 +219,8 @@ export function App() {
|
|
|
157
219
|
: []
|
|
158
220
|
const selectedOpencodeSessionName =
|
|
159
221
|
appMode === AppMode.OpencodeManage ? opencodeSessions[opencodeCursor]?.title : undefined
|
|
222
|
+
const selectedPrimaryItem =
|
|
223
|
+
viewMode === ViewMode.Sessions && appMode === AppMode.Normal ? regularSessions[cursor] : items[cursor]
|
|
160
224
|
|
|
161
225
|
async function handleKillSessionWrapper(sessionName: string) {
|
|
162
226
|
await actionKillSession(sessionName, {
|
|
@@ -172,6 +236,40 @@ export function App() {
|
|
|
172
236
|
})
|
|
173
237
|
}
|
|
174
238
|
|
|
239
|
+
async function handleSelectWrapper(item: Item) {
|
|
240
|
+
await actionHandleSelect(item, config)
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
async function handleLastSessionWrapper() {
|
|
244
|
+
try {
|
|
245
|
+
await actionHandleLastSession(sessionItems)
|
|
246
|
+
} catch (error) {
|
|
247
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to switch to the previous session'
|
|
248
|
+
setMessage(errorMessage)
|
|
249
|
+
setTimeout(() => setMessage(''), 3000)
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
async function handleRootSessionWrapper(item?: Item) {
|
|
254
|
+
try {
|
|
255
|
+
await actionHandleRootSession(item, config)
|
|
256
|
+
} catch (error) {
|
|
257
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to open the root session'
|
|
258
|
+
setMessage(errorMessage)
|
|
259
|
+
setTimeout(() => setMessage(''), 3000)
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
async function handleEditTargetWrapper(item?: Item) {
|
|
264
|
+
try {
|
|
265
|
+
await actionHandleEditTarget(item, config)
|
|
266
|
+
} catch (error) {
|
|
267
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to edit target'
|
|
268
|
+
setMessage(errorMessage)
|
|
269
|
+
setTimeout(() => setMessage(''), 3000)
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
175
273
|
async function handleRenameSubmit() {
|
|
176
274
|
const newName = searchQuery.trim()
|
|
177
275
|
if (newName && newName !== renameTarget) {
|
|
@@ -198,13 +296,14 @@ export function App() {
|
|
|
198
296
|
|
|
199
297
|
try {
|
|
200
298
|
await actionNewSessionSubmit(searchTerm, config, items, cursor)
|
|
201
|
-
} catch (error
|
|
202
|
-
|
|
299
|
+
} catch (error) {
|
|
300
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to create session'
|
|
301
|
+
setMessage(errorMessage)
|
|
203
302
|
setTimeout(() => setMessage(''), 3000)
|
|
204
303
|
}
|
|
205
304
|
}
|
|
206
305
|
|
|
207
|
-
const keyboardContext = {
|
|
306
|
+
const keyboardContext: KeyboardHandlerContext = {
|
|
208
307
|
appMode,
|
|
209
308
|
viewMode,
|
|
210
309
|
items,
|
|
@@ -229,8 +328,11 @@ export function App() {
|
|
|
229
328
|
setItems,
|
|
230
329
|
setPrefixActive,
|
|
231
330
|
refreshItems,
|
|
232
|
-
handleSelect,
|
|
331
|
+
handleSelect: handleSelectWrapper,
|
|
233
332
|
handleKillSession: handleKillSessionWrapper,
|
|
333
|
+
handleLastSession: handleLastSessionWrapper,
|
|
334
|
+
handleRootSession: handleRootSessionWrapper,
|
|
335
|
+
handleEditTarget: handleEditTargetWrapper,
|
|
234
336
|
loadOpencodeStatsForSession,
|
|
235
337
|
setMessage,
|
|
236
338
|
}
|
|
@@ -278,12 +380,38 @@ export function App() {
|
|
|
278
380
|
useEffect(() => {
|
|
279
381
|
if (appMode === AppMode.Normal && viewMode === ViewMode.Sessions) {
|
|
280
382
|
// Clear match indices when returning to normal mode
|
|
281
|
-
clearMatchIndices(sessionItems)
|
|
282
|
-
setAllItems(
|
|
283
|
-
setItems(
|
|
383
|
+
const cleanSessions = clearMatchIndices(sessionItems)
|
|
384
|
+
setAllItems(cleanSessions)
|
|
385
|
+
setItems(cleanSessions)
|
|
386
|
+
setCursor(getSessionSelectionIndex(cleanSessions))
|
|
284
387
|
}
|
|
285
388
|
}, [appMode, viewMode, sessionItems])
|
|
286
389
|
|
|
390
|
+
useEffect(() => {
|
|
391
|
+
if (appMode === AppMode.NewSession && viewMode === ViewMode.Projects) {
|
|
392
|
+
setCursor(getProjectSelectionIndex(projectItems))
|
|
393
|
+
}
|
|
394
|
+
}, [appMode, viewMode, projectItems])
|
|
395
|
+
|
|
396
|
+
useEffect(() => {
|
|
397
|
+
const selectedItem = appMode === AppMode.NewSession ? items[cursor] : selectedPrimaryItem
|
|
398
|
+
|
|
399
|
+
if (!selectedItem) {
|
|
400
|
+
return
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
if (appMode === AppMode.NewSession || viewMode === ViewMode.Projects) {
|
|
404
|
+
if (!selectedItem.isSession) {
|
|
405
|
+
lastProjectSelectionRef.current = selectedItem.path
|
|
406
|
+
}
|
|
407
|
+
return
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
if (viewMode === ViewMode.Sessions && appMode === AppMode.Normal) {
|
|
411
|
+
lastSessionSelectionRef.current = selectedItem.title
|
|
412
|
+
}
|
|
413
|
+
}, [appMode, viewMode, cursor, items, selectedPrimaryItem])
|
|
414
|
+
|
|
287
415
|
useEffect(() => {
|
|
288
416
|
if (appMode === AppMode.Search || appMode === AppMode.NewSession) {
|
|
289
417
|
if (searchQuery.trim()) {
|
|
@@ -339,7 +467,9 @@ export function App() {
|
|
|
339
467
|
}
|
|
340
468
|
|
|
341
469
|
const totalSessions =
|
|
342
|
-
viewMode === ViewMode.Sessions && appMode === AppMode.Normal
|
|
470
|
+
viewMode === ViewMode.Sessions && appMode === AppMode.Normal
|
|
471
|
+
? items.filter(item => item.isSession).length
|
|
472
|
+
: 0
|
|
343
473
|
const activeSessions = items.filter(item => item.isSession && item.isAttached).length
|
|
344
474
|
const idleSessions = totalSessions - activeSessions
|
|
345
475
|
|
|
@@ -353,6 +483,7 @@ export function App() {
|
|
|
353
483
|
sessionsWithAges.length > 0
|
|
354
484
|
? formatSessionAge(sessionsWithAges[sessionsWithAges.length - 1].createdAt!)
|
|
355
485
|
: 'N/A'
|
|
486
|
+
const maxVisibleItems = Math.max(8, rows - (appMode === AppMode.NewSession ? 10 : 16))
|
|
356
487
|
|
|
357
488
|
return (
|
|
358
489
|
<box
|
|
@@ -415,13 +546,20 @@ export function App() {
|
|
|
415
546
|
(appMode === AppMode.Normal || appMode === AppMode.OpencodeManage) ? (
|
|
416
547
|
<>
|
|
417
548
|
{/* Regular sessions */}
|
|
418
|
-
<SessionList
|
|
549
|
+
<SessionList
|
|
550
|
+
items={regularSessions}
|
|
551
|
+
cursor={cursor}
|
|
552
|
+
searchQuery={searchQuery}
|
|
553
|
+
maxItems={maxVisibleItems}
|
|
554
|
+
icons={config?.icons}
|
|
555
|
+
/>
|
|
419
556
|
|
|
420
557
|
{/* Opencode sessions group */}
|
|
421
558
|
<OpencodeSessionGroup
|
|
422
559
|
sessions={opencodeSessions}
|
|
423
560
|
appMode={appMode}
|
|
424
561
|
cursor={opencodeCursor}
|
|
562
|
+
icons={config?.icons}
|
|
425
563
|
/>
|
|
426
564
|
|
|
427
565
|
{/* Session statistics */}
|
|
@@ -434,7 +572,14 @@ export function App() {
|
|
|
434
572
|
/>
|
|
435
573
|
</>
|
|
436
574
|
) : (
|
|
437
|
-
<ItemList
|
|
575
|
+
<ItemList
|
|
576
|
+
items={items}
|
|
577
|
+
cursor={cursor}
|
|
578
|
+
appMode={appMode}
|
|
579
|
+
searchQuery={searchQuery}
|
|
580
|
+
maxItems={maxVisibleItems}
|
|
581
|
+
icons={config?.icons}
|
|
582
|
+
/>
|
|
438
583
|
)}
|
|
439
584
|
</box>
|
|
440
585
|
|
|
@@ -450,7 +595,7 @@ export function App() {
|
|
|
450
595
|
|
|
451
596
|
{/* Keybind help */}
|
|
452
597
|
<box style={{ marginTop: 1, flexDirection: 'column' }}>
|
|
453
|
-
<KeybindHelp appMode={appMode} keybindMode={config?.keybindMode} />
|
|
598
|
+
<KeybindHelp appMode={appMode} keybindMode={config?.keybindMode} selectedItem={selectedPrimaryItem} />
|
|
454
599
|
</box>
|
|
455
600
|
</box>
|
|
456
601
|
|
|
@@ -461,11 +606,8 @@ export function App() {
|
|
|
461
606
|
<OpencodeStatsPanel selectedItem={opencodeSessions[opencodeCursor]} />
|
|
462
607
|
) : (
|
|
463
608
|
<SessionDetailsPanel
|
|
464
|
-
selectedItem={
|
|
465
|
-
|
|
466
|
-
? regularSessions[cursor]
|
|
467
|
-
: items[cursor]
|
|
468
|
-
}
|
|
609
|
+
selectedItem={selectedPrimaryItem}
|
|
610
|
+
config={config}
|
|
469
611
|
/>
|
|
470
612
|
)}
|
|
471
613
|
</>
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { colors } from '../styles/theme'
|
|
2
|
-
import { AppMode, KeybindMode } from '../types'
|
|
2
|
+
import { AppMode, KeybindMode, type Item } from '../types'
|
|
3
3
|
|
|
4
4
|
interface Props {
|
|
5
5
|
appMode: AppMode
|
|
6
6
|
keybindMode?: KeybindMode
|
|
7
|
+
selectedItem?: Item
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export default function KeybindHelp({ appMode, keybindMode = 'vim' }: Props) {
|
|
10
|
+
export default function KeybindHelp({ appMode, keybindMode = 'vim', selectedItem }: Props) {
|
|
10
11
|
const isStandard = keybindMode === 'standard'
|
|
12
|
+
const showEditTarget = selectedItem?.itemKind === 'configured' && appMode === AppMode.Normal
|
|
11
13
|
if (appMode === AppMode.Search || appMode === AppMode.NewSession || appMode === AppMode.Rename) {
|
|
12
14
|
if (isStandard) {
|
|
13
15
|
// Standard mode: show Ctrl+X prefix keybinds in vertical layout matching vim mode
|
|
@@ -38,6 +40,23 @@ export default function KeybindHelp({ appMode, keybindMode = 'vim' }: Props) {
|
|
|
38
40
|
<span style={{ fg: colors.separator }}>│ </span>
|
|
39
41
|
<span style={{ fg: colors.action }}>opencode</span>
|
|
40
42
|
</text>
|
|
43
|
+
<text>
|
|
44
|
+
<span style={{ fg: colors.key }}>Ctrl+X l </span>
|
|
45
|
+
<span style={{ fg: colors.separator }}>│ </span>
|
|
46
|
+
<span style={{ fg: colors.action }}>last</span>
|
|
47
|
+
</text>
|
|
48
|
+
<text>
|
|
49
|
+
<span style={{ fg: colors.key }}>Ctrl+X g </span>
|
|
50
|
+
<span style={{ fg: colors.separator }}>│ </span>
|
|
51
|
+
<span style={{ fg: colors.action }}>root</span>
|
|
52
|
+
</text>
|
|
53
|
+
{showEditTarget && (
|
|
54
|
+
<text>
|
|
55
|
+
<span style={{ fg: colors.key }}>Ctrl+E </span>
|
|
56
|
+
<span style={{ fg: colors.separator }}>│ </span>
|
|
57
|
+
<span style={{ fg: colors.action }}>edit</span>
|
|
58
|
+
</text>
|
|
59
|
+
)}
|
|
41
60
|
<text>
|
|
42
61
|
<span style={{ fg: colors.key }}>Ctrl+X R </span>
|
|
43
62
|
<span style={{ fg: colors.separator }}>│ </span>
|
|
@@ -156,6 +175,16 @@ export default function KeybindHelp({ appMode, keybindMode = 'vim' }: Props) {
|
|
|
156
175
|
<span style={{ fg: colors.separator }}>│ </span>
|
|
157
176
|
<span style={{ fg: colors.action }}>opencode</span>
|
|
158
177
|
</text>
|
|
178
|
+
<text>
|
|
179
|
+
<span style={{ fg: colors.key }}>Ctrl+L </span>
|
|
180
|
+
<span style={{ fg: colors.separator }}>│ </span>
|
|
181
|
+
<span style={{ fg: colors.action }}>last</span>
|
|
182
|
+
</text>
|
|
183
|
+
<text>
|
|
184
|
+
<span style={{ fg: colors.key }}>Ctrl+G </span>
|
|
185
|
+
<span style={{ fg: colors.separator }}>│ </span>
|
|
186
|
+
<span style={{ fg: colors.action }}>root</span>
|
|
187
|
+
</text>
|
|
159
188
|
<text>
|
|
160
189
|
<span style={{ fg: colors.key }}>Ctrl+X R </span>
|
|
161
190
|
<span style={{ fg: colors.separator }}>│ </span>
|
|
@@ -207,6 +236,23 @@ export default function KeybindHelp({ appMode, keybindMode = 'vim' }: Props) {
|
|
|
207
236
|
<span style={{ fg: colors.separator }}>│ </span>
|
|
208
237
|
<span style={{ fg: colors.action }}>opencode</span>
|
|
209
238
|
</text>
|
|
239
|
+
<text>
|
|
240
|
+
<span style={{ fg: colors.key }}>l </span>
|
|
241
|
+
<span style={{ fg: colors.separator }}>│ </span>
|
|
242
|
+
<span style={{ fg: colors.action }}>last</span>
|
|
243
|
+
</text>
|
|
244
|
+
<text>
|
|
245
|
+
<span style={{ fg: colors.key }}>g </span>
|
|
246
|
+
<span style={{ fg: colors.separator }}>│ </span>
|
|
247
|
+
<span style={{ fg: colors.action }}>root</span>
|
|
248
|
+
</text>
|
|
249
|
+
{showEditTarget && (
|
|
250
|
+
<text>
|
|
251
|
+
<span style={{ fg: colors.key }}>e </span>
|
|
252
|
+
<span style={{ fg: colors.separator }}>│ </span>
|
|
253
|
+
<span style={{ fg: colors.action }}>edit</span>
|
|
254
|
+
</text>
|
|
255
|
+
)}
|
|
210
256
|
<text>
|
|
211
257
|
<span style={{ fg: colors.key }}>R </span>
|
|
212
258
|
<span style={{ fg: colors.separator }}>│ </span>
|