mux-sesh 1.10.0 → 2.0.1

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.
Files changed (124) hide show
  1. package/README.md +133 -86
  2. package/bin/mux-sesh +45 -17
  3. package/bin/platform.sh +139 -0
  4. package/bin/postinstall +22 -0
  5. package/package.json +27 -38
  6. package/src/agents/index.ts +0 -1
  7. package/src/agents/session-name.ts +0 -24
  8. package/src/app/commands.ts +0 -138
  9. package/src/app/controller.ts +0 -437
  10. package/src/app/controls.ts +0 -123
  11. package/src/app/core-state.ts +0 -75
  12. package/src/app/data.ts +0 -130
  13. package/src/app/derived.ts +0 -77
  14. package/src/app/effects.ts +0 -650
  15. package/src/app/handlers.ts +0 -406
  16. package/src/app/keyboard.ts +0 -165
  17. package/src/app/modal-keyboard.ts +0 -137
  18. package/src/app/modal-state.ts +0 -53
  19. package/src/app/modals-layer.tsx +0 -159
  20. package/src/app/modals.ts +0 -108
  21. package/src/app/notifications.ts +0 -21
  22. package/src/app/opencode.ts +0 -49
  23. package/src/app/operations.ts +0 -31
  24. package/src/app/runtime.ts +0 -79
  25. package/src/app/screen.tsx +0 -240
  26. package/src/app/state.ts +0 -178
  27. package/src/app/textarea.ts +0 -16
  28. package/src/app/view.ts +0 -101
  29. package/src/app.tsx +0 -50
  30. package/src/config/index.ts +0 -475
  31. package/src/config/listed-sessions.ts +0 -33
  32. package/src/config/paths.ts +0 -13
  33. package/src/config/session-rules.ts +0 -100
  34. package/src/config/store.ts +0 -33
  35. package/src/files/target.ts +0 -96
  36. package/src/handlers/action-helpers.ts +0 -83
  37. package/src/handlers/actions.ts +0 -216
  38. package/src/handlers/keyboard/agents.ts +0 -134
  39. package/src/handlers/keyboard/index.ts +0 -5
  40. package/src/handlers/keyboard/new-session.ts +0 -58
  41. package/src/handlers/keyboard/normal.ts +0 -220
  42. package/src/handlers/keyboard/search.ts +0 -118
  43. package/src/handlers/keyboard/shared.ts +0 -117
  44. package/src/herdr/backend.ts +0 -357
  45. package/src/herdr/protocol.ts +0 -268
  46. package/src/index.tsx +0 -23
  47. package/src/items/order.ts +0 -95
  48. package/src/multiplexer/backend.ts +0 -43
  49. package/src/multiplexer/command.ts +0 -48
  50. package/src/multiplexer/index.ts +0 -21
  51. package/src/multiplexer/items.ts +0 -66
  52. package/src/multiplexer/resolve.ts +0 -109
  53. package/src/multiplexer/tmux-backend.ts +0 -87
  54. package/src/multiplexer/types.ts +0 -93
  55. package/src/opencode/constants.ts +0 -7
  56. package/src/opencode/index.ts +0 -20
  57. package/src/opencode/parser.ts +0 -45
  58. package/src/opencode/session-name.ts +0 -13
  59. package/src/opencode/session.ts +0 -146
  60. package/src/opencode/sqlite.ts +0 -447
  61. package/src/opencode/stats.ts +0 -26
  62. package/src/opencode/tokens.ts +0 -116
  63. package/src/opencode/types.ts +0 -33
  64. package/src/preview/project.ts +0 -362
  65. package/src/projects/session-links.ts +0 -52
  66. package/src/search/fff.ts +0 -224
  67. package/src/search/index.ts +0 -198
  68. package/src/settings.ts +0 -465
  69. package/src/styles/omarchy.ts +0 -295
  70. package/src/styles/opencode-themes-a.ts +0 -1442
  71. package/src/styles/opencode-themes-b.ts +0 -1212
  72. package/src/styles/opencode-tui-colors.ts +0 -1784
  73. package/src/styles/terminal-palette.ts +0 -156
  74. package/src/styles/theme-follow.ts +0 -94
  75. package/src/styles/theme.tsx +0 -311
  76. package/src/tmux/actions.ts +0 -145
  77. package/src/tmux/details.ts +0 -104
  78. package/src/tmux/helpers.ts +0 -35
  79. package/src/tmux/index.ts +0 -10
  80. package/src/tmux/list.ts +0 -31
  81. package/src/tmux/project-discovery.ts +0 -116
  82. package/src/tmux/project-loader.ts +0 -92
  83. package/src/tmux/project-zoxide.ts +0 -128
  84. package/src/tmux/projects.ts +0 -38
  85. package/src/tmux/workflows.ts +0 -26
  86. package/src/types/index.ts +0 -221
  87. package/src/ui/AgentSessionGroup.tsx +0 -93
  88. package/src/ui/CommandsModal.tsx +0 -246
  89. package/src/ui/ErrorScreen.tsx +0 -102
  90. package/src/ui/HighlightedText.tsx +0 -60
  91. package/src/ui/ItemList.tsx +0 -119
  92. package/src/ui/Modal.tsx +0 -48
  93. package/src/ui/OpencodeStatsPanel.tsx +0 -233
  94. package/src/ui/RenameModal.tsx +0 -42
  95. package/src/ui/SearchInput.tsx +0 -43
  96. package/src/ui/SessionDetailsPanel.tsx +0 -273
  97. package/src/ui/SessionList.tsx +0 -119
  98. package/src/ui/SettingEditorModal.tsx +0 -55
  99. package/src/ui/SettingOptionsModal.tsx +0 -95
  100. package/src/ui/SettingsModal.tsx +0 -102
  101. package/src/ui/Toast.tsx +0 -34
  102. package/src/ui/VersionBadge.tsx +0 -45
  103. package/src/ui/item-icon.ts +0 -110
  104. package/src/ui/list-window.ts +0 -35
  105. package/src/ui/session-meta.ts +0 -10
  106. package/src/ui/text-columns.ts +0 -17
  107. package/src/ui/use-textarea-focus.ts +0 -29
  108. package/src/update/events.ts +0 -28
  109. package/src/update/index.ts +0 -91
  110. package/src/update/installation.ts +0 -161
  111. package/src/update/version.ts +0 -33
  112. package/src/util/ansi.ts +0 -3
  113. package/src/util/browser.ts +0 -37
  114. package/src/util/clipboard.ts +0 -22
  115. package/src/util/errors.ts +0 -170
  116. package/src/util/github.ts +0 -100
  117. package/src/util/glob.ts +0 -51
  118. package/src/util/path-display.ts +0 -98
  119. package/src/util/perf.ts +0 -23
  120. package/src/util/shell.ts +0 -3
  121. package/src/util/shutdown.ts +0 -111
  122. package/src/util/terminal.ts +0 -28
  123. package/src/util/time.ts +0 -48
  124. package/tsconfig.json +0 -25
@@ -1,138 +0,0 @@
1
- import { isOpencodeSessionItem } from '../opencode/session-name'
2
- import type { CommandId } from '../ui/CommandsModal'
3
- import { AppMode, ViewMode, type Item } from '../types'
4
-
5
- interface ExecuteCommandContext {
6
- appMode: AppMode
7
- viewMode: ViewMode
8
- cursor: number
9
- agentCursor: number
10
- regularSessions: Item[]
11
- agentSessions: Item[]
12
- selectedPrimaryItem?: Item
13
- sessionCandidateItems: Item[]
14
- projectSourceItems: Item[]
15
- closeModal: () => void
16
- openRenameModal: (item: Item) => void
17
- openSettingsModal: () => void
18
- openSettingOptions: (field: 'theme') => void
19
- requestKillSession: (item: Item) => void
20
- togglePinnedSession: (sessionName: string) => Promise<void>
21
- setAppMode: (mode: AppMode) => void
22
- setViewMode: (mode: ViewMode) => void
23
- setAllItems: (items: Item[]) => void
24
- setItems: (items: Item[]) => void
25
- setCursor: (cursor: number) => void
26
- setSearchQuery: (value: string) => void
27
- setAgentCursor: (cursor: number) => void
28
- refreshItems: (forceViewMode?: ViewMode) => Promise<void>
29
- handleLastSession: () => Promise<void>
30
- handleRootSession: (item?: Item) => Promise<void>
31
- handleEditTarget: (item?: Item) => Promise<void>
32
- loadOpencodeStatsForSession: (sessionName: string) => Promise<unknown>
33
- showMessage: (message: string, timeout?: number) => void
34
- }
35
-
36
- export async function executeCommand(commandID: CommandId, ctx: ExecuteCommandContext) {
37
- switch (commandID) {
38
- case 'search':
39
- ctx.closeModal()
40
- ctx.setAppMode(AppMode.Search)
41
- ctx.setSearchQuery('')
42
- return
43
- case 'new-session': {
44
- const items =
45
- ctx.sessionCandidateItems.length > 0 ? ctx.sessionCandidateItems : ctx.projectSourceItems
46
- ctx.closeModal()
47
- ctx.setAppMode(AppMode.NewSession)
48
- ctx.setViewMode(ViewMode.Projects)
49
- ctx.setAllItems(items)
50
- ctx.setItems(items)
51
- ctx.setCursor(Math.max(0, items.length - 1))
52
- ctx.setSearchQuery('')
53
- return
54
- }
55
- case 'open-settings':
56
- ctx.openSettingsModal()
57
- return
58
- case 'open-themes':
59
- ctx.openSettingOptions('theme')
60
- return
61
- case 'view-projects':
62
- ctx.closeModal()
63
- ctx.setViewMode(ViewMode.Projects)
64
- await ctx.refreshItems(ViewMode.Projects)
65
- return
66
- case 'view-sessions':
67
- ctx.closeModal()
68
- ctx.setViewMode(ViewMode.Sessions)
69
- await ctx.refreshItems(ViewMode.Sessions)
70
- return
71
- case 'rename-session': {
72
- const target =
73
- ctx.appMode === AppMode.AgentsManage
74
- ? ctx.agentSessions[ctx.agentCursor]
75
- : ctx.viewMode === ViewMode.Sessions
76
- ? ctx.regularSessions[ctx.cursor]
77
- : undefined
78
- if (target?.isSession) {
79
- ctx.openRenameModal(target)
80
- }
81
- return
82
- }
83
- case 'kill-session': {
84
- const target =
85
- ctx.appMode === AppMode.AgentsManage
86
- ? ctx.agentSessions[ctx.agentCursor]
87
- : ctx.viewMode === ViewMode.Sessions
88
- ? ctx.regularSessions[ctx.cursor]
89
- : undefined
90
- if (target?.isSession) {
91
- ctx.closeModal()
92
- ctx.requestKillSession(target)
93
- }
94
- return
95
- }
96
- case 'toggle-pin-session': {
97
- const target =
98
- ctx.viewMode === ViewMode.Sessions ? ctx.regularSessions[ctx.cursor] : undefined
99
- if (target) {
100
- ctx.closeModal()
101
- await ctx.togglePinnedSession(target.title)
102
- }
103
- return
104
- }
105
- case 'last-session':
106
- ctx.closeModal()
107
- await ctx.handleLastSession()
108
- return
109
- case 'root-session':
110
- ctx.closeModal()
111
- await ctx.handleRootSession(ctx.selectedPrimaryItem)
112
- return
113
- case 'edit-target':
114
- ctx.closeModal()
115
- await ctx.handleEditTarget(ctx.selectedPrimaryItem)
116
- return
117
- case 'open-agents':
118
- ctx.closeModal()
119
- if (ctx.viewMode === ViewMode.Sessions && ctx.agentSessions.length > 0) {
120
- ctx.setAppMode(AppMode.AgentsManage)
121
- ctx.setAgentCursor(0)
122
- const firstAgent = ctx.agentSessions[0]
123
- if (isOpencodeSessionItem(firstAgent)) {
124
- await ctx.loadOpencodeStatsForSession(firstAgent.title)
125
- }
126
- }
127
- return
128
- case 'refresh':
129
- ctx.closeModal()
130
- await ctx.refreshItems()
131
- ctx.showMessage('Refreshed')
132
- return
133
- case 'back':
134
- ctx.closeModal()
135
- ctx.setAppMode(AppMode.Normal)
136
- return
137
- }
138
- }
@@ -1,437 +0,0 @@
1
- import { useRef, useState } from 'react'
2
- import { useAppCoreState } from './core-state'
3
- import { useAutoUpdateScheduler, useAppBehaviors } from './effects'
4
- import { createAppControls } from './controls'
5
- import { getSessionCommandState, getSettingsState } from './derived'
6
- import { useAppKeyboard } from './keyboard'
7
- import { useAppModalState } from './modal-state'
8
- import { createAppRuntime } from './runtime'
9
- import { createAppHandlers, handleKillSessionWithFeedback } from './handlers'
10
- import { useAppStartup } from './state'
11
- import { getConfigPath, getHomeDir, saveConfig } from '../config'
12
- import { getOpencodeSessionStats } from '../opencode'
13
- import { resolveTheme } from '../styles/theme'
14
- import type { TerminalPalette } from '../styles/terminal-palette'
15
- import { useTerminalSize } from '../util/terminal'
16
- import { mark, measure } from '../util/perf'
17
- import { getSettingEditorTitle, isOptionSetting } from '../settings'
18
-
19
- export function useAppController() {
20
- const {
21
- appMode,
22
- setAppMode,
23
- viewMode,
24
- setViewMode,
25
- items,
26
- setItems,
27
- allItems,
28
- setAllItems,
29
- projectSourceItems,
30
- setProjectSourceItems,
31
- sessionCandidateItems,
32
- setSessionCandidateItems,
33
- sessionItems,
34
- setSessionItems,
35
- cursor,
36
- setCursor,
37
- agentCursor,
38
- setAgentCursor,
39
- searchQuery,
40
- setSearchQuery,
41
- message,
42
- setMessage,
43
- renameTarget,
44
- setRenameTarget,
45
- config,
46
- setConfig,
47
- backend,
48
- setBackend,
49
- pendingKillSessionName,
50
- setPendingKillSessionName,
51
- prefixActive,
52
- setPrefixActive,
53
- prefixTimeoutRef,
54
- textareaRef,
55
- lastSessionSelectionRef,
56
- lastProjectSelectionRef,
57
- toastMessage,
58
- setToastMessage,
59
- toastVisible,
60
- setToastVisible,
61
- updatedVersion,
62
- setUpdatedVersion,
63
- } = useAppCoreState()
64
-
65
- const {
66
- modalState,
67
- setModalState,
68
- modalInputValue,
69
- setModalInputValue,
70
- commandsCursor,
71
- setCommandsCursor,
72
- commandsSearchQuery,
73
- setCommandsSearchQuery,
74
- settingsCursor,
75
- setSettingsCursor,
76
- settingsSearchQuery,
77
- setSettingsSearchQuery,
78
- settingOptionsCursor,
79
- setSettingOptionsCursor,
80
- settingOptionsSearchQuery,
81
- themePreviewId,
82
- setThemePreviewId,
83
- setSettingOptionsSearchQuery,
84
- settingEditorValue,
85
- setSettingEditorValue,
86
- settingEditorError,
87
- setSettingEditorError,
88
- modalTextareaRef,
89
- commandsSearchTextareaRef,
90
- settingsSearchTextareaRef,
91
- settingOptionsSearchTextareaRef,
92
- settingEditorTextareaRef,
93
- } = useAppModalState()
94
-
95
- const { columns, rows } = useTerminalSize()
96
- const configPath = getConfigPath()
97
- const homeDir = getHomeDir()
98
- const [systemThemeEpoch, setSystemThemeEpoch] = useState(0)
99
- const [terminalPalette, setTerminalPalette] = useState<TerminalPalette | null>(null)
100
- const resolvedTheme = resolveTheme(
101
- themePreviewId ?? config?.theme,
102
- config?.themes,
103
- config?.colorScheme,
104
- { homeDir, terminalPalette }
105
- )
106
- void systemThemeEpoch
107
- const theme = resolvedTheme.colors
108
- const { filteredSettingsEntries, filteredSettingOptions } = getSettingsState(
109
- config,
110
- modalState,
111
- settingsSearchQuery,
112
- settingOptionsSearchQuery
113
- )
114
- const hasScheduledAutoUpdateRef = useRef(false)
115
-
116
- useAppStartup(
117
- measure,
118
- lastSessionSelectionRef,
119
- lastProjectSelectionRef,
120
- mark,
121
- setConfig,
122
- setBackend,
123
- setMessage,
124
- setAppMode,
125
- setViewMode,
126
- setSessionItems,
127
- setProjectSourceItems,
128
- setAllItems,
129
- setItems,
130
- setCursor
131
- )
132
-
133
- useAutoUpdateScheduler(config, hasScheduledAutoUpdateRef)
134
-
135
- const { showMessage, refreshItems, loadOpencodeStatsForSession } = createAppRuntime({
136
- config,
137
- backend,
138
- viewMode,
139
- measure,
140
- lastSessionSelectionRef,
141
- lastProjectSelectionRef,
142
- setSessionItems,
143
- setProjectSourceItems,
144
- setAllItems,
145
- setItems,
146
- setCursor,
147
- setMessage,
148
- getOpencodeSessionStats,
149
- })
150
-
151
- const {
152
- regularSessions,
153
- agentSessions,
154
- selectedAgentSession,
155
- selectedPrimaryItem,
156
- filteredCommandEntries,
157
- } = getSessionCommandState(
158
- appMode,
159
- viewMode,
160
- items,
161
- cursor,
162
- agentCursor,
163
- config,
164
- commandsSearchQuery
165
- )
166
-
167
- const {
168
- clearPendingKill,
169
- requestKillSession,
170
- openRenameModal,
171
- openCommandsModal,
172
- openSettingsModal,
173
- openSettingOptions,
174
- openSettingEditor,
175
- closeModal,
176
- } = createAppControls({
177
- config,
178
- pendingKillSessionName,
179
- handleKillSession: item =>
180
- handleKillSessionWithFeedback(item, {
181
- backend,
182
- config,
183
- items,
184
- sessionItems,
185
- cursor,
186
- showMessage,
187
- refreshItems,
188
- setPendingKillSessionName,
189
- regularSessions,
190
- rememberedSessions: (key: string | null) => {
191
- lastSessionSelectionRef.current = key
192
- },
193
- }),
194
- setPendingKillSessionName,
195
- setRenameTarget,
196
- setModalInputValue,
197
- setModalState,
198
- setCommandsSearchQuery,
199
- setCommandsCursor,
200
- setSettingEditorError,
201
- setSettingsSearchQuery,
202
- setSettingsCursor,
203
- setSettingOptionsSearchQuery,
204
- setSettingOptionsCursor,
205
- setSettingEditorValue,
206
- })
207
-
208
- const {
209
- handleKillSessionWrapper,
210
- handleSelectWrapper,
211
- handleLastSessionWrapper,
212
- handleRootSessionWrapper,
213
- handleEditTargetWrapper,
214
- handleRenameSubmit,
215
- handleNewSessionSubmit,
216
- handleSettingsEditorSubmit,
217
- handleSettingOptionSubmit,
218
- handleTogglePinnedSessionWrapper,
219
- executeCommand,
220
- } = createAppHandlers({
221
- backend,
222
- appMode,
223
- viewMode,
224
- config,
225
- items,
226
- sessionItems,
227
- cursor,
228
- showMessage,
229
- refreshItems,
230
- agentCursor,
231
- regularSessions,
232
- rememberedSessions: (key: string | null) => {
233
- lastSessionSelectionRef.current = key
234
- },
235
- agentSessions,
236
- selectedPrimaryItem,
237
- sessionCandidateItems,
238
- projectSourceItems,
239
- closeModal,
240
- openRenameModal,
241
- openSettingsModal,
242
- openSettingOptions,
243
- requestKillSession,
244
- setAppMode,
245
- setViewMode,
246
- setAllItems,
247
- setItems,
248
- setCursor,
249
- setSearchQuery,
250
- setAgentCursor,
251
- setPendingKillSessionName,
252
- saveConfig,
253
- setConfig,
254
- setSettingEditorError,
255
- settingEditorValue,
256
- settingEditorPlainText: settingEditorTextareaRef.current?.plainText,
257
- renameTarget,
258
- renamedValue: (modalTextareaRef.current?.plainText ?? modalInputValue).trim(),
259
- searchTerm: searchQuery.trim(),
260
- loadOpencodeStatsForSession,
261
- })
262
-
263
- useAppKeyboard({
264
- appMode,
265
- viewMode,
266
- config,
267
- items,
268
- regularSessions,
269
- agentSessions,
270
- sessionItems,
271
- sessionCandidateItems,
272
- projectSourceItems,
273
- cursor,
274
- agentCursor,
275
- searchQuery,
276
- prefixActive,
277
- prefixTimeoutRef,
278
- modalState,
279
- filteredCommandEntries,
280
- commandsCursor,
281
- setCommandsCursor,
282
- filteredSettingsEntries,
283
- settingsCursor,
284
- setSettingsCursor,
285
- filteredSettingOptions,
286
- settingOptionsCursor,
287
- setSettingOptionsCursor,
288
- setModalState,
289
- setSettingEditorError,
290
- executeCommand,
291
- handleSettingOptionSubmit,
292
- handleSettingsEditorSubmit,
293
- handleRenameSubmit,
294
- handleNewSessionSubmit,
295
- isOptionSetting,
296
- openSettingOptions,
297
- previewThemeOption: setThemePreviewId,
298
- openSettingEditor,
299
- closeModal,
300
- clearPendingKill,
301
- requestKillSession,
302
- togglePinnedSession: handleTogglePinnedSessionWrapper,
303
- openRenameModal,
304
- openCommandsModal,
305
- openSettingsModal,
306
- refreshItems,
307
- handleSelect: handleSelectWrapper,
308
- handleKillSession: handleKillSessionWrapper,
309
- handleLastSession: handleLastSessionWrapper,
310
- handleRootSession: handleRootSessionWrapper,
311
- handleEditTarget: handleEditTargetWrapper,
312
- loadOpencodeStatsForSession,
313
- setAppMode,
314
- setViewMode,
315
- setCursor,
316
- setAgentCursor,
317
- setSearchQuery,
318
- setAllItems,
319
- setItems,
320
- setPrefixActive,
321
- setMessage,
322
- })
323
-
324
- useAppBehaviors({
325
- appMode,
326
- viewMode,
327
- config,
328
- backend,
329
- sessionItems,
330
- projectSourceItems,
331
- sessionCandidateItems,
332
- lastSessionSelectionRef,
333
- lastProjectSelectionRef,
334
- setAllItems,
335
- setItems,
336
- setSessionItems,
337
- setCursor,
338
- setAgentCursor,
339
- setMessage,
340
- setSessionCandidateItems,
341
- filteredCommandEntriesLength: filteredCommandEntries.length,
342
- setCommandsCursor,
343
- commandsSearchQuery,
344
- filteredSettingsEntriesLength: filteredSettingsEntries.length,
345
- setSettingsCursor,
346
- filteredSettingOptionsLength: filteredSettingOptions.length,
347
- setSettingOptionsCursor,
348
- cursor,
349
- items,
350
- selectedPrimaryItem,
351
- pendingKillSessionName,
352
- agentSessions,
353
- agentCursor,
354
- regularSessions,
355
- setPendingKillSessionName,
356
- searchQuery,
357
- allItems,
358
- selectedAgentSession,
359
- loadOpencodeStatsForSession,
360
- setUpdatedVersion,
361
- setToastMessage,
362
- setToastVisible,
363
- homeDir,
364
- onSystemThemeRefresh: () => {
365
- setSystemThemeEpoch(current => current + 1)
366
- },
367
- onTerminalPalette: setTerminalPalette,
368
- })
369
-
370
- return {
371
- theme,
372
- resolvedTheme,
373
- columns,
374
- rows,
375
- screenProps: {
376
- theme,
377
- appMode,
378
- viewMode,
379
- config,
380
- backend,
381
- items,
382
- regularSessions,
383
- agentSessions,
384
- selectedPrimaryItem,
385
- cursor,
386
- agentCursor,
387
- searchQuery,
388
- prefixActive,
389
- pendingKillSessionName,
390
- projectCount: projectSourceItems.length,
391
- sessionItems,
392
- rows,
393
- columns,
394
- textareaRef,
395
- setSearchQuery,
396
- message,
397
- toastMessage,
398
- toastVisible,
399
- updatedVersion,
400
- },
401
- modalProps: {
402
- modalState,
403
- columns,
404
- rows,
405
- configPath,
406
- themeId: resolvedTheme.id,
407
- themeName: resolvedTheme.name,
408
- colorMode: resolvedTheme.mode,
409
- filteredCommandEntries,
410
- commandsCursor,
411
- commandsSearchQuery,
412
- setCommandsCursor,
413
- setCommandsSearchQuery,
414
- filteredSettingsEntries,
415
- settingsCursor,
416
- settingsSearchQuery,
417
- setSettingsCursor,
418
- setSettingsSearchQuery,
419
- filteredSettingOptions,
420
- settingOptionsCursor,
421
- settingOptionsSearchQuery,
422
- setSettingOptionsCursor,
423
- setSettingOptionsSearchQuery,
424
- settingEditorValue,
425
- settingEditorError,
426
- setSettingEditorValue,
427
- modalInputValue,
428
- setModalInputValue,
429
- commandsSearchTextareaRef,
430
- settingsSearchTextareaRef,
431
- settingOptionsSearchTextareaRef,
432
- settingEditorTextareaRef,
433
- modalTextareaRef,
434
- getSettingEditorTitle,
435
- },
436
- }
437
- }
@@ -1,123 +0,0 @@
1
- import type { Dispatch, SetStateAction } from 'react'
2
- import {
3
- closeModal as resetModalState,
4
- openCommandsModal as showCommandsModal,
5
- openRenameModal as showRenameModal,
6
- openSettingEditor as showSettingEditor,
7
- openSettingOptions as showSettingOptions,
8
- openSettingsModal as showSettingsModal,
9
- type ModalState,
10
- } from './modals'
11
- import type { Config, Item } from '../types'
12
- import { getItemKey } from '../multiplexer/items'
13
- import type { SettingsFieldId } from '../settings'
14
-
15
- interface AppControlsOptions {
16
- config: Config | null
17
- pendingKillSessionName: string | null
18
- handleKillSession: (item: Item) => Promise<void>
19
- setPendingKillSessionName: Dispatch<SetStateAction<string | null>>
20
- setRenameTarget: Dispatch<SetStateAction<Item | null>>
21
- setModalInputValue: Dispatch<SetStateAction<string>>
22
- setModalState: Dispatch<SetStateAction<ModalState>>
23
- setCommandsSearchQuery: Dispatch<SetStateAction<string>>
24
- setCommandsCursor: Dispatch<SetStateAction<number>>
25
- setSettingEditorError: Dispatch<SetStateAction<string>>
26
- setSettingsSearchQuery: Dispatch<SetStateAction<string>>
27
- setSettingsCursor: Dispatch<SetStateAction<number>>
28
- setSettingOptionsSearchQuery: Dispatch<SetStateAction<string>>
29
- setSettingOptionsCursor: Dispatch<SetStateAction<number>>
30
- setSettingEditorValue: Dispatch<SetStateAction<string>>
31
- }
32
-
33
- export function createAppControls(options: AppControlsOptions) {
34
- function clearPendingKill() {
35
- options.setPendingKillSessionName(null)
36
- }
37
-
38
- function requestKillSession(item: Item) {
39
- const sessionKey = getItemKey(item)
40
- if (options.pendingKillSessionName === sessionKey) {
41
- void options.handleKillSession(item)
42
- return
43
- }
44
-
45
- options.setPendingKillSessionName(sessionKey)
46
- }
47
-
48
- function openRenameModal(item: Item) {
49
- showRenameModal(
50
- item,
51
- clearPendingKill,
52
- options.setRenameTarget,
53
- options.setModalInputValue,
54
- options.setModalState
55
- )
56
- }
57
-
58
- function openCommandsModal() {
59
- showCommandsModal(
60
- clearPendingKill,
61
- options.setCommandsSearchQuery,
62
- options.setCommandsCursor,
63
- options.setModalState
64
- )
65
- }
66
-
67
- function openSettingsModal() {
68
- showSettingsModal(
69
- options.config,
70
- clearPendingKill,
71
- options.setSettingEditorError,
72
- options.setSettingsSearchQuery,
73
- options.setSettingsCursor,
74
- options.setModalState
75
- )
76
- }
77
-
78
- function openSettingOptions(field: SettingsFieldId) {
79
- showSettingOptions(
80
- field,
81
- options.setSettingOptionsSearchQuery,
82
- options.setSettingOptionsCursor,
83
- options.setModalState
84
- )
85
- }
86
-
87
- function openSettingEditor(field: SettingsFieldId) {
88
- showSettingEditor(
89
- options.config,
90
- field,
91
- options.setSettingEditorError,
92
- options.setSettingEditorValue,
93
- options.setModalState
94
- )
95
- }
96
-
97
- function closeModal() {
98
- resetModalState({
99
- setModalState: options.setModalState,
100
- setModalInputValue: options.setModalInputValue,
101
- setCommandsSearchQuery: options.setCommandsSearchQuery,
102
- setCommandsCursor: options.setCommandsCursor,
103
- setSettingsSearchQuery: options.setSettingsSearchQuery,
104
- setSettingsCursor: options.setSettingsCursor,
105
- setSettingOptionsSearchQuery: options.setSettingOptionsSearchQuery,
106
- setSettingOptionsCursor: options.setSettingOptionsCursor,
107
- setSettingEditorValue: options.setSettingEditorValue,
108
- setSettingEditorError: options.setSettingEditorError,
109
- setRenameTarget: options.setRenameTarget,
110
- })
111
- }
112
-
113
- return {
114
- clearPendingKill,
115
- requestKillSession,
116
- openRenameModal,
117
- openCommandsModal,
118
- openSettingsModal,
119
- openSettingOptions,
120
- openSettingEditor,
121
- closeModal,
122
- }
123
- }