mux-sesh 1.6.0 → 1.6.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mux-sesh",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
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": {
package/src/app.tsx CHANGED
@@ -16,12 +16,14 @@ import { ThemeProvider, getPanelStyle, resolveTheme } from './styles/theme'
16
16
  import { useTerminalSize, shouldShowDetailPanel } from './util/terminal'
17
17
  import Toast from './ui/Toast'
18
18
  import { checkAndUpdate, updateEvents } from './update'
19
+ import { CURRENT_VERSION } from './update/version'
19
20
  import OpencodeStatsPanel from './ui/OpencodeStatsPanel'
20
21
  import SessionDetailsPanel from './ui/SessionDetailsPanel'
21
22
  import SessionList from './ui/SessionList'
22
23
  import OpencodeSessionGroup from './ui/OpencodeSessionGroup'
23
24
  import SearchInput from './ui/SearchInput'
24
25
  import ItemList from './ui/ItemList'
26
+ import VersionBadge from './ui/VersionBadge'
25
27
  import RenameModal from './ui/RenameModal'
26
28
  import CommandsModal, { filterCommandEntries, getCommandEntries, type CommandId } from './ui/CommandsModal'
27
29
  import SettingsModal from './ui/SettingsModal'
@@ -101,6 +103,7 @@ export function App() {
101
103
  const { columns, rows } = useTerminalSize()
102
104
  const [toastMessage, setToastMessage] = useState('')
103
105
  const [toastVisible, setToastVisible] = useState(false)
106
+ const [updatedVersion, setUpdatedVersion] = useState<string | null>(null)
104
107
  const configPath = getConfigPath()
105
108
  const resolvedTheme = resolveTheme(config?.theme, config?.themes, config?.colorScheme)
106
109
  const theme = resolvedTheme.colors
@@ -109,6 +112,7 @@ export function App() {
109
112
  const currentOptionField = modalState?.type === 'setting-options' ? modalState.field : undefined
110
113
  const settingOptions = config && currentOptionField ? getSettingOptions(config, currentOptionField) : []
111
114
  const filteredSettingOptions = filterSettingsOptions(settingOptions, settingOptionsSearchQuery)
115
+ const hasScheduledAutoUpdateRef = useRef(false)
112
116
 
113
117
  function getSessionSelectionIndex(nextItems: Item[]): number {
114
118
  const regularItems = nextItems.filter(item => !(item.isSession && item.title.startsWith('opencode-')))
@@ -186,14 +190,25 @@ export function App() {
186
190
  setItems(projects)
187
191
  setCursor(getProjectSelectionIndex(projects))
188
192
  }
189
-
190
- checkAndUpdate(cfg).catch(error => {
191
- console.error('Auto-update check failed:', error)
192
- })
193
193
  }
194
194
  init()
195
195
  }, [])
196
196
 
197
+ useEffect(() => {
198
+ if (!config || hasScheduledAutoUpdateRef.current) {
199
+ return
200
+ }
201
+
202
+ hasScheduledAutoUpdateRef.current = true
203
+
204
+ const timeout = setTimeout(() => {
205
+ checkAndUpdate(config).catch(error => {
206
+ console.error('Auto-update check failed:', error)
207
+ })
208
+ }, 1000)
209
+
210
+ return () => clearTimeout(timeout)
211
+ }, [config])
197
212
  async function refreshItems(forceViewMode?: ViewMode, nextConfig = config) {
198
213
  if (!nextConfig) return
199
214
 
@@ -677,7 +692,14 @@ export function App() {
677
692
 
678
693
  useEffect(() => {
679
694
  const unsubscribe = updateEvents.on(event => {
680
- setToastMessage(`Update ready ${event.version}`)
695
+ if (event.kind === 'updated') {
696
+ setUpdatedVersion(event.version)
697
+ setToastMessage(`Updated in background to v${event.version}. Restart mux-sesh to use it.`)
698
+ } else if (event.kind === 'available') {
699
+ setToastMessage(`Update available: v${event.version}`)
700
+ } else {
701
+ setToastMessage(`Background update to v${event.version} failed.`)
702
+ }
681
703
  setToastVisible(true)
682
704
  setTimeout(() => {
683
705
  setToastVisible(false)
@@ -1043,6 +1065,7 @@ export function App() {
1043
1065
  )}
1044
1066
 
1045
1067
  <Toast message={toastMessage} visible={toastVisible} />
1068
+ <VersionBadge currentVersion={CURRENT_VERSION} updatedVersion={updatedVersion} />
1046
1069
  </box>
1047
1070
  </ThemeProvider>
1048
1071
  )
@@ -200,8 +200,24 @@ export interface FuzzyMatch {
200
200
 
201
201
  export type InstallMethod = 'npm' | 'bun' | 'brew' | 'unknown'
202
202
 
203
- export interface UpdateCompletedEvent {
204
- version: string
205
- }
206
-
207
- export type UpdateEventListener = (event: UpdateCompletedEvent) => void
203
+ export type UpdateEvent =
204
+ | {
205
+ kind: 'updated'
206
+ currentVersion: string
207
+ version: string
208
+ installMethod: InstallMethod
209
+ }
210
+ | {
211
+ kind: 'available'
212
+ currentVersion: string
213
+ version: string
214
+ installMethod: InstallMethod
215
+ }
216
+ | {
217
+ kind: 'failed'
218
+ currentVersion: string
219
+ version: string
220
+ installMethod: InstallMethod
221
+ }
222
+
223
+ export type UpdateEventListener = (event: UpdateEvent) => void
@@ -0,0 +1,30 @@
1
+ import { useTheme } from '../styles/theme'
2
+
3
+ interface VersionBadgeProps {
4
+ currentVersion: string
5
+ updatedVersion?: string | null
6
+ }
7
+
8
+ export function formatVersionBadge(currentVersion: string, updatedVersion?: string | null): string {
9
+ if (updatedVersion && updatedVersion !== currentVersion) {
10
+ return `v${currentVersion} -> v${updatedVersion}`
11
+ }
12
+
13
+ return `v${currentVersion}`
14
+ }
15
+
16
+ export default function VersionBadge({ currentVersion, updatedVersion }: VersionBadgeProps) {
17
+ const theme = useTheme()
18
+
19
+ return (
20
+ <box
21
+ style={{
22
+ position: 'absolute',
23
+ bottom: 0,
24
+ right: 1,
25
+ }}
26
+ >
27
+ <text style={{ fg: theme.textSubtle }}>{formatVersionBadge(currentVersion, updatedVersion)}</text>
28
+ </box>
29
+ )
30
+ }
@@ -1,4 +1,4 @@
1
- import type { UpdateEventListener, UpdateCompletedEvent } from '../types'
1
+ import type { UpdateEventListener, UpdateEvent } from '../types'
2
2
 
3
3
  class UpdateEvents {
4
4
  private listeners: UpdateEventListener[] = []
@@ -14,7 +14,7 @@ class UpdateEvents {
14
14
  }
15
15
  }
16
16
 
17
- emit(event: UpdateCompletedEvent) {
17
+ emit(event: UpdateEvent) {
18
18
  this.listeners.forEach(listener => {
19
19
  try {
20
20
  listener(event)
@@ -1,32 +1,79 @@
1
1
  import type { Config } from '../types'
2
2
  import { CURRENT_VERSION, getLatestVersion, isNewerVersion } from './version'
3
- import { detectInstallMethod, performUpgrade } from './installation'
3
+ import { canAutoUpdate, detectInstallMethod, performUpgrade } from './installation'
4
4
  import { updateEvents } from './events'
5
5
 
6
+ interface UpdateDependencies {
7
+ getLatestVersion: typeof getLatestVersion
8
+ isNewerVersion: typeof isNewerVersion
9
+ detectInstallMethod: typeof detectInstallMethod
10
+ canAutoUpdate: typeof canAutoUpdate
11
+ performUpgrade: typeof performUpgrade
12
+ emit: typeof updateEvents.emit
13
+ }
14
+
15
+ const defaultDependencies: UpdateDependencies = {
16
+ getLatestVersion,
17
+ isNewerVersion,
18
+ detectInstallMethod,
19
+ canAutoUpdate,
20
+ performUpgrade,
21
+ emit: updateEvents.emit.bind(updateEvents),
22
+ }
23
+
6
24
  function truthy(key: string): boolean {
7
25
  const value = process.env[key]?.toLowerCase()
8
26
  return value === 'true' || value === '1'
9
27
  }
10
28
 
11
- export async function checkAndUpdate(config: Config): Promise<void> {
29
+ export async function checkAndUpdate(config: Config, dependencies: Partial<UpdateDependencies> = {}): Promise<void> {
30
+ const resolvedDependencies = {
31
+ ...defaultDependencies,
32
+ ...dependencies,
33
+ }
34
+
12
35
  if (!(config.autoUpdate && !truthy('MUX_SESH_DISABLE_AUTOUPDATE'))) {
13
36
  return
14
37
  }
15
38
 
16
- const latest = await getLatestVersion()
39
+ const latest = await resolvedDependencies.getLatestVersion()
17
40
  if (!latest) {
18
41
  return
19
42
  }
20
43
 
21
- if (!isNewerVersion(CURRENT_VERSION, latest)) {
44
+ if (!resolvedDependencies.isNewerVersion(CURRENT_VERSION, latest)) {
22
45
  return
23
46
  }
24
47
 
25
- const method = await detectInstallMethod()
26
- const success = await performUpgrade(method, latest)
48
+ const method = await resolvedDependencies.detectInstallMethod()
49
+
50
+ if (!resolvedDependencies.canAutoUpdate(method)) {
51
+ resolvedDependencies.emit({
52
+ kind: 'available',
53
+ currentVersion: CURRENT_VERSION,
54
+ version: latest,
55
+ installMethod: method,
56
+ })
57
+ return
58
+ }
59
+
60
+ const success = await resolvedDependencies.performUpgrade(method, latest)
27
61
  if (success) {
28
- updateEvents.emit({ version: latest })
62
+ resolvedDependencies.emit({
63
+ kind: 'updated',
64
+ currentVersion: CURRENT_VERSION,
65
+ version: latest,
66
+ installMethod: method,
67
+ })
68
+ return
29
69
  }
70
+
71
+ resolvedDependencies.emit({
72
+ kind: 'failed',
73
+ currentVersion: CURRENT_VERSION,
74
+ version: latest,
75
+ installMethod: method,
76
+ })
30
77
  }
31
78
 
32
79
  export { updateEvents } from './events'
@@ -1,18 +1,20 @@
1
1
  import type { InstallMethod } from '../types'
2
2
 
3
+ const PACKAGE_NAME = 'mux-sesh'
4
+
3
5
  export async function detectInstallMethod(): Promise<InstallMethod> {
4
6
  const checks = [
5
7
  {
6
8
  name: 'npm' as const,
7
- command: () => Bun.spawn(['npm', 'list', '-g', '--depth=0']),
9
+ command: () => Bun.spawn(['npm', 'list', '-g', '--depth=0'], { stderr: 'ignore' }),
8
10
  },
9
11
  {
10
12
  name: 'bun' as const,
11
- command: () => Bun.spawn(['bun', 'pm', 'ls', '-g']),
13
+ command: () => Bun.spawn(['bun', 'pm', 'ls', '-g'], { stderr: 'ignore' }),
12
14
  },
13
15
  {
14
16
  name: 'brew' as const,
15
- command: () => Bun.spawn(['brew', 'list', '--formula']),
17
+ command: () => Bun.spawn(['brew', 'list', '--formula'], { stderr: 'ignore' }),
16
18
  },
17
19
  ]
18
20
 
@@ -21,7 +23,7 @@ export async function detectInstallMethod(): Promise<InstallMethod> {
21
23
  const proc = check.command()
22
24
  const output = await new Response(proc.stdout).text()
23
25
 
24
- if (output.includes('mux-sesh')) {
26
+ if (output.includes(PACKAGE_NAME)) {
25
27
  return check.name
26
28
  }
27
29
  } catch (error) {
@@ -31,6 +33,10 @@ export async function detectInstallMethod(): Promise<InstallMethod> {
31
33
  return 'unknown'
32
34
  }
33
35
 
36
+ export function canAutoUpdate(method: InstallMethod): boolean {
37
+ return method === 'npm' || method === 'bun'
38
+ }
39
+
34
40
  export async function performUpgrade(
35
41
  method: InstallMethod,
36
42
  targetVersion: string
@@ -41,17 +47,17 @@ export async function performUpgrade(
41
47
  let command: string[]
42
48
  switch (method) {
43
49
  case 'npm':
44
- command = ['npm', 'install', '-g', `mux-sesh@${targetVersion}`]
50
+ command = ['npm', 'install', '-g', `${PACKAGE_NAME}@${targetVersion}`]
45
51
  break
46
52
  case 'bun':
47
- command = ['bun', 'install', '-g', `mux-sesh@${targetVersion}`]
53
+ command = ['bun', 'install', '-g', `${PACKAGE_NAME}@${targetVersion}`]
48
54
  break
49
55
  case 'brew':
50
- command = ['brew', 'upgrade', 'mux-sesh']
56
+ command = ['brew', 'upgrade', PACKAGE_NAME]
51
57
  break
52
58
  }
53
59
  try {
54
- const proc = Bun.spawn(command)
60
+ const proc = Bun.spawn(command, { stdout: 'ignore', stderr: 'ignore' })
55
61
  await proc.exited
56
62
  return proc.exitCode === 0
57
63
  } catch (error) {