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.
Files changed (124) hide show
  1. package/README.md +133 -86
  2. package/bin/mux-sesh +45 -17
  3. package/bin/platform.sh +139 -0
  4. package/bin/postinstall +22 -0
  5. package/package.json +27 -38
  6. package/src/agents/index.ts +0 -1
  7. package/src/agents/session-name.ts +0 -24
  8. package/src/app/commands.ts +0 -138
  9. package/src/app/controller.ts +0 -437
  10. package/src/app/controls.ts +0 -123
  11. package/src/app/core-state.ts +0 -75
  12. package/src/app/data.ts +0 -130
  13. package/src/app/derived.ts +0 -77
  14. package/src/app/effects.ts +0 -650
  15. package/src/app/handlers.ts +0 -406
  16. package/src/app/keyboard.ts +0 -165
  17. package/src/app/modal-keyboard.ts +0 -137
  18. package/src/app/modal-state.ts +0 -53
  19. package/src/app/modals-layer.tsx +0 -159
  20. package/src/app/modals.ts +0 -108
  21. package/src/app/notifications.ts +0 -21
  22. package/src/app/opencode.ts +0 -49
  23. package/src/app/operations.ts +0 -31
  24. package/src/app/runtime.ts +0 -79
  25. package/src/app/screen.tsx +0 -240
  26. package/src/app/state.ts +0 -178
  27. package/src/app/textarea.ts +0 -16
  28. package/src/app/view.ts +0 -101
  29. package/src/app.tsx +0 -50
  30. package/src/config/index.ts +0 -475
  31. package/src/config/listed-sessions.ts +0 -33
  32. package/src/config/paths.ts +0 -13
  33. package/src/config/session-rules.ts +0 -100
  34. package/src/config/store.ts +0 -33
  35. package/src/files/target.ts +0 -96
  36. package/src/handlers/action-helpers.ts +0 -83
  37. package/src/handlers/actions.ts +0 -216
  38. package/src/handlers/keyboard/agents.ts +0 -134
  39. package/src/handlers/keyboard/index.ts +0 -5
  40. package/src/handlers/keyboard/new-session.ts +0 -58
  41. package/src/handlers/keyboard/normal.ts +0 -220
  42. package/src/handlers/keyboard/search.ts +0 -118
  43. package/src/handlers/keyboard/shared.ts +0 -117
  44. package/src/herdr/backend.ts +0 -357
  45. package/src/herdr/protocol.ts +0 -268
  46. package/src/index.tsx +0 -23
  47. package/src/items/order.ts +0 -95
  48. package/src/multiplexer/backend.ts +0 -43
  49. package/src/multiplexer/command.ts +0 -48
  50. package/src/multiplexer/index.ts +0 -21
  51. package/src/multiplexer/items.ts +0 -66
  52. package/src/multiplexer/resolve.ts +0 -109
  53. package/src/multiplexer/tmux-backend.ts +0 -87
  54. package/src/multiplexer/types.ts +0 -93
  55. package/src/opencode/constants.ts +0 -7
  56. package/src/opencode/index.ts +0 -20
  57. package/src/opencode/parser.ts +0 -45
  58. package/src/opencode/session-name.ts +0 -13
  59. package/src/opencode/session.ts +0 -146
  60. package/src/opencode/sqlite.ts +0 -447
  61. package/src/opencode/stats.ts +0 -26
  62. package/src/opencode/tokens.ts +0 -116
  63. package/src/opencode/types.ts +0 -33
  64. package/src/preview/project.ts +0 -362
  65. package/src/projects/session-links.ts +0 -52
  66. package/src/search/fff.ts +0 -224
  67. package/src/search/index.ts +0 -198
  68. package/src/settings.ts +0 -465
  69. package/src/styles/omarchy.ts +0 -295
  70. package/src/styles/opencode-themes-a.ts +0 -1442
  71. package/src/styles/opencode-themes-b.ts +0 -1212
  72. package/src/styles/opencode-tui-colors.ts +0 -1784
  73. package/src/styles/terminal-palette.ts +0 -156
  74. package/src/styles/theme-follow.ts +0 -94
  75. package/src/styles/theme.tsx +0 -311
  76. package/src/tmux/actions.ts +0 -145
  77. package/src/tmux/details.ts +0 -104
  78. package/src/tmux/helpers.ts +0 -35
  79. package/src/tmux/index.ts +0 -10
  80. package/src/tmux/list.ts +0 -31
  81. package/src/tmux/project-discovery.ts +0 -116
  82. package/src/tmux/project-loader.ts +0 -92
  83. package/src/tmux/project-zoxide.ts +0 -128
  84. package/src/tmux/projects.ts +0 -38
  85. package/src/tmux/workflows.ts +0 -26
  86. package/src/types/index.ts +0 -221
  87. package/src/ui/AgentSessionGroup.tsx +0 -93
  88. package/src/ui/CommandsModal.tsx +0 -246
  89. package/src/ui/ErrorScreen.tsx +0 -102
  90. package/src/ui/HighlightedText.tsx +0 -60
  91. package/src/ui/ItemList.tsx +0 -119
  92. package/src/ui/Modal.tsx +0 -48
  93. package/src/ui/OpencodeStatsPanel.tsx +0 -233
  94. package/src/ui/RenameModal.tsx +0 -42
  95. package/src/ui/SearchInput.tsx +0 -43
  96. package/src/ui/SessionDetailsPanel.tsx +0 -273
  97. package/src/ui/SessionList.tsx +0 -119
  98. package/src/ui/SettingEditorModal.tsx +0 -55
  99. package/src/ui/SettingOptionsModal.tsx +0 -95
  100. package/src/ui/SettingsModal.tsx +0 -102
  101. package/src/ui/Toast.tsx +0 -34
  102. package/src/ui/VersionBadge.tsx +0 -45
  103. package/src/ui/item-icon.ts +0 -110
  104. package/src/ui/list-window.ts +0 -35
  105. package/src/ui/session-meta.ts +0 -10
  106. package/src/ui/text-columns.ts +0 -17
  107. package/src/ui/use-textarea-focus.ts +0 -29
  108. package/src/update/events.ts +0 -28
  109. package/src/update/index.ts +0 -91
  110. package/src/update/installation.ts +0 -161
  111. package/src/update/version.ts +0 -33
  112. package/src/util/ansi.ts +0 -3
  113. package/src/util/browser.ts +0 -37
  114. package/src/util/clipboard.ts +0 -22
  115. package/src/util/errors.ts +0 -170
  116. package/src/util/github.ts +0 -100
  117. package/src/util/glob.ts +0 -51
  118. package/src/util/path-display.ts +0 -98
  119. package/src/util/perf.ts +0 -23
  120. package/src/util/shell.ts +0 -3
  121. package/src/util/shutdown.ts +0 -111
  122. package/src/util/terminal.ts +0 -28
  123. package/src/util/time.ts +0 -48
  124. package/tsconfig.json +0 -25
@@ -1,170 +0,0 @@
1
- import { arch, homedir, platform, release } from 'os'
2
- import { CURRENT_VERSION } from '../update/version'
3
-
4
- const ISSUE_URL = 'https://github.com/quiet-ghost/mux-sesh/issues/new'
5
- export const MAX_ISSUE_URL_LENGTH = 6000
6
- const TRUNCATION_MARKER = '\n\n... (diagnostics truncated to fit the GitHub issue URL)'
7
-
8
- export interface FailureDetails {
9
- message: string
10
- stack?: string
11
- }
12
-
13
- export interface DiagnosticContext {
14
- muxSeshVersion?: string
15
- bunVersion?: string
16
- os?: string
17
- architecture?: string
18
- terminal?: string
19
- backend?: string
20
- }
21
-
22
- function serializeUnknown(value: unknown): string {
23
- if (typeof value === 'string') return value
24
- if (value === undefined) return 'undefined'
25
- if (value === null) return 'null'
26
-
27
- if (typeof value === 'object') {
28
- try {
29
- const json = JSON.stringify(value, null, 2)
30
- if (json && json !== '{}') return json
31
-
32
- const text = String(value)
33
- if (text !== '[object Object]') return text
34
- const names = Object.getOwnPropertyNames(value)
35
- return names.length > 0 ? `Object { ${names.join(', ')} }` : 'Object (no message)'
36
- } catch {
37
- return 'Unexpected failure (unserializable object)'
38
- }
39
- }
40
-
41
- return String(value)
42
- }
43
-
44
- export function describeFailure(error: unknown): FailureDetails {
45
- if (error instanceof Error) {
46
- return {
47
- message: error.message || error.name || 'Unknown error',
48
- stack: error.stack,
49
- }
50
- }
51
-
52
- if (typeof error === 'object' && error !== null) {
53
- try {
54
- const message = Reflect.get(error, 'message')
55
- const stack = Reflect.get(error, 'stack')
56
- return {
57
- message: typeof message === 'string' && message ? message : serializeUnknown(error),
58
- stack: typeof stack === 'string' && stack ? stack : undefined,
59
- }
60
- } catch {
61
- return { message: serializeUnknown(error) }
62
- }
63
- }
64
-
65
- return { message: serializeUnknown(error) }
66
- }
67
-
68
- function replaceLiteral(value: string, literal: string, replacement: string): string {
69
- return literal ? value.split(literal).join(replacement) : value
70
- }
71
-
72
- export function redactDiagnosticText(value: string): string {
73
- let result = replaceLiteral(value, process.cwd(), '<cwd>')
74
- result = replaceLiteral(result, process.env.HOME ?? '', '~')
75
- result = replaceLiteral(result, homedir(), '~')
76
- return result
77
- }
78
-
79
- function bounded(value: string | undefined, fallback: string): string {
80
- const normalized = value?.trim() || fallback
81
- return redactDiagnosticText(normalized).slice(0, 300)
82
- }
83
-
84
- function detectBackend(): string {
85
- if (process.env.HERDR_ENV === '1') return 'herdr'
86
- if (process.env.TMUX) return 'tmux'
87
- return 'unknown'
88
- }
89
-
90
- function detectTerminal(): string {
91
- if (process.env.TERM_PROGRAM) {
92
- return [process.env.TERM_PROGRAM, process.env.TERM_PROGRAM_VERSION].filter(Boolean).join(' ')
93
- }
94
- if (process.env.GHOSTTY_RESOURCES_DIR) return 'ghostty'
95
- return process.env.TERM || 'unknown'
96
- }
97
-
98
- export function getDiagnosticContext(
99
- overrides: DiagnosticContext = {}
100
- ): Required<DiagnosticContext> {
101
- return {
102
- muxSeshVersion: bounded(overrides.muxSeshVersion, CURRENT_VERSION),
103
- bunVersion: bounded(overrides.bunVersion, Bun.version),
104
- os: bounded(overrides.os, `${platform()} ${release()}`),
105
- architecture: bounded(overrides.architecture, arch()),
106
- terminal: bounded(overrides.terminal, detectTerminal()),
107
- backend: bounded(overrides.backend, detectBackend()),
108
- }
109
- }
110
-
111
- export function formatDiagnostics(
112
- error: unknown,
113
- contextOverrides: DiagnosticContext = {}
114
- ): string {
115
- const failure = describeFailure(error)
116
- const context = getDiagnosticContext(contextOverrides)
117
- const lines = ['mux-sesh crashed', '', 'Message:', redactDiagnosticText(failure.message)]
118
-
119
- if (failure.stack) {
120
- lines.push('', 'Stack:', redactDiagnosticText(failure.stack))
121
- }
122
-
123
- lines.push(
124
- '',
125
- 'Environment:',
126
- `mux-sesh: ${context.muxSeshVersion}`,
127
- `Bun: ${context.bunVersion}`,
128
- `OS: ${context.os}`,
129
- `Architecture: ${context.architecture}`,
130
- `Terminal: ${context.terminal}`,
131
- `Backend: ${context.backend}`
132
- )
133
-
134
- return lines.join('\n')
135
- }
136
-
137
- export function buildIssueUrl(error: unknown, diagnostics = formatDiagnostics(error)): URL {
138
- const failure = describeFailure(error)
139
- const safeDiagnostics = redactDiagnosticText(diagnostics)
140
- const title = redactDiagnosticText(failure.message).replaceAll('\n', ' ').slice(0, 160)
141
- const url = new URL(ISSUE_URL)
142
- url.searchParams.set('title', `Crash: ${title}`)
143
-
144
- const prefix = [
145
- '## What happened?',
146
- '',
147
- 'mux-sesh generated this report after an unexpected crash. Please add any reproduction steps above the diagnostics.',
148
- '',
149
- '## Diagnostics',
150
- '',
151
- '```text',
152
- ].join('\n')
153
- const suffix = '\n```'
154
- const setBody = (value: string) => url.searchParams.set('body', `${prefix}\n${value}${suffix}`)
155
-
156
- setBody(safeDiagnostics)
157
- if (url.toString().length <= MAX_ISSUE_URL_LENGTH) return url
158
-
159
- let low = 0
160
- let high = safeDiagnostics.length
161
- while (low < high) {
162
- const middle = Math.ceil((low + high) / 2)
163
- setBody(safeDiagnostics.slice(0, middle) + TRUNCATION_MARKER)
164
- if (url.toString().length <= MAX_ISSUE_URL_LENGTH) low = middle
165
- else high = middle - 1
166
- }
167
-
168
- setBody(safeDiagnostics.slice(0, low) + TRUNCATION_MARKER)
169
- return url
170
- }
@@ -1,100 +0,0 @@
1
- import { spawn } from 'bun'
2
- import { join } from 'path'
3
- import { mkdir, stat } from 'fs/promises'
4
- import type { Config } from '../types'
5
-
6
- interface GitHubRepoRef {
7
- owner: string
8
- repo: string
9
- }
10
-
11
- function isSafeGitHubPathSegment(value: string): boolean {
12
- return value.length > 0 && value !== '.' && value !== '..' && /^[A-Za-z0-9._-]+$/.test(value)
13
- }
14
-
15
- function stripGitSuffix(value: string): string {
16
- return value.endsWith('.git') ? value.slice(0, -4) : value
17
- }
18
-
19
- function parseGitHubRepo(input: string): GitHubRepoRef | null {
20
- const trimmed = input.trim()
21
-
22
- if (trimmed.startsWith('git@github.com:')) {
23
- const path = stripGitSuffix(trimmed.slice('git@github.com:'.length))
24
- const parts = path.split('/').filter(Boolean)
25
- if (parts.length !== 2 || !parts.every(isSafeGitHubPathSegment)) {
26
- return null
27
- }
28
-
29
- return { owner: parts[0], repo: parts[1] }
30
- }
31
-
32
- try {
33
- const url = new URL(trimmed)
34
- if (url.protocol !== 'https:' || url.hostname !== 'github.com') {
35
- return null
36
- }
37
-
38
- const parts = url.pathname.split('/').filter(Boolean)
39
- if (parts.length !== 2) {
40
- return null
41
- }
42
-
43
- const owner = parts[0]
44
- const repo = stripGitSuffix(parts[1])
45
- if (!isSafeGitHubPathSegment(owner) || !isSafeGitHubPathSegment(repo)) {
46
- return null
47
- }
48
-
49
- return { owner, repo }
50
- } catch {
51
- return null
52
- }
53
- }
54
-
55
- function isMissingPathError(error: unknown): boolean {
56
- return typeof error === 'object' && error !== null && 'code' in error && error.code === 'ENOENT'
57
- }
58
-
59
- export function isGitHubURL(input: string): boolean {
60
- return parseGitHubRepo(input) !== null
61
- }
62
-
63
- export function extractRepoName(url: string): string {
64
- return parseGitHubRepo(url)?.repo ?? ''
65
- }
66
-
67
- export async function cloneGitHubRepo(url: string, config: Config): Promise<string> {
68
- const repoName = extractRepoName(url)
69
- if (!repoName) {
70
- throw new Error('Could not extract repository name from URL')
71
- }
72
-
73
- const reposDir = config.reposPath
74
- await mkdir(reposDir, { recursive: true })
75
-
76
- const targetDir = join(reposDir, repoName)
77
-
78
- try {
79
- const targetStat = await stat(targetDir)
80
- if (!targetStat.isDirectory()) {
81
- throw new Error(`Clone target exists but is not a directory: ${targetDir}`)
82
- }
83
-
84
- return targetDir
85
- } catch (error) {
86
- if (!isMissingPathError(error)) {
87
- throw error
88
- }
89
- }
90
-
91
- const proc = spawn(['git', 'clone', url, targetDir], { stderr: 'pipe' })
92
- const stderr = proc.stderr instanceof ReadableStream ? await new Response(proc.stderr).text() : ''
93
- await proc.exited
94
-
95
- if (proc.exitCode !== 0) {
96
- throw new Error(stderr.trim() || 'Failed to clone repository')
97
- }
98
-
99
- return targetDir
100
- }
package/src/util/glob.ts DELETED
@@ -1,51 +0,0 @@
1
- export interface MatchGlobOptions {
2
- pathSeparatorAware?: boolean
3
- }
4
-
5
- function escapeRegexCharacter(value: string): string {
6
- return /[|\\{}()[\]^$+?.]/.test(value) ? `\\${value}` : value
7
- }
8
-
9
- export function normalizePathForMatching(value: string): string {
10
- return value.replaceAll('\\', '/').replace(/\/+/g, '/').replace(/\/$/, '') || '/'
11
- }
12
-
13
- export function globToRegExp(pattern: string, options: MatchGlobOptions = {}): RegExp {
14
- const { pathSeparatorAware = false } = options
15
- let regex = '^'
16
-
17
- for (let index = 0; index < pattern.length; index += 1) {
18
- const char = pattern[index]
19
- const next = pattern[index + 1]
20
-
21
- if (char === '*' && next === '*') {
22
- regex += '.*'
23
- index += 1
24
- continue
25
- }
26
-
27
- if (char === '*') {
28
- regex += pathSeparatorAware ? '[^/]*' : '.*'
29
- continue
30
- }
31
-
32
- if (char === '?') {
33
- regex += pathSeparatorAware ? '[^/]' : '.'
34
- continue
35
- }
36
-
37
- regex += escapeRegexCharacter(char)
38
- }
39
-
40
- regex += '$'
41
-
42
- return new RegExp(regex)
43
- }
44
-
45
- export function matchesGlob(
46
- value: string,
47
- pattern: string,
48
- options: MatchGlobOptions = {}
49
- ): boolean {
50
- return globToRegExp(pattern, options).test(value)
51
- }
@@ -1,98 +0,0 @@
1
- import { basename, dirname } from 'path'
2
-
3
- export function toHomeRelativePath(path: string): string {
4
- const homeDir = process.env.HOME || ''
5
-
6
- if (!path) {
7
- return ''
8
- }
9
-
10
- if (homeDir && path === homeDir) {
11
- return '~'
12
- }
13
-
14
- if (homeDir && path.startsWith(`${homeDir}/`)) {
15
- return `~${path.slice(homeDir.length)}`
16
- }
17
-
18
- return path
19
- }
20
-
21
- function getWorktreeProjectName(path: string): string | null {
22
- if (!path) {
23
- return null
24
- }
25
-
26
- const parentPath = dirname(path)
27
-
28
- if (basename(parentPath) !== '.worktrees') {
29
- return null
30
- }
31
-
32
- const projectName = basename(dirname(parentPath))
33
- return projectName && projectName !== '.' && projectName !== '/' ? projectName : null
34
- }
35
-
36
- export function getPathGroupLabel(path: string): string {
37
- if (!path) {
38
- return ''
39
- }
40
-
41
- const parentPath = dirname(path)
42
- if ((process.env.HOME || '') && parentPath === (process.env.HOME || '')) {
43
- return '~'
44
- }
45
-
46
- const worktreeProject = getWorktreeProjectName(path)
47
- if (worktreeProject) {
48
- return worktreeProject
49
- }
50
-
51
- const parentName = basename(parentPath)
52
-
53
- if (!parentName || parentName === '.' || parentName === '/') {
54
- return ''
55
- }
56
-
57
- return parentName
58
- }
59
-
60
- export function getPathContextLabel(path: string): string {
61
- if (!path) {
62
- return ''
63
- }
64
-
65
- const parentPath = dirname(path)
66
-
67
- if (!parentPath || parentPath === '.' || parentPath === '/') {
68
- return parentPath === '/' ? '/' : ''
69
- }
70
-
71
- const worktreeProject = getWorktreeProjectName(path)
72
- if (worktreeProject) {
73
- return `${toHomeRelativePath(dirname(parentPath))} [worktree]`
74
- }
75
-
76
- return toHomeRelativePath(parentPath)
77
- }
78
-
79
- export function getLiveSessionGroupLabel(path: string): string {
80
- const worktreeProject = getWorktreeProjectName(path)
81
-
82
- if (worktreeProject) {
83
- return `${worktreeProject} [worktree]`
84
- }
85
-
86
- return getPathGroupLabel(path)
87
- }
88
-
89
- export function getLiveSessionSortKey(path: string, title: string): string {
90
- const worktreeProject = getWorktreeProjectName(path)
91
-
92
- if (worktreeProject) {
93
- return worktreeProject
94
- }
95
-
96
- const baseName = basename(path)
97
- return baseName && baseName !== '.' && baseName !== '/' ? baseName : title
98
- }
package/src/util/perf.ts DELETED
@@ -1,23 +0,0 @@
1
- const PERF_ENABLED = process.env.MUX_SESH_DEBUG_PERF === '1'
2
-
3
- export async function measure<T>(label: string, fn: () => Promise<T>): Promise<T> {
4
- if (!PERF_ENABLED) {
5
- return fn()
6
- }
7
-
8
- const start = performance.now()
9
- try {
10
- return await fn()
11
- } finally {
12
- const duration = performance.now() - start
13
- console.error(`[perf] ${label}: ${duration.toFixed(1)}ms`)
14
- }
15
- }
16
-
17
- export function mark(label: string): void {
18
- if (!PERF_ENABLED) {
19
- return
20
- }
21
-
22
- console.error(`[perf] ${label}`)
23
- }
package/src/util/shell.ts DELETED
@@ -1,3 +0,0 @@
1
- export function quoteShellArg(value: string): string {
2
- return `'${value.replaceAll("'", "'\\''")}'`
3
- }
@@ -1,111 +0,0 @@
1
- import type { CliRenderer } from '@opentui/core'
2
- import { buildIssueUrl, formatDiagnostics } from './errors'
3
-
4
- const TERMINAL_RESET_SEQUENCE = [
5
- '\u001b[?1000l',
6
- '\u001b[?1002l',
7
- '\u001b[?1003l',
8
- '\u001b[?1005l',
9
- '\u001b[?1006l',
10
- '\u001b[?1015l',
11
- '\u001b[?1049l',
12
- '\u001b[?2004l',
13
- '\u001b[<u',
14
- '\u001b[?25h',
15
- ].join('')
16
-
17
- const state: {
18
- renderer?: CliRenderer
19
- exiting?: Promise<never>
20
- exitListenerInstalled?: boolean
21
- fatalListenersInstalled?: boolean
22
- fatalStarted?: boolean
23
- } = {}
24
-
25
- function resetTerminalModes(): void {
26
- if (process.stdout.isTTY) {
27
- process.stdout.write(TERMINAL_RESET_SEQUENCE)
28
- }
29
-
30
- if (process.stdin.isTTY && typeof process.stdin.setRawMode === 'function') {
31
- process.stdin.setRawMode(false)
32
- }
33
-
34
- process.stdin.pause()
35
- }
36
-
37
- function destroyRenderer(): void {
38
- const renderer = state.renderer
39
- if (!renderer || renderer.isDestroyed) return
40
-
41
- try {
42
- renderer.useMouse = false
43
- renderer.disableKittyKeyboard()
44
- renderer.setTerminalTitle('')
45
- renderer.destroy()
46
- } catch {
47
- // Terminal mode reset below is the final fallback if renderer teardown fails.
48
- }
49
- }
50
-
51
- function restoreTerminal(): void {
52
- destroyRenderer()
53
- resetTerminalModes()
54
- }
55
-
56
- export function initializeFatalErrorHandling(): void {
57
- if (state.fatalListenersInstalled) return
58
-
59
- process.on('uncaughtException', error => {
60
- requestFatalShutdown(error, 'uncaught exception')
61
- })
62
- process.on('unhandledRejection', reason => {
63
- requestFatalShutdown(reason, 'unhandled rejection')
64
- })
65
- state.fatalListenersInstalled = true
66
- }
67
-
68
- export function initializeShutdown(renderer: CliRenderer): void {
69
- state.renderer = renderer
70
-
71
- if (!state.exitListenerInstalled) {
72
- process.once('exit', resetTerminalModes)
73
- state.exitListenerInstalled = true
74
- }
75
- }
76
-
77
- export function requestFatalShutdown(error: unknown, source = 'fatal error'): void {
78
- if (state.fatalStarted) return
79
- state.fatalStarted = true
80
-
81
- let diagnostics: string
82
- let reportUrl: string
83
- try {
84
- diagnostics = formatDiagnostics(error)
85
- reportUrl = buildIssueUrl(error, diagnostics).toString()
86
- } catch {
87
- diagnostics = `mux-sesh crashed\n\nMessage:\n${String(error)}`
88
- reportUrl = 'https://github.com/quiet-ghost/mux-sesh/issues/new'
89
- }
90
-
91
- restoreTerminal()
92
-
93
- try {
94
- process.stderr.write(
95
- `\nFatal ${source}:\n\n${diagnostics}\n\nReport this crash (review before submitting):\n${reportUrl}\n`
96
- )
97
- } finally {
98
- process.exit(1)
99
- }
100
- }
101
-
102
- export function requestShutdown(code = 0): Promise<never> {
103
- if (state.exiting) return state.exiting
104
-
105
- state.exiting = (async () => {
106
- restoreTerminal()
107
- process.exit(code)
108
- })()
109
-
110
- return state.exiting
111
- }
@@ -1,28 +0,0 @@
1
- import { useTerminalDimensions } from '@opentui/react'
2
-
3
- export interface TerminalSize {
4
- columns: number
5
- rows: number
6
- }
7
-
8
- export type LayoutMode = 'compact' | 'normal' | 'wide'
9
-
10
- export function useTerminalSize(): TerminalSize {
11
- const { width, height } = useTerminalDimensions()
12
-
13
- return {
14
- columns: width,
15
- rows: height,
16
- }
17
- }
18
-
19
- export function getLayoutMode(columns: number): LayoutMode {
20
- if (columns < 100) return 'compact'
21
- if (columns < 150) return 'normal'
22
- return 'wide'
23
- }
24
-
25
- export function shouldShowDetailPanel(columns: number, isNewSessionMode: boolean): boolean {
26
- if (isNewSessionMode) return false
27
- return columns >= 80
28
- }
package/src/util/time.ts DELETED
@@ -1,48 +0,0 @@
1
- export function formatDuration(seconds: number): string {
2
- if (seconds < 60) {
3
- return 'just now'
4
- }
5
-
6
- const minutes = Math.floor(seconds / 60)
7
- const hours = Math.floor(minutes / 60)
8
- const days = Math.floor(hours / 24)
9
- const weeks = Math.floor(days / 7)
10
-
11
- if (weeks > 0) {
12
- const remainingDays = days % 7
13
- if (remainingDays > 0) {
14
- return `${weeks}w ${remainingDays}d`
15
- }
16
- return `${weeks}w`
17
- }
18
-
19
- if (days > 0) {
20
- const remainingHours = hours % 24
21
- if (remainingHours > 0) {
22
- return `${days}d ${remainingHours}h`
23
- }
24
- return `${days}d`
25
- }
26
-
27
- if (hours > 0) {
28
- const remainingMinutes = minutes % 60
29
- if (remainingMinutes > 0) {
30
- return `${hours}h ${remainingMinutes}m`
31
- }
32
- return `${hours}h`
33
- }
34
-
35
- return `${minutes}m`
36
- }
37
-
38
- export function formatSessionAge(createdTimestamp: number): string {
39
- const now = Math.floor(Date.now() / 1000)
40
- const age = now - createdTimestamp
41
- return formatDuration(age)
42
- }
43
-
44
- export function formatLastActivity(activityTimestamp: number): string {
45
- const now = Math.floor(Date.now() / 1000)
46
- const timeSince = now - activityTimestamp
47
- return formatDuration(timeSince)
48
- }
package/tsconfig.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "lib": ["ESNext", "DOM"],
4
- "target": "ESNext",
5
- "module": "ESNext",
6
- "moduleResolution": "bundler",
7
- "jsx": "react-jsx",
8
- "jsxImportSource": "@opentui/react",
9
- "strict": true,
10
- "skipLibCheck": true,
11
- "types": ["bun-types"],
12
- "baseUrl": ".",
13
- "paths": {
14
- "@/*": ["src/*"]
15
- },
16
- "resolveJsonModule": true,
17
- "esModuleInterop": true,
18
- "allowSyntheticDefaultImports": true,
19
- "forceConsistentCasingInFileNames": true,
20
- "isolatedModules": true,
21
- "noEmit": true
22
- },
23
- "include": ["src/**/*"],
24
- "exclude": ["node_modules", "dist"]
25
- }