mux-sesh 1.2.0 → 1.3.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/LICENSE +2 -2
- package/package.json +4 -3
- package/src/app.tsx +28 -0
- package/src/config/index.ts +2 -0
- package/src/handlers/keyboard.ts +1 -1
- package/src/types/index.ts +9 -2
- package/src/ui/Toast.tsx +32 -0
- package/src/update/events.ts +28 -0
- package/src/update/index.ts +32 -0
- package/src/update/installation.ts +72 -0
- package/src/update/version.ts +32 -0
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025
|
|
3
|
+
Copyright (c) 2025 QuietGhost
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mux-sesh",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "A beautiful tmux session manager built with OpenTUI - fuzzy search sessions, manage projects, clone from GitHub",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"mux-sesh": "./bin/mux-sesh"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"bin",
|
|
11
|
+
"src"
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
14
|
"dev": "bun run src/index.tsx",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@opentui/core": "latest",
|
|
50
50
|
"@opentui/react": "latest",
|
|
51
|
+
"mux-sesh": "^1.2.0",
|
|
51
52
|
"react": "^19.0.0"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
package/src/app.tsx
CHANGED
|
@@ -10,6 +10,8 @@ import { getOpencodeSessionStats } from './opencode'
|
|
|
10
10
|
import { formatSessionAge } from './util/time'
|
|
11
11
|
import { colors, sessionListStyle, sessionListStyleFull } from './styles/theme'
|
|
12
12
|
import { useTerminalSize, shouldShowDetailPanel } from './util/terminal'
|
|
13
|
+
import Toast from './ui/Toast'
|
|
14
|
+
import { checkAndUpdate, updateEvents } from './update'
|
|
13
15
|
import KeybindHelp from './components/KeybindHelp'
|
|
14
16
|
import OpencodeStatsPanel from './ui/OpencodeStatsPanel'
|
|
15
17
|
import SessionDetailsPanel from './ui/SessionDetailsPanel'
|
|
@@ -51,6 +53,8 @@ export function App() {
|
|
|
51
53
|
const statsCache = useRef<Map<string, OpencodeSessionStats>>(new Map())
|
|
52
54
|
const [loadingStats, setLoadingStats] = useState(false)
|
|
53
55
|
const { columns } = useTerminalSize()
|
|
56
|
+
const [toastMessage, setToastMessage] = useState('')
|
|
57
|
+
const [toastVisible, setToastVisible] = useState(false)
|
|
54
58
|
|
|
55
59
|
useEffect(() => {
|
|
56
60
|
async function init() {
|
|
@@ -77,6 +81,9 @@ export function App() {
|
|
|
77
81
|
setAllItems(projects)
|
|
78
82
|
setItems(projects)
|
|
79
83
|
}
|
|
84
|
+
checkAndUpdate(cfg).catch(error => {
|
|
85
|
+
console.error('Auto-update check failed:', error)
|
|
86
|
+
})
|
|
80
87
|
}
|
|
81
88
|
init()
|
|
82
89
|
}, [])
|
|
@@ -248,6 +255,26 @@ export function App() {
|
|
|
248
255
|
}
|
|
249
256
|
})
|
|
250
257
|
|
|
258
|
+
useEffect(() => {
|
|
259
|
+
const unsubscribe = updateEvents.on(event => {
|
|
260
|
+
setToastMessage(`v${event.version}`)
|
|
261
|
+
setToastVisible(true)
|
|
262
|
+
setTimeout(() => {
|
|
263
|
+
setToastVisible(false)
|
|
264
|
+
}, 5000)
|
|
265
|
+
})
|
|
266
|
+
return unsubscribe
|
|
267
|
+
}, [])
|
|
268
|
+
|
|
269
|
+
//NOTE:
|
|
270
|
+
// After the updateEvents.on() effect, add:
|
|
271
|
+
useEffect(() => {
|
|
272
|
+
// Simulate an update after 2 seconds
|
|
273
|
+
setTimeout(() => {
|
|
274
|
+
updateEvents.emit({ version: '99.99.99' })
|
|
275
|
+
}, 2000)
|
|
276
|
+
}, [])
|
|
277
|
+
|
|
251
278
|
useEffect(() => {
|
|
252
279
|
if (appMode === AppMode.Search && searchQuery === '') {
|
|
253
280
|
setItems(allItems)
|
|
@@ -433,6 +460,7 @@ export function App() {
|
|
|
433
460
|
)}
|
|
434
461
|
</>
|
|
435
462
|
)}
|
|
463
|
+
<Toast message={toastMessage} visible={toastVisible} />
|
|
436
464
|
</box>
|
|
437
465
|
)
|
|
438
466
|
}
|
package/src/config/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export function getDefaultConfig(): Config {
|
|
|
11
11
|
editorCmd:
|
|
12
12
|
"nvim -c \"lua vim.defer_fn(function() if pcall(require, 'telescope') then vim.cmd('Telescope find_files') end end, 100)\"",
|
|
13
13
|
keybindMode: 'vim',
|
|
14
|
+
autoUpdate: true,
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
|
|
@@ -30,6 +31,7 @@ export async function loadConfig(): Promise<Config> {
|
|
|
30
31
|
editor: config.editor,
|
|
31
32
|
editorCmd: config.editor_cmd || config.editorCmd,
|
|
32
33
|
keybindMode: config.keybind_mode || config.keybindMode,
|
|
34
|
+
autoUpdate: config.auto_update || config.autoUpdate,
|
|
33
35
|
}
|
|
34
36
|
} catch (error) {
|
|
35
37
|
// Config doesn't exist, create default
|
package/src/handlers/keyboard.ts
CHANGED
package/src/types/index.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// Core types for the application
|
|
2
|
-
|
|
3
1
|
export enum AppMode {
|
|
4
2
|
Normal,
|
|
5
3
|
Search,
|
|
@@ -53,6 +51,7 @@ export interface Config {
|
|
|
53
51
|
editor: string
|
|
54
52
|
editorCmd: string
|
|
55
53
|
keybindMode?: KeybindMode
|
|
54
|
+
autoUpdate?: boolean
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
export interface WindowInfo {
|
|
@@ -78,3 +77,11 @@ export interface FuzzyMatch {
|
|
|
78
77
|
score: number
|
|
79
78
|
indices: number[]
|
|
80
79
|
}
|
|
80
|
+
|
|
81
|
+
export type InstallMethod = 'npm' | 'bun' | 'brew' | 'unknown'
|
|
82
|
+
|
|
83
|
+
export interface UpdateCompletedEvent {
|
|
84
|
+
version: string
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type UpdateEventListener = (event: UpdateCompletedEvent) => void
|
package/src/ui/Toast.tsx
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { colors } from '@/styles/theme'
|
|
2
|
+
|
|
3
|
+
interface ToastProps {
|
|
4
|
+
message: string
|
|
5
|
+
visible: boolean
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default function Toast({ message, visible }: ToastProps) {
|
|
9
|
+
if (!visible) return null
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<box
|
|
13
|
+
style={{
|
|
14
|
+
position: 'absolute',
|
|
15
|
+
top: 1,
|
|
16
|
+
right: 1,
|
|
17
|
+
border: true,
|
|
18
|
+
borderColor: colors.primary,
|
|
19
|
+
padding: 0.3,
|
|
20
|
+
paddingLeft: 0.5,
|
|
21
|
+
paddingRight: 0.5,
|
|
22
|
+
height: 2,
|
|
23
|
+
}}
|
|
24
|
+
>
|
|
25
|
+
<box>
|
|
26
|
+
{/* <text style={{ fg: colors.key }}> </text> */}
|
|
27
|
+
<text style={{ fg: colors.key }}> </text>
|
|
28
|
+
<text style={{ fg: colors.active, marginLeft: 1 }}> {message}</text>
|
|
29
|
+
</box>
|
|
30
|
+
</box>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { UpdateEventListener, UpdateCompletedEvent } from '../types'
|
|
2
|
+
|
|
3
|
+
class UpdateEvents {
|
|
4
|
+
private listeners: UpdateEventListener[] = []
|
|
5
|
+
|
|
6
|
+
on(listener: UpdateEventListener) {
|
|
7
|
+
this.listeners.push(listener)
|
|
8
|
+
|
|
9
|
+
return () => {
|
|
10
|
+
const index = this.listeners.indexOf(listener)
|
|
11
|
+
if (index > -1) {
|
|
12
|
+
this.listeners.splice(index, 1)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
emit(event: UpdateCompletedEvent) {
|
|
18
|
+
this.listeners.forEach(listener => {
|
|
19
|
+
try {
|
|
20
|
+
listener(event)
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.error('Update event listener error:', error)
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const updateEvents = new UpdateEvents()
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Config } from '../types'
|
|
2
|
+
import { CURRENT_VERSION, getLatestVersion, isNewerVersion } from './version'
|
|
3
|
+
import { detectInstallMethod, performUpgrade } from './installation'
|
|
4
|
+
import { updateEvents } from './events'
|
|
5
|
+
|
|
6
|
+
function truthy(key: string): boolean {
|
|
7
|
+
const value = process.env[key]?.toLowerCase()
|
|
8
|
+
return value === 'true' || value === '1'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function checkAndUpdate(config: Config): Promise<void> {
|
|
12
|
+
if (!(config.autoUpdate && !truthy('MUX_SESH_DISABLE_AUTOUPDATE'))) {
|
|
13
|
+
return
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const latest = await getLatestVersion()
|
|
17
|
+
if (!latest) {
|
|
18
|
+
return
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (!isNewerVersion(CURRENT_VERSION, latest)) {
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const method = await detectInstallMethod()
|
|
26
|
+
const success = await performUpgrade(method, latest)
|
|
27
|
+
if (success) {
|
|
28
|
+
updateEvents.emit({ version: latest })
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { updateEvents } from './events'
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { spawn } from 'bun'
|
|
2
|
+
import type { InstallMethod } from '../types'
|
|
3
|
+
|
|
4
|
+
export async function detectInstallMethod(): Promise<InstallMethod> {
|
|
5
|
+
const execPath = process.execPath.toLowerCase()
|
|
6
|
+
|
|
7
|
+
const checks = [
|
|
8
|
+
{
|
|
9
|
+
name: 'npm' as const,
|
|
10
|
+
command: () => spawn(['npm', 'list', '-g', '--depth=0']),
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
name: 'bun' as const,
|
|
14
|
+
command: () => spawn(['bun', 'pm', 'ls', '-g']),
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'brew' as const,
|
|
18
|
+
command: () => spawn(['brew', 'list', '--formula']),
|
|
19
|
+
},
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
checks.sort((a, b) => {
|
|
23
|
+
const aMatch = execPath.includes(a.name)
|
|
24
|
+
const bMatch = execPath.includes(b.name)
|
|
25
|
+
if (aMatch && !bMatch) return -1
|
|
26
|
+
if (!aMatch && bMatch) return 1
|
|
27
|
+
return 0
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
for (const check of checks) {
|
|
31
|
+
try {
|
|
32
|
+
const proc = check.command()
|
|
33
|
+
const output = await new Response(proc.stdout).text()
|
|
34
|
+
|
|
35
|
+
if (output.includes('mux-sesh')) {
|
|
36
|
+
return check.name
|
|
37
|
+
}
|
|
38
|
+
} catch (error) {
|
|
39
|
+
continue
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return 'unknown'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function performUpgrade(
|
|
46
|
+
method: InstallMethod,
|
|
47
|
+
targetVersion: string
|
|
48
|
+
): Promise<boolean> {
|
|
49
|
+
if (method === 'unknown') {
|
|
50
|
+
return false
|
|
51
|
+
}
|
|
52
|
+
let command: string[]
|
|
53
|
+
switch (method) {
|
|
54
|
+
case 'npm':
|
|
55
|
+
command = ['npm', 'install', '-g', `mux-sesh@${targetVersion}`]
|
|
56
|
+
break
|
|
57
|
+
case 'bun':
|
|
58
|
+
command = ['bun', 'install', '-g', `mux-sesh@${targetVersion}`]
|
|
59
|
+
break
|
|
60
|
+
case 'brew':
|
|
61
|
+
command = ['brew', 'upgrade', 'mux-sesh']
|
|
62
|
+
break
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const proc = spawn(command)
|
|
66
|
+
await proc.exited
|
|
67
|
+
return proc.exitCode === 0
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error('Upgrade Failed:', error)
|
|
70
|
+
return false
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import packageJson from '../../package.json'
|
|
2
|
+
|
|
3
|
+
export const CURRENT_VERSION = packageJson.version
|
|
4
|
+
|
|
5
|
+
export async function getLatestVersion(): Promise<string | null> {
|
|
6
|
+
try {
|
|
7
|
+
const response = await fetch('https://registry.npmjs.org/mux-sesh/latest')
|
|
8
|
+
|
|
9
|
+
if (!response.ok) {
|
|
10
|
+
throw new Error(`HTTP error! status: ${response.status}`)
|
|
11
|
+
}
|
|
12
|
+
const data = await response.json()
|
|
13
|
+
|
|
14
|
+
return data.version
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error('Failed to check for updates:', error)
|
|
17
|
+
return null
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function isNewerVersion(current: string, latest: string): boolean {
|
|
22
|
+
const currentParts = current.split('.').map(Number)
|
|
23
|
+
const latestParts = latest.split('.').map(Number)
|
|
24
|
+
|
|
25
|
+
for (let i = 0; i < Math.max(currentParts.length, latestParts.length); i++) {
|
|
26
|
+
const curr = currentParts[i] || 0
|
|
27
|
+
const lat = latestParts[i] || 0
|
|
28
|
+
if (lat > curr) return true
|
|
29
|
+
if (lat < curr) return false
|
|
30
|
+
}
|
|
31
|
+
return false
|
|
32
|
+
}
|