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.
- package/README.md +133 -86
- package/bin/mux-sesh +45 -17
- package/bin/platform.sh +139 -0
- package/bin/postinstall +22 -0
- package/package.json +27 -38
- package/src/agents/index.ts +0 -1
- package/src/agents/session-name.ts +0 -24
- package/src/app/commands.ts +0 -138
- package/src/app/controller.ts +0 -437
- package/src/app/controls.ts +0 -123
- package/src/app/core-state.ts +0 -75
- package/src/app/data.ts +0 -130
- package/src/app/derived.ts +0 -77
- package/src/app/effects.ts +0 -650
- package/src/app/handlers.ts +0 -406
- package/src/app/keyboard.ts +0 -165
- package/src/app/modal-keyboard.ts +0 -137
- package/src/app/modal-state.ts +0 -53
- package/src/app/modals-layer.tsx +0 -159
- package/src/app/modals.ts +0 -108
- package/src/app/notifications.ts +0 -21
- package/src/app/opencode.ts +0 -49
- package/src/app/operations.ts +0 -31
- package/src/app/runtime.ts +0 -79
- package/src/app/screen.tsx +0 -240
- package/src/app/state.ts +0 -178
- package/src/app/textarea.ts +0 -16
- package/src/app/view.ts +0 -101
- package/src/app.tsx +0 -50
- package/src/config/index.ts +0 -475
- package/src/config/listed-sessions.ts +0 -33
- package/src/config/paths.ts +0 -13
- package/src/config/session-rules.ts +0 -100
- package/src/config/store.ts +0 -33
- package/src/files/target.ts +0 -96
- package/src/handlers/action-helpers.ts +0 -83
- package/src/handlers/actions.ts +0 -216
- package/src/handlers/keyboard/agents.ts +0 -134
- package/src/handlers/keyboard/index.ts +0 -5
- package/src/handlers/keyboard/new-session.ts +0 -58
- package/src/handlers/keyboard/normal.ts +0 -220
- package/src/handlers/keyboard/search.ts +0 -118
- package/src/handlers/keyboard/shared.ts +0 -117
- package/src/herdr/backend.ts +0 -357
- package/src/herdr/protocol.ts +0 -268
- package/src/index.tsx +0 -23
- package/src/items/order.ts +0 -95
- package/src/multiplexer/backend.ts +0 -43
- package/src/multiplexer/command.ts +0 -48
- package/src/multiplexer/index.ts +0 -21
- package/src/multiplexer/items.ts +0 -66
- package/src/multiplexer/resolve.ts +0 -109
- package/src/multiplexer/tmux-backend.ts +0 -87
- package/src/multiplexer/types.ts +0 -93
- package/src/opencode/constants.ts +0 -7
- package/src/opencode/index.ts +0 -20
- package/src/opencode/parser.ts +0 -45
- package/src/opencode/session-name.ts +0 -13
- package/src/opencode/session.ts +0 -146
- package/src/opencode/sqlite.ts +0 -447
- package/src/opencode/stats.ts +0 -26
- package/src/opencode/tokens.ts +0 -116
- package/src/opencode/types.ts +0 -33
- package/src/preview/project.ts +0 -362
- package/src/projects/session-links.ts +0 -52
- package/src/search/fff.ts +0 -224
- package/src/search/index.ts +0 -198
- package/src/settings.ts +0 -465
- package/src/styles/omarchy.ts +0 -295
- package/src/styles/opencode-themes-a.ts +0 -1442
- package/src/styles/opencode-themes-b.ts +0 -1212
- package/src/styles/opencode-tui-colors.ts +0 -1784
- package/src/styles/terminal-palette.ts +0 -156
- package/src/styles/theme-follow.ts +0 -94
- package/src/styles/theme.tsx +0 -311
- package/src/tmux/actions.ts +0 -145
- package/src/tmux/details.ts +0 -104
- package/src/tmux/helpers.ts +0 -35
- package/src/tmux/index.ts +0 -10
- package/src/tmux/list.ts +0 -31
- package/src/tmux/project-discovery.ts +0 -116
- package/src/tmux/project-loader.ts +0 -92
- package/src/tmux/project-zoxide.ts +0 -128
- package/src/tmux/projects.ts +0 -38
- package/src/tmux/workflows.ts +0 -26
- package/src/types/index.ts +0 -221
- package/src/ui/AgentSessionGroup.tsx +0 -93
- package/src/ui/CommandsModal.tsx +0 -246
- package/src/ui/ErrorScreen.tsx +0 -102
- package/src/ui/HighlightedText.tsx +0 -60
- package/src/ui/ItemList.tsx +0 -119
- package/src/ui/Modal.tsx +0 -48
- package/src/ui/OpencodeStatsPanel.tsx +0 -233
- package/src/ui/RenameModal.tsx +0 -42
- package/src/ui/SearchInput.tsx +0 -43
- package/src/ui/SessionDetailsPanel.tsx +0 -273
- package/src/ui/SessionList.tsx +0 -119
- package/src/ui/SettingEditorModal.tsx +0 -55
- package/src/ui/SettingOptionsModal.tsx +0 -95
- package/src/ui/SettingsModal.tsx +0 -102
- package/src/ui/Toast.tsx +0 -34
- package/src/ui/VersionBadge.tsx +0 -45
- package/src/ui/item-icon.ts +0 -110
- package/src/ui/list-window.ts +0 -35
- package/src/ui/session-meta.ts +0 -10
- package/src/ui/text-columns.ts +0 -17
- package/src/ui/use-textarea-focus.ts +0 -29
- package/src/update/events.ts +0 -28
- package/src/update/index.ts +0 -91
- package/src/update/installation.ts +0 -161
- package/src/update/version.ts +0 -33
- package/src/util/ansi.ts +0 -3
- package/src/util/browser.ts +0 -37
- package/src/util/clipboard.ts +0 -22
- package/src/util/errors.ts +0 -170
- package/src/util/github.ts +0 -100
- package/src/util/glob.ts +0 -51
- package/src/util/path-display.ts +0 -98
- package/src/util/perf.ts +0 -23
- package/src/util/shell.ts +0 -3
- package/src/util/shutdown.ts +0 -111
- package/src/util/terminal.ts +0 -28
- package/src/util/time.ts +0 -48
- package/tsconfig.json +0 -25
package/src/app/screen.tsx
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
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 { isOpencodeSessionItem } from '../opencode/session-name'
|
|
12
|
-
import { AppMode, ViewMode, type Config, type Item, type ThemeColors } from '../types'
|
|
13
|
-
import { isGitHubURL } from '../util/github'
|
|
14
|
-
import { shouldShowDetailPanel } from '../util/terminal'
|
|
15
|
-
import SearchInput from '../ui/SearchInput'
|
|
16
|
-
import SessionList from '../ui/SessionList'
|
|
17
|
-
import AgentSessionGroup from '../ui/AgentSessionGroup'
|
|
18
|
-
import ItemList from '../ui/ItemList'
|
|
19
|
-
import OpencodeStatsPanel from '../ui/OpencodeStatsPanel'
|
|
20
|
-
import SessionDetailsPanel from '../ui/SessionDetailsPanel'
|
|
21
|
-
import Toast from '../ui/Toast'
|
|
22
|
-
import VersionBadge, { formatVersionBadge } from '../ui/VersionBadge'
|
|
23
|
-
import { CURRENT_VERSION } from '../update/version'
|
|
24
|
-
import type { MultiplexerBackend } from '../multiplexer'
|
|
25
|
-
|
|
26
|
-
interface Props {
|
|
27
|
-
theme: ThemeColors
|
|
28
|
-
appMode: AppMode
|
|
29
|
-
viewMode: ViewMode
|
|
30
|
-
config: Config | null
|
|
31
|
-
backend: MultiplexerBackend | null
|
|
32
|
-
items: Item[]
|
|
33
|
-
regularSessions: Item[]
|
|
34
|
-
agentSessions: Item[]
|
|
35
|
-
selectedPrimaryItem?: Item
|
|
36
|
-
cursor: number
|
|
37
|
-
agentCursor: number
|
|
38
|
-
searchQuery: string
|
|
39
|
-
prefixActive: boolean
|
|
40
|
-
pendingKillSessionName: string | null
|
|
41
|
-
projectCount: number
|
|
42
|
-
sessionItems: Item[]
|
|
43
|
-
rows: number
|
|
44
|
-
columns: number
|
|
45
|
-
textareaRef: MutableRefObject<TextareaRenderable | null>
|
|
46
|
-
setSearchQuery: Dispatch<SetStateAction<string>>
|
|
47
|
-
message: string
|
|
48
|
-
toastMessage: string
|
|
49
|
-
toastVisible: boolean
|
|
50
|
-
updatedVersion: string | null
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function AppScreen({
|
|
54
|
-
theme,
|
|
55
|
-
appMode,
|
|
56
|
-
viewMode,
|
|
57
|
-
config,
|
|
58
|
-
backend,
|
|
59
|
-
items,
|
|
60
|
-
regularSessions,
|
|
61
|
-
agentSessions,
|
|
62
|
-
selectedPrimaryItem,
|
|
63
|
-
cursor,
|
|
64
|
-
agentCursor,
|
|
65
|
-
searchQuery,
|
|
66
|
-
prefixActive,
|
|
67
|
-
pendingKillSessionName,
|
|
68
|
-
projectCount,
|
|
69
|
-
sessionItems,
|
|
70
|
-
rows,
|
|
71
|
-
columns,
|
|
72
|
-
textareaRef,
|
|
73
|
-
setSearchQuery,
|
|
74
|
-
message,
|
|
75
|
-
toastMessage,
|
|
76
|
-
toastVisible,
|
|
77
|
-
updatedVersion,
|
|
78
|
-
}: Props) {
|
|
79
|
-
const title = getAppTitle(appMode, viewMode, backend?.kind)
|
|
80
|
-
const listStyle = getListStyle(theme, appMode)
|
|
81
|
-
const totalSessions = sessionItems.filter(item => item.isSession).length
|
|
82
|
-
const activeSessions = items.filter(item => item.isSession && item.isAttached).length
|
|
83
|
-
const maxVisibleItems = Math.max(8, rows - (appMode === AppMode.NewSession ? 10 : 12))
|
|
84
|
-
const versionLabel = formatVersionBadge(
|
|
85
|
-
CURRENT_VERSION,
|
|
86
|
-
updatedVersion,
|
|
87
|
-
process.env.MUX_SESH_DEV === '1'
|
|
88
|
-
)
|
|
89
|
-
const selectedAgentSession = agentSessions[agentCursor]
|
|
90
|
-
const showOpencodeStats =
|
|
91
|
-
viewMode === ViewMode.Sessions &&
|
|
92
|
-
appMode === AppMode.AgentsManage &&
|
|
93
|
-
selectedAgentSession !== undefined &&
|
|
94
|
-
isOpencodeSessionItem(selectedAgentSession)
|
|
95
|
-
const footerHint = getFooterHint(appMode, config?.prefixKey, selectedPrimaryItem)
|
|
96
|
-
|
|
97
|
-
return (
|
|
98
|
-
<>
|
|
99
|
-
<box
|
|
100
|
-
style={{
|
|
101
|
-
flexDirection: 'column',
|
|
102
|
-
width: '100%',
|
|
103
|
-
height: '100%',
|
|
104
|
-
gap: 1,
|
|
105
|
-
backgroundColor: theme.background,
|
|
106
|
-
}}
|
|
107
|
-
>
|
|
108
|
-
<box
|
|
109
|
-
style={{
|
|
110
|
-
flexDirection: 'row',
|
|
111
|
-
alignItems: 'stretch',
|
|
112
|
-
justifyContent: 'center',
|
|
113
|
-
width: '100%',
|
|
114
|
-
flexGrow: 1,
|
|
115
|
-
flexShrink: 1,
|
|
116
|
-
gap: 1,
|
|
117
|
-
}}
|
|
118
|
-
>
|
|
119
|
-
<box style={listStyle}>
|
|
120
|
-
<box style={{ justifyContent: 'space-between', marginBottom: 1 }}>
|
|
121
|
-
<box style={{ flexDirection: 'column' }}>
|
|
122
|
-
<text style={{ fg: theme.text }}>mux-sesh</text>
|
|
123
|
-
<text style={{ fg: theme.textSubtle }}>{title}</text>
|
|
124
|
-
</box>
|
|
125
|
-
<box style={{ flexDirection: 'column', alignItems: 'flex-end' }}>
|
|
126
|
-
<text style={{ fg: theme.textMuted }}>
|
|
127
|
-
{getStatusLabel(viewMode, activeSessions, totalSessions, projectCount)}
|
|
128
|
-
</text>
|
|
129
|
-
</box>
|
|
130
|
-
</box>
|
|
131
|
-
|
|
132
|
-
{(appMode === AppMode.Search || appMode === AppMode.NewSession) && (
|
|
133
|
-
<SearchInput
|
|
134
|
-
key={appMode}
|
|
135
|
-
appMode={appMode}
|
|
136
|
-
searchQuery={searchQuery}
|
|
137
|
-
textareaRef={textareaRef}
|
|
138
|
-
prefixActive={prefixActive}
|
|
139
|
-
onContentChange={() => syncTextareaValue(textareaRef, setSearchQuery)}
|
|
140
|
-
/>
|
|
141
|
-
)}
|
|
142
|
-
|
|
143
|
-
<box
|
|
144
|
-
style={{
|
|
145
|
-
alignSelf: 'auto',
|
|
146
|
-
flexDirection: 'column',
|
|
147
|
-
flexGrow: 0,
|
|
148
|
-
flexShrink: 0,
|
|
149
|
-
marginTop:
|
|
150
|
-
viewMode === ViewMode.Sessions &&
|
|
151
|
-
(appMode === AppMode.Normal || appMode === AppMode.AgentsManage)
|
|
152
|
-
? 1
|
|
153
|
-
: 0,
|
|
154
|
-
}}
|
|
155
|
-
>
|
|
156
|
-
{items.length === 0 ? (
|
|
157
|
-
<text style={{ fg: theme.inactive }}>
|
|
158
|
-
{getEmptyStateMessage(appMode, searchQuery, isGitHubURL(searchQuery))}
|
|
159
|
-
</text>
|
|
160
|
-
) : viewMode === ViewMode.Sessions &&
|
|
161
|
-
(appMode === AppMode.Normal || appMode === AppMode.AgentsManage) ? (
|
|
162
|
-
<>
|
|
163
|
-
<SessionList
|
|
164
|
-
items={regularSessions}
|
|
165
|
-
cursor={cursor}
|
|
166
|
-
searchQuery={searchQuery}
|
|
167
|
-
maxItems={maxVisibleItems}
|
|
168
|
-
icons={config?.icons}
|
|
169
|
-
pendingKillSessionName={pendingKillSessionName}
|
|
170
|
-
/>
|
|
171
|
-
|
|
172
|
-
<AgentSessionGroup
|
|
173
|
-
sessions={agentSessions}
|
|
174
|
-
appMode={appMode}
|
|
175
|
-
cursor={agentCursor}
|
|
176
|
-
maxItems={maxVisibleItems}
|
|
177
|
-
icons={config?.icons}
|
|
178
|
-
pendingKillSessionName={pendingKillSessionName}
|
|
179
|
-
/>
|
|
180
|
-
</>
|
|
181
|
-
) : (
|
|
182
|
-
<ItemList
|
|
183
|
-
items={items}
|
|
184
|
-
cursor={cursor}
|
|
185
|
-
appMode={appMode}
|
|
186
|
-
searchQuery={searchQuery}
|
|
187
|
-
maxItems={maxVisibleItems}
|
|
188
|
-
icons={config?.icons}
|
|
189
|
-
pendingKillSessionName={pendingKillSessionName}
|
|
190
|
-
/>
|
|
191
|
-
)}
|
|
192
|
-
</box>
|
|
193
|
-
</box>
|
|
194
|
-
|
|
195
|
-
{shouldShowDetailPanel(columns, appMode === AppMode.NewSession) &&
|
|
196
|
-
(showOpencodeStats ? (
|
|
197
|
-
<OpencodeStatsPanel selectedItem={selectedAgentSession} />
|
|
198
|
-
) : (
|
|
199
|
-
<SessionDetailsPanel
|
|
200
|
-
selectedItem={selectedPrimaryItem}
|
|
201
|
-
config={config}
|
|
202
|
-
backend={backend}
|
|
203
|
-
/>
|
|
204
|
-
))}
|
|
205
|
-
</box>
|
|
206
|
-
|
|
207
|
-
{(message || columns < 80 || footerHint) && (
|
|
208
|
-
<box
|
|
209
|
-
style={{
|
|
210
|
-
backgroundColor: theme.surface,
|
|
211
|
-
position: 'absolute',
|
|
212
|
-
bottom: 0,
|
|
213
|
-
left: 0,
|
|
214
|
-
paddingTop: 0.4,
|
|
215
|
-
paddingBottom: 0.4,
|
|
216
|
-
paddingLeft: 1,
|
|
217
|
-
paddingRight: versionLabel.length + 3,
|
|
218
|
-
width: '100%',
|
|
219
|
-
flexDirection: 'column',
|
|
220
|
-
flexShrink: 0,
|
|
221
|
-
}}
|
|
222
|
-
>
|
|
223
|
-
{message && <text style={{ fg: theme.action }}>{message}</text>}
|
|
224
|
-
{columns < 80 && appMode !== AppMode.NewSession && (
|
|
225
|
-
<text style={{ fg: theme.textSubtle }}>Resize for the detail pane.</text>
|
|
226
|
-
)}
|
|
227
|
-
<text style={{ fg: theme.textSubtle }}>{footerHint}</text>
|
|
228
|
-
</box>
|
|
229
|
-
)}
|
|
230
|
-
|
|
231
|
-
<Toast message={toastMessage} visible={toastVisible} />
|
|
232
|
-
<VersionBadge
|
|
233
|
-
currentVersion={CURRENT_VERSION}
|
|
234
|
-
updatedVersion={updatedVersion}
|
|
235
|
-
isDev={process.env.MUX_SESH_DEV === '1'}
|
|
236
|
-
/>
|
|
237
|
-
</box>
|
|
238
|
-
</>
|
|
239
|
-
)
|
|
240
|
-
}
|
package/src/app/state.ts
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { useEffect, type Dispatch, type MutableRefObject, type SetStateAction } from 'react'
|
|
2
|
-
import { loadConfig } from '../config'
|
|
3
|
-
import { AppMode, ViewMode, type Config, type Item } from '../types'
|
|
4
|
-
import { resolveMultiplexerBackend, type MultiplexerBackend } from '../multiplexer'
|
|
5
|
-
import {
|
|
6
|
-
getProjectSelectionIndex,
|
|
7
|
-
getSessionSelectionIndex,
|
|
8
|
-
loadProjectSourceItems,
|
|
9
|
-
loadProjectItemsWithLinks,
|
|
10
|
-
loadSessionItems,
|
|
11
|
-
type Measure,
|
|
12
|
-
} from './data'
|
|
13
|
-
|
|
14
|
-
export interface RefreshedViewState {
|
|
15
|
-
items: Item[]
|
|
16
|
-
cursor: number
|
|
17
|
-
sessionItems?: Item[]
|
|
18
|
-
projectSourceItems?: Item[]
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export async function loadRefreshedViewState(
|
|
22
|
-
targetMode: ViewMode,
|
|
23
|
-
config: Config,
|
|
24
|
-
measure: Measure,
|
|
25
|
-
backend: MultiplexerBackend,
|
|
26
|
-
lastSessionSelection?: string | null,
|
|
27
|
-
lastProjectSelection?: string | null
|
|
28
|
-
): Promise<RefreshedViewState> {
|
|
29
|
-
if (targetMode === ViewMode.Sessions) {
|
|
30
|
-
const { sessionItems } = await loadSessionItems(config, measure, backend, 'refresh')
|
|
31
|
-
return {
|
|
32
|
-
items: sessionItems,
|
|
33
|
-
sessionItems,
|
|
34
|
-
cursor: getSessionSelectionIndex(sessionItems, lastSessionSelection),
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const { visibleSessions } = await loadSessionItems(config, measure, backend, 'refresh-projects')
|
|
39
|
-
const { projectSourceItems, projectItems } = await loadProjectItemsWithLinks(
|
|
40
|
-
config,
|
|
41
|
-
visibleSessions,
|
|
42
|
-
measure
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
items: projectItems,
|
|
47
|
-
projectSourceItems,
|
|
48
|
-
cursor: getProjectSelectionIndex(projectItems, lastProjectSelection),
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function applyRefreshedViewState(
|
|
53
|
-
refreshedState: RefreshedViewState,
|
|
54
|
-
setSessionItems: Dispatch<SetStateAction<Item[]>>,
|
|
55
|
-
setProjectSourceItems: Dispatch<SetStateAction<Item[]>>,
|
|
56
|
-
setAllItems: Dispatch<SetStateAction<Item[]>>,
|
|
57
|
-
setItems: Dispatch<SetStateAction<Item[]>>,
|
|
58
|
-
setCursor: Dispatch<SetStateAction<number>>
|
|
59
|
-
) {
|
|
60
|
-
if (refreshedState.sessionItems) {
|
|
61
|
-
setSessionItems(refreshedState.sessionItems)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (refreshedState.projectSourceItems) {
|
|
65
|
-
setProjectSourceItems(refreshedState.projectSourceItems)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
setAllItems(refreshedState.items)
|
|
69
|
-
setItems(refreshedState.items)
|
|
70
|
-
setCursor(refreshedState.cursor)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function useAppStartup(
|
|
74
|
-
measure: Measure,
|
|
75
|
-
lastSessionSelectionRef: MutableRefObject<string | null>,
|
|
76
|
-
lastProjectSelectionRef: MutableRefObject<string | null>,
|
|
77
|
-
mark: (label: string) => void,
|
|
78
|
-
setConfig: Dispatch<SetStateAction<Config | null>>,
|
|
79
|
-
setBackend: Dispatch<SetStateAction<MultiplexerBackend | null>>,
|
|
80
|
-
setMessage: Dispatch<SetStateAction<string>>,
|
|
81
|
-
setAppMode: Dispatch<SetStateAction<AppMode>>,
|
|
82
|
-
setViewMode: Dispatch<SetStateAction<ViewMode>>,
|
|
83
|
-
setSessionItems: Dispatch<SetStateAction<Item[]>>,
|
|
84
|
-
setProjectSourceItems: Dispatch<SetStateAction<Item[]>>,
|
|
85
|
-
setAllItems: Dispatch<SetStateAction<Item[]>>,
|
|
86
|
-
setItems: Dispatch<SetStateAction<Item[]>>,
|
|
87
|
-
setCursor: Dispatch<SetStateAction<number>>
|
|
88
|
-
) {
|
|
89
|
-
useEffect(() => {
|
|
90
|
-
let cancelled = false
|
|
91
|
-
|
|
92
|
-
async function init() {
|
|
93
|
-
mark('startup begin')
|
|
94
|
-
const config = await measure('loadConfig', loadConfig)
|
|
95
|
-
if (cancelled) {
|
|
96
|
-
return
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const startupAppMode = config.keybindMode === 'standard' ? AppMode.Search : AppMode.Normal
|
|
100
|
-
const backend = await measure('resolveBackend', () =>
|
|
101
|
-
resolveMultiplexerBackend({ preference: config.backend })
|
|
102
|
-
)
|
|
103
|
-
if (cancelled) return
|
|
104
|
-
setConfig(config)
|
|
105
|
-
setBackend(backend)
|
|
106
|
-
setAppMode(startupAppMode)
|
|
107
|
-
|
|
108
|
-
const { visibleSessions, sessionItems } = await loadSessionItems(
|
|
109
|
-
config,
|
|
110
|
-
measure,
|
|
111
|
-
backend,
|
|
112
|
-
'startup'
|
|
113
|
-
)
|
|
114
|
-
if (cancelled) {
|
|
115
|
-
return
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
setSessionItems(sessionItems)
|
|
119
|
-
|
|
120
|
-
if (sessionItems.length > 0) {
|
|
121
|
-
setViewMode(ViewMode.Sessions)
|
|
122
|
-
setAllItems(sessionItems)
|
|
123
|
-
setItems(sessionItems)
|
|
124
|
-
setCursor(getSessionSelectionIndex(sessionItems, lastSessionSelectionRef.current))
|
|
125
|
-
mark('startup complete')
|
|
126
|
-
|
|
127
|
-
const projectSourceItems = await loadProjectSourceItems(config, measure)
|
|
128
|
-
if (cancelled) {
|
|
129
|
-
return
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
setProjectSourceItems(projectSourceItems)
|
|
133
|
-
return
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const { projectSourceItems, projectItems } = await loadProjectItemsWithLinks(
|
|
137
|
-
config,
|
|
138
|
-
visibleSessions,
|
|
139
|
-
measure
|
|
140
|
-
)
|
|
141
|
-
if (cancelled) {
|
|
142
|
-
return
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
setViewMode(ViewMode.Projects)
|
|
146
|
-
setProjectSourceItems(projectSourceItems)
|
|
147
|
-
setAllItems(projectItems)
|
|
148
|
-
setItems(projectItems)
|
|
149
|
-
setCursor(getProjectSelectionIndex(projectItems, lastProjectSelectionRef.current))
|
|
150
|
-
mark('startup complete')
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
void init().catch(error => {
|
|
154
|
-
if (!cancelled) {
|
|
155
|
-
setMessage(error instanceof Error ? error.message : 'Failed to start mux-sesh')
|
|
156
|
-
}
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
return () => {
|
|
160
|
-
cancelled = true
|
|
161
|
-
}
|
|
162
|
-
}, [
|
|
163
|
-
lastProjectSelectionRef,
|
|
164
|
-
lastSessionSelectionRef,
|
|
165
|
-
mark,
|
|
166
|
-
measure,
|
|
167
|
-
setAllItems,
|
|
168
|
-
setAppMode,
|
|
169
|
-
setConfig,
|
|
170
|
-
setBackend,
|
|
171
|
-
setMessage,
|
|
172
|
-
setCursor,
|
|
173
|
-
setItems,
|
|
174
|
-
setProjectSourceItems,
|
|
175
|
-
setSessionItems,
|
|
176
|
-
setViewMode,
|
|
177
|
-
])
|
|
178
|
-
}
|
package/src/app/textarea.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { TextareaRenderable } from '@opentui/core'
|
|
2
|
-
import type { Dispatch, MutableRefObject, SetStateAction } from 'react'
|
|
3
|
-
|
|
4
|
-
export function syncTextareaValue(
|
|
5
|
-
textareaRef: MutableRefObject<TextareaRenderable | null>,
|
|
6
|
-
setValue: Dispatch<SetStateAction<string>>,
|
|
7
|
-
resetCursor?: Dispatch<SetStateAction<number>>
|
|
8
|
-
) {
|
|
9
|
-
const value = textareaRef.current?.plainText
|
|
10
|
-
if (value === undefined) {
|
|
11
|
-
return
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
setValue(value)
|
|
15
|
-
resetCursor?.(0)
|
|
16
|
-
}
|
package/src/app/view.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { isAgentSessionItem } from '../agents/session-name'
|
|
2
|
-
import { isHerdrAgentItem } from '../multiplexer/items'
|
|
3
|
-
import { getPanelStyle } from '../styles/theme'
|
|
4
|
-
import { AppMode, ViewMode, type BackendKind, type Item, type ThemeColors } from '../types'
|
|
5
|
-
|
|
6
|
-
export function splitVisibleSessions<T extends { isSession: boolean; title: string }>(
|
|
7
|
-
items: readonly T[]
|
|
8
|
-
) {
|
|
9
|
-
return {
|
|
10
|
-
regularSessions: items.filter(item => !isAgentSessionItem(item)),
|
|
11
|
-
agentSessions: items.filter(isAgentSessionItem),
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function getAppTitle(
|
|
16
|
-
appMode: AppMode,
|
|
17
|
-
viewMode: ViewMode,
|
|
18
|
-
backend: BackendKind = 'tmux'
|
|
19
|
-
): string {
|
|
20
|
-
if (appMode === AppMode.Search) {
|
|
21
|
-
return 'Search'
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (appMode === AppMode.NewSession) {
|
|
25
|
-
return backend === 'herdr' ? 'New Workspace' : 'New Session'
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (appMode === AppMode.AgentsManage) {
|
|
29
|
-
return 'Agent Sessions'
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return viewMode === ViewMode.Projects
|
|
33
|
-
? 'Projects'
|
|
34
|
-
: backend === 'herdr'
|
|
35
|
-
? 'Workspaces'
|
|
36
|
-
: 'Sessions'
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function getListStyle(theme: ThemeColors, appMode: AppMode) {
|
|
40
|
-
if (appMode === AppMode.NewSession) {
|
|
41
|
-
return {
|
|
42
|
-
...getPanelStyle(theme, 'full'),
|
|
43
|
-
flexGrow: 1,
|
|
44
|
-
flexShrink: 1,
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
...getPanelStyle(theme, 'split'),
|
|
50
|
-
flexGrow: 1,
|
|
51
|
-
flexShrink: 1,
|
|
52
|
-
minWidth: 40,
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function getStatusLabel(
|
|
57
|
-
viewMode: ViewMode,
|
|
58
|
-
activeSessions: number,
|
|
59
|
-
totalSessions: number,
|
|
60
|
-
projectCount: number
|
|
61
|
-
): string {
|
|
62
|
-
return viewMode === ViewMode.Sessions
|
|
63
|
-
? `${activeSessions}/${totalSessions} active`
|
|
64
|
-
: `${projectCount} projects`
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function getFooterHint(appMode: AppMode, prefixKey?: string, selectedItem?: Item): string {
|
|
68
|
-
const prefixLabel = prefixKey ? `${prefixKey} ...` : 'direct keys'
|
|
69
|
-
|
|
70
|
-
if (appMode === AppMode.AgentsManage) {
|
|
71
|
-
return isHerdrAgentItem(selectedItem)
|
|
72
|
-
? `o back enter focus ctrl+p commands ${prefixLabel}`
|
|
73
|
-
: `o back d kill ctrl+p commands ${prefixLabel}`
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (appMode === AppMode.NewSession) {
|
|
77
|
-
return 'enter create esc cancel'
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (appMode === AppMode.Search) {
|
|
81
|
-
return 'enter select esc cancel'
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return `enter select i search n new o agents d kill ctrl+p commands ${prefixLabel}`
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function getEmptyStateMessage(
|
|
88
|
-
appMode: AppMode,
|
|
89
|
-
searchQuery: string,
|
|
90
|
-
isGitHubURL: boolean
|
|
91
|
-
): string {
|
|
92
|
-
if (appMode === AppMode.NewSession && searchQuery && isGitHubURL) {
|
|
93
|
-
return 'Clone & create session'
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (appMode === AppMode.NewSession && searchQuery) {
|
|
97
|
-
return `Create session: ${searchQuery}`
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return 'No items found'
|
|
101
|
-
}
|
package/src/app.tsx
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Component, type ReactNode } from 'react'
|
|
2
|
-
import { useAppController } from './app/controller'
|
|
3
|
-
import { AppModalsLayer } from './app/modals-layer'
|
|
4
|
-
import { AppScreen } from './app/screen'
|
|
5
|
-
import { ThemeProvider } from './styles/theme'
|
|
6
|
-
import { ErrorScreen } from './ui/ErrorScreen'
|
|
7
|
-
|
|
8
|
-
interface ErrorBoundaryState {
|
|
9
|
-
error?: unknown
|
|
10
|
-
hasError: boolean
|
|
11
|
-
retryKey: number
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
class RootErrorBoundary extends Component<
|
|
15
|
-
{ children: (retryKey: number) => ReactNode },
|
|
16
|
-
ErrorBoundaryState
|
|
17
|
-
> {
|
|
18
|
-
state: ErrorBoundaryState = { hasError: false, retryKey: 0 }
|
|
19
|
-
|
|
20
|
-
static getDerivedStateFromError(error: unknown): Partial<ErrorBoundaryState> {
|
|
21
|
-
return { error, hasError: true }
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
private retry = () => {
|
|
25
|
-
this.setState(state => ({ error: undefined, hasError: false, retryKey: state.retryKey + 1 }))
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
render() {
|
|
29
|
-
if (this.state.hasError) {
|
|
30
|
-
return <ErrorScreen error={this.state.error} onRetry={this.retry} />
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return this.props.children(this.state.retryKey)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function AppTree() {
|
|
38
|
-
const { theme, screenProps, modalProps } = useAppController()
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<ThemeProvider theme={theme}>
|
|
42
|
-
<AppScreen {...screenProps} />
|
|
43
|
-
<AppModalsLayer {...modalProps} />
|
|
44
|
-
</ThemeProvider>
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function App() {
|
|
49
|
-
return <RootErrorBoundary>{retryKey => <AppTree key={retryKey} />}</RootErrorBoundary>
|
|
50
|
-
}
|