From 2a2374afcf1f5e96ea746af7b16aecfe8b0d1c6b Mon Sep 17 00:00:00 2001 From: Grimmer Kang Date: Wed, 25 Mar 2026 11:27:23 +0800 Subject: [PATCH] feat: expose per-surface TTY in tree output (#2040) Add tty field to surface items in system.tree JSON response, reading from existing surfaceTTYNames dictionary. Also show tty= in the CLI text tree output for terminals that have a registered TTY. This enables external tools (e.g. CodeV) to cross-reference claude process TTYs with cmux surfaces for accurate session detection when multiple sessions share the same working directory. --- CLI/cmux.swift | 3 +++ Sources/TerminalController.swift | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CLI/cmux.swift b/CLI/cmux.swift index 17279ef6..a0120002 100644 --- a/CLI/cmux.swift +++ b/CLI/cmux.swift @@ -8565,6 +8565,9 @@ struct CMUXCLI { if (surface["here"] as? Bool) == true { parts.append("◀ here") } + if let tty = surface["tty"] as? String, !tty.isEmpty { + parts.append("tty=\(tty)") + } if surfaceType.lowercased() == "browser", let url = surface["url"] as? String, !url.isEmpty { diff --git a/Sources/TerminalController.swift b/Sources/TerminalController.swift index c6509f46..0aa4f56b 100644 --- a/Sources/TerminalController.swift +++ b/Sources/TerminalController.swift @@ -2849,7 +2849,8 @@ class TerminalController { "selected_in_pane": v2OrNull(selectedInPaneByPanelId[panel.id]), "pane_id": v2OrNull(paneUUID?.uuidString), "pane_ref": v2Ref(kind: .pane, uuid: paneUUID), - "index_in_pane": v2OrNull(indexInPaneByPanelId[panel.id]) + "index_in_pane": v2OrNull(indexInPaneByPanelId[panel.id]), + "tty": v2OrNull(workspace.surfaceTTYNames[panel.id]) ] if panel.panelType == .browser, let browserPanel = panel as? BrowserPanel {