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.

fix(agent-naming): resolve session title strictly by sessionId

enesaddef987ac7b
diff --git a/src/main/index.ts b/src/main/index.ts
index f899885e8..6de106406 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -223,8 +223,8 @@ app.whenReady().then(async () => {
ptyManager.captureSession(persistKey, full)
)
- ipcMain.handle(IPC.ptyReadSessionName, (_e, sessionId: string, cwd: string) =>
- readSessionName(sessionId ?? '', cwd ?? '')
+ ipcMain.handle(IPC.ptyReadSessionName, (_e, sessionId: string) =>
+ readSessionName(sessionId ?? '')
)
ipcMain.on(IPC.appCloseWindow, () => BrowserWindow.getFocusedWindow()?.close())
diff --git a/src/main/transcript-reader.ts b/src/main/transcript-reader.ts
index e257b55b3..e38dc0134 100644
--- a/src/main/transcript-reader.ts
+++ b/src/main/transcript-reader.ts
@@ -248,11 +248,13 @@ export function pickSessionName(text: string): string | null {
// The current display name of a Claude session, read from its transcript. This is the name shown
// in `/resume` — the authoritative source, since `/rename` does NOT push to the OSC terminal
-// title. Resolved by sessionId when known, else by cwd. Returns null if none found.
+// title. Resolved STRICTLY by sessionId: the cwd is intentionally not a fallback here, because
+// multiple Claude nodes in one folder would all resolve to the same newest transcript and adopt
+// each other's names. Returns null until the node's own sessionId is known.
const TITLE_TAIL_BYTES = 128 * 1024
-export async function readSessionName(sessionId: string, cwd: string): Promise<string | null> {
- let p = sessionId ? await resolveTranscriptPath(sessionId) : undefined
- if (!p && cwd) p = await transcriptPathForCwd(cwd)
+export async function readSessionName(sessionId: string): Promise<string | null> {
+ if (!sessionId) return null
+ const p = await resolveTranscriptPath(sessionId)
if (!p) return null
const tail = await readSmallTail(p, TITLE_TAIL_BYTES)
if (!tail) return null
diff --git a/src/preload/index.ts b/src/preload/index.ts
index 1de1196a3..08742f23f 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -53,8 +53,7 @@ const api: NodeTerminalApi = {
capture: (persistKey, full) => ipcRenderer.invoke(IPC.ptyCapture, persistKey, full),
readScrollback: (persistKey) => ipcRenderer.invoke(IPC.ptyReadScrollback, persistKey),
sendText: (persistKey, text) => ipcRenderer.invoke(IPC.ptySendText, persistKey, text),
- readSessionName: (sessionId, cwd) =>
- ipcRenderer.invoke(IPC.ptyReadSessionName, sessionId, cwd),
+ readSessionName: (sessionId) => ipcRenderer.invoke(IPC.ptyReadSessionName, sessionId),
onData: (sessionId, listener) => {
const channel = IPC.ptyData(sessionId)
const handler = (_e: unknown, data: string) => listener(data)
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index 5f4523b67..162a42b80 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -590,17 +590,18 @@ export function TerminalNode({ id, data, selected, parentId }: NodeProps<CanvasN
// Keep the node title in sync with the agent session's display name — the name shown in
// `/resume`, read from the transcript (`/rename` name, else auto name). This is the authoritative
// source: `/rename` doesn't update the OSC terminal title, so reading the transcript is the only
- // way the name shows up after a resume. Polls only while the title still auto-tracks the session
- // (titleAuto) and stops once the user renames by hand. Claude-only via canRenameNode.
+ // way the name shows up after a resume. Resolved strictly by THIS node's sessionId — we do NOT
+ // sync until it's known, otherwise same-folder nodes would adopt whichever session wrote last.
+ // Polls only while the title still auto-tracks the session (titleAuto) and stops once the user
+ // renames by hand. Claude-only via canRenameNode.
useEffect(() => {
if (!canRenameNode || data.titleAuto === false) return
const sid = status?.sessionId ?? ''
- const cwd = (data.cwd as string) ?? ''
- if (!sid && !cwd) return
+ if (!sid) return
let cancelled = false
const sync = async () => {
if (!titleAutoRef.current || editingTitleRef.current) return
- const name = await window.nodeTerminal.pty.readSessionName(sid, cwd)
+ const name = await window.nodeTerminal.pty.readSessionName(sid)
if (
!cancelled &&
name &&
@@ -617,7 +618,7 @@ export function TerminalNode({ id, data, selected, parentId }: NodeProps<CanvasN
cancelled = true
clearInterval(timer)
}
- }, [id, canRenameNode, status?.sessionId, data.cwd, data.titleAuto, updateNodeData])
+ }, [id, canRenameNode, status?.sessionId, data.titleAuto, updateNodeData])
// Cmd/Ctrl+M toggles markdown view of this terminal's output (only when hovered).
useEffect(() => {
diff --git a/src/shared/types.ts b/src/shared/types.ts
index b179fba10..9e79d0f27 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -188,9 +188,10 @@ export interface PtyApi {
readScrollback(persistKey: string): Promise<string>
/** Send literal text + Enter into a session (e.g. a slash command). Returns false if unavailable. */
sendText(persistKey: string, text: string): Promise<boolean>
- /** The agent session's display name (`/rename` name, else auto name) read from its transcript;
- * null if none. Used to keep a node title in sync with the `/resume` name (e.g. after resume). */
- readSessionName(sessionId: string, cwd: string): Promise<string | null>
+ /** The agent session's display name (`/rename` name, else auto name) read from its transcript,
+ * resolved strictly by sessionId; null if unknown. Keeps a node title in sync with the
+ * `/resume` name (e.g. after resume) without cross-contaminating same-folder sessions. */
+ readSessionName(sessionId: string): Promise<string | null>
/** Listens for PTY output. Returns an unsubscribe function. */
onData(sessionId: string, listener: (data: string) => void): () => void
/** Fires when the PTY process exits. Returns an unsubscribe function. */