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
package/src/app/state.ts
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
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 {
|
|
5
|
+
getProjectSelectionIndex,
|
|
6
|
+
getSessionSelectionIndex,
|
|
7
|
+
loadProjectItemsWithLinks,
|
|
8
|
+
loadSessionItems,
|
|
9
|
+
type Measure,
|
|
10
|
+
} from './data'
|
|
11
|
+
|
|
12
|
+
export interface StartupState {
|
|
13
|
+
config: Config
|
|
14
|
+
appMode: AppMode
|
|
15
|
+
viewMode: ViewMode
|
|
16
|
+
items: Item[]
|
|
17
|
+
sessionItems: Item[]
|
|
18
|
+
projectSourceItems: Item[]
|
|
19
|
+
cursor: number
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface RefreshedViewState {
|
|
23
|
+
items: Item[]
|
|
24
|
+
cursor: number
|
|
25
|
+
sessionItems?: Item[]
|
|
26
|
+
projectSourceItems?: Item[]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export async function loadStartupState(
|
|
30
|
+
measure: Measure,
|
|
31
|
+
lastSessionSelection?: string | null,
|
|
32
|
+
lastProjectSelection?: string | null
|
|
33
|
+
): Promise<StartupState> {
|
|
34
|
+
const config = await measure('loadConfig', loadConfig)
|
|
35
|
+
const { visibleSessions, sessionItems } = await loadSessionItems(config, measure, 'startup')
|
|
36
|
+
const { projectSourceItems, projectItems } = await loadProjectItemsWithLinks(
|
|
37
|
+
config,
|
|
38
|
+
visibleSessions,
|
|
39
|
+
measure
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
if (sessionItems.length > 0) {
|
|
43
|
+
return {
|
|
44
|
+
config,
|
|
45
|
+
appMode: config.keybindMode === 'standard' ? AppMode.Search : AppMode.Normal,
|
|
46
|
+
viewMode: ViewMode.Sessions,
|
|
47
|
+
items: sessionItems,
|
|
48
|
+
sessionItems,
|
|
49
|
+
projectSourceItems,
|
|
50
|
+
cursor: getSessionSelectionIndex(sessionItems, lastSessionSelection),
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
config,
|
|
56
|
+
appMode: config.keybindMode === 'standard' ? AppMode.Search : AppMode.Normal,
|
|
57
|
+
viewMode: ViewMode.Projects,
|
|
58
|
+
items: projectItems,
|
|
59
|
+
sessionItems,
|
|
60
|
+
projectSourceItems,
|
|
61
|
+
cursor: getProjectSelectionIndex(projectItems, lastProjectSelection),
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export async function loadRefreshedViewState(
|
|
66
|
+
targetMode: ViewMode,
|
|
67
|
+
config: Config,
|
|
68
|
+
measure: Measure,
|
|
69
|
+
lastSessionSelection?: string | null,
|
|
70
|
+
lastProjectSelection?: string | null
|
|
71
|
+
): Promise<RefreshedViewState> {
|
|
72
|
+
if (targetMode === ViewMode.Sessions) {
|
|
73
|
+
const { sessionItems } = await loadSessionItems(config, measure, 'refresh')
|
|
74
|
+
return {
|
|
75
|
+
items: sessionItems,
|
|
76
|
+
sessionItems,
|
|
77
|
+
cursor: getSessionSelectionIndex(sessionItems, lastSessionSelection),
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const { visibleSessions } = await loadSessionItems(config, measure, 'refresh-projects')
|
|
82
|
+
const { projectSourceItems, projectItems } = await loadProjectItemsWithLinks(
|
|
83
|
+
config,
|
|
84
|
+
visibleSessions,
|
|
85
|
+
measure
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
items: projectItems,
|
|
90
|
+
projectSourceItems,
|
|
91
|
+
cursor: getProjectSelectionIndex(projectItems, lastProjectSelection),
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function applyRefreshedViewState(
|
|
96
|
+
refreshedState: RefreshedViewState,
|
|
97
|
+
setSessionItems: Dispatch<SetStateAction<Item[]>>,
|
|
98
|
+
setProjectSourceItems: Dispatch<SetStateAction<Item[]>>,
|
|
99
|
+
setAllItems: Dispatch<SetStateAction<Item[]>>,
|
|
100
|
+
setItems: Dispatch<SetStateAction<Item[]>>,
|
|
101
|
+
setCursor: Dispatch<SetStateAction<number>>
|
|
102
|
+
) {
|
|
103
|
+
if (refreshedState.sessionItems) {
|
|
104
|
+
setSessionItems(refreshedState.sessionItems)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (refreshedState.projectSourceItems) {
|
|
108
|
+
setProjectSourceItems(refreshedState.projectSourceItems)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
setAllItems(refreshedState.items)
|
|
112
|
+
setItems(refreshedState.items)
|
|
113
|
+
setCursor(refreshedState.cursor)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function useAppStartup(
|
|
117
|
+
measure: Measure,
|
|
118
|
+
lastSessionSelectionRef: MutableRefObject<string | null>,
|
|
119
|
+
lastProjectSelectionRef: MutableRefObject<string | null>,
|
|
120
|
+
mark: (label: string) => void,
|
|
121
|
+
setConfig: Dispatch<SetStateAction<Config | null>>,
|
|
122
|
+
setAppMode: Dispatch<SetStateAction<AppMode>>,
|
|
123
|
+
setViewMode: Dispatch<SetStateAction<ViewMode>>,
|
|
124
|
+
setSessionItems: Dispatch<SetStateAction<Item[]>>,
|
|
125
|
+
setProjectSourceItems: Dispatch<SetStateAction<Item[]>>,
|
|
126
|
+
setAllItems: Dispatch<SetStateAction<Item[]>>,
|
|
127
|
+
setItems: Dispatch<SetStateAction<Item[]>>,
|
|
128
|
+
setCursor: Dispatch<SetStateAction<number>>
|
|
129
|
+
) {
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
async function init() {
|
|
132
|
+
mark('startup begin')
|
|
133
|
+
const startupState = await loadStartupState(
|
|
134
|
+
measure,
|
|
135
|
+
lastSessionSelectionRef.current,
|
|
136
|
+
lastProjectSelectionRef.current
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
setConfig(startupState.config)
|
|
140
|
+
setAppMode(startupState.appMode)
|
|
141
|
+
setViewMode(startupState.viewMode)
|
|
142
|
+
setSessionItems(startupState.sessionItems)
|
|
143
|
+
setProjectSourceItems(startupState.projectSourceItems)
|
|
144
|
+
setAllItems(startupState.items)
|
|
145
|
+
setItems(startupState.items)
|
|
146
|
+
setCursor(startupState.cursor)
|
|
147
|
+
|
|
148
|
+
mark('startup complete')
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
void init()
|
|
152
|
+
}, [
|
|
153
|
+
lastProjectSelectionRef,
|
|
154
|
+
lastSessionSelectionRef,
|
|
155
|
+
mark,
|
|
156
|
+
measure,
|
|
157
|
+
setAllItems,
|
|
158
|
+
setAppMode,
|
|
159
|
+
setConfig,
|
|
160
|
+
setCursor,
|
|
161
|
+
setItems,
|
|
162
|
+
setProjectSourceItems,
|
|
163
|
+
setSessionItems,
|
|
164
|
+
setViewMode,
|
|
165
|
+
])
|
|
166
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { getPanelStyle } from '../styles/theme'
|
|
2
|
+
import { AppMode, ViewMode, type ThemeColors } from '../types'
|
|
3
|
+
|
|
4
|
+
export function splitVisibleSessions<T extends { isSession: boolean; title: string }>(
|
|
5
|
+
items: readonly T[]
|
|
6
|
+
) {
|
|
7
|
+
return {
|
|
8
|
+
regularSessions: items.filter(item => !(item.isSession && item.title.startsWith('opencode-'))),
|
|
9
|
+
opencodeSessions: items.filter(item => item.isSession && item.title.startsWith('opencode-')),
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function getAppTitle(appMode: AppMode, viewMode: ViewMode): string {
|
|
14
|
+
if (appMode === AppMode.Search) {
|
|
15
|
+
return 'Search'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (appMode === AppMode.NewSession) {
|
|
19
|
+
return 'New Session'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (appMode === AppMode.OpencodeManage) {
|
|
23
|
+
return 'OpenCode Sessions'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return viewMode === ViewMode.Projects ? 'Projects' : 'Sessions'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getListStyle(theme: ThemeColors, appMode: AppMode) {
|
|
30
|
+
if (appMode === AppMode.NewSession) {
|
|
31
|
+
return {
|
|
32
|
+
...getPanelStyle(theme, 'full'),
|
|
33
|
+
flexGrow: 1,
|
|
34
|
+
flexShrink: 1,
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
...getPanelStyle(theme, 'split'),
|
|
40
|
+
flexGrow: 1,
|
|
41
|
+
flexShrink: 1,
|
|
42
|
+
minWidth: 40,
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function getStatusLabel(
|
|
47
|
+
viewMode: ViewMode,
|
|
48
|
+
activeSessions: number,
|
|
49
|
+
totalSessions: number,
|
|
50
|
+
projectCount: number
|
|
51
|
+
): string {
|
|
52
|
+
return viewMode === ViewMode.Sessions
|
|
53
|
+
? `${activeSessions}/${totalSessions} active`
|
|
54
|
+
: `${projectCount} projects`
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function getFooterHint(appMode: AppMode, prefixKey?: string): string {
|
|
58
|
+
const prefixLabel = prefixKey ? `${prefixKey} ...` : 'direct keys'
|
|
59
|
+
|
|
60
|
+
if (appMode === AppMode.OpencodeManage) {
|
|
61
|
+
return `o back d kill ctrl+p commands ${prefixLabel}`
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (appMode === AppMode.NewSession) {
|
|
65
|
+
return 'enter create esc cancel'
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (appMode === AppMode.Search) {
|
|
69
|
+
return 'enter select esc cancel'
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return `enter select i search n new o opencode d kill ctrl+p commands ${prefixLabel}`
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function getEmptyStateMessage(
|
|
76
|
+
appMode: AppMode,
|
|
77
|
+
searchQuery: string,
|
|
78
|
+
isGitHubURL: boolean
|
|
79
|
+
): string {
|
|
80
|
+
if (appMode === AppMode.NewSession && searchQuery && isGitHubURL) {
|
|
81
|
+
return 'Clone & create session'
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (appMode === AppMode.NewSession && searchQuery) {
|
|
85
|
+
return `Create session: ${searchQuery}`
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return 'No items found'
|
|
89
|
+
}
|