mux-sesh 1.6.3 → 1.6.4

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.3",
3
+ "version": "1.6.4",
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
@@ -24,7 +24,7 @@ import SessionList from './ui/SessionList'
24
24
  import OpencodeSessionGroup from './ui/OpencodeSessionGroup'
25
25
  import SearchInput from './ui/SearchInput'
26
26
  import ItemList from './ui/ItemList'
27
- import VersionBadge from './ui/VersionBadge'
27
+ import VersionBadge, { formatVersionBadge } from './ui/VersionBadge'
28
28
  import RenameModal from './ui/RenameModal'
29
29
  import CommandsModal, { filterCommandEntries, getCommandEntries, type CommandId } from './ui/CommandsModal'
30
30
  import SettingsModal from './ui/SettingsModal'
@@ -749,15 +749,26 @@ export function App() {
749
749
  let cancelled = false
750
750
 
751
751
  async function loadSessionCandidates() {
752
- const candidates = await measure('loadSessionCandidateItems', () => getSessionCandidateItems(nextConfig))
752
+ const [candidates, sessions] = await measure('loadSessionCandidateItems', () =>
753
+ Promise.all([getSessionCandidateItems(nextConfig), listTmuxSessions()])
754
+ )
753
755
  if (cancelled) {
754
756
  return
755
757
  }
756
758
 
757
- setSessionCandidateItems(candidates)
758
- setAllItems(candidates)
759
- setItems(candidates)
760
- setCursor(getProjectSelectionIndex(candidates))
759
+ const visibleSessions = filterHiddenSessions(sessions, nextConfig.hiddenSessions)
760
+ const linkedCandidates = await measure('linkSessionCandidateItems', () =>
761
+ annotateProjectItemsWithSessionLinks(candidates, visibleSessions, nextConfig)
762
+ )
763
+
764
+ if (cancelled) {
765
+ return
766
+ }
767
+
768
+ setSessionCandidateItems(linkedCandidates)
769
+ setAllItems(linkedCandidates)
770
+ setItems(linkedCandidates)
771
+ setCursor(getProjectSelectionIndex(linkedCandidates))
761
772
  }
762
773
 
763
774
  void loadSessionCandidates()
@@ -892,6 +903,7 @@ export function App() {
892
903
  const activeSessions = items.filter(item => item.isSession && item.isAttached).length
893
904
  const maxVisibleItems = Math.max(8, rows - (appMode === AppMode.NewSession ? 10 : 12))
894
905
  const prefixLabel = config?.prefixKey ? `${config.prefixKey} ...` : 'direct keys'
906
+ const versionLabel = formatVersionBadge(CURRENT_VERSION, updatedVersion)
895
907
  const footerHint =
896
908
  appMode === AppMode.OpencodeManage
897
909
  ? `o back d kill ctrl+p commands ${prefixLabel}`
@@ -905,115 +917,138 @@ export function App() {
905
917
  <ThemeProvider theme={theme}>
906
918
  <box
907
919
  style={{
908
- flexDirection: 'row',
909
- alignItems: 'stretch',
910
- justifyContent: 'center',
920
+ flexDirection: 'column',
911
921
  width: '100%',
912
922
  height: '100%',
913
923
  gap: 1,
914
924
  backgroundColor: theme.background,
915
925
  }}
916
926
  >
917
- <box style={listStyle}>
918
- <box style={{ justifyContent: 'space-between', marginBottom: 1 }}>
919
- <box style={{ flexDirection: 'column' }}>
920
- <text style={{ fg: theme.text }}>mux-sesh</text>
921
- <text style={{ fg: theme.textSubtle }}>{title}</text>
922
- </box>
923
- <box style={{ flexDirection: 'column', alignItems: 'flex-end' }}>
924
- <text style={{ fg: theme.textMuted }}>
925
- {viewMode === ViewMode.Sessions ? `${activeSessions}/${totalSessions} active` : `${projectItems.length} projects`}
926
- </text>
927
- <text style={{ fg: theme.textSubtle }}>{`${resolvedTheme.name} · ${resolvedTheme.mode}`}</text>
927
+ <box
928
+ style={{
929
+ flexDirection: 'row',
930
+ alignItems: 'stretch',
931
+ justifyContent: 'center',
932
+ width: '100%',
933
+ flexGrow: 1,
934
+ flexShrink: 1,
935
+ gap: 1,
936
+ }}
937
+ >
938
+ <box style={listStyle}>
939
+ <box style={{ justifyContent: 'space-between', marginBottom: 1 }}>
940
+ <box style={{ flexDirection: 'column' }}>
941
+ <text style={{ fg: theme.text }}>mux-sesh</text>
942
+ <text style={{ fg: theme.textSubtle }}>{title}</text>
943
+ </box>
944
+ <box style={{ flexDirection: 'column', alignItems: 'flex-end' }}>
945
+ <text style={{ fg: theme.textMuted }}>
946
+ {viewMode === ViewMode.Sessions ? `${activeSessions}/${totalSessions} active` : `${projectItems.length} projects`}
947
+ </text>
948
+ </box>
928
949
  </box>
929
- </box>
930
950
 
931
- {(appMode === AppMode.Search || appMode === AppMode.NewSession) && (
932
- <SearchInput
933
- key={appMode}
934
- appMode={appMode}
935
- searchQuery={searchQuery}
936
- textareaRef={textareaRef}
937
- prefixActive={prefixActive}
938
- onContentChange={() => {
939
- if (textareaRef.current && textareaRef.current.plainText !== undefined) {
940
- setSearchQuery(textareaRef.current.plainText)
941
- }
942
- }}
943
- />
944
- )}
951
+ {(appMode === AppMode.Search || appMode === AppMode.NewSession) && (
952
+ <SearchInput
953
+ key={appMode}
954
+ appMode={appMode}
955
+ searchQuery={searchQuery}
956
+ textareaRef={textareaRef}
957
+ prefixActive={prefixActive}
958
+ onContentChange={() => {
959
+ if (textareaRef.current && textareaRef.current.plainText !== undefined) {
960
+ setSearchQuery(textareaRef.current.plainText)
961
+ }
962
+ }}
963
+ />
964
+ )}
945
965
 
946
- <box
947
- style={{
948
- alignSelf: 'auto',
949
- flexDirection: 'column',
950
- flexGrow: 0,
951
- flexShrink: 0,
952
- marginTop:
953
- viewMode === ViewMode.Sessions && (appMode === AppMode.Normal || appMode === AppMode.OpencodeManage)
954
- ? 1
955
- : 0,
956
- }}
957
- >
958
- {items.length === 0 ? (
959
- <text style={{ fg: theme.inactive }}>
960
- {appMode === AppMode.NewSession && searchQuery && isGitHubURL(searchQuery)
961
- ? 'Clone & create session'
962
- : appMode === AppMode.NewSession && searchQuery
963
- ? `Create session: ${searchQuery}`
964
- : 'No items found'}
965
- </text>
966
- ) : viewMode === ViewMode.Sessions && (appMode === AppMode.Normal || appMode === AppMode.OpencodeManage) ? (
967
- <>
968
- <SessionList
969
- items={regularSessions}
966
+ <box
967
+ style={{
968
+ alignSelf: 'auto',
969
+ flexDirection: 'column',
970
+ flexGrow: 0,
971
+ flexShrink: 0,
972
+ marginTop:
973
+ viewMode === ViewMode.Sessions && (appMode === AppMode.Normal || appMode === AppMode.OpencodeManage)
974
+ ? 1
975
+ : 0,
976
+ }}
977
+ >
978
+ {items.length === 0 ? (
979
+ <text style={{ fg: theme.inactive }}>
980
+ {appMode === AppMode.NewSession && searchQuery && isGitHubURL(searchQuery)
981
+ ? 'Clone & create session'
982
+ : appMode === AppMode.NewSession && searchQuery
983
+ ? `Create session: ${searchQuery}`
984
+ : 'No items found'}
985
+ </text>
986
+ ) : viewMode === ViewMode.Sessions && (appMode === AppMode.Normal || appMode === AppMode.OpencodeManage) ? (
987
+ <>
988
+ <SessionList
989
+ items={regularSessions}
990
+ cursor={cursor}
991
+ searchQuery={searchQuery}
992
+ maxItems={maxVisibleItems}
993
+ icons={config?.icons}
994
+ pendingKillSessionName={pendingKillSessionName}
995
+ />
996
+
997
+ <OpencodeSessionGroup
998
+ sessions={opencodeSessions}
999
+ appMode={appMode}
1000
+ cursor={opencodeCursor}
1001
+ icons={config?.icons}
1002
+ pendingKillSessionName={pendingKillSessionName}
1003
+ />
1004
+ </>
1005
+ ) : (
1006
+ <ItemList
1007
+ items={items}
970
1008
  cursor={cursor}
1009
+ appMode={appMode}
971
1010
  searchQuery={searchQuery}
972
1011
  maxItems={maxVisibleItems}
973
1012
  icons={config?.icons}
974
1013
  pendingKillSessionName={pendingKillSessionName}
975
1014
  />
976
-
977
- <OpencodeSessionGroup
978
- sessions={opencodeSessions}
979
- appMode={appMode}
980
- cursor={opencodeCursor}
981
- icons={config?.icons}
982
- pendingKillSessionName={pendingKillSessionName}
983
- />
984
- </>
985
- ) : (
986
- <ItemList
987
- items={items}
988
- cursor={cursor}
989
- appMode={appMode}
990
- searchQuery={searchQuery}
991
- maxItems={maxVisibleItems}
992
- icons={config?.icons}
993
- pendingKillSessionName={pendingKillSessionName}
994
- />
995
- )}
1015
+ )}
1016
+ </box>
996
1017
  </box>
997
1018
 
998
- {(message || columns < 80 || footerHint) && (
999
- <box style={{ flexDirection: 'column', marginTop: 1 }}>
1000
- {message && <text style={{ fg: theme.action }}>{message}</text>}
1001
- {columns < 80 && appMode !== AppMode.NewSession && (
1002
- <text style={{ fg: theme.textSubtle }}>Resize for the detail pane.</text>
1019
+ {shouldShowDetailPanel(columns, appMode === AppMode.NewSession) && (
1020
+ <>
1021
+ {viewMode === ViewMode.Sessions && appMode === AppMode.OpencodeManage ? (
1022
+ <OpencodeStatsPanel selectedItem={opencodeSessions[opencodeCursor]} />
1023
+ ) : (
1024
+ <SessionDetailsPanel selectedItem={selectedPrimaryItem} config={config} />
1003
1025
  )}
1004
- <text style={{ fg: theme.textSubtle }}>{footerHint}</text>
1005
- </box>
1026
+ </>
1006
1027
  )}
1007
1028
  </box>
1008
1029
 
1009
- {shouldShowDetailPanel(columns, appMode === AppMode.NewSession) && (
1010
- <>
1011
- {viewMode === ViewMode.Sessions && appMode === AppMode.OpencodeManage ? (
1012
- <OpencodeStatsPanel selectedItem={opencodeSessions[opencodeCursor]} />
1013
- ) : (
1014
- <SessionDetailsPanel selectedItem={selectedPrimaryItem} config={config} />
1030
+ {(message || columns < 80 || footerHint) && (
1031
+ <box
1032
+ style={{
1033
+ backgroundColor: theme.surface,
1034
+ position: 'absolute',
1035
+ bottom: 0,
1036
+ left: 0,
1037
+ paddingTop: 0.4,
1038
+ paddingBottom: 0.4,
1039
+ paddingLeft: 1,
1040
+ paddingRight: versionLabel.length + 3,
1041
+ width: '100%',
1042
+ flexDirection: 'column',
1043
+ flexShrink: 0,
1044
+ }}
1045
+ >
1046
+ {message && <text style={{ fg: theme.action }}>{message}</text>}
1047
+ {columns < 80 && appMode !== AppMode.NewSession && (
1048
+ <text style={{ fg: theme.textSubtle }}>Resize for the detail pane.</text>
1015
1049
  )}
1016
- </>
1050
+ <text style={{ fg: theme.textSubtle }}>{footerHint}</text>
1051
+ </box>
1017
1052
  )}
1018
1053
 
1019
1054
  {modalState?.type === 'rename' && (
@@ -1,9 +1,6 @@
1
1
  import type { Config, Item, ProjectProfile } from '../types'
2
2
  import { resolveProjectSession } from './session-rules'
3
-
4
- function displayPath(path: string): string {
5
- return path.replace(process.env.HOME || '', '~')
6
- }
3
+ import { getPathGroupLabel } from '../util/path-display'
7
4
 
8
5
  function isListedProjectProfile(profile: ProjectProfile): boolean {
9
6
  return profile.listed === true
@@ -18,7 +15,7 @@ export async function getListedSessionItems(config: Config): Promise<Item[]> {
18
15
 
19
16
  return {
20
17
  title: resolvedSession.sessionName,
21
- desc: displayPath(profile.path),
18
+ desc: getPathGroupLabel(profile.path),
22
19
  path: profile.path,
23
20
  isSession: false,
24
21
  itemKind: 'configured' as const,
@@ -50,8 +50,8 @@ export async function getGitRoot(projectPath: string): Promise<string | null> {
50
50
  }
51
51
  }
52
52
 
53
- function buildSessionName(projectPath: string, dirLength = 1, gitRoot: string | null): string {
54
- const namingPath = normalizePathForMatching(gitRoot ?? projectPath)
53
+ function buildSessionName(projectPath: string, dirLength = 1): string {
54
+ const namingPath = normalizePathForMatching(projectPath)
55
55
  const parts = namingPath.split('/').filter(Boolean)
56
56
  const segmentCount = Math.max(1, dirLength)
57
57
  const relevantParts = parts.slice(-segmentCount)
@@ -63,16 +63,14 @@ function buildSessionName(projectPath: string, dirLength = 1, gitRoot: string |
63
63
  export async function resolveProjectSession(
64
64
  projectPath: string,
65
65
  config: Config,
66
- options: ResolveProjectSessionOptions = {}
66
+ _options: ResolveProjectSessionOptions = {}
67
67
  ): Promise<ResolvedProjectSession> {
68
68
  const normalizedProjectPath = normalizePathForMatching(projectPath)
69
- const getGitRootForPath = options.getGitRoot ?? getGitRoot
70
69
  const projectProfile = findProjectProfile(normalizedProjectPath, config)
71
70
 
72
71
  if (projectProfile) {
73
- const gitRoot = await getGitRootForPath(projectPath)
74
72
  return {
75
- sessionName: sanitizeSessionName(projectProfile.sessionName ?? buildSessionName(projectPath, config.dirLength, gitRoot)),
73
+ sessionName: sanitizeSessionName(projectProfile.sessionName ?? buildSessionName(projectPath, config.dirLength)),
76
74
  startupCommand: projectProfile.startupCommand ?? config.defaultSession?.startupCommand,
77
75
  previewCommand: projectProfile.previewCommand ?? config.defaultSession?.previewCommand,
78
76
  source: 'project',
@@ -81,19 +79,16 @@ export async function resolveProjectSession(
81
79
 
82
80
  const wildcard = findWildcard(normalizedProjectPath, config)
83
81
  if (wildcard) {
84
- const gitRoot = await getGitRootForPath(projectPath)
85
82
  return {
86
- sessionName: sanitizeSessionName(wildcard.sessionName ?? buildSessionName(projectPath, config.dirLength, gitRoot)),
83
+ sessionName: sanitizeSessionName(wildcard.sessionName ?? buildSessionName(projectPath, config.dirLength)),
87
84
  startupCommand: wildcard.startupCommand ?? config.defaultSession?.startupCommand,
88
85
  previewCommand: wildcard.previewCommand ?? config.defaultSession?.previewCommand,
89
86
  source: 'wildcard',
90
87
  }
91
88
  }
92
89
 
93
- const gitRoot = await getGitRootForPath(projectPath)
94
-
95
90
  return {
96
- sessionName: buildSessionName(projectPath, config.dirLength, gitRoot),
91
+ sessionName: buildSessionName(projectPath, config.dirLength),
97
92
  startupCommand: config.defaultSession?.startupCommand,
98
93
  previewCommand: config.defaultSession?.previewCommand,
99
94
  source: 'default',
@@ -1,9 +1,22 @@
1
1
  import type { Item, SortOrder } from '../types'
2
+ import { getLiveSessionSortKey } from '../util/path-display'
2
3
 
3
4
  function compareByTitle(left: Item, right: Item): number {
4
5
  return left.title.localeCompare(right.title)
5
6
  }
6
7
 
8
+ function compareLiveSessions(left: Item, right: Item): number {
9
+ const leftGroupKey = getLiveSessionSortKey(left.path, left.title)
10
+ const rightGroupKey = getLiveSessionSortKey(right.path, right.title)
11
+ const groupDifference = leftGroupKey.localeCompare(rightGroupKey)
12
+
13
+ if (groupDifference !== 0) {
14
+ return groupDifference
15
+ }
16
+
17
+ return left.title.localeCompare(right.title)
18
+ }
19
+
7
20
  function isOpencodeSession(item: Item): boolean {
8
21
  return item.isSession && item.title.startsWith('opencode-')
9
22
  }
@@ -14,7 +27,7 @@ function isConfiguredSession(item: Item): boolean {
14
27
 
15
28
  function sortByGroup(items: Item[], groups: Array<'live' | 'configured'>): Item[] {
16
29
  const configuredItems = items.filter(isConfiguredSession).sort(compareByTitle)
17
- const liveItems = items.filter(item => !isConfiguredSession(item)).sort(compareByTitle)
30
+ const liveItems = items.filter(item => !isConfiguredSession(item)).sort(compareLiveSessions)
18
31
  const groupedItems = new Map([
19
32
  ['configured', configuredItems],
20
33
  ['live', liveItems],
@@ -31,7 +44,13 @@ export function orderSessionItems(items: Item[], sortOrder: SortOrder = 'live-fi
31
44
  sortOrder === 'configured-first'
32
45
  ? sortByGroup(regularItems, ['configured', 'live'])
33
46
  : sortOrder === 'alphabetical'
34
- ? [...regularItems].sort(compareByTitle)
47
+ ? [...regularItems].sort((left, right) => {
48
+ if (isConfiguredSession(left) || isConfiguredSession(right)) {
49
+ return compareByTitle(left, right)
50
+ }
51
+
52
+ return compareLiveSessions(left, right)
53
+ })
35
54
  : sortByGroup(regularItems, ['live', 'configured'])
36
55
 
37
56
  return [...orderedRegularItems, ...opencodeItems]
package/src/tmux/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { spawn } from 'bun'
2
2
  import type { Item, SessionDetails, WindowInfo } from '../types'
3
+ import { getLiveSessionGroupLabel } from '../util/path-display'
3
4
 
4
5
  const SESSION_DETAILS_CACHE_TTL_MS = 4000
5
6
  const sessionDetailsCache = new Map<string, { details: SessionDetails; expiresAt: number }>()
@@ -47,18 +48,19 @@ export async function listTmuxSessions(): Promise<Item[]> {
47
48
  'tmux',
48
49
  'list-sessions',
49
50
  '-F',
50
- '#{session_name}:#{session_attached}:#{session_windows}:#{session_created}:#{session_activity}',
51
+ '#{session_name}\t#{session_attached}\t#{session_windows}\t#{session_created}\t#{session_activity}\t#{session_path}',
51
52
  ])
52
53
 
53
54
  const output = await new Response(proc.stdout).text()
54
55
  const lines = output.trim().split('\n').filter(Boolean)
55
56
 
56
57
  const sessions = lines.map(line => {
57
- const [name, attached, windows, created, activity] = line.split(':')
58
+ const [name, attached, windows, created, activity, sessionPath = ''] = line.split('\t')
59
+
58
60
  return {
59
61
  title: name,
60
- path: name,
61
- desc: '',
62
+ path: sessionPath,
63
+ desc: getLiveSessionGroupLabel(sessionPath),
62
64
  isSession: true,
63
65
  itemKind: 'tmux' as const,
64
66
  isAttached: attached === '1',
@@ -68,7 +70,7 @@ export async function listTmuxSessions(): Promise<Item[]> {
68
70
  }
69
71
  })
70
72
 
71
- return sessions.sort((a, b) => a.title.localeCompare(b.title))
73
+ return sessions
72
74
  }
73
75
 
74
76
  export async function createTmuxSession(
@@ -3,6 +3,7 @@ import { basename } from 'path'
3
3
  import { access, stat } from 'fs/promises'
4
4
  import type { Config, Item } from '../types'
5
5
  import { normalizePathForMatching } from '../util/glob'
6
+ import { getPathContextLabel } from '../util/path-display'
6
7
 
7
8
  interface ZoxideEntry {
8
9
  score: number
@@ -34,7 +35,7 @@ function isIgnoredProjectDirectory(baseName: string): boolean {
34
35
  function toProjectItem(projectPath: string): Item {
35
36
  return {
36
37
  title: basename(projectPath),
37
- desc: projectPath.replace(process.env.HOME || '', '~'),
38
+ desc: getPathContextLabel(projectPath),
38
39
  path: projectPath,
39
40
  isSession: false,
40
41
  itemKind: 'project',
@@ -63,21 +63,26 @@ export default function ItemList({
63
63
  ) : (
64
64
  <span style={{ fg: theme.text }}>{item.title}</span>
65
65
  )}
66
+ {item.desc ? <span style={{ fg: theme.textSubtle }}>{` ${item.desc}`}</span> : null}
66
67
  </>
67
68
  ) : (
68
69
  <>
69
70
  <span style={{ fg: icon.color }}>{icon.glyph}</span>{' '}
70
- {appMode === AppMode.NewSession ? (
71
- isSearching && hasDescMatch ? (
72
- <HighlightedText text={item.desc} matchIndices={descMatchIndices} />
73
- ) : (
74
- <span style={{ fg: theme.text }}>{item.desc}</span>
75
- )
76
- ) : isSearching && hasTitleMatch ? (
71
+ {isSearching && hasTitleMatch ? (
77
72
  <HighlightedText text={item.title} matchIndices={titleMatchIndices} />
78
73
  ) : (
79
74
  <span style={{ fg: theme.text }}>{item.title}</span>
80
75
  )}
76
+ {item.desc ? (
77
+ <>
78
+ <span style={{ fg: theme.textSubtle }}>{' '}</span>
79
+ {isSearching && hasDescMatch ? (
80
+ <HighlightedText text={item.desc} matchIndices={descMatchIndices} />
81
+ ) : (
82
+ <span style={{ fg: theme.textSubtle }}>{item.desc}</span>
83
+ )}
84
+ </>
85
+ ) : null}
81
86
  </>
82
87
  )}
83
88
  </text>
@@ -89,7 +94,7 @@ export default function ItemList({
89
94
  : `(${item.windowCount})`
90
95
  : appMode === AppMode.NewSession
91
96
  ? `${sessionStatusLabel}${linkedSessionLabel}`
92
- : item.desc ?? ''}
97
+ : ''}
93
98
  </text>
94
99
  </box>
95
100
  )
@@ -5,6 +5,7 @@ import { getSessionSection } from '../items/order'
5
5
  import HighlightedText from './HighlightedText'
6
6
  import { formatSectionHeader, getItemIconPresentation } from './item-icon'
7
7
  import { getVisibleWindow } from './list-window'
8
+ import { getMutedLabelColumnWidth, getMutedLabelSpacer } from './text-columns'
8
9
 
9
10
  interface Props {
10
11
  items: Item[]
@@ -26,6 +27,7 @@ export default function SessionList({
26
27
  const theme = useTheme()
27
28
  const isSearching = searchQuery.trim().length > 0
28
29
  const visibleWindow = getVisibleWindow(items, cursor, maxItems)
30
+ const mutedLabelColumnWidth = getMutedLabelColumnWidth(items)
29
31
 
30
32
  return (
31
33
  <>
@@ -41,6 +43,7 @@ export default function SessionList({
41
43
  const sectionHeader = formatSectionHeader(theme, currentSection, icons)
42
44
  const pendingKill = item.title === pendingKillSessionName
43
45
  const selected = absoluteIndex === cursor
46
+ const mutedLabelSpacer = item.isSession && item.desc ? getMutedLabelSpacer(item.title, mutedLabelColumnWidth) : ''
44
47
 
45
48
  return (
46
49
  <box key={i} style={{ flexDirection: 'column' }}>
@@ -68,6 +71,7 @@ export default function SessionList({
68
71
  ) : (
69
72
  <span style={{ fg: theme.text }}>{item.title}</span>
70
73
  )}
74
+ {item.isSession && item.desc ? <span style={{ fg: theme.textSubtle }}>{`${mutedLabelSpacer}${item.desc}`}</span> : null}
71
75
  </text>
72
76
 
73
77
  <text style={{ fg: pendingKill ? theme.danger : theme.textSubtle }}>
@@ -0,0 +1,17 @@
1
+ import type { Item } from '../types'
2
+
3
+ const MIN_COLUMN_GAP = 2
4
+
5
+ export function getMutedLabelColumnWidth(items: Item[]): number {
6
+ return items.reduce((maxWidth, item) => {
7
+ if (!item.isSession || !item.desc) {
8
+ return maxWidth
9
+ }
10
+
11
+ return Math.max(maxWidth, item.title.length)
12
+ }, 0)
13
+ }
14
+
15
+ export function getMutedLabelSpacer(title: string, columnWidth: number): string {
16
+ return ' '.repeat(Math.max(MIN_COLUMN_GAP, columnWidth - title.length + MIN_COLUMN_GAP))
17
+ }
@@ -0,0 +1,98 @@
1
+ import { basename, dirname } from 'path'
2
+
3
+ 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
+ }