Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

refactor(agents): move isShellCommand into shared so main can ask the same question

enese6689804d807
diff --git a/src/renderer/terminal/agent-restart.ts b/src/renderer/terminal/agent-restart.ts
index 73a4b5b67..5e5b73629 100644
--- a/src/renderer/terminal/agent-restart.ts
+++ b/src/renderer/terminal/agent-restart.ts
@@ -5,6 +5,7 @@
* filter and the restart choreography can all share exactly one set of rules.
*/
import { canResume, resumeCommand } from '../../shared/agents/config'
+import { isShellCommand } from '@shared/agents/pane'
import {
DELIVERY_ATTEMPTS,
KILL_LINE,
@@ -27,15 +28,9 @@ export function exitSequence(agentId: string): string | null {
return EXIT_SEQUENCES[agentId] ?? null
}
-/** Foreground commands that mean "the CLI is gone, a shell owns the pane". Login shells
- * report as '-zsh'; tmux may report a full path. */
-const SHELLS = new Set(['zsh', 'bash', 'sh', 'fish', 'dash', 'ksh', 'tcsh'])
-
-export function isShellCommand(cmd: string | null | undefined): boolean {
- if (!cmd) return false
- const base = cmd.replace(/^-/, '').split('/').pop() ?? ''
- return SHELLS.has(base)
-}
+/** Re-exported, not redefined: it lives in `@shared/agents/pane` so the main process can ask the
+ * same question, and `lib/sessionRename.ts` (plus this module's own tests) import it from here. */
+export { isShellCommand }
export type IneligibleReason = 'working' | 'no-session' | 'not-resumable'
diff --git a/src/shared/agents/pane.test.ts b/src/shared/agents/pane.test.ts
new file mode 100644
index 000000000..c75a6841b
--- /dev/null
+++ b/src/shared/agents/pane.test.ts
@@ -0,0 +1,24 @@
+import { describe, it, expect } from 'vitest'
+import { isShellCommand } from './pane'
+
+describe('isShellCommand', () => {
+ it('recognises plain and login shells', () => {
+ expect(isShellCommand('zsh')).toBe(true)
+ expect(isShellCommand('-zsh')).toBe(true)
+ expect(isShellCommand('bash')).toBe(true)
+ expect(isShellCommand('/bin/sh')).toBe(true)
+ expect(isShellCommand('/usr/bin/fish')).toBe(true)
+ })
+
+ it('does not mistake an agent CLI for a shell', () => {
+ expect(isShellCommand('claude')).toBe(false)
+ expect(isShellCommand('codex')).toBe(false)
+ expect(isShellCommand('node')).toBe(false)
+ })
+
+ it('treats an unknown answer as not-a-shell', () => {
+ expect(isShellCommand(null)).toBe(false)
+ expect(isShellCommand(undefined)).toBe(false)
+ expect(isShellCommand('')).toBe(false)
+ })
+})
diff --git a/src/shared/agents/pane.ts b/src/shared/agents/pane.ts
new file mode 100644
index 000000000..7812f6b77
--- /dev/null
+++ b/src/shared/agents/pane.ts
@@ -0,0 +1,13 @@
+// What the tmux pane's foreground command tells us about a session. Shared because BOTH the
+// renderer (agent-restart's exit poll) and the main process (the reconnect resync) ask the same
+// question of the same `#{pane_current_command}` answer.
+
+/** Foreground commands that mean "the CLI is gone, a shell owns the pane". Login shells
+ * report as '-zsh'; tmux may report a full path. */
+const SHELLS = new Set(['zsh', 'bash', 'sh', 'fish', 'dash', 'ksh', 'tcsh'])
+
+export function isShellCommand(cmd: string | null | undefined): boolean {
+ if (!cmd) return false
+ const base = cmd.replace(/^-/, '').split('/').pop() ?? ''
+ return SHELLS.has(base)
+}