mux-sesh 1.7.2 → 1.9.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.
@@ -167,6 +167,39 @@ export async function handleSettingOptionSubmitWithFeedback(
167
167
  )
168
168
  }
169
169
 
170
+ export function getPinnedSessionsAfterToggle(config: Config, sessionName: string): string[] {
171
+ const pinnedSessions = config.pinnedSessions ?? []
172
+
173
+ return pinnedSessions.includes(sessionName)
174
+ ? pinnedSessions.filter(pinnedSession => pinnedSession !== sessionName)
175
+ : [...pinnedSessions, sessionName]
176
+ }
177
+
178
+ export async function handleTogglePinnedSessionWithFeedback(
179
+ sessionName: string,
180
+ options: SettingsHandlerOptions
181
+ ): Promise<void> {
182
+ if (!options.config) {
183
+ return
184
+ }
185
+
186
+ const pinnedSessions = getPinnedSessionsAfterToggle(options.config, sessionName)
187
+ const nextConfig = {
188
+ ...options.config,
189
+ pinnedSessions,
190
+ }
191
+ const isPinned = pinnedSessions.includes(sessionName)
192
+
193
+ await persistConfigUpdate(
194
+ nextConfig,
195
+ `Session '${sessionName}' ${isPinned ? 'pinned' : 'unpinned'}`,
196
+ options.saveConfig,
197
+ options.setConfig,
198
+ options.refreshItems,
199
+ options.showMessage
200
+ )
201
+ }
202
+
170
203
  export async function executeAppCommand(
171
204
  commandID: Parameters<typeof runCommand>[0],
172
205
  options: Parameters<typeof runCommand>[1]
@@ -279,6 +312,19 @@ export function createAppHandlers(options: CreateAppHandlersOptions) {
279
312
  })
280
313
  }
281
314
 
315
+ async function handleTogglePinnedSessionWrapper(sessionName: string) {
316
+ await handleTogglePinnedSessionWithFeedback(sessionName, {
317
+ config: options.config,
318
+ saveConfig: options.saveConfig,
319
+ setConfig: options.setConfig,
320
+ setSettingEditorError: options.setSettingEditorError,
321
+ openSettingsModal: options.openSettingsModal,
322
+ settingEditorValue: options.settingEditorValue,
323
+ refreshItems: options.refreshItems,
324
+ showMessage: options.showMessage,
325
+ })
326
+ }
327
+
282
328
  async function executeCommand(commandID: Parameters<typeof executeAppCommand>[0]) {
283
329
  await executeAppCommand(commandID, {
284
330
  appMode: options.appMode,
@@ -294,6 +340,7 @@ export function createAppHandlers(options: CreateAppHandlersOptions) {
294
340
  openRenameModal: options.openRenameModal,
295
341
  openSettingsModal: options.openSettingsModal,
296
342
  requestKillSession: options.requestKillSession,
343
+ togglePinnedSession: handleTogglePinnedSessionWrapper,
297
344
  setAppMode: options.setAppMode,
298
345
  setViewMode: options.setViewMode,
299
346
  setAllItems: options.setAllItems,
@@ -320,6 +367,7 @@ export function createAppHandlers(options: CreateAppHandlersOptions) {
320
367
  handleNewSessionSubmit,
321
368
  handleSettingsEditorSubmit,
322
369
  handleSettingOptionSubmit,
370
+ handleTogglePinnedSessionWrapper,
323
371
  executeCommand,
324
372
  }
325
373
  }
@@ -52,6 +52,7 @@ interface UseAppKeyboardOptions {
52
52
  closeModal: () => void
53
53
  clearPendingKill: () => void
54
54
  requestKillSession: (sessionName: string) => void
55
+ togglePinnedSession: (sessionName: string) => Promise<void>
55
56
  openRenameModal: (sessionName: string) => void
56
57
  openCommandsModal: () => void
57
58
  openSettingsModal: () => void
@@ -101,6 +102,7 @@ export function useAppKeyboard(options: UseAppKeyboardOptions) {
101
102
  setPrefixActive: options.setPrefixActive,
102
103
  refreshItems: options.refreshItems,
103
104
  requestKillSession: options.requestKillSession,
105
+ togglePinnedSession: options.togglePinnedSession,
104
106
  clearPendingKill: options.clearPendingKill,
105
107
  handleSelect: options.handleSelect,
106
108
  handleKillSession: options.handleKillSession,
@@ -51,6 +51,24 @@ function asStringArray(value: unknown): string[] | undefined {
51
51
  return strings.length > 0 ? strings : undefined
52
52
  }
53
53
 
54
+ function uniqueStrings(values?: string[]): string[] | undefined {
55
+ if (!values || values.length === 0) {
56
+ return undefined
57
+ }
58
+
59
+ const seen = new Set<string>()
60
+ const unique = values.filter(value => {
61
+ if (seen.has(value)) {
62
+ return false
63
+ }
64
+
65
+ seen.add(value)
66
+ return true
67
+ })
68
+
69
+ return unique.length > 0 ? unique : undefined
70
+ }
71
+
54
72
  function asKeybindMode(value: unknown): KeybindMode | undefined {
55
73
  return value === 'vim' || value === 'standard' ? value : undefined
56
74
  }
@@ -320,6 +338,9 @@ export function normalizeConfig(rawConfig: unknown, homeDir = process.env.HOME |
320
338
  asStringArray(raw.hidden_sessions) ??
321
339
  asStringArray(raw.hiddenSessions) ??
322
340
  defaultConfig.hiddenSessions
341
+ const pinnedSessions =
342
+ uniqueStrings(asStringArray(raw.pinned_sessions) ?? asStringArray(raw.pinnedSessions)) ??
343
+ defaultConfig.pinnedSessions
323
344
  const icons = normalizeIcons(raw.icons) ?? defaultConfig.icons
324
345
  const configuredDefaultSession =
325
346
  normalizeSessionDefaults(raw.default_session) ?? normalizeSessionDefaults(raw.defaultSession)
@@ -343,6 +364,7 @@ export function normalizeConfig(rawConfig: unknown, homeDir = process.env.HOME |
343
364
  autoUpdate,
344
365
  dirLength,
345
366
  hiddenSessions,
367
+ pinnedSessions,
346
368
  icons,
347
369
  defaultSession,
348
370
  projects: normalizeProjectProfiles(raw.projects, homeDir) ?? defaultConfig.projects,
@@ -366,6 +388,7 @@ export function getDefaultConfig(homeDir = process.env.HOME || '~'): Config {
366
388
  autoUpdate: true,
367
389
  dirLength: 1,
368
390
  hiddenSessions: [],
391
+ pinnedSessions: [],
369
392
  icons: DEFAULT_ICONS,
370
393
  defaultSession: {
371
394
  startupCommand: DEFAULT_EDITOR_COMMAND,
@@ -401,6 +424,7 @@ export function serializeConfig(config: Config): Record<string, unknown> {
401
424
  auto_update: config.autoUpdate,
402
425
  dir_length: config.dirLength,
403
426
  hidden_sessions: config.hiddenSessions,
427
+ pinned_sessions: config.pinnedSessions,
404
428
  icons: config.icons,
405
429
  default_session: config.defaultSession
406
430
  ? {
@@ -0,0 +1,99 @@
1
+ import { basename, dirname, isAbsolute, join } from 'path'
2
+ import { stat } from 'fs/promises'
3
+ import type { Config, Item } from '../types'
4
+
5
+ export interface ResolvedFileSession {
6
+ sessionName: string
7
+ cwd: string
8
+ startupCommand: string
9
+ }
10
+
11
+ export type TypedPathTarget = { kind: 'file' | 'directory'; path: string }
12
+
13
+ function quoteShellArg(value: string): string {
14
+ return `'${value.replaceAll("'", "'\\''")}'`
15
+ }
16
+
17
+ function sanitizeSessionName(value: string): string {
18
+ return value.replace(/[.\s/]+/g, '_')
19
+ }
20
+
21
+ export function isFileItem(item: Pick<Item, 'itemKind'>): boolean {
22
+ return item.itemKind === 'file'
23
+ }
24
+
25
+ export function expandUserPath(value: string, homeDir = process.env.HOME || ''): string {
26
+ if (value === '~') {
27
+ return homeDir || value
28
+ }
29
+
30
+ if (value.startsWith('~/') && homeDir) {
31
+ return join(homeDir, value.slice(2))
32
+ }
33
+
34
+ return value
35
+ }
36
+
37
+ export function buildFileSessionName(filePath: string): string {
38
+ const fileBase = basename(filePath)
39
+ const parentBase = basename(dirname(filePath))
40
+ const combined =
41
+ parentBase && parentBase !== '.' && parentBase !== '/' ? `${parentBase}_${fileBase}` : fileBase
42
+
43
+ return sanitizeSessionName(combined)
44
+ }
45
+
46
+ export function interpolateStartupCommand(command: string, filePath: string): string {
47
+ return command
48
+ .replaceAll('{file}', quoteShellArg(filePath))
49
+ .replaceAll('{dir}', quoteShellArg(dirname(filePath)))
50
+ .replaceAll('{}', quoteShellArg(filePath))
51
+ }
52
+
53
+ export function buildFileStartupCommand(filePath: string, config: Config): string {
54
+ const configured = config.defaultSession?.startupCommand
55
+ if (configured && /\{file\}|\{dir\}|\{\}/.test(configured)) {
56
+ return interpolateStartupCommand(configured, filePath)
57
+ }
58
+
59
+ return `${config.editor} ${quoteShellArg(filePath)}`
60
+ }
61
+
62
+ export function resolveFileSession(filePath: string, config: Config): ResolvedFileSession {
63
+ return {
64
+ sessionName: buildFileSessionName(filePath),
65
+ cwd: dirname(filePath),
66
+ startupCommand: buildFileStartupCommand(filePath, config),
67
+ }
68
+ }
69
+
70
+ export function looksLikePathInput(value: string): boolean {
71
+ return value.startsWith('/') || value === '~' || value.startsWith('~/') || value.startsWith('./')
72
+ }
73
+
74
+ export async function resolveTypedPathTarget(
75
+ searchTerm: string,
76
+ homeDir = process.env.HOME || ''
77
+ ): Promise<TypedPathTarget | null> {
78
+ if (!looksLikePathInput(searchTerm)) {
79
+ return null
80
+ }
81
+
82
+ const expanded = expandUserPath(searchTerm, homeDir)
83
+ const absolute = isAbsolute(expanded) ? expanded : join(process.cwd(), expanded)
84
+
85
+ try {
86
+ const info = await stat(absolute)
87
+ if (info.isFile()) {
88
+ return { kind: 'file', path: absolute }
89
+ }
90
+
91
+ if (info.isDirectory()) {
92
+ return { kind: 'directory', path: absolute }
93
+ }
94
+
95
+ return null
96
+ } catch {
97
+ return null
98
+ }
99
+ }
@@ -1,5 +1,7 @@
1
+ import { dirname } from 'path'
1
2
  import type { Config, Item } from '../types'
2
3
  import { getGitRoot, resolveProjectSession } from '../config/session-rules'
4
+ import { isFileItem, resolveFileSession } from '../files/target'
3
5
  import { createTmuxSession, getTmuxSessionDirectory } from '../tmux'
4
6
  import { requestShutdown } from '../util/shutdown'
5
7
 
@@ -44,7 +46,16 @@ export async function openProjectSession(projectPath: string, config: Config): P
44
46
  await requestShutdown(0)
45
47
  }
46
48
 
49
+ export async function openFileSession(filePath: string, config: Config): Promise<void> {
50
+ const resolvedSession = resolveFileSession(filePath, config)
51
+ await createTmuxSession(resolvedSession.sessionName, resolvedSession.cwd, {
52
+ startupCommand: resolvedSession.startupCommand,
53
+ })
54
+ await requestShutdown(0)
55
+ }
56
+
47
57
  export async function getRootSessionPath(item: Item): Promise<string> {
48
58
  const itemPath = item.isSession ? await getTmuxSessionDirectory(item.title) : item.path
49
- return (await getGitRoot(itemPath)) ?? itemPath
59
+ const searchRoot = !item.isSession && isFileItem(item) ? dirname(itemPath) : itemPath
60
+ return (await getGitRoot(searchRoot)) ?? searchRoot
50
61
  }
@@ -8,12 +8,14 @@ import {
8
8
  getCurrentTmuxSessionName,
9
9
  } from '../tmux'
10
10
  import { getLastSessionTarget } from '../tmux/workflows'
11
+ import { isFileItem, resolveTypedPathTarget } from '../files/target'
11
12
  import { isGitHubURL, cloneGitHubRepo } from '../util/github'
12
13
  import { requestShutdown } from '../util/shutdown'
13
14
  import {
14
15
  buildEditorCommand,
15
16
  getNextSessionName,
16
17
  getRootSessionPath,
18
+ openFileSession,
17
19
  openProjectSession,
18
20
  requireConfig,
19
21
  requireConfiguredItem,
@@ -26,6 +28,11 @@ export async function handleSelect(item: Item, config: Config | null) {
26
28
  return
27
29
  }
28
30
 
31
+ if (isFileItem(item)) {
32
+ await openFileSession(item.path, requireConfig(config))
33
+ return
34
+ }
35
+
29
36
  await openProjectSession(item.path, requireConfig(config))
30
37
  }
31
38
 
@@ -85,13 +92,33 @@ export async function handleNewSessionSubmit(
85
92
  } catch (error) {
86
93
  throw new Error(`Error cloning repository: ${error}`)
87
94
  }
88
- } else if (items.length > 0 && cursor < items.length) {
95
+ return
96
+ }
97
+
98
+ const typedTarget = await resolveTypedPathTarget(searchTerm)
99
+ if (typedTarget) {
100
+ if (typedTarget.kind === 'file') {
101
+ await openFileSession(typedTarget.path, requireConfig(config))
102
+ return
103
+ }
104
+
105
+ await openProjectSession(typedTarget.path, requireConfig(config))
106
+ return
107
+ }
108
+
109
+ if (items.length > 0 && cursor < items.length) {
89
110
  const selectedItem = items[cursor]
111
+ if (isFileItem(selectedItem)) {
112
+ await openFileSession(selectedItem.path, requireConfig(config))
113
+ return
114
+ }
115
+
90
116
  await openProjectSession(selectedItem.path, requireConfig(config))
91
- } else {
92
- await createNamedTmuxSession(searchTerm)
93
- await requestShutdown(0)
117
+ return
94
118
  }
119
+
120
+ await createNamedTmuxSession(searchTerm)
121
+ await requestShutdown(0)
95
122
  }
96
123
 
97
124
  export async function handleLastSession(items: Item[]) {
@@ -111,6 +111,15 @@ export function handleNormalMode(
111
111
  return
112
112
  }
113
113
 
114
+ if (key.ctrl && keyName === 'f') {
115
+ const item = ctx.viewMode === ViewMode.Sessions ? ctx.regularSessions[ctx.cursor] : undefined
116
+ if (item) {
117
+ ctx.clearPendingKill()
118
+ void ctx.togglePinnedSession(item.title)
119
+ }
120
+ return
121
+ }
122
+
114
123
  if (!ctx.prefixKey && !isStandard && keyName === 'l') {
115
124
  ctx.clearPendingKill()
116
125
  void ctx.handleLastSession()
@@ -31,6 +31,7 @@ export interface KeyboardHandlerContext {
31
31
  setPrefixActive: (active: boolean) => void
32
32
  refreshItems: (forceViewMode?: ViewMode, nextConfig?: Config) => Promise<void>
33
33
  requestKillSession: (sessionName: string) => void
34
+ togglePinnedSession: (sessionName: string) => Promise<void>
34
35
  clearPendingKill: () => void
35
36
  handleSelect: (item: Item) => Promise<void>
36
37
  handleKillSession: (sessionName: string) => Promise<void>
@@ -1,6 +1,8 @@
1
1
  import type { Item, SortOrder } from '../types'
2
2
  import { getLiveSessionSortKey } from '../util/path-display'
3
3
 
4
+ export type SessionSection = 'pinned' | 'live' | 'configured'
5
+
4
6
  function compareByTitle(left: Item, right: Item): number {
5
7
  return left.title.localeCompare(right.title)
6
8
  }
@@ -25,6 +27,27 @@ function isConfiguredSession(item: Item): boolean {
25
27
  return item.itemKind === 'configured'
26
28
  }
27
29
 
30
+ function applyPinnedState(items: Item[], pinnedSessions: readonly string[]): Item[] {
31
+ const pinnedSet = new Set(pinnedSessions)
32
+
33
+ return items.map(item => ({
34
+ ...item,
35
+ isPinned: pinnedSet.has(item.title),
36
+ }))
37
+ }
38
+
39
+ function splitPinnedItems(items: Item[], pinnedSessions: readonly string[]) {
40
+ const itemByTitle = new Map(items.map(item => [item.title, item]))
41
+ const pinnedItems = pinnedSessions.flatMap(title => {
42
+ const item = itemByTitle.get(title)
43
+ return item ? [item] : []
44
+ })
45
+ const pinnedSet = new Set(pinnedItems.map(item => item.title))
46
+ const remainingItems = items.filter(item => !pinnedSet.has(item.title))
47
+
48
+ return { pinnedItems, remainingItems }
49
+ }
50
+
28
51
  function sortByGroup(items: Item[], groups: Array<'live' | 'configured'>): Item[] {
29
52
  const configuredItems = items.filter(isConfiguredSession).sort(compareByTitle)
30
53
  const liveItems = items.filter(item => !isConfiguredSession(item)).sort(compareLiveSessions)
@@ -36,24 +59,30 @@ function sortByGroup(items: Item[], groups: Array<'live' | 'configured'>): Item[
36
59
  return groups.flatMap(group => groupedItems.get(group) ?? [])
37
60
  }
38
61
 
39
- export function orderSessionItems(items: Item[], sortOrder: SortOrder = 'live-first'): Item[] {
40
- const opencodeItems = items.filter(isOpencodeSession).sort(compareByTitle)
41
- const regularItems = items.filter(item => !isOpencodeSession(item))
62
+ export function orderSessionItems(
63
+ items: Item[],
64
+ sortOrder: SortOrder = 'live-first',
65
+ pinnedSessions: readonly string[] = []
66
+ ): Item[] {
67
+ const itemsWithPinnedState = applyPinnedState(items, pinnedSessions)
68
+ const opencodeItems = itemsWithPinnedState.filter(isOpencodeSession).sort(compareByTitle)
69
+ const regularItems = itemsWithPinnedState.filter(item => !isOpencodeSession(item))
70
+ const { pinnedItems, remainingItems } = splitPinnedItems(regularItems, pinnedSessions)
42
71
 
43
72
  const orderedRegularItems =
44
73
  sortOrder === 'configured-first'
45
- ? sortByGroup(regularItems, ['configured', 'live'])
74
+ ? sortByGroup(remainingItems, ['configured', 'live'])
46
75
  : sortOrder === 'alphabetical'
47
- ? [...regularItems].sort((left, right) => {
76
+ ? [...remainingItems].sort((left, right) => {
48
77
  if (isConfiguredSession(left) || isConfiguredSession(right)) {
49
78
  return compareByTitle(left, right)
50
79
  }
51
80
 
52
81
  return compareLiveSessions(left, right)
53
82
  })
54
- : sortByGroup(regularItems, ['live', 'configured'])
83
+ : sortByGroup(remainingItems, ['live', 'configured'])
55
84
 
56
- return [...orderedRegularItems, ...opencodeItems]
85
+ return [...pinnedItems, ...orderedRegularItems, ...opencodeItems]
57
86
  }
58
87
 
59
88
  export function orderProjectItems(items: Item[], sortOrder: SortOrder = 'live-first'): Item[] {
@@ -64,6 +93,10 @@ export function orderProjectItems(items: Item[], sortOrder: SortOrder = 'live-fi
64
93
  return items
65
94
  }
66
95
 
67
- export function getSessionSection(item: Item): 'live' | 'configured' {
96
+ export function getSessionSection(item: Item): SessionSection {
97
+ if (item.isPinned) {
98
+ return 'pinned'
99
+ }
100
+
68
101
  return item.itemKind === 'configured' ? 'configured' : 'live'
69
102
  }
@@ -1,10 +1,11 @@
1
- import { readdir } from 'fs/promises'
2
- import { basename, join } from 'path'
1
+ import { readdir, stat } from 'fs/promises'
2
+ import { basename, dirname, join } from 'path'
3
3
  import { spawn } from 'bun'
4
4
  import { getSessionDetails } from '../tmux'
5
5
  import type { Config, SessionDetails } from '../types'
6
6
  import { stripAnsi } from '../util/ansi'
7
7
  import { getGitRoot, resolveProjectSession } from '../config/session-rules'
8
+ import { resolveFileSession } from '../files/target'
8
9
 
9
10
  const MAX_PREVIEW_LINES = 24
10
11
  const MAX_PREVIEW_LINE_LENGTH = 120
@@ -15,13 +16,13 @@ const projectPreviewCache = new Map<string, { preview: ProjectPreview; expiresAt
15
16
  export interface ProjectPreview {
16
17
  path: string
17
18
  sessionName: string
18
- source: 'project' | 'wildcard' | 'default'
19
+ source: 'project' | 'wildcard' | 'default' | 'file'
19
20
  startupCommand?: string
20
21
  previewCommand?: string
21
22
  gitRoot?: string
22
23
  gitBranch?: string
23
24
  linkedSession?: SessionDetails
24
- previewKind: 'command' | 'directory'
25
+ previewKind: 'command' | 'directory' | 'file'
25
26
  previewLabel: string
26
27
  previewLines: string[]
27
28
  previewNotice?: string
@@ -281,3 +282,81 @@ export async function getProjectPreview(
281
282
 
282
283
  return preview
283
284
  }
285
+
286
+ const FILE_PREVIEW_MAX_BYTES = 16 * 1024
287
+
288
+ async function getFilePreviewLines(
289
+ filePath: string
290
+ ): Promise<{ lines: string[]; notice?: string }> {
291
+ try {
292
+ const fileInfo = await stat(filePath)
293
+ const bytes = new Uint8Array(
294
+ await Bun.file(filePath).slice(0, FILE_PREVIEW_MAX_BYTES).arrayBuffer()
295
+ )
296
+
297
+ if (bytes.includes(0)) {
298
+ return {
299
+ lines: [`${basename(filePath)} (${fileInfo.size} bytes)`],
300
+ notice: 'Binary file; preview skipped.',
301
+ }
302
+ }
303
+
304
+ const formatted = formatPreviewOutput(new TextDecoder().decode(bytes))
305
+ return {
306
+ lines: formatted.lines.length > 0 ? formatted.lines : ['(empty file)'],
307
+ notice:
308
+ formatted.truncated || fileInfo.size > FILE_PREVIEW_MAX_BYTES
309
+ ? 'File preview truncated to fit the panel.'
310
+ : undefined,
311
+ }
312
+ } catch {
313
+ return {
314
+ lines: [basename(filePath)],
315
+ notice: 'Unable to read file contents.',
316
+ }
317
+ }
318
+ }
319
+
320
+ export async function getFilePreview(
321
+ filePath: string,
322
+ config: Config,
323
+ linkedSessionName?: string
324
+ ): Promise<ProjectPreview> {
325
+ const cacheKey = `file::${filePath}::${linkedSessionName ?? ''}`
326
+ const cached = projectPreviewCache.get(cacheKey)
327
+ if (cached && cached.expiresAt > Date.now()) {
328
+ return cached.preview
329
+ }
330
+
331
+ const parentDirectory = dirname(filePath)
332
+ const resolvedSession = resolveFileSession(filePath, config)
333
+ const [gitRootPath, gitBranch, linkedSession, fileLines] = await Promise.all([
334
+ getGitRoot(parentDirectory),
335
+ getGitBranch(parentDirectory),
336
+ linkedSessionName
337
+ ? getSessionDetails(linkedSessionName).catch(() => null)
338
+ : Promise.resolve(null),
339
+ getFilePreviewLines(filePath),
340
+ ])
341
+
342
+ const preview: ProjectPreview = {
343
+ path: displayPath(filePath),
344
+ sessionName: resolvedSession.sessionName,
345
+ source: 'file',
346
+ startupCommand: resolvedSession.startupCommand,
347
+ gitRoot: gitRootPath ? displayPath(gitRootPath) : undefined,
348
+ gitBranch,
349
+ linkedSession: linkedSession ?? undefined,
350
+ previewKind: 'file',
351
+ previewLabel: 'File Preview',
352
+ previewLines: fileLines.lines,
353
+ previewNotice: fileLines.notice,
354
+ }
355
+
356
+ projectPreviewCache.set(cacheKey, {
357
+ preview,
358
+ expiresAt: Date.now() + PROJECT_PREVIEW_CACHE_TTL_MS,
359
+ })
360
+
361
+ return preview
362
+ }
@@ -1,5 +1,6 @@
1
1
  import type { Config, Item } from '../types'
2
2
  import { resolveProjectSession } from '../config/session-rules'
3
+ import { buildFileSessionName, isFileItem } from '../files/target'
3
4
 
4
5
  export async function annotateProjectItemsWithSessionLinks(
5
6
  projectItems: Item[],
@@ -10,8 +11,10 @@ export async function annotateProjectItemsWithSessionLinks(
10
11
 
11
12
  return Promise.all(
12
13
  projectItems.map(async projectItem => {
13
- const resolvedSession = await resolveProjectSession(projectItem.path, config)
14
- const linkedSession = liveSessionsByTitle.get(resolvedSession.sessionName)
14
+ const sessionName = isFileItem(projectItem)
15
+ ? buildFileSessionName(projectItem.path)
16
+ : (await resolveProjectSession(projectItem.path, config)).sessionName
17
+ const linkedSession = liveSessionsByTitle.get(sessionName)
15
18
 
16
19
  if (!linkedSession) {
17
20
  return {