mux-sesh 1.9.4 → 1.9.6

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 (48) hide show
  1. package/README.md +27 -9
  2. package/package.json +12 -10
  3. package/src/agents/session-name.ts +11 -2
  4. package/src/app/commands.ts +8 -8
  5. package/src/app/controller.ts +16 -4
  6. package/src/app/controls.ts +11 -9
  7. package/src/app/core-state.ts +5 -1
  8. package/src/app/data.ts +40 -5
  9. package/src/app/derived.ts +3 -3
  10. package/src/app/effects.ts +132 -15
  11. package/src/app/handlers.ts +42 -18
  12. package/src/app/keyboard.ts +3 -3
  13. package/src/app/modals.ts +8 -8
  14. package/src/app/runtime.ts +4 -1
  15. package/src/app/screen.tsx +11 -3
  16. package/src/app/state.ts +24 -4
  17. package/src/app/view.ts +17 -6
  18. package/src/config/index.ts +10 -0
  19. package/src/handlers/action-helpers.ts +22 -7
  20. package/src/handlers/actions.ts +51 -42
  21. package/src/handlers/keyboard/agents.ts +36 -14
  22. package/src/handlers/keyboard/new-session.ts +1 -1
  23. package/src/handlers/keyboard/normal.ts +8 -8
  24. package/src/handlers/keyboard/search.ts +6 -6
  25. package/src/handlers/keyboard/shared.ts +3 -3
  26. package/src/herdr/backend.ts +357 -0
  27. package/src/herdr/protocol.ts +268 -0
  28. package/src/items/order.ts +3 -7
  29. package/src/multiplexer/backend.ts +43 -0
  30. package/src/multiplexer/command.ts +48 -0
  31. package/src/multiplexer/index.ts +21 -0
  32. package/src/multiplexer/items.ts +66 -0
  33. package/src/multiplexer/resolve.ts +106 -0
  34. package/src/multiplexer/tmux-backend.ts +87 -0
  35. package/src/multiplexer/types.ts +93 -0
  36. package/src/opencode/session-name.ts +4 -2
  37. package/src/preview/project.ts +13 -11
  38. package/src/projects/session-links.ts +22 -4
  39. package/src/settings.ts +19 -0
  40. package/src/tmux/workflows.ts +5 -1
  41. package/src/types/index.ts +13 -1
  42. package/src/ui/AgentSessionGroup.tsx +25 -10
  43. package/src/ui/CommandsModal.tsx +15 -7
  44. package/src/ui/ItemList.tsx +3 -2
  45. package/src/ui/SessionDetailsPanel.tsx +68 -34
  46. package/src/ui/SessionList.tsx +23 -7
  47. package/src/ui/item-icon.ts +20 -7
  48. package/src/ui/session-meta.ts +10 -0
@@ -0,0 +1,48 @@
1
+ import { spawn } from 'bun'
2
+
3
+ export interface CommandResult {
4
+ exitCode: number
5
+ stdout: string
6
+ stderr: string
7
+ }
8
+
9
+ export interface CommandOptions {
10
+ inheritStdio?: boolean
11
+ }
12
+
13
+ export interface CommandRunner {
14
+ run(command: readonly string[], options?: CommandOptions): Promise<CommandResult>
15
+ }
16
+
17
+ async function readStream(stream: unknown): Promise<string> {
18
+ return stream instanceof ReadableStream ? new Response(stream).text() : ''
19
+ }
20
+
21
+ export function createCommandRunner(): CommandRunner {
22
+ return {
23
+ async run(command, options = {}): Promise<CommandResult> {
24
+ try {
25
+ const proc = spawn(
26
+ [...command],
27
+ options.inheritStdio
28
+ ? { stdin: 'inherit', stdout: 'inherit', stderr: 'inherit' }
29
+ : { stdout: 'pipe', stderr: 'pipe' }
30
+ )
31
+ const stdoutPromise = readStream(proc.stdout)
32
+ const stderrPromise = readStream(proc.stderr)
33
+ await proc.exited
34
+ return {
35
+ exitCode: proc.exitCode ?? 1,
36
+ stdout: await stdoutPromise,
37
+ stderr: await stderrPromise,
38
+ }
39
+ } catch (error) {
40
+ return {
41
+ exitCode: 127,
42
+ stdout: '',
43
+ stderr: error instanceof Error ? error.message : 'Unable to start command',
44
+ }
45
+ }
46
+ },
47
+ }
48
+ }
@@ -0,0 +1,21 @@
1
+ export { probeBackendAvailability, probeHerdrAvailability, resolveBackendKind } from './resolve'
2
+ export type { BackendAvailability, BackendState } from './resolve'
3
+ export { MultiplexerError } from './types'
4
+ export { createCommandRunner } from './command'
5
+ export { resolveMultiplexerBackend } from './backend'
6
+ export { createTmuxBackend } from './tmux-backend'
7
+ export type { CommandOptions, CommandResult, CommandRunner } from './command'
8
+ export type {
9
+ AgentStatus,
10
+ BackendKind,
11
+ BackendPreference,
12
+ HerdrAgentTarget,
13
+ LiveWorkspace,
14
+ MultiplexerBackend,
15
+ MultiplexerCapabilities,
16
+ OpenWorkspaceInput,
17
+ WorkspaceAgentDetails,
18
+ WorkspaceDetails,
19
+ WorkspaceRef,
20
+ WorkspaceUnitDetails,
21
+ } from './types'
@@ -0,0 +1,66 @@
1
+ import type { Item } from '../types'
2
+ import type { HerdrAgentTarget, LiveWorkspace, WorkspaceRef } from './types'
3
+ import { getLiveSessionGroupLabel } from '../util/path-display'
4
+
5
+ export interface LiveSessionItem extends Item {
6
+ isSession: true
7
+ itemKind: 'tmux' | 'herdr'
8
+ sessionId: string
9
+ backend: 'tmux' | 'herdr'
10
+ target?: HerdrAgentTarget
11
+ }
12
+
13
+ export function workspaceToItem(workspace: LiveWorkspace): LiveSessionItem {
14
+ return {
15
+ title: workspace.title,
16
+ desc: getLiveSessionGroupLabel(workspace.path),
17
+ path: workspace.path,
18
+ isSession: true,
19
+ itemKind: workspace.backend,
20
+ sessionId: workspace.id,
21
+ backend: workspace.backend,
22
+ target: workspace.backend === 'herdr' ? workspace.target : undefined,
23
+ workspaceTitle: workspace.workspaceTitle,
24
+ agentStatus: workspace.agentStatus,
25
+ isAttached: workspace.isActive,
26
+ windowCount: String(workspace.unitCount),
27
+ createdAt: workspace.createdAt,
28
+ lastActivity: workspace.lastActivity,
29
+ }
30
+ }
31
+
32
+ export function isLiveSessionItem(item: Item): item is LiveSessionItem {
33
+ return (
34
+ item.isSession &&
35
+ (item.itemKind === 'tmux' || item.itemKind === 'herdr') &&
36
+ item.backend === item.itemKind &&
37
+ typeof item.sessionId === 'string'
38
+ )
39
+ }
40
+
41
+ export function isHerdrAgentItem(
42
+ item: Item | undefined
43
+ ): item is LiveSessionItem & { backend: 'herdr'; target: HerdrAgentTarget } {
44
+ return (
45
+ item !== undefined &&
46
+ isLiveSessionItem(item) &&
47
+ item.backend === 'herdr' &&
48
+ item.target?.kind === 'agent'
49
+ )
50
+ }
51
+
52
+ export function getWorkspaceRef(item: LiveSessionItem): WorkspaceRef {
53
+ return item.backend === 'herdr'
54
+ ? { backend: 'herdr', id: item.sessionId, title: item.title, target: item.target }
55
+ : { backend: 'tmux', id: item.sessionId, title: item.title }
56
+ }
57
+
58
+ export function getSessionKey(item: LiveSessionItem): string {
59
+ return item.target
60
+ ? `${item.backend}:${item.sessionId}:agent:${item.target.paneId}`
61
+ : `${item.backend}:${item.sessionId}`
62
+ }
63
+
64
+ export function getItemKey(item: Item): string {
65
+ return isLiveSessionItem(item) ? getSessionKey(item) : `${item.itemKind ?? 'item'}:${item.title}`
66
+ }
@@ -0,0 +1,106 @@
1
+ import { MultiplexerError, type BackendKind, type BackendPreference } from './types'
2
+ import type { CommandRunner } from './command'
3
+ import { parseHerdrStatus, SUPPORTED_HERDR_PROTOCOL } from '../herdr/protocol'
4
+
5
+ export interface BackendState {
6
+ installed: boolean
7
+ running: boolean
8
+ compatible?: boolean
9
+ }
10
+
11
+ export interface BackendAvailability {
12
+ tmux: BackendState
13
+ herdr: BackendState
14
+ }
15
+
16
+ export async function probeHerdrAvailability(runner: CommandRunner): Promise<BackendState> {
17
+ const result = await runner.run(['herdr', 'status', '--json'])
18
+ if (result.exitCode !== 0) {
19
+ return { installed: result.exitCode !== 127, running: false }
20
+ }
21
+ const status = parseHerdrStatus(result.stdout)
22
+ return {
23
+ installed: true,
24
+ running: status.running,
25
+ compatible: status.compatible === true && status.protocol === SUPPORTED_HERDR_PROTOCOL,
26
+ }
27
+ }
28
+
29
+ export async function probeBackendAvailability(
30
+ runner: CommandRunner
31
+ ): Promise<BackendAvailability> {
32
+ const [tmuxVersion, tmuxServer, herdr] = await Promise.all([
33
+ runner.run(['tmux', '-V']),
34
+ runner.run(['tmux', 'list-sessions']),
35
+ probeHerdrAvailability(runner),
36
+ ])
37
+ const tmuxInstalled = tmuxVersion.exitCode === 0
38
+
39
+ return {
40
+ tmux: { installed: tmuxInstalled, running: tmuxInstalled && tmuxServer.exitCode === 0 },
41
+ herdr,
42
+ }
43
+ }
44
+
45
+ export function resolveBackendKind(
46
+ env: Readonly<Record<string, string | undefined>>,
47
+ preference: BackendPreference | undefined,
48
+ availability: BackendAvailability
49
+ ): BackendKind {
50
+ if (env.HERDR_ENV === '1') {
51
+ return 'herdr'
52
+ }
53
+
54
+ if (env.TMUX) {
55
+ return 'tmux'
56
+ }
57
+
58
+ if (preference === 'herdr') {
59
+ if (availability.herdr.running && availability.herdr.compatible !== true) {
60
+ throw new MultiplexerError(
61
+ 'protocol-mismatch',
62
+ 'Herdr is configured, but its client and server protocols are incompatible. Restart the Herdr server, then relaunch mux-sesh.'
63
+ )
64
+ }
65
+ if (!availability.herdr.running) {
66
+ throw new MultiplexerError(
67
+ 'server-stopped',
68
+ 'Herdr is configured, but its server is not running. Start Herdr, then relaunch mux-sesh.'
69
+ )
70
+ }
71
+ return 'herdr'
72
+ }
73
+
74
+ if (preference === 'tmux') {
75
+ if (!availability.tmux.installed) {
76
+ throw new MultiplexerError(
77
+ 'unavailable',
78
+ 'tmux is configured, but its executable is unavailable. Install tmux, then relaunch mux-sesh.'
79
+ )
80
+ }
81
+ return 'tmux'
82
+ }
83
+
84
+ if (availability.tmux.running && !availability.herdr.running) {
85
+ return 'tmux'
86
+ }
87
+
88
+ const herdrUsable = availability.herdr.running && availability.herdr.compatible === true
89
+
90
+ if (herdrUsable && !availability.tmux.running) {
91
+ return 'herdr'
92
+ }
93
+
94
+ if (availability.tmux.running && herdrUsable) {
95
+ return 'tmux'
96
+ }
97
+
98
+ if (availability.tmux.installed) {
99
+ return 'tmux'
100
+ }
101
+
102
+ throw new MultiplexerError(
103
+ 'unavailable',
104
+ 'No usable multiplexer backend was found. Install tmux or start Herdr, then relaunch mux-sesh.'
105
+ )
106
+ }
@@ -0,0 +1,87 @@
1
+ import type { CommandRunner } from './command'
2
+ import type {
3
+ LiveWorkspace,
4
+ MultiplexerBackend,
5
+ OpenWorkspaceInput,
6
+ WorkspaceDetails,
7
+ WorkspaceRef,
8
+ } from './types'
9
+ import {
10
+ createTmuxSession,
11
+ getCurrentTmuxSessionName,
12
+ getSessionDetails,
13
+ getTmuxSessionDirectory,
14
+ killTmuxSession,
15
+ listTmuxSessions,
16
+ renameTmuxSession,
17
+ switchTmuxSession,
18
+ } from '../tmux'
19
+
20
+ export interface TmuxBackendOptions {
21
+ runner: CommandRunner
22
+ insideTmux: boolean
23
+ }
24
+
25
+ export function createTmuxBackend(options: TmuxBackendOptions): MultiplexerBackend {
26
+ return {
27
+ kind: 'tmux',
28
+ capabilities: { previousWorkspace: true },
29
+ async list(): Promise<LiveWorkspace[]> {
30
+ return (await listTmuxSessions()).map(item => ({
31
+ backend: 'tmux',
32
+ id: item.title,
33
+ title: item.title,
34
+ path: item.path,
35
+ isActive: item.isAttached === true,
36
+ unitCount: Number.parseInt(item.windowCount ?? '0', 10),
37
+ createdAt: item.createdAt,
38
+ lastActivity: item.lastActivity,
39
+ }))
40
+ },
41
+ async open(workspace: WorkspaceRef): Promise<void> {
42
+ await switchTmuxSession(workspace.id)
43
+ },
44
+ async openOrCreate(input: OpenWorkspaceInput): Promise<void> {
45
+ await createTmuxSession(input.title, input.path, { startupCommand: input.startupCommand })
46
+ },
47
+ async rename(workspace: WorkspaceRef, title: string): Promise<void> {
48
+ await renameTmuxSession(workspace.id, title)
49
+ },
50
+ async close(workspace: WorkspaceRef): Promise<void> {
51
+ await killTmuxSession(workspace.id)
52
+ },
53
+ async current(): Promise<WorkspaceRef | undefined> {
54
+ const title = await getCurrentTmuxSessionName()
55
+ return { backend: 'tmux', id: title, title }
56
+ },
57
+ async directory(workspace: WorkspaceRef): Promise<string | undefined> {
58
+ return getTmuxSessionDirectory(workspace.id)
59
+ },
60
+ async details(workspace: WorkspaceRef): Promise<WorkspaceDetails> {
61
+ const details = await getSessionDetails(workspace.id)
62
+ return {
63
+ workspace,
64
+ isActive: details.isAttached,
65
+ unitLabel: 'Windows',
66
+ units: details.windows.map(window => ({
67
+ id: window.index,
68
+ name: window.name,
69
+ currentPath: window.currentPath,
70
+ currentCommand: window.currentCommand,
71
+ })),
72
+ previewLines: details.panePreviewLines,
73
+ agents: [],
74
+ }
75
+ },
76
+ async openEditor(path: string, command: string): Promise<boolean> {
77
+ if (!options.insideTmux) {
78
+ return false
79
+ }
80
+ const result = await options.runner.run(['tmux', 'new-window', '-c', path, command])
81
+ if (result.exitCode !== 0) {
82
+ throw new Error(`Failed to open tmux editor window: ${result.stderr.trim()}`)
83
+ }
84
+ return true
85
+ },
86
+ }
87
+ }
@@ -0,0 +1,93 @@
1
+ export type BackendKind = 'tmux' | 'herdr'
2
+ export type BackendPreference = BackendKind
3
+ export type AgentStatus = 'idle' | 'working' | 'blocked' | 'done' | 'unknown'
4
+
5
+ interface WorkspaceIdentity {
6
+ id: string
7
+ title: string
8
+ }
9
+
10
+ export interface HerdrAgentTarget {
11
+ kind: 'agent'
12
+ tabId: string
13
+ paneId: string
14
+ }
15
+
16
+ export type WorkspaceRef =
17
+ | (WorkspaceIdentity & { backend: 'tmux' })
18
+ | (WorkspaceIdentity & { backend: 'herdr'; target?: HerdrAgentTarget })
19
+
20
+ export type LiveWorkspace = WorkspaceRef & {
21
+ workspaceTitle?: string
22
+ path: string
23
+ isActive: boolean
24
+ unitCount: number
25
+ createdAt?: number
26
+ lastActivity?: number
27
+ agentStatus?: AgentStatus
28
+ }
29
+
30
+ export interface OpenWorkspaceInput {
31
+ title: string
32
+ path: string
33
+ startupCommand?: string
34
+ }
35
+
36
+ export interface WorkspaceUnitDetails {
37
+ id: string
38
+ name: string
39
+ currentPath: string
40
+ currentCommand: string
41
+ }
42
+
43
+ export interface WorkspaceAgentDetails {
44
+ paneId: string
45
+ name: string
46
+ status: AgentStatus
47
+ cwd?: string
48
+ }
49
+
50
+ export interface WorkspaceDetails {
51
+ workspace: WorkspaceRef
52
+ isActive: boolean
53
+ unitLabel: 'Windows' | 'Tabs'
54
+ units: WorkspaceUnitDetails[]
55
+ previewLines?: string[]
56
+ agents: WorkspaceAgentDetails[]
57
+ }
58
+
59
+ export interface MultiplexerCapabilities {
60
+ previousWorkspace: boolean
61
+ }
62
+
63
+ export interface MultiplexerBackend {
64
+ kind: BackendKind
65
+ capabilities: MultiplexerCapabilities
66
+ list(): Promise<LiveWorkspace[]>
67
+ open(workspace: WorkspaceRef): Promise<void>
68
+ openOrCreate(input: OpenWorkspaceInput): Promise<void>
69
+ rename(workspace: WorkspaceRef, title: string): Promise<void>
70
+ close(workspace: WorkspaceRef): Promise<void>
71
+ current(): Promise<WorkspaceRef | undefined>
72
+ directory(workspace: WorkspaceRef): Promise<string | undefined>
73
+ details(workspace: WorkspaceRef): Promise<WorkspaceDetails>
74
+ openEditor(path: string, command: string): Promise<boolean>
75
+ }
76
+
77
+ export type MultiplexerErrorCode =
78
+ | 'unavailable'
79
+ | 'server-stopped'
80
+ | 'protocol-mismatch'
81
+ | 'command-failed'
82
+ | 'invalid-response'
83
+ | 'unsupported'
84
+
85
+ export class MultiplexerError extends Error {
86
+ constructor(
87
+ readonly code: MultiplexerErrorCode,
88
+ message: string
89
+ ) {
90
+ super(message)
91
+ this.name = 'MultiplexerError'
92
+ }
93
+ }
@@ -6,6 +6,8 @@ export function isOpencodeSessionName(sessionName: string): boolean {
6
6
  return sessionName.startsWith(OPENCODE_SESSION_PREFIX)
7
7
  }
8
8
 
9
- export function isOpencodeSessionItem(item: Pick<Item, 'isSession' | 'title'>): boolean {
10
- return item.isSession && isOpencodeSessionName(item.title)
9
+ export function isOpencodeSessionItem(
10
+ item: Pick<Item, 'isSession' | 'title' | 'itemKind'>
11
+ ): boolean {
12
+ return item.isSession && item.itemKind !== 'herdr' && isOpencodeSessionName(item.title)
11
13
  }
@@ -1,8 +1,8 @@
1
1
  import { readdir, stat } from 'fs/promises'
2
2
  import { basename, dirname, join } from 'path'
3
3
  import { spawn } from 'bun'
4
- import { getSessionDetails } from '../tmux'
5
- import type { Config, SessionDetails } from '../types'
4
+ import type { Config } from '../types'
5
+ import type { WorkspaceDetails, WorkspaceRef } from '../multiplexer'
6
6
  import { stripAnsi } from '../util/ansi'
7
7
  import { getGitRoot, resolveProjectSession } from '../config/session-rules'
8
8
  import { resolveFileSession } from '../files/target'
@@ -23,7 +23,7 @@ export interface ProjectPreview {
23
23
  previewCommand?: string
24
24
  gitRoot?: string
25
25
  gitBranch?: string
26
- linkedSession?: SessionDetails
26
+ linkedSession?: WorkspaceDetails
27
27
  previewKind: 'command' | 'directory' | 'file'
28
28
  previewLabel: string
29
29
  previewLines: string[]
@@ -197,9 +197,10 @@ async function runPreviewCommand(
197
197
  export async function getProjectPreview(
198
198
  projectPath: string,
199
199
  config: Config,
200
- linkedSessionName?: string
200
+ linkedWorkspace?: WorkspaceRef,
201
+ loadWorkspaceDetails?: (workspace: WorkspaceRef) => Promise<WorkspaceDetails>
201
202
  ): Promise<ProjectPreview> {
202
- const cacheKey = `${projectPath}::${linkedSessionName ?? ''}`
203
+ const cacheKey = `${projectPath}::${linkedWorkspace ? `${linkedWorkspace.backend}:${linkedWorkspace.id}` : ''}`
203
204
  const cached = projectPreviewCache.get(cacheKey)
204
205
  if (cached && cached.expiresAt > Date.now()) {
205
206
  return cached.preview
@@ -209,8 +210,8 @@ export async function getProjectPreview(
209
210
  resolveProjectSession(projectPath, config),
210
211
  getGitRoot(projectPath),
211
212
  getGitBranch(projectPath),
212
- linkedSessionName
213
- ? getSessionDetails(linkedSessionName).catch(() => null)
213
+ linkedWorkspace && loadWorkspaceDetails
214
+ ? loadWorkspaceDetails(linkedWorkspace).catch(() => null)
214
215
  : Promise.resolve(null),
215
216
  ])
216
217
 
@@ -318,9 +319,10 @@ async function getFilePreviewLines(
318
319
  export async function getFilePreview(
319
320
  filePath: string,
320
321
  config: Config,
321
- linkedSessionName?: string
322
+ linkedWorkspace?: WorkspaceRef,
323
+ loadWorkspaceDetails?: (workspace: WorkspaceRef) => Promise<WorkspaceDetails>
322
324
  ): Promise<ProjectPreview> {
323
- const cacheKey = `file::${filePath}::${linkedSessionName ?? ''}`
325
+ const cacheKey = `file::${filePath}::${linkedWorkspace ? `${linkedWorkspace.backend}:${linkedWorkspace.id}` : ''}`
324
326
  const cached = projectPreviewCache.get(cacheKey)
325
327
  if (cached && cached.expiresAt > Date.now()) {
326
328
  return cached.preview
@@ -331,8 +333,8 @@ export async function getFilePreview(
331
333
  const [gitRootPath, gitBranch, linkedSession, fileLines] = await Promise.all([
332
334
  getGitRoot(parentDirectory),
333
335
  getGitBranch(parentDirectory),
334
- linkedSessionName
335
- ? getSessionDetails(linkedSessionName).catch(() => null)
336
+ linkedWorkspace && loadWorkspaceDetails
337
+ ? loadWorkspaceDetails(linkedWorkspace).catch(() => null)
336
338
  : Promise.resolve(null),
337
339
  getFilePreviewLines(filePath),
338
340
  ])
@@ -1,25 +1,39 @@
1
+ import { resolve } from 'path'
1
2
  import type { Config, Item } from '../types'
3
+ import { isLiveSessionItem } from '../multiplexer/items'
2
4
  import { resolveProjectSession } from '../config/session-rules'
3
- import { buildFileSessionName, isFileItem } from '../files/target'
5
+ import { buildFileSessionName, isFileItem, resolveFileSession } from '../files/target'
4
6
 
5
7
  export async function annotateProjectItemsWithSessionLinks(
6
8
  projectItems: Item[],
7
9
  liveSessions: Item[],
8
10
  config: Config
9
11
  ): Promise<Item[]> {
10
- const liveSessionsByTitle = new Map(liveSessions.map(session => [session.title, session]))
11
-
12
12
  return Promise.all(
13
13
  projectItems.map(async projectItem => {
14
14
  const sessionName = isFileItem(projectItem)
15
15
  ? buildFileSessionName(projectItem.path)
16
16
  : (await resolveProjectSession(projectItem.path, config)).sessionName
17
- const linkedSession = liveSessionsByTitle.get(sessionName)
17
+ const sessionPath = isFileItem(projectItem)
18
+ ? resolveFileSession(projectItem.path, config).cwd
19
+ : projectItem.path
20
+ const liveItems = liveSessions.filter(session => session.isSession)
21
+ const pathMatches = liveItems.filter(
22
+ session =>
23
+ session.title === sessionName &&
24
+ session.path &&
25
+ resolve(session.path) === resolve(sessionPath)
26
+ )
27
+ const titleMatches = liveItems.filter(session => session.title === sessionName)
28
+ const linkedSession =
29
+ pathMatches[0] ?? (titleMatches.length === 1 ? titleMatches[0] : undefined)
18
30
 
19
31
  if (!linkedSession) {
20
32
  return {
21
33
  ...projectItem,
22
34
  linkedSessionName: undefined,
35
+ linkedSessionId: undefined,
36
+ linkedSessionBackend: undefined,
23
37
  linkedSessionAttached: undefined,
24
38
  }
25
39
  }
@@ -27,6 +41,10 @@ export async function annotateProjectItemsWithSessionLinks(
27
41
  return {
28
42
  ...projectItem,
29
43
  linkedSessionName: linkedSession.title,
44
+ linkedSessionId: isLiveSessionItem(linkedSession)
45
+ ? linkedSession.sessionId
46
+ : linkedSession.title,
47
+ linkedSessionBackend: isLiveSessionItem(linkedSession) ? linkedSession.backend : 'tmux',
30
48
  linkedSessionAttached: linkedSession.isAttached,
31
49
  }
32
50
  })
package/src/settings.ts CHANGED
@@ -3,6 +3,7 @@ import { BUILTIN_THEMES } from './styles/theme'
3
3
  import type { Config, KeybindMode, SortOrder, ThemeColorScheme, ZoxideMode } from './types'
4
4
 
5
5
  export type SettingsFieldId =
6
+ | 'backend'
6
7
  | 'theme'
7
8
  | 'colorScheme'
8
9
  | 'keybindMode'
@@ -47,6 +48,7 @@ const SORT_ORDER_OPTIONS: SortOrder[] = [
47
48
  'alphabetical',
48
49
  ]
49
50
  const ZOXIDE_OPTIONS: ZoxideMode[] = ['off', 'rank', 'merge']
51
+ const BACKEND_OPTIONS = ['auto', 'tmux', 'herdr'] as const
50
52
 
51
53
  type SettingsFieldKind = SettingsEntry['kind']
52
54
 
@@ -95,6 +97,23 @@ function choiceOptions(
95
97
  }
96
98
 
97
99
  const SETTINGS_FIELDS: readonly SettingsFieldDefinition[] = [
100
+ {
101
+ id: 'backend',
102
+ label: 'Backend',
103
+ hint: 'Multiplexer selection; applies next launch',
104
+ kind: 'options',
105
+ getValue: config => config.backend ?? 'auto',
106
+ getOptions: () =>
107
+ choiceOptions(BACKEND_OPTIONS, {
108
+ auto: 'Detect current or running multiplexer',
109
+ tmux: 'Require tmux',
110
+ herdr: 'Require a running Herdr server',
111
+ }),
112
+ applyOption: (config, value) => ({
113
+ ...config,
114
+ backend: value === 'tmux' || value === 'herdr' ? value : undefined,
115
+ }),
116
+ },
98
117
  {
99
118
  id: 'theme',
100
119
  label: 'Theme',
@@ -11,7 +11,11 @@ export function filterHiddenSessions(items: Item[], hiddenSessions: string[] = [
11
11
  return true
12
12
  }
13
13
 
14
- return !hiddenSessions.some(pattern => matchesGlob(item.title, pattern))
14
+ return !hiddenSessions.some(
15
+ pattern =>
16
+ matchesGlob(item.title, pattern) ||
17
+ (item.workspaceTitle !== undefined && matchesGlob(item.workspaceTitle, pattern))
18
+ )
15
19
  })
16
20
  }
17
21
 
@@ -1,4 +1,7 @@
1
1
  import type { OpencodeStats } from '../opencode/types'
2
+ import type { AgentStatus, BackendKind, BackendPreference, HerdrAgentTarget } from '../multiplexer'
3
+
4
+ export type { AgentStatus, BackendKind, BackendPreference } from '../multiplexer'
2
5
 
3
6
  export enum AppMode {
4
7
  Normal,
@@ -14,11 +17,12 @@ export enum ViewMode {
14
17
 
15
18
  export type KeybindMode = 'vim' | 'standard'
16
19
  export type ZoxideMode = 'off' | 'rank' | 'merge'
17
- export type ItemKind = 'tmux' | 'configured' | 'project' | 'file'
20
+ export type ItemKind = BackendKind | 'configured' | 'project' | 'file'
18
21
  export type SortOrder = 'live-first' | 'configured-first' | 'zoxide-first' | 'alphabetical'
19
22
 
20
23
  export interface IconConfig {
21
24
  tmux: string
25
+ herdr: string
22
26
  configured: string
23
27
  project: string
24
28
  opencode: string
@@ -125,10 +129,17 @@ export interface Item {
125
129
  path: string
126
130
  isSession: boolean
127
131
  itemKind?: ItemKind
132
+ sessionId?: string
133
+ backend?: BackendKind
134
+ target?: HerdrAgentTarget
135
+ workspaceTitle?: string
136
+ agentStatus?: AgentStatus
128
137
  icon?: string
129
138
  isPinned?: boolean
130
139
  isAttached?: boolean
131
140
  linkedSessionName?: string
141
+ linkedSessionId?: string
142
+ linkedSessionBackend?: BackendKind
132
143
  linkedSessionAttached?: boolean
133
144
  windowCount?: string
134
145
  createdAt?: number
@@ -138,6 +149,7 @@ export interface Item {
138
149
  }
139
150
 
140
151
  export interface Config {
152
+ backend?: BackendPreference
141
153
  projectPaths: string[]
142
154
  reposPath: string
143
155
  editor: string