mux-sesh 1.6.4 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -59
- package/package.json +7 -5
- package/src/app/commands.ts +120 -0
- package/src/app/controller.ts +397 -0
- package/src/app/controls.ts +121 -0
- package/src/app/core-state.ts +71 -0
- package/src/app/data.ts +90 -0
- package/src/app/derived.ts +77 -0
- package/src/app/effects.ts +392 -0
- package/src/app/handlers.ts +325 -0
- package/src/app/keyboard.ts +161 -0
- package/src/app/modal-keyboard.ts +118 -0
- package/src/app/modal-state.ts +50 -0
- package/src/app/modals-layer.tsx +159 -0
- package/src/app/modals.ts +108 -0
- package/src/app/notifications.ts +21 -0
- package/src/app/opencode.ts +49 -0
- package/src/app/operations.ts +31 -0
- package/src/app/runtime.ts +76 -0
- package/src/app/screen.tsx +217 -0
- package/src/app/state.ts +166 -0
- package/src/app/textarea.ts +16 -0
- package/src/app/view.ts +89 -0
- package/src/app.tsx +7 -1136
- package/src/config/index.ts +36 -42
- package/src/config/paths.ts +13 -0
- package/src/config/session-rules.ts +6 -2
- package/src/config/store.ts +26 -0
- package/src/handlers/action-helpers.ts +50 -0
- package/src/handlers/actions.ts +34 -65
- package/src/handlers/keyboard/index.ts +5 -0
- package/src/handlers/keyboard/new-session.ts +57 -0
- package/src/handlers/keyboard/normal.ts +201 -0
- package/src/handlers/keyboard/opencode.ts +104 -0
- package/src/handlers/keyboard/search.ts +113 -0
- package/src/handlers/keyboard/shared.ts +116 -0
- package/src/opencode/sqlite.ts +21 -6
- package/src/preview/project.ts +41 -15
- package/src/search/index.ts +4 -1
- package/src/settings.ts +294 -297
- package/src/styles/opencode-themes-a.ts +1442 -1
- package/src/styles/opencode-themes-b.ts +1212 -1
- package/src/styles/opencode-tui-colors.ts +1784 -1
- package/src/styles/theme.tsx +2 -1
- package/src/tmux/actions.ts +103 -0
- package/src/tmux/details.ts +123 -0
- package/src/tmux/helpers.ts +35 -0
- package/src/tmux/index.ts +10 -288
- package/src/tmux/list.ts +31 -0
- package/src/tmux/project-discovery.ts +113 -0
- package/src/tmux/project-loader.ts +74 -0
- package/src/tmux/project-zoxide.ts +128 -0
- package/src/tmux/projects.ts +23 -262
- package/src/types/index.ts +0 -1
- package/src/ui/CommandsModal.tsx +87 -22
- package/src/ui/HighlightedText.tsx +1 -5
- package/src/ui/ItemList.tsx +14 -4
- package/src/ui/Modal.tsx +8 -1
- package/src/ui/OpencodeSessionGroup.tsx +20 -9
- package/src/ui/OpencodeStatsPanel.tsx +48 -15
- package/src/ui/RenameModal.tsx +17 -17
- package/src/ui/SearchInput.tsx +1 -20
- package/src/ui/SessionDetailsPanel.tsx +43 -15
- package/src/ui/SessionList.tsx +23 -6
- package/src/ui/SettingEditorModal.tsx +15 -9
- package/src/ui/SettingOptionsModal.tsx +30 -12
- package/src/ui/SettingsModal.tsx +20 -14
- package/src/ui/VersionBadge.tsx +3 -1
- package/src/ui/item-icon.ts +5 -1
- package/src/ui/list-window.ts +5 -1
- package/src/ui/use-textarea-focus.ts +26 -0
- package/src/update/index.ts +10 -2
- package/src/update/installation.ts +6 -2
- package/src/util/ansi.ts +3 -0
- package/src/util/glob.ts +5 -1
- package/src/components/KeybindHelp.tsx +0 -289
- package/src/handlers/keyboard.ts +0 -654
- package/src/ui/SessionStats.tsx +0 -32
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { filterCommandEntries, getCommandEntries, type CommandEntry } from '../ui/CommandsModal'
|
|
2
|
+
import {
|
|
3
|
+
filterSettingsEntries,
|
|
4
|
+
filterSettingsOptions,
|
|
5
|
+
getSettingsEntries,
|
|
6
|
+
getSettingOptions,
|
|
7
|
+
type SettingsEntry,
|
|
8
|
+
type SettingsOption,
|
|
9
|
+
} from '../settings'
|
|
10
|
+
import { AppMode, ViewMode, type Config, type Item } from '../types'
|
|
11
|
+
import type { ModalState } from './modals'
|
|
12
|
+
import { splitVisibleSessions } from './view'
|
|
13
|
+
|
|
14
|
+
interface SessionCommandState {
|
|
15
|
+
regularSessions: Item[]
|
|
16
|
+
opencodeSessions: Item[]
|
|
17
|
+
selectedOpencodeSessionName: string | undefined
|
|
18
|
+
selectedPrimaryItem: Item | undefined
|
|
19
|
+
filteredCommandEntries: CommandEntry[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface SettingsState {
|
|
23
|
+
filteredSettingsEntries: SettingsEntry[]
|
|
24
|
+
filteredSettingOptions: SettingsOption[]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function getSessionCommandState(
|
|
28
|
+
appMode: AppMode,
|
|
29
|
+
viewMode: ViewMode,
|
|
30
|
+
items: Item[],
|
|
31
|
+
cursor: number,
|
|
32
|
+
opencodeCursor: number,
|
|
33
|
+
config: Config | null,
|
|
34
|
+
commandsSearchQuery: string
|
|
35
|
+
): SessionCommandState {
|
|
36
|
+
const sessionSplit =
|
|
37
|
+
viewMode === ViewMode.Sessions &&
|
|
38
|
+
(appMode === AppMode.Normal || appMode === AppMode.OpencodeManage)
|
|
39
|
+
? splitVisibleSessions(items)
|
|
40
|
+
: { regularSessions: items, opencodeSessions: [] }
|
|
41
|
+
|
|
42
|
+
const selectedPrimaryItem =
|
|
43
|
+
viewMode === ViewMode.Sessions && appMode === AppMode.Normal
|
|
44
|
+
? sessionSplit.regularSessions[cursor]
|
|
45
|
+
: items[cursor]
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
regularSessions: sessionSplit.regularSessions,
|
|
49
|
+
opencodeSessions: sessionSplit.opencodeSessions,
|
|
50
|
+
selectedOpencodeSessionName:
|
|
51
|
+
appMode === AppMode.OpencodeManage
|
|
52
|
+
? sessionSplit.opencodeSessions[opencodeCursor]?.title
|
|
53
|
+
: undefined,
|
|
54
|
+
selectedPrimaryItem,
|
|
55
|
+
filteredCommandEntries: filterCommandEntries(
|
|
56
|
+
getCommandEntries(appMode, config?.keybindMode, config?.prefixKey, selectedPrimaryItem),
|
|
57
|
+
commandsSearchQuery
|
|
58
|
+
),
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function getSettingsState(
|
|
63
|
+
config: Config | null,
|
|
64
|
+
modalState: ModalState,
|
|
65
|
+
settingsSearchQuery: string,
|
|
66
|
+
settingOptionsSearchQuery: string
|
|
67
|
+
): SettingsState {
|
|
68
|
+
const settingsEntries = config ? getSettingsEntries(config) : []
|
|
69
|
+
const currentOptionField = modalState?.type === 'setting-options' ? modalState.field : undefined
|
|
70
|
+
const settingOptions =
|
|
71
|
+
config && currentOptionField ? getSettingOptions(config, currentOptionField) : []
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
filteredSettingsEntries: filterSettingsEntries(settingsEntries, settingsSearchQuery),
|
|
75
|
+
filteredSettingOptions: filterSettingsOptions(settingOptions, settingOptionsSearchQuery),
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import { useEffect, useRef, type Dispatch, type MutableRefObject, type SetStateAction } from 'react'
|
|
2
|
+
import { checkAndUpdate, updateEvents } from '../update'
|
|
3
|
+
import { showTemporaryToast } from './notifications'
|
|
4
|
+
import { clearMatchIndices, filterAndSortItems } from '../search'
|
|
5
|
+
import {
|
|
6
|
+
getProjectSelectionIndex,
|
|
7
|
+
getSessionSelectionIndex,
|
|
8
|
+
loadSessionCandidateItems,
|
|
9
|
+
} from './data'
|
|
10
|
+
import { AppMode, ViewMode, type Config, type Item } from '../types'
|
|
11
|
+
import { measure } from '../util/perf'
|
|
12
|
+
|
|
13
|
+
export function useAutoUpdateScheduler(
|
|
14
|
+
config: Config | null,
|
|
15
|
+
hasScheduledAutoUpdateRef: MutableRefObject<boolean>
|
|
16
|
+
) {
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (!config || hasScheduledAutoUpdateRef.current) {
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
hasScheduledAutoUpdateRef.current = true
|
|
23
|
+
|
|
24
|
+
const timeout = setTimeout(() => {
|
|
25
|
+
checkAndUpdate(config).catch(error => {
|
|
26
|
+
console.error('Auto-update check failed:', error)
|
|
27
|
+
})
|
|
28
|
+
}, 1000)
|
|
29
|
+
|
|
30
|
+
return () => clearTimeout(timeout)
|
|
31
|
+
}, [config, hasScheduledAutoUpdateRef])
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function useUpdateEventToasts(
|
|
35
|
+
setUpdatedVersion: Dispatch<SetStateAction<string | null>>,
|
|
36
|
+
setToastMessage: Dispatch<SetStateAction<string>>,
|
|
37
|
+
setToastVisible: Dispatch<SetStateAction<boolean>>
|
|
38
|
+
) {
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const unsubscribe = updateEvents.on(event => {
|
|
41
|
+
if (event.kind === 'updated') {
|
|
42
|
+
setUpdatedVersion(event.version)
|
|
43
|
+
showTemporaryToast(
|
|
44
|
+
setToastMessage,
|
|
45
|
+
setToastVisible,
|
|
46
|
+
`Updated in background to v${event.version}. Restart mux-sesh to use it.`
|
|
47
|
+
)
|
|
48
|
+
} else if (event.kind === 'available') {
|
|
49
|
+
showTemporaryToast(setToastMessage, setToastVisible, `Update available: v${event.version}`)
|
|
50
|
+
} else {
|
|
51
|
+
showTemporaryToast(
|
|
52
|
+
setToastMessage,
|
|
53
|
+
setToastVisible,
|
|
54
|
+
`Background update to v${event.version} failed.`
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
return unsubscribe
|
|
60
|
+
}, [setToastMessage, setToastVisible, setUpdatedVersion])
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function useNormalModeSessionReset(
|
|
64
|
+
appMode: AppMode,
|
|
65
|
+
viewMode: ViewMode,
|
|
66
|
+
sessionItems: Item[],
|
|
67
|
+
lastSessionSelectionRef: MutableRefObject<string | null>,
|
|
68
|
+
setAllItems: Dispatch<SetStateAction<Item[]>>,
|
|
69
|
+
setItems: Dispatch<SetStateAction<Item[]>>,
|
|
70
|
+
setCursor: Dispatch<SetStateAction<number>>
|
|
71
|
+
) {
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (appMode !== AppMode.Normal || viewMode !== ViewMode.Sessions) {
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const cleanSessions = clearMatchIndices(sessionItems)
|
|
78
|
+
setAllItems(cleanSessions)
|
|
79
|
+
setItems(cleanSessions)
|
|
80
|
+
setCursor(getSessionSelectionIndex(cleanSessions, lastSessionSelectionRef.current))
|
|
81
|
+
}, [appMode, lastSessionSelectionRef, sessionItems, setAllItems, setCursor, setItems, viewMode])
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function useNewSessionProjectCursor(
|
|
85
|
+
appMode: AppMode,
|
|
86
|
+
viewMode: ViewMode,
|
|
87
|
+
projectSourceItems: Item[],
|
|
88
|
+
sessionCandidateItems: Item[],
|
|
89
|
+
lastProjectSelectionRef: MutableRefObject<string | null>,
|
|
90
|
+
setCursor: Dispatch<SetStateAction<number>>
|
|
91
|
+
) {
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (appMode !== AppMode.NewSession || viewMode !== ViewMode.Projects) {
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
setCursor(
|
|
98
|
+
getProjectSelectionIndex(
|
|
99
|
+
sessionCandidateItems.length > 0 ? sessionCandidateItems : projectSourceItems,
|
|
100
|
+
lastProjectSelectionRef.current
|
|
101
|
+
)
|
|
102
|
+
)
|
|
103
|
+
}, [
|
|
104
|
+
appMode,
|
|
105
|
+
lastProjectSelectionRef,
|
|
106
|
+
projectSourceItems,
|
|
107
|
+
sessionCandidateItems,
|
|
108
|
+
setCursor,
|
|
109
|
+
viewMode,
|
|
110
|
+
])
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function useSessionCandidateLoader(
|
|
114
|
+
appMode: AppMode,
|
|
115
|
+
config: Config | null,
|
|
116
|
+
lastProjectSelectionRef: MutableRefObject<string | null>,
|
|
117
|
+
setSessionCandidateItems: Dispatch<SetStateAction<Item[]>>,
|
|
118
|
+
setAllItems: Dispatch<SetStateAction<Item[]>>,
|
|
119
|
+
setItems: Dispatch<SetStateAction<Item[]>>,
|
|
120
|
+
setCursor: Dispatch<SetStateAction<number>>
|
|
121
|
+
) {
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
if (appMode !== AppMode.NewSession || !config) {
|
|
124
|
+
return
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const nextConfig = config
|
|
128
|
+
let cancelled = false
|
|
129
|
+
|
|
130
|
+
async function loadCandidates() {
|
|
131
|
+
const linkedCandidates = await loadSessionCandidateItems(nextConfig, measure)
|
|
132
|
+
if (cancelled) {
|
|
133
|
+
return
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
setSessionCandidateItems(linkedCandidates)
|
|
137
|
+
setAllItems(linkedCandidates)
|
|
138
|
+
setItems(linkedCandidates)
|
|
139
|
+
setCursor(getProjectSelectionIndex(linkedCandidates, lastProjectSelectionRef.current))
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
void loadCandidates()
|
|
143
|
+
|
|
144
|
+
return () => {
|
|
145
|
+
cancelled = true
|
|
146
|
+
}
|
|
147
|
+
}, [
|
|
148
|
+
appMode,
|
|
149
|
+
config,
|
|
150
|
+
lastProjectSelectionRef,
|
|
151
|
+
setAllItems,
|
|
152
|
+
setCursor,
|
|
153
|
+
setItems,
|
|
154
|
+
setSessionCandidateItems,
|
|
155
|
+
])
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function useBoundedCursor(length: number, setCursor: Dispatch<SetStateAction<number>>) {
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
if (length === 0) {
|
|
161
|
+
setCursor(0)
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
setCursor(current => Math.min(current, length - 1))
|
|
166
|
+
}, [length, setCursor])
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function useResetCursorOnValue(value: string, setCursor: Dispatch<SetStateAction<number>>) {
|
|
170
|
+
useEffect(() => {
|
|
171
|
+
setCursor(0)
|
|
172
|
+
}, [setCursor, value])
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export function useSelectionMemory(
|
|
176
|
+
appMode: AppMode,
|
|
177
|
+
viewMode: ViewMode,
|
|
178
|
+
cursor: number,
|
|
179
|
+
items: Item[],
|
|
180
|
+
selectedPrimaryItem: Item | undefined,
|
|
181
|
+
lastProjectSelectionRef: MutableRefObject<string | null>,
|
|
182
|
+
lastSessionSelectionRef: MutableRefObject<string | null>
|
|
183
|
+
) {
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
const selectedItem = appMode === AppMode.NewSession ? items[cursor] : selectedPrimaryItem
|
|
186
|
+
|
|
187
|
+
if (!selectedItem) {
|
|
188
|
+
return
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (appMode === AppMode.NewSession || viewMode === ViewMode.Projects) {
|
|
192
|
+
if (!selectedItem.isSession) {
|
|
193
|
+
lastProjectSelectionRef.current = selectedItem.path
|
|
194
|
+
}
|
|
195
|
+
return
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (viewMode === ViewMode.Sessions && appMode === AppMode.Normal) {
|
|
199
|
+
lastSessionSelectionRef.current = selectedItem.title
|
|
200
|
+
}
|
|
201
|
+
}, [
|
|
202
|
+
appMode,
|
|
203
|
+
cursor,
|
|
204
|
+
items,
|
|
205
|
+
lastProjectSelectionRef,
|
|
206
|
+
lastSessionSelectionRef,
|
|
207
|
+
selectedPrimaryItem,
|
|
208
|
+
viewMode,
|
|
209
|
+
])
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export function usePendingKillReset(
|
|
213
|
+
pendingKillSessionName: string | null,
|
|
214
|
+
appMode: AppMode,
|
|
215
|
+
viewMode: ViewMode,
|
|
216
|
+
opencodeSessions: Item[],
|
|
217
|
+
opencodeCursor: number,
|
|
218
|
+
regularSessions: Item[],
|
|
219
|
+
cursor: number,
|
|
220
|
+
setPendingKillSessionName: Dispatch<SetStateAction<string | null>>
|
|
221
|
+
) {
|
|
222
|
+
useEffect(() => {
|
|
223
|
+
if (!pendingKillSessionName) {
|
|
224
|
+
return
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const selectedSessionName =
|
|
228
|
+
appMode === AppMode.OpencodeManage
|
|
229
|
+
? opencodeSessions[opencodeCursor]?.title
|
|
230
|
+
: viewMode === ViewMode.Sessions
|
|
231
|
+
? regularSessions[cursor]?.title
|
|
232
|
+
: undefined
|
|
233
|
+
|
|
234
|
+
if (selectedSessionName !== pendingKillSessionName) {
|
|
235
|
+
setPendingKillSessionName(null)
|
|
236
|
+
}
|
|
237
|
+
}, [
|
|
238
|
+
appMode,
|
|
239
|
+
cursor,
|
|
240
|
+
opencodeCursor,
|
|
241
|
+
opencodeSessions,
|
|
242
|
+
pendingKillSessionName,
|
|
243
|
+
regularSessions,
|
|
244
|
+
setPendingKillSessionName,
|
|
245
|
+
viewMode,
|
|
246
|
+
])
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export function useSearchFiltering(
|
|
250
|
+
appMode: AppMode,
|
|
251
|
+
searchQuery: string,
|
|
252
|
+
allItems: Item[],
|
|
253
|
+
setItems: Dispatch<SetStateAction<Item[]>>,
|
|
254
|
+
setCursor: Dispatch<SetStateAction<number>>
|
|
255
|
+
) {
|
|
256
|
+
useEffect(() => {
|
|
257
|
+
if (appMode !== AppMode.Search && appMode !== AppMode.NewSession) {
|
|
258
|
+
return
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (searchQuery.trim()) {
|
|
262
|
+
setItems(filterAndSortItems(allItems, searchQuery))
|
|
263
|
+
setCursor(0)
|
|
264
|
+
return
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
setItems(allItems)
|
|
268
|
+
setCursor(0)
|
|
269
|
+
}, [allItems, appMode, searchQuery, setCursor, setItems])
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export function useOpencodeStatsPolling(
|
|
273
|
+
selectedOpencodeSessionName: string | undefined,
|
|
274
|
+
loadOpencodeStatsForSession: (sessionName: string) => Promise<unknown>
|
|
275
|
+
) {
|
|
276
|
+
const loadStatsRef = useRef(loadOpencodeStatsForSession)
|
|
277
|
+
loadStatsRef.current = loadOpencodeStatsForSession
|
|
278
|
+
|
|
279
|
+
useEffect(() => {
|
|
280
|
+
if (!selectedOpencodeSessionName) {
|
|
281
|
+
return
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
void loadStatsRef.current(selectedOpencodeSessionName)
|
|
285
|
+
|
|
286
|
+
const interval = setInterval(() => {
|
|
287
|
+
void loadStatsRef.current(selectedOpencodeSessionName)
|
|
288
|
+
}, 2000)
|
|
289
|
+
|
|
290
|
+
return () => {
|
|
291
|
+
clearInterval(interval)
|
|
292
|
+
}
|
|
293
|
+
}, [selectedOpencodeSessionName])
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
interface UseAppBehaviorsOptions {
|
|
297
|
+
appMode: AppMode
|
|
298
|
+
viewMode: ViewMode
|
|
299
|
+
config: Config | null
|
|
300
|
+
sessionItems: Item[]
|
|
301
|
+
projectSourceItems: Item[]
|
|
302
|
+
sessionCandidateItems: Item[]
|
|
303
|
+
lastSessionSelectionRef: MutableRefObject<string | null>
|
|
304
|
+
lastProjectSelectionRef: MutableRefObject<string | null>
|
|
305
|
+
setAllItems: Dispatch<SetStateAction<Item[]>>
|
|
306
|
+
setItems: Dispatch<SetStateAction<Item[]>>
|
|
307
|
+
setCursor: Dispatch<SetStateAction<number>>
|
|
308
|
+
setSessionCandidateItems: Dispatch<SetStateAction<Item[]>>
|
|
309
|
+
filteredCommandEntriesLength: number
|
|
310
|
+
setCommandsCursor: Dispatch<SetStateAction<number>>
|
|
311
|
+
commandsSearchQuery: string
|
|
312
|
+
filteredSettingsEntriesLength: number
|
|
313
|
+
setSettingsCursor: Dispatch<SetStateAction<number>>
|
|
314
|
+
filteredSettingOptionsLength: number
|
|
315
|
+
setSettingOptionsCursor: Dispatch<SetStateAction<number>>
|
|
316
|
+
cursor: number
|
|
317
|
+
items: Item[]
|
|
318
|
+
selectedPrimaryItem: Item | undefined
|
|
319
|
+
pendingKillSessionName: string | null
|
|
320
|
+
opencodeSessions: Item[]
|
|
321
|
+
opencodeCursor: number
|
|
322
|
+
regularSessions: Item[]
|
|
323
|
+
setPendingKillSessionName: Dispatch<SetStateAction<string | null>>
|
|
324
|
+
searchQuery: string
|
|
325
|
+
allItems: Item[]
|
|
326
|
+
selectedOpencodeSessionName: string | undefined
|
|
327
|
+
loadOpencodeStatsForSession: (sessionName: string) => Promise<unknown>
|
|
328
|
+
setUpdatedVersion: Dispatch<SetStateAction<string | null>>
|
|
329
|
+
setToastMessage: Dispatch<SetStateAction<string>>
|
|
330
|
+
setToastVisible: Dispatch<SetStateAction<boolean>>
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export function useAppBehaviors(options: UseAppBehaviorsOptions) {
|
|
334
|
+
useUpdateEventToasts(options.setUpdatedVersion, options.setToastMessage, options.setToastVisible)
|
|
335
|
+
useNormalModeSessionReset(
|
|
336
|
+
options.appMode,
|
|
337
|
+
options.viewMode,
|
|
338
|
+
options.sessionItems,
|
|
339
|
+
options.lastSessionSelectionRef,
|
|
340
|
+
options.setAllItems,
|
|
341
|
+
options.setItems,
|
|
342
|
+
options.setCursor
|
|
343
|
+
)
|
|
344
|
+
useNewSessionProjectCursor(
|
|
345
|
+
options.appMode,
|
|
346
|
+
options.viewMode,
|
|
347
|
+
options.projectSourceItems,
|
|
348
|
+
options.sessionCandidateItems,
|
|
349
|
+
options.lastProjectSelectionRef,
|
|
350
|
+
options.setCursor
|
|
351
|
+
)
|
|
352
|
+
useSessionCandidateLoader(
|
|
353
|
+
options.appMode,
|
|
354
|
+
options.config,
|
|
355
|
+
options.lastProjectSelectionRef,
|
|
356
|
+
options.setSessionCandidateItems,
|
|
357
|
+
options.setAllItems,
|
|
358
|
+
options.setItems,
|
|
359
|
+
options.setCursor
|
|
360
|
+
)
|
|
361
|
+
useBoundedCursor(options.filteredCommandEntriesLength, options.setCommandsCursor)
|
|
362
|
+
useResetCursorOnValue(options.commandsSearchQuery, options.setCommandsCursor)
|
|
363
|
+
useBoundedCursor(options.filteredSettingsEntriesLength, options.setSettingsCursor)
|
|
364
|
+
useBoundedCursor(options.filteredSettingOptionsLength, options.setSettingOptionsCursor)
|
|
365
|
+
useSelectionMemory(
|
|
366
|
+
options.appMode,
|
|
367
|
+
options.viewMode,
|
|
368
|
+
options.cursor,
|
|
369
|
+
options.items,
|
|
370
|
+
options.selectedPrimaryItem,
|
|
371
|
+
options.lastProjectSelectionRef,
|
|
372
|
+
options.lastSessionSelectionRef
|
|
373
|
+
)
|
|
374
|
+
usePendingKillReset(
|
|
375
|
+
options.pendingKillSessionName,
|
|
376
|
+
options.appMode,
|
|
377
|
+
options.viewMode,
|
|
378
|
+
options.opencodeSessions,
|
|
379
|
+
options.opencodeCursor,
|
|
380
|
+
options.regularSessions,
|
|
381
|
+
options.cursor,
|
|
382
|
+
options.setPendingKillSessionName
|
|
383
|
+
)
|
|
384
|
+
useSearchFiltering(
|
|
385
|
+
options.appMode,
|
|
386
|
+
options.searchQuery,
|
|
387
|
+
options.allItems,
|
|
388
|
+
options.setItems,
|
|
389
|
+
options.setCursor
|
|
390
|
+
)
|
|
391
|
+
useOpencodeStatsPolling(options.selectedOpencodeSessionName, options.loadOpencodeStatsForSession)
|
|
392
|
+
}
|