mux-sesh 1.4.0 → 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 +178 -35
- 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/SearchInput.tsx +19 -1
- 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
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import type { TextareaRenderable } from '@opentui/core'
|
|
1
2
|
import { useKeyboard } from '@opentui/react'
|
|
2
3
|
import { useState, useEffect, useRef } from 'react'
|
|
3
4
|
import { AppMode, ViewMode, type Item, type Config, type OpencodeStatsState } from './types'
|
|
4
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'
|
|
5
9
|
import { listTmuxSessions } from './tmux'
|
|
10
|
+
import { filterHiddenSessions } from './tmux/workflows'
|
|
6
11
|
import { getProjectItems } from './tmux/projects'
|
|
7
12
|
import { filterAndSortItems, clearMatchIndices } from './search'
|
|
8
13
|
import { isGitHubURL } from './util/github'
|
|
@@ -21,6 +26,7 @@ import SearchInput from './ui/SearchInput'
|
|
|
21
26
|
import SessionStats from './ui/SessionStats'
|
|
22
27
|
import ItemList from './ui/ItemList'
|
|
23
28
|
import {
|
|
29
|
+
type KeyboardHandlerContext,
|
|
24
30
|
handleNormalMode,
|
|
25
31
|
handleOpencodeManageMode,
|
|
26
32
|
handleSearchMode,
|
|
@@ -28,10 +34,13 @@ import {
|
|
|
28
34
|
handleRenameMode,
|
|
29
35
|
} from './handlers/keyboard'
|
|
30
36
|
import {
|
|
31
|
-
handleSelect,
|
|
37
|
+
handleSelect as actionHandleSelect,
|
|
32
38
|
handleKillSession as actionKillSession,
|
|
39
|
+
handleLastSession as actionHandleLastSession,
|
|
33
40
|
handleRenameSubmit as actionRenameSubmit,
|
|
34
41
|
handleNewSessionSubmit as actionNewSessionSubmit,
|
|
42
|
+
handleRootSession as actionHandleRootSession,
|
|
43
|
+
handleEditTarget as actionHandleEditTarget,
|
|
35
44
|
} from './handlers/actions'
|
|
36
45
|
|
|
37
46
|
export function App() {
|
|
@@ -49,11 +58,42 @@ export function App() {
|
|
|
49
58
|
const [config, setConfig] = useState<Config | null>(null)
|
|
50
59
|
const [prefixActive, setPrefixActive] = useState(false)
|
|
51
60
|
const prefixTimeoutRef = useRef<NodeJS.Timeout | null>(null)
|
|
52
|
-
const textareaRef = useRef<
|
|
53
|
-
const
|
|
61
|
+
const textareaRef = useRef<TextareaRenderable | null>(null)
|
|
62
|
+
const lastSessionSelectionRef = useRef<string | null>(null)
|
|
63
|
+
const lastProjectSelectionRef = useRef<string | null>(null)
|
|
64
|
+
const { columns, rows } = useTerminalSize()
|
|
54
65
|
const [toastMessage, setToastMessage] = useState('')
|
|
55
66
|
const [toastVisible, setToastVisible] = useState(false)
|
|
56
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
|
+
|
|
57
97
|
function updateOpencodeState(sessionName: string, nextState: OpencodeStatsState) {
|
|
58
98
|
const applyState = (existingItems: Item[]) =>
|
|
59
99
|
existingItems.map(item =>
|
|
@@ -76,19 +116,27 @@ export function App() {
|
|
|
76
116
|
}
|
|
77
117
|
|
|
78
118
|
const sessions = await listTmuxSessions()
|
|
79
|
-
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
|
+
)
|
|
80
126
|
|
|
81
127
|
setProjectItems(projects)
|
|
82
128
|
|
|
83
|
-
if (
|
|
129
|
+
if (combinedSessions.length > 0) {
|
|
84
130
|
setViewMode(ViewMode.Sessions)
|
|
85
|
-
setSessionItems(
|
|
86
|
-
setAllItems(
|
|
87
|
-
setItems(
|
|
131
|
+
setSessionItems(combinedSessions)
|
|
132
|
+
setAllItems(combinedSessions)
|
|
133
|
+
setItems(combinedSessions)
|
|
134
|
+
setCursor(getSessionSelectionIndex(combinedSessions))
|
|
88
135
|
} else {
|
|
89
136
|
setViewMode(ViewMode.Projects)
|
|
90
137
|
setAllItems(projects)
|
|
91
138
|
setItems(projects)
|
|
139
|
+
setCursor(getProjectSelectionIndex(projects))
|
|
92
140
|
}
|
|
93
141
|
checkAndUpdate(cfg).catch(error => {
|
|
94
142
|
console.error('Auto-update check failed:', error)
|
|
@@ -104,18 +152,33 @@ export function App() {
|
|
|
104
152
|
|
|
105
153
|
if (targetMode === ViewMode.Sessions) {
|
|
106
154
|
const sessions = await listTmuxSessions()
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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))
|
|
111
169
|
} else {
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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))
|
|
117
181
|
}
|
|
118
|
-
setCursor(0)
|
|
119
182
|
}
|
|
120
183
|
|
|
121
184
|
async function loadOpencodeStatsForSession(sessionName: string) {
|
|
@@ -146,7 +209,7 @@ export function App() {
|
|
|
146
209
|
const regularSessions =
|
|
147
210
|
viewMode === ViewMode.Sessions &&
|
|
148
211
|
(appMode === AppMode.Normal || appMode === AppMode.OpencodeManage)
|
|
149
|
-
? items.filter(item => item.isSession &&
|
|
212
|
+
? items.filter(item => !(item.isSession && item.title.startsWith('opencode-')))
|
|
150
213
|
: items
|
|
151
214
|
|
|
152
215
|
const opencodeSessions =
|
|
@@ -156,6 +219,8 @@ export function App() {
|
|
|
156
219
|
: []
|
|
157
220
|
const selectedOpencodeSessionName =
|
|
158
221
|
appMode === AppMode.OpencodeManage ? opencodeSessions[opencodeCursor]?.title : undefined
|
|
222
|
+
const selectedPrimaryItem =
|
|
223
|
+
viewMode === ViewMode.Sessions && appMode === AppMode.Normal ? regularSessions[cursor] : items[cursor]
|
|
159
224
|
|
|
160
225
|
async function handleKillSessionWrapper(sessionName: string) {
|
|
161
226
|
await actionKillSession(sessionName, {
|
|
@@ -171,6 +236,40 @@ export function App() {
|
|
|
171
236
|
})
|
|
172
237
|
}
|
|
173
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
|
+
|
|
174
273
|
async function handleRenameSubmit() {
|
|
175
274
|
const newName = searchQuery.trim()
|
|
176
275
|
if (newName && newName !== renameTarget) {
|
|
@@ -197,13 +296,14 @@ export function App() {
|
|
|
197
296
|
|
|
198
297
|
try {
|
|
199
298
|
await actionNewSessionSubmit(searchTerm, config, items, cursor)
|
|
200
|
-
} catch (error
|
|
201
|
-
|
|
299
|
+
} catch (error) {
|
|
300
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to create session'
|
|
301
|
+
setMessage(errorMessage)
|
|
202
302
|
setTimeout(() => setMessage(''), 3000)
|
|
203
303
|
}
|
|
204
304
|
}
|
|
205
305
|
|
|
206
|
-
const keyboardContext = {
|
|
306
|
+
const keyboardContext: KeyboardHandlerContext = {
|
|
207
307
|
appMode,
|
|
208
308
|
viewMode,
|
|
209
309
|
items,
|
|
@@ -228,8 +328,11 @@ export function App() {
|
|
|
228
328
|
setItems,
|
|
229
329
|
setPrefixActive,
|
|
230
330
|
refreshItems,
|
|
231
|
-
handleSelect,
|
|
331
|
+
handleSelect: handleSelectWrapper,
|
|
232
332
|
handleKillSession: handleKillSessionWrapper,
|
|
333
|
+
handleLastSession: handleLastSessionWrapper,
|
|
334
|
+
handleRootSession: handleRootSessionWrapper,
|
|
335
|
+
handleEditTarget: handleEditTargetWrapper,
|
|
233
336
|
loadOpencodeStatsForSession,
|
|
234
337
|
setMessage,
|
|
235
338
|
}
|
|
@@ -277,12 +380,38 @@ export function App() {
|
|
|
277
380
|
useEffect(() => {
|
|
278
381
|
if (appMode === AppMode.Normal && viewMode === ViewMode.Sessions) {
|
|
279
382
|
// Clear match indices when returning to normal mode
|
|
280
|
-
clearMatchIndices(sessionItems)
|
|
281
|
-
setAllItems(
|
|
282
|
-
setItems(
|
|
383
|
+
const cleanSessions = clearMatchIndices(sessionItems)
|
|
384
|
+
setAllItems(cleanSessions)
|
|
385
|
+
setItems(cleanSessions)
|
|
386
|
+
setCursor(getSessionSelectionIndex(cleanSessions))
|
|
283
387
|
}
|
|
284
388
|
}, [appMode, viewMode, sessionItems])
|
|
285
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
|
+
|
|
286
415
|
useEffect(() => {
|
|
287
416
|
if (appMode === AppMode.Search || appMode === AppMode.NewSession) {
|
|
288
417
|
if (searchQuery.trim()) {
|
|
@@ -338,7 +467,9 @@ export function App() {
|
|
|
338
467
|
}
|
|
339
468
|
|
|
340
469
|
const totalSessions =
|
|
341
|
-
viewMode === ViewMode.Sessions && appMode === AppMode.Normal
|
|
470
|
+
viewMode === ViewMode.Sessions && appMode === AppMode.Normal
|
|
471
|
+
? items.filter(item => item.isSession).length
|
|
472
|
+
: 0
|
|
342
473
|
const activeSessions = items.filter(item => item.isSession && item.isAttached).length
|
|
343
474
|
const idleSessions = totalSessions - activeSessions
|
|
344
475
|
|
|
@@ -352,6 +483,7 @@ export function App() {
|
|
|
352
483
|
sessionsWithAges.length > 0
|
|
353
484
|
? formatSessionAge(sessionsWithAges[sessionsWithAges.length - 1].createdAt!)
|
|
354
485
|
: 'N/A'
|
|
486
|
+
const maxVisibleItems = Math.max(8, rows - (appMode === AppMode.NewSession ? 10 : 16))
|
|
355
487
|
|
|
356
488
|
return (
|
|
357
489
|
<box
|
|
@@ -414,13 +546,20 @@ export function App() {
|
|
|
414
546
|
(appMode === AppMode.Normal || appMode === AppMode.OpencodeManage) ? (
|
|
415
547
|
<>
|
|
416
548
|
{/* Regular sessions */}
|
|
417
|
-
<SessionList
|
|
549
|
+
<SessionList
|
|
550
|
+
items={regularSessions}
|
|
551
|
+
cursor={cursor}
|
|
552
|
+
searchQuery={searchQuery}
|
|
553
|
+
maxItems={maxVisibleItems}
|
|
554
|
+
icons={config?.icons}
|
|
555
|
+
/>
|
|
418
556
|
|
|
419
557
|
{/* Opencode sessions group */}
|
|
420
558
|
<OpencodeSessionGroup
|
|
421
559
|
sessions={opencodeSessions}
|
|
422
560
|
appMode={appMode}
|
|
423
561
|
cursor={opencodeCursor}
|
|
562
|
+
icons={config?.icons}
|
|
424
563
|
/>
|
|
425
564
|
|
|
426
565
|
{/* Session statistics */}
|
|
@@ -433,7 +572,14 @@ export function App() {
|
|
|
433
572
|
/>
|
|
434
573
|
</>
|
|
435
574
|
) : (
|
|
436
|
-
<ItemList
|
|
575
|
+
<ItemList
|
|
576
|
+
items={items}
|
|
577
|
+
cursor={cursor}
|
|
578
|
+
appMode={appMode}
|
|
579
|
+
searchQuery={searchQuery}
|
|
580
|
+
maxItems={maxVisibleItems}
|
|
581
|
+
icons={config?.icons}
|
|
582
|
+
/>
|
|
437
583
|
)}
|
|
438
584
|
</box>
|
|
439
585
|
|
|
@@ -449,7 +595,7 @@ export function App() {
|
|
|
449
595
|
|
|
450
596
|
{/* Keybind help */}
|
|
451
597
|
<box style={{ marginTop: 1, flexDirection: 'column' }}>
|
|
452
|
-
<KeybindHelp appMode={appMode} keybindMode={config?.keybindMode} />
|
|
598
|
+
<KeybindHelp appMode={appMode} keybindMode={config?.keybindMode} selectedItem={selectedPrimaryItem} />
|
|
453
599
|
</box>
|
|
454
600
|
</box>
|
|
455
601
|
|
|
@@ -460,11 +606,8 @@ export function App() {
|
|
|
460
606
|
<OpencodeStatsPanel selectedItem={opencodeSessions[opencodeCursor]} />
|
|
461
607
|
) : (
|
|
462
608
|
<SessionDetailsPanel
|
|
463
|
-
selectedItem={
|
|
464
|
-
|
|
465
|
-
? regularSessions[cursor]
|
|
466
|
-
: items[cursor]
|
|
467
|
-
}
|
|
609
|
+
selectedItem={selectedPrimaryItem}
|
|
610
|
+
config={config}
|
|
468
611
|
/>
|
|
469
612
|
)}
|
|
470
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>
|