mux-sesh 1.6.3 → 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.
Files changed (82) hide show
  1. package/README.md +90 -59
  2. package/package.json +7 -5
  3. package/src/app/commands.ts +120 -0
  4. package/src/app/controller.ts +397 -0
  5. package/src/app/controls.ts +121 -0
  6. package/src/app/core-state.ts +71 -0
  7. package/src/app/data.ts +90 -0
  8. package/src/app/derived.ts +77 -0
  9. package/src/app/effects.ts +392 -0
  10. package/src/app/handlers.ts +325 -0
  11. package/src/app/keyboard.ts +161 -0
  12. package/src/app/modal-keyboard.ts +118 -0
  13. package/src/app/modal-state.ts +50 -0
  14. package/src/app/modals-layer.tsx +159 -0
  15. package/src/app/modals.ts +108 -0
  16. package/src/app/notifications.ts +21 -0
  17. package/src/app/opencode.ts +49 -0
  18. package/src/app/operations.ts +31 -0
  19. package/src/app/runtime.ts +76 -0
  20. package/src/app/screen.tsx +217 -0
  21. package/src/app/state.ts +166 -0
  22. package/src/app/textarea.ts +16 -0
  23. package/src/app/view.ts +89 -0
  24. package/src/app.tsx +7 -1101
  25. package/src/config/index.ts +36 -42
  26. package/src/config/listed-sessions.ts +2 -5
  27. package/src/config/paths.ts +13 -0
  28. package/src/config/session-rules.ts +10 -11
  29. package/src/config/store.ts +26 -0
  30. package/src/handlers/action-helpers.ts +50 -0
  31. package/src/handlers/actions.ts +34 -65
  32. package/src/handlers/keyboard/index.ts +5 -0
  33. package/src/handlers/keyboard/new-session.ts +57 -0
  34. package/src/handlers/keyboard/normal.ts +201 -0
  35. package/src/handlers/keyboard/opencode.ts +104 -0
  36. package/src/handlers/keyboard/search.ts +113 -0
  37. package/src/handlers/keyboard/shared.ts +116 -0
  38. package/src/items/order.ts +21 -2
  39. package/src/opencode/sqlite.ts +21 -6
  40. package/src/preview/project.ts +41 -15
  41. package/src/search/index.ts +4 -1
  42. package/src/settings.ts +294 -297
  43. package/src/styles/opencode-themes-a.ts +1442 -1
  44. package/src/styles/opencode-themes-b.ts +1212 -1
  45. package/src/styles/opencode-tui-colors.ts +1784 -1
  46. package/src/styles/theme.tsx +2 -1
  47. package/src/tmux/actions.ts +103 -0
  48. package/src/tmux/details.ts +123 -0
  49. package/src/tmux/helpers.ts +35 -0
  50. package/src/tmux/index.ts +10 -286
  51. package/src/tmux/list.ts +31 -0
  52. package/src/tmux/project-discovery.ts +113 -0
  53. package/src/tmux/project-loader.ts +74 -0
  54. package/src/tmux/project-zoxide.ts +128 -0
  55. package/src/tmux/projects.ts +23 -261
  56. package/src/types/index.ts +0 -1
  57. package/src/ui/CommandsModal.tsx +87 -22
  58. package/src/ui/HighlightedText.tsx +1 -5
  59. package/src/ui/ItemList.tsx +26 -11
  60. package/src/ui/Modal.tsx +8 -1
  61. package/src/ui/OpencodeSessionGroup.tsx +20 -9
  62. package/src/ui/OpencodeStatsPanel.tsx +48 -15
  63. package/src/ui/RenameModal.tsx +17 -17
  64. package/src/ui/SearchInput.tsx +1 -20
  65. package/src/ui/SessionDetailsPanel.tsx +43 -15
  66. package/src/ui/SessionList.tsx +25 -4
  67. package/src/ui/SettingEditorModal.tsx +15 -9
  68. package/src/ui/SettingOptionsModal.tsx +30 -12
  69. package/src/ui/SettingsModal.tsx +20 -14
  70. package/src/ui/VersionBadge.tsx +3 -1
  71. package/src/ui/item-icon.ts +5 -1
  72. package/src/ui/list-window.ts +5 -1
  73. package/src/ui/text-columns.ts +17 -0
  74. package/src/ui/use-textarea-focus.ts +26 -0
  75. package/src/update/index.ts +10 -2
  76. package/src/update/installation.ts +6 -2
  77. package/src/util/ansi.ts +3 -0
  78. package/src/util/glob.ts +5 -1
  79. package/src/util/path-display.ts +98 -0
  80. package/src/components/KeybindHelp.tsx +0 -289
  81. package/src/handlers/keyboard.ts +0 -654
  82. package/src/ui/SessionStats.tsx +0 -32
@@ -3,6 +3,7 @@ import { basename, join } from 'path'
3
3
  import { spawn } from 'bun'
4
4
  import { getSessionDetails } from '../tmux'
5
5
  import type { Config, SessionDetails } from '../types'
6
+ import { stripAnsi } from '../util/ansi'
6
7
  import { getGitRoot, resolveProjectSession } from '../config/session-rules'
7
8
 
8
9
  const MAX_PREVIEW_LINES = 24
@@ -40,11 +41,10 @@ function displayPath(path: string): string {
40
41
  return path.replace(process.env.HOME || '', '~')
41
42
  }
42
43
 
43
- function stripAnsi(value: string): string {
44
- return value.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, '')
45
- }
46
-
47
- export function interpolatePreviewCommand(command: string | undefined, projectPath: string): string | undefined {
44
+ export function interpolatePreviewCommand(
45
+ command: string | undefined,
46
+ projectPath: string
47
+ ): string | undefined {
48
48
  if (!command) {
49
49
  return undefined
50
50
  }
@@ -52,13 +52,20 @@ export function interpolatePreviewCommand(command: string | undefined, projectPa
52
52
  return command.replaceAll('{}', projectPath)
53
53
  }
54
54
 
55
- export function formatPreviewOutput(output: string, maxLines = MAX_PREVIEW_LINES): FormattedPreviewOutput {
55
+ export function formatPreviewOutput(
56
+ output: string,
57
+ maxLines = MAX_PREVIEW_LINES
58
+ ): FormattedPreviewOutput {
56
59
  const cleanedLines = stripAnsi(output)
57
60
  .replace(/\r/g, '')
58
61
  .split('\n')
59
62
  .map(line => line.trimEnd())
60
63
  .filter(line => line.length > 0)
61
- .map(line => (line.length > MAX_PREVIEW_LINE_LENGTH ? `${line.slice(0, MAX_PREVIEW_LINE_LENGTH - 1)}…` : line))
64
+ .map(line =>
65
+ line.length > MAX_PREVIEW_LINE_LENGTH
66
+ ? `${line.slice(0, MAX_PREVIEW_LINE_LENGTH - 1)}…`
67
+ : line
68
+ )
62
69
 
63
70
  if (cleanedLines.length === 0) {
64
71
  return {
@@ -118,7 +125,11 @@ async function getDirectoryPreviewLines(projectPath: string): Promise<string[]>
118
125
 
119
126
  const visibleEntries = entries
120
127
  .filter(entry => !entry.name.startsWith('.'))
121
- .sort((left, right) => Number(right.isDirectory()) - Number(left.isDirectory()) || left.name.localeCompare(right.name))
128
+ .sort(
129
+ (left, right) =>
130
+ Number(right.isDirectory()) - Number(left.isDirectory()) ||
131
+ left.name.localeCompare(right.name)
132
+ )
122
133
  .slice(0, 16)
123
134
 
124
135
  const lines: string[] = []
@@ -149,7 +160,10 @@ async function getDirectoryPreviewLines(projectPath: string): Promise<string[]>
149
160
  }
150
161
  }
151
162
 
152
- async function runPreviewCommand(command: string, cwd: string): Promise<{ output?: string; notice?: string }> {
163
+ async function runPreviewCommand(
164
+ command: string,
165
+ cwd: string
166
+ ): Promise<{ output?: string; notice?: string }> {
153
167
  try {
154
168
  const proc = spawn(['sh', '-lc', command], {
155
169
  cwd,
@@ -196,12 +210,21 @@ export async function getProjectPreview(
196
210
  resolveProjectSession(projectPath, config),
197
211
  getGitRoot(projectPath),
198
212
  getGitBranch(projectPath),
199
- linkedSessionName ? getSessionDetails(linkedSessionName).catch(() => null) : Promise.resolve(null),
213
+ linkedSessionName
214
+ ? getSessionDetails(linkedSessionName).catch(() => null)
215
+ : Promise.resolve(null),
200
216
  ])
201
217
 
202
- const resolvedPreviewCommand = interpolatePreviewCommand(resolvedSession.previewCommand, projectPath)
203
- const commandResult = resolvedPreviewCommand ? await runPreviewCommand(resolvedPreviewCommand, projectPath) : undefined
204
- const formattedCommandOutput = commandResult?.output ? formatPreviewOutput(commandResult.output) : undefined
218
+ const resolvedPreviewCommand = interpolatePreviewCommand(
219
+ resolvedSession.previewCommand,
220
+ projectPath
221
+ )
222
+ const commandResult = resolvedPreviewCommand
223
+ ? await runPreviewCommand(resolvedPreviewCommand, projectPath)
224
+ : undefined
225
+ const formattedCommandOutput = commandResult?.output
226
+ ? formatPreviewOutput(commandResult.output)
227
+ : undefined
205
228
 
206
229
  if (formattedCommandOutput && formattedCommandOutput.lines.length > 0) {
207
230
  const preview: ProjectPreview = {
@@ -244,8 +267,11 @@ export async function getProjectPreview(
244
267
  previewKind: 'directory',
245
268
  previewLabel: 'Directory Listing',
246
269
  previewLines: formattedDirectoryOutput.lines,
247
- previewNotice: commandResult?.notice ??
248
- (formattedDirectoryOutput.truncated ? 'Directory listing truncated to fit the panel.' : undefined),
270
+ previewNotice:
271
+ commandResult?.notice ??
272
+ (formattedDirectoryOutput.truncated
273
+ ? 'Directory listing truncated to fit the panel.'
274
+ : undefined),
249
275
  }
250
276
 
251
277
  projectPreviewCache.set(cacheKey, {
@@ -108,7 +108,10 @@ function calculateItemBonus(item: Item, query: string): number {
108
108
  bonus += 1200
109
109
  }
110
110
 
111
- if (item.path.toLowerCase().endsWith(`/${normalizedQuery}`) || description.endsWith(`/${normalizedQuery}`)) {
111
+ if (
112
+ item.path.toLowerCase().endsWith(`/${normalizedQuery}`) ||
113
+ description.endsWith(`/${normalizedQuery}`)
114
+ ) {
112
115
  bonus += 2000
113
116
  }
114
117