mux-sesh 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/app.tsx +606 -175
- package/src/components/KeybindHelp.tsx +156 -135
- package/src/config/index.ts +208 -2
- package/src/handlers/keyboard.ts +204 -34
- package/src/settings.ts +425 -0
- package/src/styles/opencode-themes-a.ts +1 -0
- package/src/styles/opencode-themes-b.ts +1 -0
- package/src/styles/theme.tsx +441 -0
- package/src/types/index.ts +65 -0
- package/src/ui/CommandsModal.tsx +145 -0
- package/src/ui/HighlightedText.tsx +6 -3
- package/src/ui/ItemList.tsx +34 -35
- package/src/ui/Modal.tsx +41 -0
- package/src/ui/OpencodeSessionGroup.tsx +26 -28
- package/src/ui/OpencodeStatsPanel.tsx +34 -39
- package/src/ui/RenameModal.tsx +42 -0
- package/src/ui/SearchInput.tsx +3 -1
- package/src/ui/SessionDetailsPanel.tsx +68 -106
- package/src/ui/SessionList.tsx +33 -42
- package/src/ui/SessionStats.tsx +5 -3
- package/src/ui/SettingEditorModal.tsx +49 -0
- package/src/ui/SettingOptionsModal.tsx +77 -0
- package/src/ui/SettingsModal.tsx +96 -0
- package/src/ui/Toast.tsx +8 -9
- package/src/ui/item-icon.ts +13 -12
- package/src/styles/theme.ts +0 -50
package/src/handlers/keyboard.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TextareaRenderable } from '@opentui/core'
|
|
2
2
|
import type { Dispatch, MutableRefObject, SetStateAction } from 'react'
|
|
3
|
-
import { AppMode, ViewMode, KeybindMode, type Item, type OpencodeSessionStats } from '../types'
|
|
3
|
+
import { AppMode, ViewMode, KeybindMode, type Config, type Item, type OpencodeSessionStats } from '../types'
|
|
4
4
|
import { requestShutdown } from '../util/shutdown'
|
|
5
5
|
|
|
6
6
|
export interface KeyboardInput {
|
|
@@ -19,6 +19,7 @@ export interface KeyboardHandlerContext {
|
|
|
19
19
|
opencodeCursor: number
|
|
20
20
|
searchQuery: string
|
|
21
21
|
renameTarget: string
|
|
22
|
+
prefixKey?: string
|
|
22
23
|
projectItems: Item[]
|
|
23
24
|
sessionItems: Item[]
|
|
24
25
|
prefixActive: boolean
|
|
@@ -35,12 +36,17 @@ export interface KeyboardHandlerContext {
|
|
|
35
36
|
setItems: Dispatch<SetStateAction<Item[]>>
|
|
36
37
|
setPrefixActive: (active: boolean) => void
|
|
37
38
|
|
|
38
|
-
refreshItems: (forceViewMode?: ViewMode) => Promise<void>
|
|
39
|
+
refreshItems: (forceViewMode?: ViewMode, nextConfig?: Config) => Promise<void>
|
|
40
|
+
requestKillSession: (sessionName: string) => void
|
|
41
|
+
clearPendingKill: () => void
|
|
39
42
|
handleSelect: (item: Item) => Promise<void>
|
|
40
43
|
handleKillSession: (sessionName: string) => Promise<void>
|
|
41
44
|
handleLastSession: () => Promise<void>
|
|
42
45
|
handleRootSession: (item?: Item) => Promise<void>
|
|
43
46
|
handleEditTarget: (item?: Item) => Promise<void>
|
|
47
|
+
openRenameModal: (sessionName: string) => void
|
|
48
|
+
openCommandsModal: () => void
|
|
49
|
+
openSettingsModal: () => void
|
|
44
50
|
loadOpencodeStatsForSession: (sessionName: string) => Promise<OpencodeSessionStats | null>
|
|
45
51
|
setMessage: (message: string) => void
|
|
46
52
|
}
|
|
@@ -49,6 +55,15 @@ function getKeyName(key: KeyboardInput): string {
|
|
|
49
55
|
return key.name ?? ''
|
|
50
56
|
}
|
|
51
57
|
|
|
58
|
+
function matchesPrefixKey(key: KeyboardInput, prefixKey = 'ctrl+x'): boolean {
|
|
59
|
+
const parts = prefixKey.toLowerCase().split('+')
|
|
60
|
+
const keyPart = parts.at(-1) ?? prefixKey.toLowerCase()
|
|
61
|
+
const expectsCtrl = parts.includes('ctrl')
|
|
62
|
+
const expectsShift = parts.includes('shift')
|
|
63
|
+
|
|
64
|
+
return Boolean(key.ctrl) === expectsCtrl && Boolean(key.shift) === expectsShift && getKeyName(key).toLowerCase() === keyPart
|
|
65
|
+
}
|
|
66
|
+
|
|
52
67
|
export function handleNormalMode(
|
|
53
68
|
key: KeyboardInput,
|
|
54
69
|
ctx: KeyboardHandlerContext,
|
|
@@ -58,6 +73,77 @@ export function handleNormalMode(
|
|
|
58
73
|
// Standard mode requires Ctrl for most actions
|
|
59
74
|
const isStandard = keybindMode === 'standard'
|
|
60
75
|
|
|
76
|
+
if (ctx.prefixActive) {
|
|
77
|
+
if (ctx.prefixTimeoutRef.current) {
|
|
78
|
+
clearTimeout(ctx.prefixTimeoutRef.current)
|
|
79
|
+
ctx.prefixTimeoutRef.current = null
|
|
80
|
+
}
|
|
81
|
+
ctx.setPrefixActive(false)
|
|
82
|
+
|
|
83
|
+
if (key.shift && keyName.toLowerCase() === 'r') {
|
|
84
|
+
ctx.clearPendingKill()
|
|
85
|
+
ctx.refreshItems()
|
|
86
|
+
ctx.setMessage('Refreshed')
|
|
87
|
+
setTimeout(() => ctx.setMessage(''), 2000)
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
switch (keyName) {
|
|
92
|
+
case 'l':
|
|
93
|
+
ctx.clearPendingKill()
|
|
94
|
+
void ctx.handleLastSession()
|
|
95
|
+
return
|
|
96
|
+
case 'g': {
|
|
97
|
+
ctx.clearPendingKill()
|
|
98
|
+
const selectedItem =
|
|
99
|
+
ctx.viewMode === ViewMode.Sessions ? ctx.regularSessions[ctx.cursor] : ctx.items[ctx.cursor]
|
|
100
|
+
void ctx.handleRootSession(selectedItem)
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
case 'e': {
|
|
104
|
+
ctx.clearPendingKill()
|
|
105
|
+
const selectedItem =
|
|
106
|
+
ctx.viewMode === ViewMode.Sessions ? ctx.regularSessions[ctx.cursor] : ctx.items[ctx.cursor]
|
|
107
|
+
if (selectedItem?.itemKind === 'configured') {
|
|
108
|
+
void ctx.handleEditTarget(selectedItem)
|
|
109
|
+
}
|
|
110
|
+
return
|
|
111
|
+
}
|
|
112
|
+
case 'd':
|
|
113
|
+
if (ctx.viewMode === ViewMode.Sessions && ctx.regularSessions[ctx.cursor]?.isSession) {
|
|
114
|
+
ctx.requestKillSession(ctx.regularSessions[ctx.cursor].title)
|
|
115
|
+
}
|
|
116
|
+
return
|
|
117
|
+
case 'r':
|
|
118
|
+
if (ctx.viewMode === ViewMode.Sessions && ctx.regularSessions[ctx.cursor]?.isSession) {
|
|
119
|
+
ctx.clearPendingKill()
|
|
120
|
+
ctx.openRenameModal(ctx.regularSessions[ctx.cursor].title)
|
|
121
|
+
}
|
|
122
|
+
return
|
|
123
|
+
case 's':
|
|
124
|
+
ctx.clearPendingKill()
|
|
125
|
+
ctx.setViewMode(ViewMode.Sessions)
|
|
126
|
+
ctx.refreshItems(ViewMode.Sessions)
|
|
127
|
+
return
|
|
128
|
+
case 'p':
|
|
129
|
+
ctx.clearPendingKill()
|
|
130
|
+
ctx.setViewMode(ViewMode.Projects)
|
|
131
|
+
ctx.refreshItems(ViewMode.Projects)
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (ctx.prefixKey && matchesPrefixKey(key, ctx.prefixKey)) {
|
|
139
|
+
ctx.setPrefixActive(true)
|
|
140
|
+
const timeout = setTimeout(() => {
|
|
141
|
+
ctx.setPrefixActive(false)
|
|
142
|
+
}, 2000)
|
|
143
|
+
ctx.prefixTimeoutRef.current = timeout
|
|
144
|
+
return
|
|
145
|
+
}
|
|
146
|
+
|
|
61
147
|
// Handle quit (q for vim, Ctrl+Q or Escape for standard)
|
|
62
148
|
if (
|
|
63
149
|
(isStandard && ((key.ctrl && keyName === 'q') || keyName === 'escape')) ||
|
|
@@ -68,14 +154,16 @@ export function handleNormalMode(
|
|
|
68
154
|
}
|
|
69
155
|
|
|
70
156
|
// Handle search mode (i for vim, Ctrl+I for standard)
|
|
71
|
-
if (
|
|
157
|
+
if (!isStandard && keyName === 'i') {
|
|
158
|
+
ctx.clearPendingKill()
|
|
72
159
|
ctx.setAppMode(AppMode.Search)
|
|
73
160
|
ctx.setSearchQuery('')
|
|
74
161
|
return
|
|
75
162
|
}
|
|
76
163
|
|
|
77
164
|
// Handle new session (n for vim, Ctrl+N for standard)
|
|
78
|
-
if (
|
|
165
|
+
if (!isStandard && keyName === 'n') {
|
|
166
|
+
ctx.clearPendingKill()
|
|
79
167
|
ctx.setAppMode(AppMode.NewSession)
|
|
80
168
|
if (ctx.viewMode === ViewMode.Sessions) {
|
|
81
169
|
}
|
|
@@ -88,7 +176,8 @@ export function handleNormalMode(
|
|
|
88
176
|
}
|
|
89
177
|
|
|
90
178
|
// Handle opencode mode (o for vim, Ctrl+O for standard)
|
|
91
|
-
if (
|
|
179
|
+
if (!isStandard && keyName === 'o') {
|
|
180
|
+
ctx.clearPendingKill()
|
|
92
181
|
if (ctx.viewMode === ViewMode.Sessions && ctx.opencodeSessions.length > 0) {
|
|
93
182
|
ctx.setAppMode(AppMode.OpencodeManage)
|
|
94
183
|
ctx.setOpencodeCursor(0)
|
|
@@ -97,19 +186,28 @@ export function handleNormalMode(
|
|
|
97
186
|
return
|
|
98
187
|
}
|
|
99
188
|
|
|
100
|
-
if (
|
|
189
|
+
if (key.ctrl && keyName === 'p') {
|
|
190
|
+
ctx.clearPendingKill()
|
|
191
|
+
ctx.openCommandsModal()
|
|
192
|
+
return
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (!ctx.prefixKey && !isStandard && keyName === 'l') {
|
|
196
|
+
ctx.clearPendingKill()
|
|
101
197
|
void ctx.handleLastSession()
|
|
102
198
|
return
|
|
103
199
|
}
|
|
104
200
|
|
|
105
|
-
if (
|
|
201
|
+
if (!ctx.prefixKey && !isStandard && keyName === 'g') {
|
|
202
|
+
ctx.clearPendingKill()
|
|
106
203
|
const selectedItem =
|
|
107
204
|
ctx.viewMode === ViewMode.Sessions ? ctx.regularSessions[ctx.cursor] : ctx.items[ctx.cursor]
|
|
108
205
|
void ctx.handleRootSession(selectedItem)
|
|
109
206
|
return
|
|
110
207
|
}
|
|
111
208
|
|
|
112
|
-
if (
|
|
209
|
+
if (!ctx.prefixKey && !isStandard && keyName === 'e') {
|
|
210
|
+
ctx.clearPendingKill()
|
|
113
211
|
const selectedItem = ctx.viewMode === ViewMode.Sessions ? ctx.regularSessions[ctx.cursor] : ctx.items[ctx.cursor]
|
|
114
212
|
if (selectedItem?.itemKind === 'configured') {
|
|
115
213
|
void ctx.handleEditTarget(selectedItem)
|
|
@@ -118,31 +216,29 @@ export function handleNormalMode(
|
|
|
118
216
|
}
|
|
119
217
|
|
|
120
218
|
// Handle delete/kill (d for vim, Ctrl+D for standard)
|
|
121
|
-
if (
|
|
219
|
+
if (!isStandard && keyName === 'd') {
|
|
122
220
|
if (ctx.viewMode === ViewMode.Sessions && ctx.regularSessions[ctx.cursor]?.isSession) {
|
|
123
|
-
ctx.
|
|
221
|
+
ctx.requestKillSession(ctx.regularSessions[ctx.cursor].title)
|
|
124
222
|
}
|
|
125
223
|
return
|
|
126
224
|
}
|
|
127
225
|
|
|
128
226
|
// Handle rename (r for vim, Ctrl+R for standard)
|
|
129
227
|
if (
|
|
130
|
-
|
|
131
|
-
(isStandard && key.ctrl && keyName === 'r' && !key.shift)
|
|
228
|
+
!ctx.prefixKey && !isStandard && keyName === 'r'
|
|
132
229
|
) {
|
|
133
230
|
if (ctx.viewMode === ViewMode.Sessions && ctx.regularSessions[ctx.cursor]?.isSession) {
|
|
134
|
-
ctx.
|
|
135
|
-
ctx.
|
|
136
|
-
ctx.setSearchQuery(ctx.regularSessions[ctx.cursor].title)
|
|
231
|
+
ctx.clearPendingKill()
|
|
232
|
+
ctx.openRenameModal(ctx.regularSessions[ctx.cursor].title)
|
|
137
233
|
}
|
|
138
234
|
return
|
|
139
235
|
}
|
|
140
236
|
|
|
141
237
|
// Handle refresh (R for vim, Ctrl+Shift+R for standard)
|
|
142
238
|
if (
|
|
143
|
-
|
|
144
|
-
(isStandard && key.ctrl && key.shift && keyName === 'r')
|
|
239
|
+
!ctx.prefixKey && !isStandard && keyName === 'R'
|
|
145
240
|
) {
|
|
241
|
+
ctx.clearPendingKill()
|
|
146
242
|
ctx.refreshItems()
|
|
147
243
|
ctx.setMessage('Refreshed')
|
|
148
244
|
setTimeout(() => ctx.setMessage(''), 2000)
|
|
@@ -152,11 +248,13 @@ export function handleNormalMode(
|
|
|
152
248
|
// Handle view mode switches (vim only)
|
|
153
249
|
if (!isStandard) {
|
|
154
250
|
if (keyName === 's') {
|
|
251
|
+
ctx.clearPendingKill()
|
|
155
252
|
ctx.setViewMode(ViewMode.Sessions)
|
|
156
253
|
ctx.refreshItems(ViewMode.Sessions)
|
|
157
254
|
return
|
|
158
255
|
}
|
|
159
256
|
if (keyName === 'p') {
|
|
257
|
+
ctx.clearPendingKill()
|
|
160
258
|
ctx.setViewMode(ViewMode.Projects)
|
|
161
259
|
ctx.refreshItems(ViewMode.Projects)
|
|
162
260
|
return
|
|
@@ -165,6 +263,7 @@ export function handleNormalMode(
|
|
|
165
263
|
|
|
166
264
|
// Handle navigation
|
|
167
265
|
if (keyName === 'down' || (!isStandard && keyName === 'j')) {
|
|
266
|
+
ctx.clearPendingKill()
|
|
168
267
|
if (ctx.viewMode === ViewMode.Sessions) {
|
|
169
268
|
ctx.setCursor(c => Math.min(c + 1, ctx.regularSessions.length - 1))
|
|
170
269
|
} else {
|
|
@@ -174,12 +273,14 @@ export function handleNormalMode(
|
|
|
174
273
|
}
|
|
175
274
|
|
|
176
275
|
if (keyName === 'up' || (!isStandard && keyName === 'k')) {
|
|
276
|
+
ctx.clearPendingKill()
|
|
177
277
|
ctx.setCursor(c => Math.max(c - 1, 0))
|
|
178
278
|
return
|
|
179
279
|
}
|
|
180
280
|
|
|
181
281
|
// Handle selection
|
|
182
282
|
if (keyName === 'return') {
|
|
283
|
+
ctx.clearPendingKill()
|
|
183
284
|
if (ctx.regularSessions[ctx.cursor]) {
|
|
184
285
|
ctx.handleSelect(ctx.regularSessions[ctx.cursor])
|
|
185
286
|
}
|
|
@@ -188,6 +289,7 @@ export function handleNormalMode(
|
|
|
188
289
|
|
|
189
290
|
// Handle number shortcuts (vim only)
|
|
190
291
|
if (!isStandard && keyName >= '1' && keyName <= '9') {
|
|
292
|
+
ctx.clearPendingKill()
|
|
191
293
|
const num = parseInt(keyName, 10) - 1
|
|
192
294
|
if (num >= 0 && num < ctx.regularSessions.length) {
|
|
193
295
|
ctx.handleSelect(ctx.regularSessions[num])
|
|
@@ -203,18 +305,62 @@ export function handleOpencodeManageMode(
|
|
|
203
305
|
const keyName = getKeyName(key)
|
|
204
306
|
const isStandard = keybindMode === 'standard'
|
|
205
307
|
|
|
308
|
+
if (key.ctrl && keyName === 'p') {
|
|
309
|
+
ctx.clearPendingKill()
|
|
310
|
+
ctx.openCommandsModal()
|
|
311
|
+
return
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (ctx.prefixActive) {
|
|
315
|
+
if (ctx.prefixTimeoutRef.current) {
|
|
316
|
+
clearTimeout(ctx.prefixTimeoutRef.current)
|
|
317
|
+
ctx.prefixTimeoutRef.current = null
|
|
318
|
+
}
|
|
319
|
+
ctx.setPrefixActive(false)
|
|
320
|
+
|
|
321
|
+
switch (keyName) {
|
|
322
|
+
case 'o':
|
|
323
|
+
ctx.clearPendingKill()
|
|
324
|
+
ctx.setAppMode(AppMode.Normal)
|
|
325
|
+
return
|
|
326
|
+
case 'd':
|
|
327
|
+
if (ctx.opencodeSessions[ctx.opencodeCursor]) {
|
|
328
|
+
ctx.requestKillSession(ctx.opencodeSessions[ctx.opencodeCursor].title)
|
|
329
|
+
}
|
|
330
|
+
return
|
|
331
|
+
case 'r':
|
|
332
|
+
if (ctx.opencodeSessions[ctx.opencodeCursor]) {
|
|
333
|
+
ctx.clearPendingKill()
|
|
334
|
+
ctx.openRenameModal(ctx.opencodeSessions[ctx.opencodeCursor].title)
|
|
335
|
+
}
|
|
336
|
+
return
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if (ctx.prefixKey && matchesPrefixKey(key, ctx.prefixKey)) {
|
|
343
|
+
ctx.setPrefixActive(true)
|
|
344
|
+
const timeout = setTimeout(() => {
|
|
345
|
+
ctx.setPrefixActive(false)
|
|
346
|
+
}, 2000)
|
|
347
|
+
ctx.prefixTimeoutRef.current = timeout
|
|
348
|
+
return
|
|
349
|
+
}
|
|
350
|
+
|
|
206
351
|
// Handle back/exit (o/Esc for vim, Ctrl+O/Esc for standard)
|
|
207
352
|
if (
|
|
208
353
|
keyName === 'escape' ||
|
|
209
|
-
(!isStandard && keyName === 'o')
|
|
210
|
-
(isStandard && key.ctrl && keyName === 'o')
|
|
354
|
+
(!ctx.prefixKey && !isStandard && keyName === 'o')
|
|
211
355
|
) {
|
|
356
|
+
ctx.clearPendingKill()
|
|
212
357
|
ctx.setAppMode(AppMode.Normal)
|
|
213
358
|
return
|
|
214
359
|
}
|
|
215
360
|
|
|
216
361
|
// Handle navigation down
|
|
217
362
|
if (keyName === 'down' || (!isStandard && keyName === 'j')) {
|
|
363
|
+
ctx.clearPendingKill()
|
|
218
364
|
ctx.setOpencodeCursor(c => {
|
|
219
365
|
const newCursor = Math.min(c + 1, ctx.opencodeSessions.length - 1)
|
|
220
366
|
if (newCursor !== c && ctx.opencodeSessions[newCursor]) {
|
|
@@ -227,6 +373,7 @@ export function handleOpencodeManageMode(
|
|
|
227
373
|
|
|
228
374
|
// Handle navigation up
|
|
229
375
|
if (keyName === 'up' || (!isStandard && keyName === 'k')) {
|
|
376
|
+
ctx.clearPendingKill()
|
|
230
377
|
ctx.setOpencodeCursor(c => {
|
|
231
378
|
const newCursor = Math.max(c - 1, 0)
|
|
232
379
|
if (newCursor !== c && ctx.opencodeSessions[newCursor]) {
|
|
@@ -238,20 +385,26 @@ export function handleOpencodeManageMode(
|
|
|
238
385
|
}
|
|
239
386
|
|
|
240
387
|
// Handle delete/kill (d for vim, Ctrl+D for standard)
|
|
241
|
-
if (
|
|
388
|
+
if (!isStandard && keyName === 'd') {
|
|
242
389
|
if (ctx.opencodeSessions[ctx.opencodeCursor]) {
|
|
243
|
-
ctx.
|
|
390
|
+
ctx.requestKillSession(ctx.opencodeSessions[ctx.opencodeCursor].title)
|
|
244
391
|
}
|
|
245
392
|
return
|
|
246
393
|
}
|
|
247
394
|
|
|
248
395
|
// Handle rename (r for vim, Ctrl+R for standard)
|
|
249
|
-
if (
|
|
396
|
+
if (!ctx.prefixKey && !isStandard && keyName === 'r') {
|
|
250
397
|
if (ctx.opencodeSessions[ctx.opencodeCursor]) {
|
|
251
|
-
ctx.
|
|
252
|
-
ctx.
|
|
253
|
-
ctx.setSearchQuery(ctx.opencodeSessions[ctx.opencodeCursor].title)
|
|
398
|
+
ctx.clearPendingKill()
|
|
399
|
+
ctx.openRenameModal(ctx.opencodeSessions[ctx.opencodeCursor].title)
|
|
254
400
|
}
|
|
401
|
+
return
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
if (!ctx.prefixKey && !isStandard && keyName === ',') {
|
|
405
|
+
ctx.clearPendingKill()
|
|
406
|
+
ctx.openSettingsModal()
|
|
407
|
+
return
|
|
255
408
|
}
|
|
256
409
|
}
|
|
257
410
|
|
|
@@ -277,10 +430,11 @@ export function handleSearchMode(
|
|
|
277
430
|
switch (keyName) {
|
|
278
431
|
case 'd': // Ctrl+X d - delete/kill
|
|
279
432
|
if (ctx.viewMode === ViewMode.Sessions && ctx.items[ctx.cursor]?.isSession) {
|
|
280
|
-
ctx.
|
|
433
|
+
ctx.requestKillSession(ctx.items[ctx.cursor].title)
|
|
281
434
|
}
|
|
282
435
|
return
|
|
283
436
|
case 'n': // Ctrl+X n - new session
|
|
437
|
+
ctx.clearPendingKill()
|
|
284
438
|
ctx.setSearchQuery('')
|
|
285
439
|
ctx.setAppMode(AppMode.NewSession)
|
|
286
440
|
ctx.setViewMode(ViewMode.Projects)
|
|
@@ -289,16 +443,23 @@ export function handleSearchMode(
|
|
|
289
443
|
ctx.setCursor(Math.max(0, ctx.projectItems.length - 1))
|
|
290
444
|
return
|
|
291
445
|
case 'o': // Ctrl+X o - opencode
|
|
446
|
+
ctx.clearPendingKill()
|
|
292
447
|
if (ctx.viewMode === ViewMode.Sessions && ctx.opencodeSessions.length > 0) {
|
|
293
448
|
ctx.setAppMode(AppMode.OpencodeManage)
|
|
294
449
|
ctx.setOpencodeCursor(0)
|
|
295
450
|
ctx.loadOpencodeStatsForSession(ctx.opencodeSessions[0].title)
|
|
296
451
|
}
|
|
297
452
|
return
|
|
453
|
+
case 's':
|
|
454
|
+
ctx.clearPendingKill()
|
|
455
|
+
ctx.openSettingsModal()
|
|
456
|
+
return
|
|
298
457
|
case 'l': // Ctrl+X l - last session
|
|
458
|
+
ctx.clearPendingKill()
|
|
299
459
|
void ctx.handleLastSession()
|
|
300
460
|
return
|
|
301
461
|
case 'g': { // Ctrl+X g - root session
|
|
462
|
+
ctx.clearPendingKill()
|
|
302
463
|
const selectedItem = ctx.viewMode === ViewMode.Sessions ? ctx.items[ctx.cursor] : ctx.items[ctx.cursor]
|
|
303
464
|
void ctx.handleRootSession(selectedItem)
|
|
304
465
|
return
|
|
@@ -312,9 +473,8 @@ export function handleSearchMode(
|
|
|
312
473
|
}
|
|
313
474
|
|
|
314
475
|
if (ctx.viewMode === ViewMode.Sessions && ctx.items[ctx.cursor]?.isSession) {
|
|
315
|
-
ctx.
|
|
316
|
-
ctx.
|
|
317
|
-
ctx.setSearchQuery(ctx.items[ctx.cursor].title)
|
|
476
|
+
ctx.clearPendingKill()
|
|
477
|
+
ctx.openRenameModal(ctx.items[ctx.cursor].title)
|
|
318
478
|
}
|
|
319
479
|
return
|
|
320
480
|
default:
|
|
@@ -324,7 +484,7 @@ export function handleSearchMode(
|
|
|
324
484
|
}
|
|
325
485
|
|
|
326
486
|
// Handle Ctrl+X prefix activation
|
|
327
|
-
if (key.
|
|
487
|
+
if (matchesPrefixKey(key, ctx.prefixKey)) {
|
|
328
488
|
ctx.setPrefixActive(true)
|
|
329
489
|
|
|
330
490
|
// Clear prefix after 2 seconds if no key pressed
|
|
@@ -344,6 +504,7 @@ export function handleSearchMode(
|
|
|
344
504
|
|
|
345
505
|
// Handle Esc differently based on mode
|
|
346
506
|
if (keyName === 'escape') {
|
|
507
|
+
ctx.clearPendingKill()
|
|
347
508
|
if (isStandard) {
|
|
348
509
|
// Standard mode: just clear search, stay in search mode
|
|
349
510
|
ctx.setSearchQuery('')
|
|
@@ -359,14 +520,17 @@ export function handleSearchMode(
|
|
|
359
520
|
|
|
360
521
|
switch (keyName) {
|
|
361
522
|
case 'return':
|
|
523
|
+
ctx.clearPendingKill()
|
|
362
524
|
if (ctx.items.length > 0) {
|
|
363
525
|
ctx.handleSelect(ctx.items[0])
|
|
364
526
|
}
|
|
365
527
|
break
|
|
366
528
|
case 'down':
|
|
529
|
+
ctx.clearPendingKill()
|
|
367
530
|
ctx.setCursor(c => Math.min(c + 1, ctx.items.length - 1))
|
|
368
531
|
break
|
|
369
532
|
case 'up':
|
|
533
|
+
ctx.clearPendingKill()
|
|
370
534
|
ctx.setCursor(c => Math.max(c - 1, 0))
|
|
371
535
|
break
|
|
372
536
|
}
|
|
@@ -383,7 +547,8 @@ export function handleNewSessionMode(
|
|
|
383
547
|
// Handle Ctrl keybinds in standard mode
|
|
384
548
|
if (isStandard && key.ctrl) {
|
|
385
549
|
// Ctrl+I to switch to search mode
|
|
386
|
-
|
|
550
|
+
if (keyName === 'i') {
|
|
551
|
+
ctx.clearPendingKill()
|
|
387
552
|
ctx.setAppMode(AppMode.Search)
|
|
388
553
|
ctx.setViewMode(ViewMode.Sessions)
|
|
389
554
|
ctx.setAllItems(ctx.sessionItems)
|
|
@@ -394,13 +559,14 @@ export function handleNewSessionMode(
|
|
|
394
559
|
|
|
395
560
|
// Ctrl+D to delete session (if on sessions view)
|
|
396
561
|
if (keyName === 'd' && ctx.items[ctx.cursor]?.isSession) {
|
|
397
|
-
ctx.
|
|
562
|
+
ctx.requestKillSession(ctx.items[ctx.cursor].title)
|
|
398
563
|
return
|
|
399
564
|
}
|
|
400
565
|
}
|
|
401
566
|
|
|
402
567
|
// Handle Esc differently based on mode
|
|
403
568
|
if (keyName === 'escape') {
|
|
569
|
+
ctx.clearPendingKill()
|
|
404
570
|
if (isStandard) {
|
|
405
571
|
// Standard mode: return to search mode (always in insert mode)
|
|
406
572
|
ctx.setAppMode(AppMode.Search)
|
|
@@ -423,9 +589,11 @@ export function handleNewSessionMode(
|
|
|
423
589
|
case 'return':
|
|
424
590
|
break
|
|
425
591
|
case 'down':
|
|
592
|
+
ctx.clearPendingKill()
|
|
426
593
|
ctx.setCursor(c => Math.min(c + 1, ctx.items.length - 1))
|
|
427
594
|
break
|
|
428
595
|
case 'up':
|
|
596
|
+
ctx.clearPendingKill()
|
|
429
597
|
ctx.setCursor(c => Math.max(c - 1, 0))
|
|
430
598
|
break
|
|
431
599
|
}
|
|
@@ -442,7 +610,8 @@ export function handleRenameMode(
|
|
|
442
610
|
// Handle Ctrl keybinds in standard mode
|
|
443
611
|
if (isStandard && key.ctrl) {
|
|
444
612
|
// Ctrl+I to switch to search mode
|
|
445
|
-
|
|
613
|
+
if (keyName === 'i') {
|
|
614
|
+
ctx.clearPendingKill()
|
|
446
615
|
ctx.setAppMode(AppMode.Search)
|
|
447
616
|
ctx.setSearchQuery('')
|
|
448
617
|
ctx.setRenameTarget('')
|
|
@@ -451,7 +620,7 @@ export function handleRenameMode(
|
|
|
451
620
|
|
|
452
621
|
// Ctrl+D to delete the rename target session
|
|
453
622
|
if (keyName === 'd' && ctx.renameTarget) {
|
|
454
|
-
ctx.
|
|
623
|
+
ctx.requestKillSession(ctx.renameTarget)
|
|
455
624
|
ctx.setAppMode(AppMode.Search)
|
|
456
625
|
ctx.setSearchQuery('')
|
|
457
626
|
ctx.setRenameTarget('')
|
|
@@ -461,6 +630,7 @@ export function handleRenameMode(
|
|
|
461
630
|
|
|
462
631
|
// Handle Esc differently based on mode
|
|
463
632
|
if (keyName === 'escape') {
|
|
633
|
+
ctx.clearPendingKill()
|
|
464
634
|
if (isStandard) {
|
|
465
635
|
// Standard mode: return to search mode (always in insert mode)
|
|
466
636
|
ctx.setAppMode(AppMode.Search)
|