mux-sesh 1.7.0 → 1.7.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/package.json +1 -1
- package/src/app/data.ts +8 -6
- package/src/app/state.ts +51 -59
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "mux-sesh",
|
|
4
|
-
"version": "1.7.
|
|
4
|
+
"version": "1.7.1",
|
|
5
5
|
"description": "A beautiful tmux session manager built with OpenTUI - fuzzy search sessions, manage projects, clone from GitHub",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"packageManager": "bun@1.3.5",
|
package/src/app/data.ts
CHANGED
|
@@ -56,12 +56,7 @@ export async function loadProjectItemsWithLinks(
|
|
|
56
56
|
measure: Measure,
|
|
57
57
|
sourceItems?: Item[]
|
|
58
58
|
): Promise<{ projectSourceItems: Item[]; projectItems: Item[] }> {
|
|
59
|
-
const projectSourceItems =
|
|
60
|
-
sourceItems ??
|
|
61
|
-
orderProjectItems(
|
|
62
|
-
await measure('projects:getProjectItems', () => getProjectItems(config)),
|
|
63
|
-
config.sortOrder
|
|
64
|
-
)
|
|
59
|
+
const projectSourceItems = sourceItems ?? (await loadProjectSourceItems(config, measure))
|
|
65
60
|
|
|
66
61
|
const projectItems = clearMatchIndices(
|
|
67
62
|
orderProjectItems(
|
|
@@ -78,6 +73,13 @@ export async function loadProjectItemsWithLinks(
|
|
|
78
73
|
}
|
|
79
74
|
}
|
|
80
75
|
|
|
76
|
+
export async function loadProjectSourceItems(config: Config, measure: Measure): Promise<Item[]> {
|
|
77
|
+
return orderProjectItems(
|
|
78
|
+
await measure('projects:getProjectItems', () => getProjectItems(config)),
|
|
79
|
+
config.sortOrder
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
81
83
|
export async function loadSessionCandidateItems(config: Config, measure: Measure): Promise<Item[]> {
|
|
82
84
|
const [candidates, sessions] = await measure('loadSessionCandidateItems', () =>
|
|
83
85
|
Promise.all([getSessionCandidateItems(config), listTmuxSessions()])
|
package/src/app/state.ts
CHANGED
|
@@ -4,21 +4,12 @@ import { AppMode, ViewMode, type Config, type Item } from '../types'
|
|
|
4
4
|
import {
|
|
5
5
|
getProjectSelectionIndex,
|
|
6
6
|
getSessionSelectionIndex,
|
|
7
|
+
loadProjectSourceItems,
|
|
7
8
|
loadProjectItemsWithLinks,
|
|
8
9
|
loadSessionItems,
|
|
9
10
|
type Measure,
|
|
10
11
|
} from './data'
|
|
11
12
|
|
|
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
13
|
export interface RefreshedViewState {
|
|
23
14
|
items: Item[]
|
|
24
15
|
cursor: number
|
|
@@ -26,42 +17,6 @@ export interface RefreshedViewState {
|
|
|
26
17
|
projectSourceItems?: Item[]
|
|
27
18
|
}
|
|
28
19
|
|
|
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
20
|
export async function loadRefreshedViewState(
|
|
66
21
|
targetMode: ViewMode,
|
|
67
22
|
config: Config,
|
|
@@ -128,27 +83,64 @@ export function useAppStartup(
|
|
|
128
83
|
setCursor: Dispatch<SetStateAction<number>>
|
|
129
84
|
) {
|
|
130
85
|
useEffect(() => {
|
|
86
|
+
let cancelled = false
|
|
87
|
+
|
|
131
88
|
async function init() {
|
|
132
89
|
mark('startup begin')
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
)
|
|
90
|
+
const config = await measure('loadConfig', loadConfig)
|
|
91
|
+
if (cancelled) {
|
|
92
|
+
return
|
|
93
|
+
}
|
|
138
94
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
setSessionItems(startupState.sessionItems)
|
|
143
|
-
setProjectSourceItems(startupState.projectSourceItems)
|
|
144
|
-
setAllItems(startupState.items)
|
|
145
|
-
setItems(startupState.items)
|
|
146
|
-
setCursor(startupState.cursor)
|
|
95
|
+
const startupAppMode = config.keybindMode === 'standard' ? AppMode.Search : AppMode.Normal
|
|
96
|
+
setConfig(config)
|
|
97
|
+
setAppMode(startupAppMode)
|
|
147
98
|
|
|
99
|
+
const { visibleSessions, sessionItems } = await loadSessionItems(config, measure, 'startup')
|
|
100
|
+
if (cancelled) {
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
setSessionItems(sessionItems)
|
|
105
|
+
|
|
106
|
+
if (sessionItems.length > 0) {
|
|
107
|
+
setViewMode(ViewMode.Sessions)
|
|
108
|
+
setAllItems(sessionItems)
|
|
109
|
+
setItems(sessionItems)
|
|
110
|
+
setCursor(getSessionSelectionIndex(sessionItems, lastSessionSelectionRef.current))
|
|
111
|
+
mark('startup complete')
|
|
112
|
+
|
|
113
|
+
const projectSourceItems = await loadProjectSourceItems(config, measure)
|
|
114
|
+
if (cancelled) {
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
setProjectSourceItems(projectSourceItems)
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const { projectSourceItems, projectItems } = await loadProjectItemsWithLinks(
|
|
123
|
+
config,
|
|
124
|
+
visibleSessions,
|
|
125
|
+
measure
|
|
126
|
+
)
|
|
127
|
+
if (cancelled) {
|
|
128
|
+
return
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
setViewMode(ViewMode.Projects)
|
|
132
|
+
setProjectSourceItems(projectSourceItems)
|
|
133
|
+
setAllItems(projectItems)
|
|
134
|
+
setItems(projectItems)
|
|
135
|
+
setCursor(getProjectSelectionIndex(projectItems, lastProjectSelectionRef.current))
|
|
148
136
|
mark('startup complete')
|
|
149
137
|
}
|
|
150
138
|
|
|
151
139
|
void init()
|
|
140
|
+
|
|
141
|
+
return () => {
|
|
142
|
+
cancelled = true
|
|
143
|
+
}
|
|
152
144
|
}, [
|
|
153
145
|
lastProjectSelectionRef,
|
|
154
146
|
lastSessionSelectionRef,
|