mux-sesh 1.9.4 → 1.9.5

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 +4 -2
  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
package/src/app/view.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { isAgentSessionItem } from '../agents/session-name'
2
+ import { isHerdrAgentItem } from '../multiplexer/items'
2
3
  import { getPanelStyle } from '../styles/theme'
3
- import { AppMode, ViewMode, type ThemeColors } from '../types'
4
+ import { AppMode, ViewMode, type BackendKind, type Item, type ThemeColors } from '../types'
4
5
 
5
6
  export function splitVisibleSessions<T extends { isSession: boolean; title: string }>(
6
7
  items: readonly T[]
@@ -11,20 +12,28 @@ export function splitVisibleSessions<T extends { isSession: boolean; title: stri
11
12
  }
12
13
  }
13
14
 
14
- export function getAppTitle(appMode: AppMode, viewMode: ViewMode): string {
15
+ export function getAppTitle(
16
+ appMode: AppMode,
17
+ viewMode: ViewMode,
18
+ backend: BackendKind = 'tmux'
19
+ ): string {
15
20
  if (appMode === AppMode.Search) {
16
21
  return 'Search'
17
22
  }
18
23
 
19
24
  if (appMode === AppMode.NewSession) {
20
- return 'New Session'
25
+ return backend === 'herdr' ? 'New Workspace' : 'New Session'
21
26
  }
22
27
 
23
28
  if (appMode === AppMode.AgentsManage) {
24
29
  return 'Agent Sessions'
25
30
  }
26
31
 
27
- return viewMode === ViewMode.Projects ? 'Projects' : 'Sessions'
32
+ return viewMode === ViewMode.Projects
33
+ ? 'Projects'
34
+ : backend === 'herdr'
35
+ ? 'Workspaces'
36
+ : 'Sessions'
28
37
  }
29
38
 
30
39
  export function getListStyle(theme: ThemeColors, appMode: AppMode) {
@@ -55,11 +64,13 @@ export function getStatusLabel(
55
64
  : `${projectCount} projects`
56
65
  }
57
66
 
58
- export function getFooterHint(appMode: AppMode, prefixKey?: string): string {
67
+ export function getFooterHint(appMode: AppMode, prefixKey?: string, selectedItem?: Item): string {
59
68
  const prefixLabel = prefixKey ? `${prefixKey} ...` : 'direct keys'
60
69
 
61
70
  if (appMode === AppMode.AgentsManage) {
62
- return `o back d kill ctrl+p commands ${prefixLabel}`
71
+ return isHerdrAgentItem(selectedItem)
72
+ ? `o back enter focus ctrl+p commands ${prefixLabel}`
73
+ : `o back d kill ctrl+p commands ${prefixLabel}`
63
74
  }
64
75
 
65
76
  if (appMode === AppMode.NewSession) {
@@ -1,6 +1,7 @@
1
1
  import { join } from 'path'
2
2
  import type {
3
3
  Config,
4
+ BackendPreference,
4
5
  IconConfig,
5
6
  KeybindMode,
6
7
  ProjectProfile,
@@ -22,6 +23,7 @@ const DEFAULT_EDITOR_COMMAND =
22
23
  "nvim -c \"lua vim.defer_fn(function() if pcall(require, 'telescope') then vim.cmd('Telescope find_files') end end, 100)\""
23
24
  const DEFAULT_ICONS: IconConfig = {
24
25
  tmux: '',
26
+ herdr: '',
25
27
  configured: '',
26
28
  project: '',
27
29
  opencode: '',
@@ -86,6 +88,10 @@ function asSortOrder(value: unknown): SortOrder | undefined {
86
88
  : undefined
87
89
  }
88
90
 
91
+ function asBackendPreference(value: unknown): BackendPreference | undefined {
92
+ return value === 'tmux' || value === 'herdr' ? value : undefined
93
+ }
94
+
89
95
  function asThemeColorScheme(value: unknown): ThemeColorScheme | undefined {
90
96
  return value === 'light' || value === 'dark' || value === 'system' ? value : undefined
91
97
  }
@@ -127,6 +133,7 @@ function normalizeIcons(value: unknown): IconConfig | undefined {
127
133
 
128
134
  return {
129
135
  tmux: asString(value.tmux) ?? DEFAULT_ICONS.tmux,
136
+ herdr: asString(value.herdr) ?? DEFAULT_ICONS.herdr,
130
137
  configured: asString(value.configured) ?? asString(value.config) ?? DEFAULT_ICONS.configured,
131
138
  project: asString(value.project) ?? DEFAULT_ICONS.project,
132
139
  opencode: asString(value.opencode) ?? DEFAULT_ICONS.opencode,
@@ -315,6 +322,7 @@ export function normalizeConfig(rawConfig: unknown, homeDir = process.env.HOME |
315
322
  homeDir
316
323
  )
317
324
  const editor = asString(raw.editor) ?? defaultConfig.editor
325
+ const backend = asBackendPreference(raw.backend)
318
326
  const editorCmd = asString(raw.editor_cmd) ?? asString(raw.editorCmd) ?? defaultConfig.editorCmd
319
327
  const keybindMode =
320
328
  asKeybindMode(raw.keybind_mode) ?? asKeybindMode(raw.keybindMode) ?? defaultConfig.keybindMode
@@ -350,6 +358,7 @@ export function normalizeConfig(rawConfig: unknown, homeDir = process.env.HOME |
350
358
  }
351
359
 
352
360
  return {
361
+ backend,
353
362
  projectPaths,
354
363
  reposPath,
355
364
  editor,
@@ -411,6 +420,7 @@ function serializeThemeVariant(variant: ThemeVariant) {
411
420
 
412
421
  export function serializeConfig(config: Config): Record<string, unknown> {
413
422
  return {
423
+ backend: config.backend,
414
424
  project_paths: config.projectPaths,
415
425
  repos_path: config.reposPath,
416
426
  editor: config.editor,
@@ -1,8 +1,9 @@
1
1
  import { dirname } from 'path'
2
2
  import type { Config, Item } from '../types'
3
+ import type { MultiplexerBackend } from '../multiplexer'
4
+ import { getWorkspaceRef, isLiveSessionItem } from '../multiplexer/items'
3
5
  import { getGitRoot, resolveProjectSession } from '../config/session-rules'
4
6
  import { isFileItem, resolveFileSession } from '../files/target'
5
- import { createTmuxSession, getTmuxSessionDirectory } from '../tmux'
6
7
  import { requestShutdown } from '../util/shutdown'
7
8
  import { quoteShellArg } from '../util/shell'
8
9
 
@@ -37,24 +38,38 @@ export function getNextSessionName(renameTarget: string, newName: string): strin
37
38
  return trimmedName
38
39
  }
39
40
 
40
- export async function openProjectSession(projectPath: string, config: Config): Promise<void> {
41
+ export async function openProjectSession(
42
+ projectPath: string,
43
+ config: Config,
44
+ backend: MultiplexerBackend
45
+ ): Promise<void> {
41
46
  const resolvedSession = await resolveProjectSession(projectPath, config)
42
- await createTmuxSession(resolvedSession.sessionName, projectPath, {
47
+ await backend.openOrCreate({
48
+ title: resolvedSession.sessionName,
49
+ path: projectPath,
43
50
  startupCommand: resolvedSession.startupCommand,
44
51
  })
45
52
  await requestShutdown(0)
46
53
  }
47
54
 
48
- export async function openFileSession(filePath: string, config: Config): Promise<void> {
55
+ export async function openFileSession(
56
+ filePath: string,
57
+ config: Config,
58
+ backend: MultiplexerBackend
59
+ ): Promise<void> {
49
60
  const resolvedSession = resolveFileSession(filePath, config)
50
- await createTmuxSession(resolvedSession.sessionName, resolvedSession.cwd, {
61
+ await backend.openOrCreate({
62
+ title: resolvedSession.sessionName,
63
+ path: resolvedSession.cwd,
51
64
  startupCommand: resolvedSession.startupCommand,
52
65
  })
53
66
  await requestShutdown(0)
54
67
  }
55
68
 
56
- export async function getRootSessionPath(item: Item): Promise<string> {
57
- const itemPath = item.isSession ? await getTmuxSessionDirectory(item.title) : item.path
69
+ export async function getRootSessionPath(item: Item, backend: MultiplexerBackend): Promise<string> {
70
+ const itemPath = isLiveSessionItem(item)
71
+ ? ((await backend.directory(getWorkspaceRef(item))) ?? item.path)
72
+ : item.path
58
73
  const searchRoot = !item.isSession && isFileItem(item) ? dirname(itemPath) : itemPath
59
74
  return (await getGitRoot(searchRoot)) ?? searchRoot
60
75
  }
@@ -1,12 +1,7 @@
1
1
  import { spawn } from 'bun'
2
2
  import type { Item, Config } from '../types'
3
- import {
4
- switchTmuxSession,
5
- killTmuxSession,
6
- renameTmuxSession,
7
- createNamedTmuxSession,
8
- getCurrentTmuxSessionName,
9
- } from '../tmux'
3
+ import type { MultiplexerBackend } from '../multiplexer'
4
+ import { getWorkspaceRef, isLiveSessionItem } from '../multiplexer/items'
10
5
  import { getLastSessionTarget } from '../tmux/workflows'
11
6
  import { isFileItem, resolveTypedPathTarget } from '../files/target'
12
7
  import { isGitHubURL, cloneGitHubRepo } from '../util/github'
@@ -21,23 +16,24 @@ import {
21
16
  requireConfiguredItem,
22
17
  } from './action-helpers'
23
18
 
24
- export async function handleSelect(item: Item, config: Config | null) {
25
- if (item.isSession) {
26
- await switchTmuxSession(item.title)
19
+ export async function handleSelect(item: Item, config: Config | null, backend: MultiplexerBackend) {
20
+ if (isLiveSessionItem(item)) {
21
+ await backend.open(getWorkspaceRef(item))
27
22
  await requestShutdown(0)
28
23
  return
29
24
  }
30
25
 
31
26
  if (isFileItem(item)) {
32
- await openFileSession(item.path, requireConfig(config))
27
+ await openFileSession(item.path, requireConfig(config), backend)
33
28
  return
34
29
  }
35
30
 
36
- await openProjectSession(item.path, requireConfig(config))
31
+ await openProjectSession(item.path, requireConfig(config), backend)
37
32
  }
38
33
 
39
34
  export async function handleKillSession(
40
- sessionName: string,
35
+ item: Item,
36
+ backend: MultiplexerBackend,
41
37
  callbacks: {
42
38
  onSuccess: (message: string) => void
43
39
  onError: (message: string) => void
@@ -45,8 +41,11 @@ export async function handleKillSession(
45
41
  }
46
42
  ) {
47
43
  try {
48
- await killTmuxSession(sessionName)
49
- callbacks.onSuccess(`Session '${sessionName}' killed`)
44
+ if (!isLiveSessionItem(item)) throw new Error('Select a live session to close')
45
+ await backend.close(getWorkspaceRef(item))
46
+ callbacks.onSuccess(
47
+ `${backend.kind === 'herdr' ? 'Workspace' : 'Session'} '${item.title}' closed`
48
+ )
50
49
  await callbacks.refreshItems()
51
50
  } catch (error) {
52
51
  callbacks.onError(`Error killing session: ${error}`)
@@ -54,22 +53,26 @@ export async function handleKillSession(
54
53
  }
55
54
 
56
55
  export async function handleRenameSubmit(
57
- renameTarget: string,
56
+ renameTarget: Item,
58
57
  newName: string,
58
+ backend: MultiplexerBackend,
59
59
  callbacks: {
60
60
  onSuccess: (message: string) => void
61
61
  onError: (message: string) => void
62
62
  refreshItems: () => Promise<void>
63
63
  }
64
64
  ) {
65
- const nextSessionName = getNextSessionName(renameTarget, newName)
65
+ if (!isLiveSessionItem(renameTarget)) return
66
+ const nextSessionName = getNextSessionName(renameTarget.title, newName)
66
67
  if (!nextSessionName) {
67
68
  return
68
69
  }
69
70
 
70
71
  try {
71
- await renameTmuxSession(renameTarget, nextSessionName)
72
- callbacks.onSuccess(`Session renamed to '${nextSessionName}'`)
72
+ await backend.rename(getWorkspaceRef(renameTarget), nextSessionName)
73
+ callbacks.onSuccess(
74
+ `${backend.kind === 'herdr' ? 'Workspace' : 'Session'} renamed to '${nextSessionName}'`
75
+ )
73
76
  await callbacks.refreshItems()
74
77
  } catch (error) {
75
78
  callbacks.onError(`Error renaming session: ${error}`)
@@ -80,7 +83,8 @@ export async function handleNewSessionSubmit(
80
83
  searchTerm: string,
81
84
  config: Config | null,
82
85
  items: Item[],
83
- cursor: number
86
+ cursor: number,
87
+ backend: MultiplexerBackend
84
88
  ) {
85
89
  if (!searchTerm) return
86
90
 
@@ -88,7 +92,7 @@ export async function handleNewSessionSubmit(
88
92
  try {
89
93
  if (!config) return
90
94
  const clonedPath = await cloneGitHubRepo(searchTerm, config)
91
- await openProjectSession(clonedPath, config)
95
+ await openProjectSession(clonedPath, config, backend)
92
96
  } catch (error) {
93
97
  throw new Error(`Error cloning repository: ${error}`)
94
98
  }
@@ -98,64 +102,69 @@ export async function handleNewSessionSubmit(
98
102
  const typedTarget = await resolveTypedPathTarget(searchTerm)
99
103
  if (typedTarget) {
100
104
  if (typedTarget.kind === 'file') {
101
- await openFileSession(typedTarget.path, requireConfig(config))
105
+ await openFileSession(typedTarget.path, requireConfig(config), backend)
102
106
  return
103
107
  }
104
108
 
105
- await openProjectSession(typedTarget.path, requireConfig(config))
109
+ await openProjectSession(typedTarget.path, requireConfig(config), backend)
106
110
  return
107
111
  }
108
112
 
109
113
  if (items.length > 0 && cursor < items.length) {
110
114
  const selectedItem = items[cursor]
111
115
  if (isFileItem(selectedItem)) {
112
- await openFileSession(selectedItem.path, requireConfig(config))
116
+ await openFileSession(selectedItem.path, requireConfig(config), backend)
113
117
  return
114
118
  }
115
119
 
116
- await openProjectSession(selectedItem.path, requireConfig(config))
120
+ await openProjectSession(selectedItem.path, requireConfig(config), backend)
117
121
  return
118
122
  }
119
123
 
120
- await createNamedTmuxSession(searchTerm)
124
+ await backend.openOrCreate({ title: searchTerm, path: process.cwd() })
121
125
  await requestShutdown(0)
122
126
  }
123
127
 
124
- export async function handleLastSession(items: Item[]) {
125
- const currentSessionName = await getCurrentTmuxSessionName().catch(() => undefined)
128
+ export async function handleLastSession(items: Item[], backend: MultiplexerBackend) {
129
+ if (!backend.capabilities.previousWorkspace) {
130
+ throw new Error(
131
+ 'Previous workspace is unavailable because Herdr does not expose workspace activity history'
132
+ )
133
+ }
134
+ const currentSessionName = (await backend.current().catch(() => undefined))?.title
126
135
  const target = getLastSessionTarget(items, currentSessionName)
127
136
 
128
137
  if (!target) {
129
138
  throw new Error('No previous tmux session is available')
130
139
  }
131
140
 
132
- await switchTmuxSession(target.title)
141
+ if (!isLiveSessionItem(target)) throw new Error('No previous live session is available')
142
+ await backend.open(getWorkspaceRef(target))
133
143
  await requestShutdown(0)
134
144
  }
135
145
 
136
- export async function handleRootSession(item: Item | undefined, config: Config | null) {
146
+ export async function handleRootSession(
147
+ item: Item | undefined,
148
+ config: Config | null,
149
+ backend: MultiplexerBackend
150
+ ) {
137
151
  if (!item) {
138
152
  throw new Error('No session or project is selected')
139
153
  }
140
154
 
141
- await openProjectSession(await getRootSessionPath(item), requireConfig(config))
155
+ await openProjectSession(await getRootSessionPath(item, backend), requireConfig(config), backend)
142
156
  }
143
157
 
144
- export async function handleEditTarget(item: Item | undefined, config: Config | null) {
158
+ export async function handleEditTarget(
159
+ item: Item | undefined,
160
+ config: Config | null,
161
+ backend: MultiplexerBackend
162
+ ) {
145
163
  const configuredItem = requireConfiguredItem(item)
146
164
  const loadedConfig = requireConfig(config)
147
165
  const command = buildEditorCommand(loadedConfig.editor, configuredItem.path)
148
166
 
149
- if (process.env.TMUX) {
150
- const proc = spawn(['tmux', 'new-window', '-c', configuredItem.path, command], {
151
- stderr: 'pipe',
152
- })
153
- await proc.exited
154
-
155
- if (proc.exitCode !== 0) {
156
- throw new Error(`Failed to open editor for '${configuredItem.title}'`)
157
- }
158
-
167
+ if (await backend.openEditor(configuredItem.path, command)) {
159
168
  await requestShutdown(0)
160
169
  return
161
170
  }
@@ -1,4 +1,6 @@
1
- import { isOpencodeSessionName } from '../../opencode/session-name'
1
+ import { isOpencodeSessionItem } from '../../opencode/session-name'
2
+ import { isHerdrAgentItem } from '../../multiplexer/items'
3
+ import type { Item } from '../../types'
2
4
  import { AppMode, type KeybindMode } from '../../types'
3
5
  import { clampCursorIndex } from '../../ui/list-window'
4
6
  import {
@@ -10,9 +12,9 @@ import {
10
12
  type KeyboardInput,
11
13
  } from './shared'
12
14
 
13
- function loadStatsIfOpencode(ctx: KeyboardHandlerContext, sessionName: string) {
14
- if (isOpencodeSessionName(sessionName)) {
15
- void ctx.loadOpencodeStatsForSession(sessionName)
15
+ function loadStatsIfOpencode(ctx: KeyboardHandlerContext, item: Item) {
16
+ if (isOpencodeSessionItem(item)) {
17
+ void ctx.loadOpencodeStatsForSession(item.title)
16
18
  }
17
19
  }
18
20
 
@@ -39,14 +41,20 @@ export function handleAgentsManageMode(
39
41
  ctx.setAppMode(AppMode.Normal)
40
42
  return
41
43
  case 'd':
42
- if (ctx.agentSessions[ctx.agentCursor]) {
43
- ctx.requestKillSession(ctx.agentSessions[ctx.agentCursor].title)
44
+ if (
45
+ ctx.agentSessions[ctx.agentCursor] &&
46
+ !isHerdrAgentItem(ctx.agentSessions[ctx.agentCursor])
47
+ ) {
48
+ ctx.requestKillSession(ctx.agentSessions[ctx.agentCursor])
44
49
  }
45
50
  return
46
51
  case 'r':
47
- if (ctx.agentSessions[ctx.agentCursor]) {
52
+ if (
53
+ ctx.agentSessions[ctx.agentCursor] &&
54
+ !isHerdrAgentItem(ctx.agentSessions[ctx.agentCursor])
55
+ ) {
48
56
  ctx.clearPendingKill()
49
- ctx.openRenameModal(ctx.agentSessions[ctx.agentCursor].title)
57
+ ctx.openRenameModal(ctx.agentSessions[ctx.agentCursor])
50
58
  }
51
59
  return
52
60
  }
@@ -65,12 +73,20 @@ export function handleAgentsManageMode(
65
73
  return
66
74
  }
67
75
 
76
+ if (keyName === 'return' || keyName === 'enter') {
77
+ const selectedAgent = ctx.agentSessions[ctx.agentCursor]
78
+ if (selectedAgent) {
79
+ void ctx.handleSelect(selectedAgent)
80
+ }
81
+ return
82
+ }
83
+
68
84
  if (keyName === 'down' || (!isStandard && keyName === 'j')) {
69
85
  ctx.clearPendingKill()
70
86
  ctx.setAgentCursor(cursor => {
71
87
  const next = clampCursorIndex(ctx.agentSessions.length, cursor + 1)
72
88
  if (next !== cursor && ctx.agentSessions[next]) {
73
- loadStatsIfOpencode(ctx, ctx.agentSessions[next].title)
89
+ loadStatsIfOpencode(ctx, ctx.agentSessions[next])
74
90
  }
75
91
  return next
76
92
  })
@@ -82,7 +98,7 @@ export function handleAgentsManageMode(
82
98
  ctx.setAgentCursor(cursor => {
83
99
  const next = clampCursorIndex(ctx.agentSessions.length, cursor - 1)
84
100
  if (next !== cursor && ctx.agentSessions[next]) {
85
- loadStatsIfOpencode(ctx, ctx.agentSessions[next].title)
101
+ loadStatsIfOpencode(ctx, ctx.agentSessions[next])
86
102
  }
87
103
  return next
88
104
  })
@@ -90,16 +106,22 @@ export function handleAgentsManageMode(
90
106
  }
91
107
 
92
108
  if (!isStandard && keyName === 'd') {
93
- if (ctx.agentSessions[ctx.agentCursor]) {
94
- ctx.requestKillSession(ctx.agentSessions[ctx.agentCursor].title)
109
+ if (
110
+ ctx.agentSessions[ctx.agentCursor] &&
111
+ !isHerdrAgentItem(ctx.agentSessions[ctx.agentCursor])
112
+ ) {
113
+ ctx.requestKillSession(ctx.agentSessions[ctx.agentCursor])
95
114
  }
96
115
  return
97
116
  }
98
117
 
99
118
  if (!ctx.prefixKey && !isStandard && keyName === 'r') {
100
- if (ctx.agentSessions[ctx.agentCursor]) {
119
+ if (
120
+ ctx.agentSessions[ctx.agentCursor] &&
121
+ !isHerdrAgentItem(ctx.agentSessions[ctx.agentCursor])
122
+ ) {
101
123
  ctx.clearPendingKill()
102
- ctx.openRenameModal(ctx.agentSessions[ctx.agentCursor].title)
124
+ ctx.openRenameModal(ctx.agentSessions[ctx.agentCursor])
103
125
  }
104
126
  return
105
127
  }
@@ -22,7 +22,7 @@ export function handleNewSessionMode(
22
22
  }
23
23
 
24
24
  if (keyName === 'd' && ctx.items[ctx.cursor]?.isSession) {
25
- ctx.requestKillSession(ctx.items[ctx.cursor].title)
25
+ ctx.requestKillSession(ctx.items[ctx.cursor])
26
26
  return
27
27
  }
28
28
  }
@@ -1,4 +1,4 @@
1
- import { isOpencodeSessionName } from '../../opencode/session-name'
1
+ import { isOpencodeSessionItem } from '../../opencode/session-name'
2
2
  import { AppMode, ViewMode, type KeybindMode } from '../../types'
3
3
  import { clampCursorIndex } from '../../ui/list-window'
4
4
  import { requestShutdown } from '../../util/shutdown'
@@ -48,13 +48,13 @@ export function handleNormalMode(
48
48
  return
49
49
  case 'd':
50
50
  if (ctx.viewMode === ViewMode.Sessions && ctx.regularSessions[ctx.cursor]?.isSession) {
51
- ctx.requestKillSession(ctx.regularSessions[ctx.cursor].title)
51
+ ctx.requestKillSession(ctx.regularSessions[ctx.cursor])
52
52
  }
53
53
  return
54
54
  case 'r':
55
55
  if (ctx.viewMode === ViewMode.Sessions && ctx.regularSessions[ctx.cursor]?.isSession) {
56
56
  ctx.clearPendingKill()
57
- ctx.openRenameModal(ctx.regularSessions[ctx.cursor].title)
57
+ ctx.openRenameModal(ctx.regularSessions[ctx.cursor])
58
58
  }
59
59
  return
60
60
  case 's':
@@ -102,9 +102,9 @@ export function handleNormalMode(
102
102
  if (ctx.viewMode === ViewMode.Sessions && ctx.agentSessions.length > 0) {
103
103
  ctx.setAppMode(AppMode.AgentsManage)
104
104
  ctx.setAgentCursor(0)
105
- const firstAgent = ctx.agentSessions[0].title
106
- if (isOpencodeSessionName(firstAgent)) {
107
- void ctx.loadOpencodeStatsForSession(firstAgent)
105
+ const firstAgent = ctx.agentSessions[0]
106
+ if (isOpencodeSessionItem(firstAgent)) {
107
+ void ctx.loadOpencodeStatsForSession(firstAgent.title)
108
108
  }
109
109
  }
110
110
  return
@@ -143,7 +143,7 @@ export function handleNormalMode(
143
143
 
144
144
  if (!isStandard && keyName === 'd') {
145
145
  if (ctx.viewMode === ViewMode.Sessions && ctx.regularSessions[ctx.cursor]?.isSession) {
146
- ctx.requestKillSession(ctx.regularSessions[ctx.cursor].title)
146
+ ctx.requestKillSession(ctx.regularSessions[ctx.cursor])
147
147
  }
148
148
  return
149
149
  }
@@ -151,7 +151,7 @@ export function handleNormalMode(
151
151
  if (!ctx.prefixKey && !isStandard && keyName === 'r') {
152
152
  if (ctx.viewMode === ViewMode.Sessions && ctx.regularSessions[ctx.cursor]?.isSession) {
153
153
  ctx.clearPendingKill()
154
- ctx.openRenameModal(ctx.regularSessions[ctx.cursor].title)
154
+ ctx.openRenameModal(ctx.regularSessions[ctx.cursor])
155
155
  }
156
156
  return
157
157
  }
@@ -1,4 +1,4 @@
1
- import { isOpencodeSessionName } from '../../opencode/session-name'
1
+ import { isOpencodeSessionItem } from '../../opencode/session-name'
2
2
  import { AppMode, ViewMode, type KeybindMode } from '../../types'
3
3
  import { clampCursorIndex } from '../../ui/list-window'
4
4
  import { requestShutdown } from '../../util/shutdown'
@@ -28,7 +28,7 @@ export function handleSearchMode(
28
28
  switch (keyName) {
29
29
  case 'd':
30
30
  if (ctx.viewMode === ViewMode.Sessions && ctx.items[ctx.cursor]?.isSession) {
31
- ctx.requestKillSession(ctx.items[ctx.cursor].title)
31
+ ctx.requestKillSession(ctx.items[ctx.cursor])
32
32
  }
33
33
  return
34
34
  case 'n':
@@ -39,9 +39,9 @@ export function handleSearchMode(
39
39
  if (ctx.viewMode === ViewMode.Sessions && ctx.agentSessions.length > 0) {
40
40
  ctx.setAppMode(AppMode.AgentsManage)
41
41
  ctx.setAgentCursor(0)
42
- const firstAgent = ctx.agentSessions[0].title
43
- if (isOpencodeSessionName(firstAgent)) {
44
- void ctx.loadOpencodeStatsForSession(firstAgent)
42
+ const firstAgent = ctx.agentSessions[0]
43
+ if (isOpencodeSessionItem(firstAgent)) {
44
+ void ctx.loadOpencodeStatsForSession(firstAgent.title)
45
45
  }
46
46
  }
47
47
  return
@@ -66,7 +66,7 @@ export function handleSearchMode(
66
66
 
67
67
  if (ctx.viewMode === ViewMode.Sessions && ctx.items[ctx.cursor]?.isSession) {
68
68
  ctx.clearPendingKill()
69
- ctx.openRenameModal(ctx.items[ctx.cursor].title)
69
+ ctx.openRenameModal(ctx.items[ctx.cursor])
70
70
  }
71
71
  return
72
72
  default:
@@ -30,15 +30,15 @@ export interface KeyboardHandlerContext {
30
30
  setItems: Dispatch<SetStateAction<Item[]>>
31
31
  setPrefixActive: (active: boolean) => void
32
32
  refreshItems: (forceViewMode?: ViewMode, nextConfig?: Config) => Promise<void>
33
- requestKillSession: (sessionName: string) => void
33
+ requestKillSession: (item: Item) => void
34
34
  togglePinnedSession: (sessionName: string) => Promise<void>
35
35
  clearPendingKill: () => void
36
36
  handleSelect: (item: Item) => Promise<void>
37
- handleKillSession: (sessionName: string) => Promise<void>
37
+ handleKillSession: (item: Item) => Promise<void>
38
38
  handleLastSession: () => Promise<void>
39
39
  handleRootSession: (item?: Item) => Promise<void>
40
40
  handleEditTarget: (item?: Item) => Promise<void>
41
- openRenameModal: (sessionName: string) => void
41
+ openRenameModal: (item: Item) => void
42
42
  openCommandsModal: () => void
43
43
  openSettingsModal: () => void
44
44
  loadOpencodeStatsForSession: (sessionName: string) => Promise<OpencodeSessionStats | null>