mux-sesh 1.6.4 → 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 (78) 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 -1136
  25. package/src/config/index.ts +36 -42
  26. package/src/config/paths.ts +13 -0
  27. package/src/config/session-rules.ts +6 -2
  28. package/src/config/store.ts +26 -0
  29. package/src/handlers/action-helpers.ts +50 -0
  30. package/src/handlers/actions.ts +34 -65
  31. package/src/handlers/keyboard/index.ts +5 -0
  32. package/src/handlers/keyboard/new-session.ts +57 -0
  33. package/src/handlers/keyboard/normal.ts +201 -0
  34. package/src/handlers/keyboard/opencode.ts +104 -0
  35. package/src/handlers/keyboard/search.ts +113 -0
  36. package/src/handlers/keyboard/shared.ts +116 -0
  37. package/src/opencode/sqlite.ts +21 -6
  38. package/src/preview/project.ts +41 -15
  39. package/src/search/index.ts +4 -1
  40. package/src/settings.ts +294 -297
  41. package/src/styles/opencode-themes-a.ts +1442 -1
  42. package/src/styles/opencode-themes-b.ts +1212 -1
  43. package/src/styles/opencode-tui-colors.ts +1784 -1
  44. package/src/styles/theme.tsx +2 -1
  45. package/src/tmux/actions.ts +103 -0
  46. package/src/tmux/details.ts +123 -0
  47. package/src/tmux/helpers.ts +35 -0
  48. package/src/tmux/index.ts +10 -288
  49. package/src/tmux/list.ts +31 -0
  50. package/src/tmux/project-discovery.ts +113 -0
  51. package/src/tmux/project-loader.ts +74 -0
  52. package/src/tmux/project-zoxide.ts +128 -0
  53. package/src/tmux/projects.ts +23 -262
  54. package/src/types/index.ts +0 -1
  55. package/src/ui/CommandsModal.tsx +87 -22
  56. package/src/ui/HighlightedText.tsx +1 -5
  57. package/src/ui/ItemList.tsx +14 -4
  58. package/src/ui/Modal.tsx +8 -1
  59. package/src/ui/OpencodeSessionGroup.tsx +20 -9
  60. package/src/ui/OpencodeStatsPanel.tsx +48 -15
  61. package/src/ui/RenameModal.tsx +17 -17
  62. package/src/ui/SearchInput.tsx +1 -20
  63. package/src/ui/SessionDetailsPanel.tsx +43 -15
  64. package/src/ui/SessionList.tsx +23 -6
  65. package/src/ui/SettingEditorModal.tsx +15 -9
  66. package/src/ui/SettingOptionsModal.tsx +30 -12
  67. package/src/ui/SettingsModal.tsx +20 -14
  68. package/src/ui/VersionBadge.tsx +3 -1
  69. package/src/ui/item-icon.ts +5 -1
  70. package/src/ui/list-window.ts +5 -1
  71. package/src/ui/use-textarea-focus.ts +26 -0
  72. package/src/update/index.ts +10 -2
  73. package/src/update/installation.ts +6 -2
  74. package/src/util/ansi.ts +3 -0
  75. package/src/util/glob.ts +5 -1
  76. package/src/components/KeybindHelp.tsx +0 -289
  77. package/src/handlers/keyboard.ts +0 -654
  78. package/src/ui/SessionStats.tsx +0 -32
@@ -0,0 +1,104 @@
1
+ import { AppMode, type KeybindMode } from '../../types'
2
+ import {
3
+ activatePrefix,
4
+ clearPrefix,
5
+ getKeyName,
6
+ matchesPrefixKey,
7
+ type KeyboardHandlerContext,
8
+ type KeyboardInput,
9
+ } from './shared'
10
+
11
+ export function handleOpencodeManageMode(
12
+ key: KeyboardInput,
13
+ ctx: KeyboardHandlerContext,
14
+ keybindMode: KeybindMode = 'vim'
15
+ ) {
16
+ const keyName = getKeyName(key)
17
+ const isStandard = keybindMode === 'standard'
18
+
19
+ if (key.ctrl && keyName === 'p') {
20
+ ctx.clearPendingKill()
21
+ ctx.openCommandsModal()
22
+ return
23
+ }
24
+
25
+ if (ctx.prefixActive) {
26
+ clearPrefix(ctx)
27
+
28
+ switch (keyName) {
29
+ case 'o':
30
+ ctx.clearPendingKill()
31
+ ctx.setAppMode(AppMode.Normal)
32
+ return
33
+ case 'd':
34
+ if (ctx.opencodeSessions[ctx.opencodeCursor]) {
35
+ ctx.requestKillSession(ctx.opencodeSessions[ctx.opencodeCursor].title)
36
+ }
37
+ return
38
+ case 'r':
39
+ if (ctx.opencodeSessions[ctx.opencodeCursor]) {
40
+ ctx.clearPendingKill()
41
+ ctx.openRenameModal(ctx.opencodeSessions[ctx.opencodeCursor].title)
42
+ }
43
+ return
44
+ }
45
+
46
+ return
47
+ }
48
+
49
+ if (ctx.prefixKey && matchesPrefixKey(key, ctx.prefixKey)) {
50
+ activatePrefix(ctx)
51
+ return
52
+ }
53
+
54
+ if (keyName === 'escape' || (!ctx.prefixKey && !isStandard && keyName === 'o')) {
55
+ ctx.clearPendingKill()
56
+ ctx.setAppMode(AppMode.Normal)
57
+ return
58
+ }
59
+
60
+ if (keyName === 'down' || (!isStandard && keyName === 'j')) {
61
+ ctx.clearPendingKill()
62
+ ctx.setOpencodeCursor(cursor => {
63
+ const next = Math.min(cursor + 1, ctx.opencodeSessions.length - 1)
64
+ if (next !== cursor && ctx.opencodeSessions[next]) {
65
+ void ctx.loadOpencodeStatsForSession(ctx.opencodeSessions[next].title)
66
+ }
67
+ return next
68
+ })
69
+ return
70
+ }
71
+
72
+ if (keyName === 'up' || (!isStandard && keyName === 'k')) {
73
+ ctx.clearPendingKill()
74
+ ctx.setOpencodeCursor(cursor => {
75
+ const next = Math.max(cursor - 1, 0)
76
+ if (next !== cursor && ctx.opencodeSessions[next]) {
77
+ void ctx.loadOpencodeStatsForSession(ctx.opencodeSessions[next].title)
78
+ }
79
+ return next
80
+ })
81
+ return
82
+ }
83
+
84
+ if (!isStandard && keyName === 'd') {
85
+ if (ctx.opencodeSessions[ctx.opencodeCursor]) {
86
+ ctx.requestKillSession(ctx.opencodeSessions[ctx.opencodeCursor].title)
87
+ }
88
+ return
89
+ }
90
+
91
+ if (!ctx.prefixKey && !isStandard && keyName === 'r') {
92
+ if (ctx.opencodeSessions[ctx.opencodeCursor]) {
93
+ ctx.clearPendingKill()
94
+ ctx.openRenameModal(ctx.opencodeSessions[ctx.opencodeCursor].title)
95
+ }
96
+ return
97
+ }
98
+
99
+ if (!ctx.prefixKey && !isStandard && keyName === ',') {
100
+ ctx.clearPendingKill()
101
+ ctx.openSettingsModal()
102
+ return
103
+ }
104
+ }
@@ -0,0 +1,113 @@
1
+ import { AppMode, ViewMode, type KeybindMode } from '../../types'
2
+ import { requestShutdown } from '../../util/shutdown'
3
+ import {
4
+ activatePrefix,
5
+ clearPrefix,
6
+ enterNewSessionMode,
7
+ getKeyName,
8
+ matchesPrefixKey,
9
+ setTimedMessage,
10
+ type KeyboardHandlerContext,
11
+ type KeyboardInput,
12
+ } from './shared'
13
+
14
+ export function handleSearchMode(
15
+ key: KeyboardInput,
16
+ ctx: KeyboardHandlerContext,
17
+ keybindMode: KeybindMode = 'vim'
18
+ ) {
19
+ const keyName = getKeyName(key)
20
+ const isStandard = keybindMode === 'standard'
21
+
22
+ if (isStandard) {
23
+ if (ctx.prefixActive) {
24
+ clearPrefix(ctx)
25
+
26
+ switch (keyName) {
27
+ case 'd':
28
+ if (ctx.viewMode === ViewMode.Sessions && ctx.items[ctx.cursor]?.isSession) {
29
+ ctx.requestKillSession(ctx.items[ctx.cursor].title)
30
+ }
31
+ return
32
+ case 'n':
33
+ enterNewSessionMode(ctx)
34
+ return
35
+ case 'o':
36
+ ctx.clearPendingKill()
37
+ if (ctx.viewMode === ViewMode.Sessions && ctx.opencodeSessions.length > 0) {
38
+ ctx.setAppMode(AppMode.OpencodeManage)
39
+ ctx.setOpencodeCursor(0)
40
+ void ctx.loadOpencodeStatsForSession(ctx.opencodeSessions[0].title)
41
+ }
42
+ return
43
+ case 's':
44
+ ctx.clearPendingKill()
45
+ ctx.openSettingsModal()
46
+ return
47
+ case 'l':
48
+ ctx.clearPendingKill()
49
+ void ctx.handleLastSession()
50
+ return
51
+ case 'g':
52
+ ctx.clearPendingKill()
53
+ void ctx.handleRootSession(ctx.items[ctx.cursor])
54
+ return
55
+ case 'r':
56
+ if (key.shift) {
57
+ void ctx.refreshItems()
58
+ setTimedMessage(ctx, 'Refreshed')
59
+ return
60
+ }
61
+
62
+ if (ctx.viewMode === ViewMode.Sessions && ctx.items[ctx.cursor]?.isSession) {
63
+ ctx.clearPendingKill()
64
+ ctx.openRenameModal(ctx.items[ctx.cursor].title)
65
+ }
66
+ return
67
+ default:
68
+ return
69
+ }
70
+ }
71
+
72
+ if (matchesPrefixKey(key, ctx.prefixKey)) {
73
+ activatePrefix(ctx)
74
+ return
75
+ }
76
+
77
+ if (key.ctrl && keyName === 'q') {
78
+ void requestShutdown(0)
79
+ return
80
+ }
81
+ }
82
+
83
+ if (keyName === 'escape') {
84
+ ctx.clearPendingKill()
85
+ if (isStandard) {
86
+ ctx.setSearchQuery('')
87
+ ctx.setCursor(0)
88
+ return
89
+ }
90
+
91
+ ctx.setAppMode(AppMode.Normal)
92
+ ctx.setSearchQuery('')
93
+ ctx.setCursor(0)
94
+ return
95
+ }
96
+
97
+ switch (keyName) {
98
+ case 'return':
99
+ ctx.clearPendingKill()
100
+ if (ctx.items.length > 0) {
101
+ void ctx.handleSelect(ctx.items[0])
102
+ }
103
+ break
104
+ case 'down':
105
+ ctx.clearPendingKill()
106
+ ctx.setCursor(cursor => Math.min(cursor + 1, ctx.items.length - 1))
107
+ break
108
+ case 'up':
109
+ ctx.clearPendingKill()
110
+ ctx.setCursor(cursor => Math.max(cursor - 1, 0))
111
+ break
112
+ }
113
+ }
@@ -0,0 +1,116 @@
1
+ import type { Dispatch, MutableRefObject, SetStateAction } from 'react'
2
+ import { AppMode, ViewMode, type Config, type Item, type OpencodeSessionStats } from '../../types'
3
+
4
+ export interface KeyboardInput {
5
+ name?: string
6
+ ctrl?: boolean
7
+ shift?: boolean
8
+ }
9
+
10
+ export interface KeyboardHandlerContext {
11
+ appMode: AppMode
12
+ viewMode: ViewMode
13
+ items: Item[]
14
+ regularSessions: Item[]
15
+ opencodeSessions: Item[]
16
+ cursor: number
17
+ opencodeCursor: number
18
+ searchQuery: string
19
+ prefixKey?: string
20
+ projectItems: Item[]
21
+ sessionItems: Item[]
22
+ prefixActive: boolean
23
+ prefixTimeoutRef: MutableRefObject<NodeJS.Timeout | null>
24
+ setAppMode: (mode: AppMode) => void
25
+ setViewMode: (mode: ViewMode) => void
26
+ setCursor: Dispatch<SetStateAction<number>>
27
+ setOpencodeCursor: Dispatch<SetStateAction<number>>
28
+ setSearchQuery: (query: string) => void
29
+ setAllItems: Dispatch<SetStateAction<Item[]>>
30
+ setItems: Dispatch<SetStateAction<Item[]>>
31
+ setPrefixActive: (active: boolean) => void
32
+ refreshItems: (forceViewMode?: ViewMode, nextConfig?: Config) => Promise<void>
33
+ requestKillSession: (sessionName: string) => void
34
+ clearPendingKill: () => void
35
+ handleSelect: (item: Item) => Promise<void>
36
+ handleKillSession: (sessionName: string) => Promise<void>
37
+ handleLastSession: () => Promise<void>
38
+ handleRootSession: (item?: Item) => Promise<void>
39
+ handleEditTarget: (item?: Item) => Promise<void>
40
+ openRenameModal: (sessionName: string) => void
41
+ openCommandsModal: () => void
42
+ openSettingsModal: () => void
43
+ loadOpencodeStatsForSession: (sessionName: string) => Promise<OpencodeSessionStats | null>
44
+ setMessage: (message: string) => void
45
+ }
46
+
47
+ export function getKeyName(key: KeyboardInput): string {
48
+ return key.name ?? ''
49
+ }
50
+
51
+ export function matchesPrefixKey(key: KeyboardInput, prefixKey = 'ctrl+x'): boolean {
52
+ const parts = prefixKey.toLowerCase().split('+')
53
+ const keyPart = parts.at(-1) ?? prefixKey.toLowerCase()
54
+ const expectsCtrl = parts.includes('ctrl')
55
+ const expectsShift = parts.includes('shift')
56
+
57
+ return (
58
+ Boolean(key.ctrl) === expectsCtrl &&
59
+ Boolean(key.shift) === expectsShift &&
60
+ getKeyName(key).toLowerCase() === keyPart
61
+ )
62
+ }
63
+
64
+ export function clearPrefix(ctx: KeyboardHandlerContext) {
65
+ if (ctx.prefixTimeoutRef.current) {
66
+ clearTimeout(ctx.prefixTimeoutRef.current)
67
+ ctx.prefixTimeoutRef.current = null
68
+ }
69
+
70
+ ctx.setPrefixActive(false)
71
+ }
72
+
73
+ export function activatePrefix(ctx: KeyboardHandlerContext) {
74
+ ctx.setPrefixActive(true)
75
+ ctx.prefixTimeoutRef.current = setTimeout(() => {
76
+ ctx.setPrefixActive(false)
77
+ }, 2000)
78
+ }
79
+
80
+ export function setTimedMessage(ctx: KeyboardHandlerContext, message: string, timeout = 2000) {
81
+ ctx.setMessage(message)
82
+ setTimeout(() => ctx.setMessage(''), timeout)
83
+ }
84
+
85
+ export function getSelectedItem(ctx: KeyboardHandlerContext): Item | undefined {
86
+ return ctx.viewMode === ViewMode.Sessions
87
+ ? ctx.regularSessions[ctx.cursor]
88
+ : ctx.items[ctx.cursor]
89
+ }
90
+
91
+ export function getQuickSelectItem(ctx: KeyboardHandlerContext, index: number): Item | undefined {
92
+ return ctx.viewMode === ViewMode.Sessions ? ctx.regularSessions[index] : ctx.items[index]
93
+ }
94
+
95
+ export function enterNewSessionMode(ctx: KeyboardHandlerContext) {
96
+ ctx.clearPendingKill()
97
+ ctx.setAppMode(AppMode.NewSession)
98
+ ctx.setViewMode(ViewMode.Projects)
99
+ ctx.setAllItems(ctx.projectItems)
100
+ ctx.setItems(ctx.projectItems)
101
+ ctx.setCursor(Math.max(0, ctx.projectItems.length - 1))
102
+ ctx.setSearchQuery('')
103
+ }
104
+
105
+ export function openSelectedRootSession(ctx: KeyboardHandlerContext) {
106
+ ctx.clearPendingKill()
107
+ void ctx.handleRootSession(getSelectedItem(ctx))
108
+ }
109
+
110
+ export function openSelectedEditTarget(ctx: KeyboardHandlerContext) {
111
+ ctx.clearPendingKill()
112
+ const item = getSelectedItem(ctx)
113
+ if (item?.itemKind === 'configured') {
114
+ void ctx.handleEditTarget(item)
115
+ }
116
+ }
@@ -260,7 +260,9 @@ export function getMostRecentSessionRowFromDatabase(
260
260
  return getSessionRow(database, directory)
261
261
  }
262
262
 
263
- export async function getMostRecentSessionRow(directory: string): Promise<OpencodeSessionRow | null> {
263
+ export async function getMostRecentSessionRow(
264
+ directory: string
265
+ ): Promise<OpencodeSessionRow | null> {
264
266
  return withDatabase(database => getMostRecentSessionRowFromDatabase(database, directory))
265
267
  }
266
268
 
@@ -309,11 +311,18 @@ export function getMostRecentSessionTitleForDirectoryFromDatabase(
309
311
  return statement.get(directory)?.title ?? null
310
312
  }
311
313
 
312
- export async function getMostRecentSessionTitleForDirectory(directory: string): Promise<string | null> {
313
- return withDatabase(database => getMostRecentSessionTitleForDirectoryFromDatabase(database, directory))
314
+ export async function getMostRecentSessionTitleForDirectory(
315
+ directory: string
316
+ ): Promise<string | null> {
317
+ return withDatabase(database =>
318
+ getMostRecentSessionTitleForDirectoryFromDatabase(database, directory)
319
+ )
314
320
  }
315
321
 
316
- export function getMessageCountBySessionFromDatabase(database: Database, sessionID: string): number {
322
+ export function getMessageCountBySessionFromDatabase(
323
+ database: Database,
324
+ sessionID: string
325
+ ): number {
317
326
  return getMessageAggregate(database, sessionID).messageCount
318
327
  }
319
328
 
@@ -321,7 +330,10 @@ export async function getMessageCountBySession(sessionID: string): Promise<numbe
321
330
  return withDatabase(database => getMessageCountBySessionFromDatabase(database, sessionID))
322
331
  }
323
332
 
324
- export function getMessageCountByDirectoryFromDatabase(database: Database, directory: string): number {
333
+ export function getMessageCountByDirectoryFromDatabase(
334
+ database: Database,
335
+ directory: string
336
+ ): number {
325
337
  const statement = database.query<{ messageCount: number }, [string]>(`
326
338
  SELECT COUNT(m.id) AS messageCount
327
339
  FROM message m
@@ -336,7 +348,10 @@ export async function getMessageCountByDirectory(directory: string): Promise<num
336
348
  return withDatabase(database => getMessageCountByDirectoryFromDatabase(database, directory))
337
349
  }
338
350
 
339
- export function getAssistantCostTotalBySessionFromDatabase(database: Database, sessionID: string): number {
351
+ export function getAssistantCostTotalBySessionFromDatabase(
352
+ database: Database,
353
+ sessionID: string
354
+ ): number {
340
355
  return getMessageAggregate(database, sessionID).totalCost
341
356
  }
342
357
 
@@ -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