mux-sesh 1.6.3 → 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.
Files changed (82) hide show
  1. package/README.md +90 -59
  2. package/package.json +7 -5
  3. package/src/app/commands.ts +120 -0
  4. package/src/app/controller.ts +397 -0
  5. package/src/app/controls.ts +121 -0
  6. package/src/app/core-state.ts +71 -0
  7. package/src/app/data.ts +90 -0
  8. package/src/app/derived.ts +77 -0
  9. package/src/app/effects.ts +392 -0
  10. package/src/app/handlers.ts +325 -0
  11. package/src/app/keyboard.ts +161 -0
  12. package/src/app/modal-keyboard.ts +118 -0
  13. package/src/app/modal-state.ts +50 -0
  14. package/src/app/modals-layer.tsx +159 -0
  15. package/src/app/modals.ts +108 -0
  16. package/src/app/notifications.ts +21 -0
  17. package/src/app/opencode.ts +49 -0
  18. package/src/app/operations.ts +31 -0
  19. package/src/app/runtime.ts +76 -0
  20. package/src/app/screen.tsx +217 -0
  21. package/src/app/state.ts +166 -0
  22. package/src/app/textarea.ts +16 -0
  23. package/src/app/view.ts +89 -0
  24. package/src/app.tsx +7 -1101
  25. package/src/config/index.ts +36 -42
  26. package/src/config/listed-sessions.ts +2 -5
  27. package/src/config/paths.ts +13 -0
  28. package/src/config/session-rules.ts +10 -11
  29. package/src/config/store.ts +26 -0
  30. package/src/handlers/action-helpers.ts +50 -0
  31. package/src/handlers/actions.ts +34 -65
  32. package/src/handlers/keyboard/index.ts +5 -0
  33. package/src/handlers/keyboard/new-session.ts +57 -0
  34. package/src/handlers/keyboard/normal.ts +201 -0
  35. package/src/handlers/keyboard/opencode.ts +104 -0
  36. package/src/handlers/keyboard/search.ts +113 -0
  37. package/src/handlers/keyboard/shared.ts +116 -0
  38. package/src/items/order.ts +21 -2
  39. package/src/opencode/sqlite.ts +21 -6
  40. package/src/preview/project.ts +41 -15
  41. package/src/search/index.ts +4 -1
  42. package/src/settings.ts +294 -297
  43. package/src/styles/opencode-themes-a.ts +1442 -1
  44. package/src/styles/opencode-themes-b.ts +1212 -1
  45. package/src/styles/opencode-tui-colors.ts +1784 -1
  46. package/src/styles/theme.tsx +2 -1
  47. package/src/tmux/actions.ts +103 -0
  48. package/src/tmux/details.ts +123 -0
  49. package/src/tmux/helpers.ts +35 -0
  50. package/src/tmux/index.ts +10 -286
  51. package/src/tmux/list.ts +31 -0
  52. package/src/tmux/project-discovery.ts +113 -0
  53. package/src/tmux/project-loader.ts +74 -0
  54. package/src/tmux/project-zoxide.ts +128 -0
  55. package/src/tmux/projects.ts +23 -261
  56. package/src/types/index.ts +0 -1
  57. package/src/ui/CommandsModal.tsx +87 -22
  58. package/src/ui/HighlightedText.tsx +1 -5
  59. package/src/ui/ItemList.tsx +26 -11
  60. package/src/ui/Modal.tsx +8 -1
  61. package/src/ui/OpencodeSessionGroup.tsx +20 -9
  62. package/src/ui/OpencodeStatsPanel.tsx +48 -15
  63. package/src/ui/RenameModal.tsx +17 -17
  64. package/src/ui/SearchInput.tsx +1 -20
  65. package/src/ui/SessionDetailsPanel.tsx +43 -15
  66. package/src/ui/SessionList.tsx +25 -4
  67. package/src/ui/SettingEditorModal.tsx +15 -9
  68. package/src/ui/SettingOptionsModal.tsx +30 -12
  69. package/src/ui/SettingsModal.tsx +20 -14
  70. package/src/ui/VersionBadge.tsx +3 -1
  71. package/src/ui/item-icon.ts +5 -1
  72. package/src/ui/list-window.ts +5 -1
  73. package/src/ui/text-columns.ts +17 -0
  74. package/src/ui/use-textarea-focus.ts +26 -0
  75. package/src/update/index.ts +10 -2
  76. package/src/update/installation.ts +6 -2
  77. package/src/util/ansi.ts +3 -0
  78. package/src/util/glob.ts +5 -1
  79. package/src/util/path-display.ts +98 -0
  80. package/src/components/KeybindHelp.tsx +0 -289
  81. package/src/handlers/keyboard.ts +0 -654
  82. package/src/ui/SessionStats.tsx +0 -32
@@ -0,0 +1,159 @@
1
+ import type { TextareaRenderable } from '@opentui/core'
2
+ import type { Dispatch, MutableRefObject, SetStateAction } from 'react'
3
+ import type { SettingsEntry, SettingsOption, SettingsFieldId } from '../settings'
4
+ import type { CommandEntry } from '../ui/CommandsModal'
5
+ import type { ModalState } from './modals'
6
+ import { syncTextareaValue } from './textarea'
7
+ import CommandsModal from '../ui/CommandsModal'
8
+ import RenameModal from '../ui/RenameModal'
9
+ import SettingEditorModal from '../ui/SettingEditorModal'
10
+ import SettingOptionsModal from '../ui/SettingOptionsModal'
11
+ import SettingsModal from '../ui/SettingsModal'
12
+
13
+ interface Props {
14
+ modalState: ModalState
15
+ columns: number
16
+ rows: number
17
+ configPath: string
18
+ themeId: string
19
+ themeName: string
20
+ colorMode: string
21
+ filteredCommandEntries: CommandEntry[]
22
+ commandsCursor: number
23
+ commandsSearchQuery: string
24
+ setCommandsCursor: Dispatch<SetStateAction<number>>
25
+ setCommandsSearchQuery: Dispatch<SetStateAction<string>>
26
+ filteredSettingsEntries: SettingsEntry[]
27
+ settingsCursor: number
28
+ settingsSearchQuery: string
29
+ setSettingsCursor: Dispatch<SetStateAction<number>>
30
+ setSettingsSearchQuery: Dispatch<SetStateAction<string>>
31
+ filteredSettingOptions: SettingsOption[]
32
+ settingOptionsCursor: number
33
+ settingOptionsSearchQuery: string
34
+ setSettingOptionsCursor: Dispatch<SetStateAction<number>>
35
+ setSettingOptionsSearchQuery: Dispatch<SetStateAction<string>>
36
+ settingEditorValue: string
37
+ settingEditorError: string
38
+ setSettingEditorValue: Dispatch<SetStateAction<string>>
39
+ modalInputValue: string
40
+ setModalInputValue: Dispatch<SetStateAction<string>>
41
+ commandsSearchTextareaRef: MutableRefObject<TextareaRenderable | null>
42
+ settingsSearchTextareaRef: MutableRefObject<TextareaRenderable | null>
43
+ settingOptionsSearchTextareaRef: MutableRefObject<TextareaRenderable | null>
44
+ settingEditorTextareaRef: MutableRefObject<TextareaRenderable | null>
45
+ modalTextareaRef: MutableRefObject<TextareaRenderable | null>
46
+ getSettingEditorTitle: (field: SettingsFieldId) => string
47
+ }
48
+
49
+ export function AppModalsLayer({
50
+ modalState,
51
+ columns,
52
+ rows,
53
+ configPath,
54
+ themeId,
55
+ themeName,
56
+ colorMode,
57
+ filteredCommandEntries,
58
+ commandsCursor,
59
+ commandsSearchQuery,
60
+ setCommandsCursor,
61
+ setCommandsSearchQuery,
62
+ filteredSettingsEntries,
63
+ settingsCursor,
64
+ settingsSearchQuery,
65
+ setSettingsCursor,
66
+ setSettingsSearchQuery,
67
+ filteredSettingOptions,
68
+ settingOptionsCursor,
69
+ settingOptionsSearchQuery,
70
+ setSettingOptionsCursor,
71
+ setSettingOptionsSearchQuery,
72
+ settingEditorValue,
73
+ settingEditorError,
74
+ setSettingEditorValue,
75
+ modalInputValue,
76
+ setModalInputValue,
77
+ commandsSearchTextareaRef,
78
+ settingsSearchTextareaRef,
79
+ settingOptionsSearchTextareaRef,
80
+ settingEditorTextareaRef,
81
+ modalTextareaRef,
82
+ getSettingEditorTitle,
83
+ }: Props) {
84
+ return (
85
+ <>
86
+ {modalState?.type === 'rename' && (
87
+ <RenameModal
88
+ target={modalState.target}
89
+ initialValue={modalInputValue}
90
+ columns={columns}
91
+ textareaRef={modalTextareaRef}
92
+ onContentChange={() => syncTextareaValue(modalTextareaRef, setModalInputValue)}
93
+ />
94
+ )}
95
+
96
+ {modalState?.type === 'commands' && (
97
+ <CommandsModal
98
+ columns={columns}
99
+ themeId={themeId}
100
+ entries={filteredCommandEntries}
101
+ cursor={commandsCursor}
102
+ searchQuery={commandsSearchQuery}
103
+ textareaRef={commandsSearchTextareaRef}
104
+ onContentChange={() =>
105
+ syncTextareaValue(commandsSearchTextareaRef, setCommandsSearchQuery, setCommandsCursor)
106
+ }
107
+ />
108
+ )}
109
+
110
+ {modalState?.type === 'settings' && (
111
+ <SettingsModal
112
+ configPath={configPath}
113
+ themeName={themeName}
114
+ colorMode={colorMode}
115
+ columns={columns}
116
+ entries={filteredSettingsEntries}
117
+ cursor={settingsCursor}
118
+ searchQuery={settingsSearchQuery}
119
+ textareaRef={settingsSearchTextareaRef}
120
+ onContentChange={() =>
121
+ syncTextareaValue(settingsSearchTextareaRef, setSettingsSearchQuery, setSettingsCursor)
122
+ }
123
+ />
124
+ )}
125
+
126
+ {modalState?.type === 'setting-options' && (
127
+ <SettingOptionsModal
128
+ title={getSettingEditorTitle(modalState.field)}
129
+ description="Select an option to apply it immediately"
130
+ columns={columns}
131
+ options={filteredSettingOptions}
132
+ cursor={settingOptionsCursor}
133
+ searchQuery={settingOptionsSearchQuery}
134
+ textareaRef={settingOptionsSearchTextareaRef}
135
+ onContentChange={() =>
136
+ syncTextareaValue(
137
+ settingOptionsSearchTextareaRef,
138
+ setSettingOptionsSearchQuery,
139
+ setSettingOptionsCursor
140
+ )
141
+ }
142
+ />
143
+ )}
144
+
145
+ {modalState?.type === 'setting-editor' && (
146
+ <SettingEditorModal
147
+ title={getSettingEditorTitle(modalState.field)}
148
+ description="Edit value and press Enter to apply immediately"
149
+ value={settingEditorValue}
150
+ error={settingEditorError}
151
+ columns={columns}
152
+ rows={rows}
153
+ textareaRef={settingEditorTextareaRef}
154
+ onContentChange={() => syncTextareaValue(settingEditorTextareaRef, setSettingEditorValue)}
155
+ />
156
+ )}
157
+ </>
158
+ )
159
+ }
@@ -0,0 +1,108 @@
1
+ import type { Dispatch, SetStateAction } from 'react'
2
+ import { getSettingEditorValue, type SettingsFieldId } from '../settings'
3
+ import type { Config } from '../types'
4
+
5
+ export type ModalState =
6
+ | { type: 'rename'; target: string }
7
+ | { type: 'commands' }
8
+ | { type: 'settings' }
9
+ | { type: 'setting-options'; field: SettingsFieldId }
10
+ | { type: 'setting-editor'; field: SettingsFieldId }
11
+ | null
12
+
13
+ interface ModalSetters {
14
+ setModalState: Dispatch<SetStateAction<ModalState>>
15
+ setModalInputValue: Dispatch<SetStateAction<string>>
16
+ setCommandsSearchQuery: Dispatch<SetStateAction<string>>
17
+ setCommandsCursor: Dispatch<SetStateAction<number>>
18
+ setSettingsSearchQuery: Dispatch<SetStateAction<string>>
19
+ setSettingsCursor: Dispatch<SetStateAction<number>>
20
+ setSettingOptionsSearchQuery: Dispatch<SetStateAction<string>>
21
+ setSettingOptionsCursor: Dispatch<SetStateAction<number>>
22
+ setSettingEditorValue: Dispatch<SetStateAction<string>>
23
+ setSettingEditorError: Dispatch<SetStateAction<string>>
24
+ setRenameTarget: Dispatch<SetStateAction<string>>
25
+ }
26
+
27
+ export function openRenameModal(
28
+ sessionName: string,
29
+ clearPendingKill: () => void,
30
+ setRenameTarget: Dispatch<SetStateAction<string>>,
31
+ setModalInputValue: Dispatch<SetStateAction<string>>,
32
+ setModalState: Dispatch<SetStateAction<ModalState>>
33
+ ) {
34
+ clearPendingKill()
35
+ setRenameTarget(sessionName)
36
+ setModalInputValue(sessionName)
37
+ setModalState({ type: 'rename', target: sessionName })
38
+ }
39
+
40
+ export function openCommandsModal(
41
+ clearPendingKill: () => void,
42
+ setCommandsSearchQuery: Dispatch<SetStateAction<string>>,
43
+ setCommandsCursor: Dispatch<SetStateAction<number>>,
44
+ setModalState: Dispatch<SetStateAction<ModalState>>
45
+ ) {
46
+ clearPendingKill()
47
+ setCommandsSearchQuery('')
48
+ setCommandsCursor(0)
49
+ setModalState({ type: 'commands' })
50
+ }
51
+
52
+ export function openSettingsModal(
53
+ config: Config | null,
54
+ clearPendingKill: () => void,
55
+ setSettingEditorError: Dispatch<SetStateAction<string>>,
56
+ setSettingsSearchQuery: Dispatch<SetStateAction<string>>,
57
+ setSettingsCursor: Dispatch<SetStateAction<number>>,
58
+ setModalState: Dispatch<SetStateAction<ModalState>>
59
+ ) {
60
+ if (!config) {
61
+ return
62
+ }
63
+
64
+ clearPendingKill()
65
+ setSettingEditorError('')
66
+ setSettingsSearchQuery('')
67
+ setSettingsCursor(0)
68
+ setModalState({ type: 'settings' })
69
+ }
70
+
71
+ export function openSettingOptions(
72
+ field: SettingsFieldId,
73
+ setSettingOptionsSearchQuery: Dispatch<SetStateAction<string>>,
74
+ setSettingOptionsCursor: Dispatch<SetStateAction<number>>,
75
+ setModalState: Dispatch<SetStateAction<ModalState>>
76
+ ) {
77
+ setSettingOptionsSearchQuery('')
78
+ setSettingOptionsCursor(0)
79
+ setModalState({ type: 'setting-options', field })
80
+ }
81
+
82
+ export function openSettingEditor(
83
+ config: Config | null,
84
+ field: SettingsFieldId,
85
+ setSettingEditorError: Dispatch<SetStateAction<string>>,
86
+ setSettingEditorValue: Dispatch<SetStateAction<string>>,
87
+ setModalState: Dispatch<SetStateAction<ModalState>>
88
+ ) {
89
+ if (!config) {
90
+ return
91
+ }
92
+
93
+ setSettingEditorError('')
94
+ setSettingEditorValue(getSettingEditorValue(config, field))
95
+ setModalState({ type: 'setting-editor', field })
96
+ }
97
+
98
+ export function closeModal(setters: ModalSetters) {
99
+ setters.setModalState(null)
100
+ setters.setModalInputValue('')
101
+ setters.setCommandsSearchQuery('')
102
+ setters.setCommandsCursor(0)
103
+ setters.setSettingsSearchQuery('')
104
+ setters.setSettingOptionsSearchQuery('')
105
+ setters.setSettingEditorValue('')
106
+ setters.setSettingEditorError('')
107
+ setters.setRenameTarget('')
108
+ }
@@ -0,0 +1,21 @@
1
+ export function showTemporaryMessage(
2
+ setMessage: (message: string) => void,
3
+ message: string,
4
+ timeout = 2000
5
+ ) {
6
+ setMessage(message)
7
+ setTimeout(() => setMessage(''), timeout)
8
+ }
9
+
10
+ export function showTemporaryToast(
11
+ setToastMessage: (message: string) => void,
12
+ setToastVisible: (visible: boolean) => void,
13
+ message: string,
14
+ timeout = 5000
15
+ ) {
16
+ setToastMessage(message)
17
+ setToastVisible(true)
18
+ setTimeout(() => {
19
+ setToastVisible(false)
20
+ }, timeout)
21
+ }
@@ -0,0 +1,49 @@
1
+ import type { Dispatch, SetStateAction } from 'react'
2
+ import type { Item, OpencodeSessionStats, OpencodeStatsState } from '../types'
3
+
4
+ export function applyOpencodeState(
5
+ sessionName: string,
6
+ nextState: OpencodeStatsState,
7
+ setSessionItems: Dispatch<SetStateAction<Item[]>>,
8
+ setAllItems: Dispatch<SetStateAction<Item[]>>,
9
+ setItems: Dispatch<SetStateAction<Item[]>>
10
+ ) {
11
+ const applyState = (existingItems: Item[]) =>
12
+ existingItems.map(item =>
13
+ item.title === sessionName ? { ...item, opencodeState: nextState } : item
14
+ )
15
+
16
+ setSessionItems(applyState)
17
+ setAllItems(applyState)
18
+ setItems(applyState)
19
+ }
20
+
21
+ export async function loadOpencodeSessionStats(
22
+ sessionName: string,
23
+ getStats: (sessionName: string) => Promise<OpencodeSessionStats | null>,
24
+ updateState: (sessionName: string, nextState: OpencodeStatsState) => void,
25
+ showMessage: (message: string, timeout?: number) => void
26
+ ) {
27
+ updateState(sessionName, { status: 'loading' })
28
+
29
+ try {
30
+ const stats = await getStats(sessionName)
31
+
32
+ if (stats) {
33
+ updateState(sessionName, { status: 'ready', stats })
34
+ return stats
35
+ }
36
+
37
+ updateState(sessionName, {
38
+ status: 'missing',
39
+ message: `No OpenCode stats found for '${sessionName}'`,
40
+ })
41
+ return null
42
+ } catch (error) {
43
+ const errorMessage =
44
+ error instanceof Error ? error.message : `Failed to load stats for '${sessionName}'`
45
+ updateState(sessionName, { status: 'error', message: errorMessage })
46
+ showMessage(errorMessage, 4000)
47
+ return null
48
+ }
49
+ }
@@ -0,0 +1,31 @@
1
+ import type { Config, ViewMode } from '../types'
2
+
3
+ type ShowMessage = (message: string, timeout?: number) => void
4
+ type RefreshItems = (forceViewMode?: ViewMode, nextConfig?: Config) => Promise<void>
5
+
6
+ export async function runWithErrorMessage(
7
+ operation: () => Promise<void>,
8
+ fallbackMessage: string,
9
+ showMessage: ShowMessage
10
+ ): Promise<void> {
11
+ try {
12
+ await operation()
13
+ } catch (error) {
14
+ const errorMessage = error instanceof Error ? error.message : fallbackMessage
15
+ showMessage(errorMessage, 3000)
16
+ }
17
+ }
18
+
19
+ export async function persistConfigUpdate(
20
+ nextConfig: Config,
21
+ successMessage: string,
22
+ saveConfig: (config: Config) => Promise<void>,
23
+ setConfig: (config: Config) => void,
24
+ refreshItems: RefreshItems,
25
+ showMessage: ShowMessage
26
+ ): Promise<void> {
27
+ await saveConfig(nextConfig)
28
+ setConfig(nextConfig)
29
+ await refreshItems(undefined, nextConfig)
30
+ showMessage(successMessage)
31
+ }
@@ -0,0 +1,76 @@
1
+ import type { Dispatch, MutableRefObject, SetStateAction } from 'react'
2
+ import { showTemporaryMessage } from './notifications'
3
+ import { applyOpencodeState, loadOpencodeSessionStats } from './opencode'
4
+ import { applyRefreshedViewState, loadRefreshedViewState } from './state'
5
+ import type { Measure } from './data'
6
+ import type { Config, Item, OpencodeSessionStats, OpencodeStatsState, ViewMode } from '../types'
7
+
8
+ interface AppRuntimeOptions {
9
+ config: Config | null
10
+ viewMode: ViewMode
11
+ measure: Measure
12
+ lastSessionSelectionRef: MutableRefObject<string | null>
13
+ lastProjectSelectionRef: MutableRefObject<string | null>
14
+ setSessionItems: Dispatch<SetStateAction<Item[]>>
15
+ setProjectSourceItems: Dispatch<SetStateAction<Item[]>>
16
+ setAllItems: Dispatch<SetStateAction<Item[]>>
17
+ setItems: Dispatch<SetStateAction<Item[]>>
18
+ setCursor: Dispatch<SetStateAction<number>>
19
+ setMessage: Dispatch<SetStateAction<string>>
20
+ getOpencodeSessionStats: (sessionName: string) => Promise<OpencodeSessionStats | null>
21
+ }
22
+
23
+ export function createAppRuntime(options: AppRuntimeOptions) {
24
+ function showMessage(message: string, timeout = 2000) {
25
+ showTemporaryMessage(options.setMessage, message, timeout)
26
+ }
27
+
28
+ function updateOpencodeState(sessionName: string, nextState: OpencodeStatsState) {
29
+ applyOpencodeState(
30
+ sessionName,
31
+ nextState,
32
+ options.setSessionItems,
33
+ options.setAllItems,
34
+ options.setItems
35
+ )
36
+ }
37
+
38
+ async function refreshItems(forceViewMode?: ViewMode, nextConfig = options.config) {
39
+ if (!nextConfig) {
40
+ return
41
+ }
42
+
43
+ const targetMode = forceViewMode ?? options.viewMode
44
+ const refreshedState = await loadRefreshedViewState(
45
+ targetMode,
46
+ nextConfig,
47
+ options.measure,
48
+ options.lastSessionSelectionRef.current,
49
+ options.lastProjectSelectionRef.current
50
+ )
51
+
52
+ applyRefreshedViewState(
53
+ refreshedState,
54
+ options.setSessionItems,
55
+ options.setProjectSourceItems,
56
+ options.setAllItems,
57
+ options.setItems,
58
+ options.setCursor
59
+ )
60
+ }
61
+
62
+ async function loadOpencodeStatsForSession(sessionName: string) {
63
+ return loadOpencodeSessionStats(
64
+ sessionName,
65
+ options.getOpencodeSessionStats,
66
+ updateOpencodeState,
67
+ showMessage
68
+ )
69
+ }
70
+
71
+ return {
72
+ showMessage,
73
+ refreshItems,
74
+ loadOpencodeStatsForSession,
75
+ }
76
+ }
@@ -0,0 +1,217 @@
1
+ import type { TextareaRenderable } from '@opentui/core'
2
+ import type { Dispatch, MutableRefObject, SetStateAction } from 'react'
3
+ import {
4
+ getAppTitle,
5
+ getEmptyStateMessage,
6
+ getFooterHint,
7
+ getListStyle,
8
+ getStatusLabel,
9
+ } from './view'
10
+ import { syncTextareaValue } from './textarea'
11
+ import { AppMode, ViewMode, type Config, type Item, type ThemeColors } from '../types'
12
+ import { isGitHubURL } from '../util/github'
13
+ import { shouldShowDetailPanel } from '../util/terminal'
14
+ import SearchInput from '../ui/SearchInput'
15
+ import SessionList from '../ui/SessionList'
16
+ import OpencodeSessionGroup from '../ui/OpencodeSessionGroup'
17
+ import ItemList from '../ui/ItemList'
18
+ import OpencodeStatsPanel from '../ui/OpencodeStatsPanel'
19
+ import SessionDetailsPanel from '../ui/SessionDetailsPanel'
20
+ import Toast from '../ui/Toast'
21
+ import VersionBadge, { formatVersionBadge } from '../ui/VersionBadge'
22
+ import { CURRENT_VERSION } from '../update/version'
23
+
24
+ interface Props {
25
+ theme: ThemeColors
26
+ appMode: AppMode
27
+ viewMode: ViewMode
28
+ config: Config | null
29
+ items: Item[]
30
+ regularSessions: Item[]
31
+ opencodeSessions: Item[]
32
+ selectedPrimaryItem?: Item
33
+ cursor: number
34
+ opencodeCursor: number
35
+ searchQuery: string
36
+ prefixActive: boolean
37
+ pendingKillSessionName: string | null
38
+ projectCount: number
39
+ sessionItems: Item[]
40
+ rows: number
41
+ columns: number
42
+ textareaRef: MutableRefObject<TextareaRenderable | null>
43
+ setSearchQuery: Dispatch<SetStateAction<string>>
44
+ message: string
45
+ toastMessage: string
46
+ toastVisible: boolean
47
+ updatedVersion: string | null
48
+ }
49
+
50
+ export function AppScreen({
51
+ theme,
52
+ appMode,
53
+ viewMode,
54
+ config,
55
+ items,
56
+ regularSessions,
57
+ opencodeSessions,
58
+ selectedPrimaryItem,
59
+ cursor,
60
+ opencodeCursor,
61
+ searchQuery,
62
+ prefixActive,
63
+ pendingKillSessionName,
64
+ projectCount,
65
+ sessionItems,
66
+ rows,
67
+ columns,
68
+ textareaRef,
69
+ setSearchQuery,
70
+ message,
71
+ toastMessage,
72
+ toastVisible,
73
+ updatedVersion,
74
+ }: Props) {
75
+ const title = getAppTitle(appMode, viewMode)
76
+ const listStyle = getListStyle(theme, appMode)
77
+ const totalSessions = sessionItems.filter(item => item.isSession).length
78
+ const activeSessions = items.filter(item => item.isSession && item.isAttached).length
79
+ const maxVisibleItems = Math.max(8, rows - (appMode === AppMode.NewSession ? 10 : 12))
80
+ const versionLabel = formatVersionBadge(CURRENT_VERSION, updatedVersion)
81
+ const footerHint = getFooterHint(appMode, config?.prefixKey)
82
+
83
+ return (
84
+ <>
85
+ <box
86
+ style={{
87
+ flexDirection: 'column',
88
+ width: '100%',
89
+ height: '100%',
90
+ gap: 1,
91
+ backgroundColor: theme.background,
92
+ }}
93
+ >
94
+ <box
95
+ style={{
96
+ flexDirection: 'row',
97
+ alignItems: 'stretch',
98
+ justifyContent: 'center',
99
+ width: '100%',
100
+ flexGrow: 1,
101
+ flexShrink: 1,
102
+ gap: 1,
103
+ }}
104
+ >
105
+ <box style={listStyle}>
106
+ <box style={{ justifyContent: 'space-between', marginBottom: 1 }}>
107
+ <box style={{ flexDirection: 'column' }}>
108
+ <text style={{ fg: theme.text }}>mux-sesh</text>
109
+ <text style={{ fg: theme.textSubtle }}>{title}</text>
110
+ </box>
111
+ <box style={{ flexDirection: 'column', alignItems: 'flex-end' }}>
112
+ <text style={{ fg: theme.textMuted }}>
113
+ {getStatusLabel(viewMode, activeSessions, totalSessions, projectCount)}
114
+ </text>
115
+ </box>
116
+ </box>
117
+
118
+ {(appMode === AppMode.Search || appMode === AppMode.NewSession) && (
119
+ <SearchInput
120
+ key={appMode}
121
+ appMode={appMode}
122
+ searchQuery={searchQuery}
123
+ textareaRef={textareaRef}
124
+ prefixActive={prefixActive}
125
+ onContentChange={() => syncTextareaValue(textareaRef, setSearchQuery)}
126
+ />
127
+ )}
128
+
129
+ <box
130
+ style={{
131
+ alignSelf: 'auto',
132
+ flexDirection: 'column',
133
+ flexGrow: 0,
134
+ flexShrink: 0,
135
+ marginTop:
136
+ viewMode === ViewMode.Sessions &&
137
+ (appMode === AppMode.Normal || appMode === AppMode.OpencodeManage)
138
+ ? 1
139
+ : 0,
140
+ }}
141
+ >
142
+ {items.length === 0 ? (
143
+ <text style={{ fg: theme.inactive }}>
144
+ {getEmptyStateMessage(appMode, searchQuery, isGitHubURL(searchQuery))}
145
+ </text>
146
+ ) : viewMode === ViewMode.Sessions &&
147
+ (appMode === AppMode.Normal || appMode === AppMode.OpencodeManage) ? (
148
+ <>
149
+ <SessionList
150
+ items={regularSessions}
151
+ cursor={cursor}
152
+ searchQuery={searchQuery}
153
+ maxItems={maxVisibleItems}
154
+ icons={config?.icons}
155
+ pendingKillSessionName={pendingKillSessionName}
156
+ />
157
+
158
+ <OpencodeSessionGroup
159
+ sessions={opencodeSessions}
160
+ appMode={appMode}
161
+ cursor={opencodeCursor}
162
+ icons={config?.icons}
163
+ pendingKillSessionName={pendingKillSessionName}
164
+ />
165
+ </>
166
+ ) : (
167
+ <ItemList
168
+ items={items}
169
+ cursor={cursor}
170
+ appMode={appMode}
171
+ searchQuery={searchQuery}
172
+ maxItems={maxVisibleItems}
173
+ icons={config?.icons}
174
+ pendingKillSessionName={pendingKillSessionName}
175
+ />
176
+ )}
177
+ </box>
178
+ </box>
179
+
180
+ {shouldShowDetailPanel(columns, appMode === AppMode.NewSession) &&
181
+ (viewMode === ViewMode.Sessions && appMode === AppMode.OpencodeManage ? (
182
+ <OpencodeStatsPanel selectedItem={opencodeSessions[opencodeCursor]} />
183
+ ) : (
184
+ <SessionDetailsPanel selectedItem={selectedPrimaryItem} config={config} />
185
+ ))}
186
+ </box>
187
+
188
+ {(message || columns < 80 || footerHint) && (
189
+ <box
190
+ style={{
191
+ backgroundColor: theme.surface,
192
+ position: 'absolute',
193
+ bottom: 0,
194
+ left: 0,
195
+ paddingTop: 0.4,
196
+ paddingBottom: 0.4,
197
+ paddingLeft: 1,
198
+ paddingRight: versionLabel.length + 3,
199
+ width: '100%',
200
+ flexDirection: 'column',
201
+ flexShrink: 0,
202
+ }}
203
+ >
204
+ {message && <text style={{ fg: theme.action }}>{message}</text>}
205
+ {columns < 80 && appMode !== AppMode.NewSession && (
206
+ <text style={{ fg: theme.textSubtle }}>Resize for the detail pane.</text>
207
+ )}
208
+ <text style={{ fg: theme.textSubtle }}>{footerHint}</text>
209
+ </box>
210
+ )}
211
+
212
+ <Toast message={toastMessage} visible={toastVisible} />
213
+ <VersionBadge currentVersion={CURRENT_VERSION} updatedVersion={updatedVersion} />
214
+ </box>
215
+ </>
216
+ )
217
+ }