From 223c674d09de9d5443f5afcc3f6970aa165eb78d Mon Sep 17 00:00:00 2001 From: basedcorp99 Date: Tue, 2 Jun 2026 11:30:56 +0200 Subject: [PATCH 1/8] Add cmux terminal surface detection to getTerminalId - Add CMUX_SURFACE_ID env var fallback to getTerminalId() so cmux surfaces get a stable terminal identifier alongside kitty/tmux. Enables per-surface session breadcrumbs for omp -c in cmux. - Update tip text to mention cmux alongside kitty/tmux. --- packages/coding-agent/CHANGELOG.md | 1 + packages/coding-agent/src/modes/components/tips.txt | 2 +- packages/tui/CHANGELOG.md | 4 ++++ packages/tui/src/ttyid.ts | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 947704833..de7d315c6 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -15,6 +15,7 @@ - Changed resuming a session that belongs to a different project to switch the process into that project's working directory. `pi --resume` and the in-session `/resume` picker now `chdir` into the resumed session's `cwd` and re-scope every cwd-derived input — project dir, **project settings** (`.claude/settings.yml`, `.omp/settings.json`, path-scoped `enabledModels`/`disabledProviders`), plugin roots, capabilities, slash commands, and the ssh tool — so tools, discovery, configuration, and commands all follow the resumed project. The `SessionManager` adopts the resumed session's own `cwd`/session directory on load (rolled back if the switch fails). - Documented `ANTHROPIC_SEARCH_API_KEY` and `ANTHROPIC_SEARCH_BASE_URL` more thoroughly in `docs/environment-variables.md`, surfaced them in `docs/tools/web_search.md`'s Anthropic provider section, and added `ANTHROPIC_SEARCH_BASE_URL` to `omp --help`'s env-var summary so the search-only overrides are discoverable alongside `ANTHROPIC_SEARCH_API_KEY` ([#1694](https://github.com/can1357/oh-my-pi/issues/1694)). - Migrated the Kagi web search provider to Kagi's V1 Search API (`POST /api/v1/search`), replacing the sunset V0 endpoint while keeping the `kagi` provider id, `KAGI_API_KEY` credential, and `/login kagi` flow unchanged ([#1272](https://github.com/can1357/oh-my-pi/pull/1272) by [@thismat](https://github.com/thismat)) +- Updated the "each kitty/tmux split" tip to include cmux. ### Fixed diff --git a/packages/coding-agent/src/modes/components/tips.txt b/packages/coding-agent/src/modes/components/tips.txt index bada0f954..c8d45eab2 100644 --- a/packages/coding-agent/src/modes/components/tips.txt +++ b/packages/coding-agent/src/modes/components/tips.txt @@ -5,7 +5,7 @@ Find out which model you emotionally abuse the most with `omp stats` Try task isolation to create CoW worktrees Your LLM can call an LLM using `llm(x...)`. Have a big batch of tasks? Ask clanker to use it! Spaghetti code? Try complaining with /omfg -Did you know? Each kitty/tmux split keeps its own session — `omp -c` resumes the right one +Did you know? Each kitty/tmux/cmux split keeps its own session — `omp -c` resumes the right one Drop the word `ultrathink` in your message for harder multi-step reasoning — watch it glow rainbow as you type Say `orchestrate` in your message to drive a multi-phase task with parallel subagents — watch it glow as you type Say `workflow` in your message to drive the task with parallel subagents in eval — watch it glow as you type diff --git a/packages/tui/CHANGELOG.md b/packages/tui/CHANGELOG.md index eade28f07..5badf2b23 100644 --- a/packages/tui/CHANGELOG.md +++ b/packages/tui/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Added + +- Added `CMUX_SURFACE_ID` environment variable support to `getTerminalId()`, so cmux terminal surfaces get a stable identifier alongside kitty, tmux, macOS Terminal.app, and Windows Terminal — enabling per-surface session breadcrumbs for `omp -c` in cmux. + ### Fixed - Deferred eager live scrollback rebuilds on POSIX terminals where xterm ED3 (`CSI 3 J`, erase saved lines) can disturb scrolled-up readers during streaming, while keeping direct user-input and checkpoint rebuilds explicit ([#1682](https://github.com/can1357/oh-my-pi/issues/1682)). diff --git a/packages/tui/src/ttyid.ts b/packages/tui/src/ttyid.ts index 313d5cfee..2d9a0f7ce 100644 --- a/packages/tui/src/ttyid.ts +++ b/packages/tui/src/ttyid.ts @@ -52,6 +52,8 @@ export function getTerminalId(): string | null { // Fallback to terminal-specific env vars const kittyId = process.env.KITTY_WINDOW_ID; if (kittyId) return `kitty-${kittyId}`; + const cmuxSurface = process.env.CMUX_SURFACE_ID; + if (cmuxSurface) return `cmux-${cmuxSurface}`; const tmuxPane = process.env.TMUX_PANE; if (tmuxPane) return `tmux-${tmuxPane}`; From 656e855e4ad2bb149841dc4ca9626a3f902eb0d6 Mon Sep 17 00:00:00 2001 From: basedcorp99 Date: Tue, 2 Jun 2026 11:52:19 +0200 Subject: [PATCH 2/8] Add CMUX_SURFACE_ID to docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to CMUX_SURFACE_ID env var support — document it alongside KITTY_WINDOW_ID, TMUX_PANE, etc. in environment-variables.md and session-switching-and-recent-listing.md. --- docs/environment-variables.md | 2 +- docs/session-switching-and-recent-listing.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/environment-variables.md b/docs/environment-variables.md index e63a14a00..55b530b27 100644 --- a/docs/environment-variables.md +++ b/docs/environment-variables.md @@ -372,7 +372,7 @@ These are read as runtime signals; they are usually set by the terminal/OS rathe | `COLORFGBG` | Terminal background light/dark auto-detection | | `TERM_PROGRAM`, `TERM_PROGRAM_VERSION`, `TERMINAL_EMULATOR` | Terminal identity in system prompt/context | | `KDE_FULL_SESSION`, `XDG_CURRENT_DESKTOP`, `DESKTOP_SESSION`, `XDG_SESSION_DESKTOP`, `GDMSESSION`, `WINDOWMANAGER` | Desktop/window-manager detection in system prompt/context | -| `KITTY_WINDOW_ID`, `TMUX_PANE`, `TERM_SESSION_ID`, `WT_SESSION` | Stable per-terminal session breadcrumb IDs | +| `KITTY_WINDOW_ID`, `TMUX_PANE`, `TERM_SESSION_ID`, `WT_SESSION`, `CMUX_SURFACE_ID` | Stable per-terminal session breadcrumb IDs | | `SHELL`, `ComSpec`, `TERM_PROGRAM`, `TERM` | System info diagnostics | | `APPDATA`, `XDG_CONFIG_HOME` | lspmux config path resolution | | `HOME` | Path shortening in MCP command UI | diff --git a/docs/session-switching-and-recent-listing.md b/docs/session-switching-and-recent-listing.md index faa2f2eac..1e8d0371f 100644 --- a/docs/session-switching-and-recent-listing.md +++ b/docs/session-switching-and-recent-listing.md @@ -67,7 +67,7 @@ For `SessionInfo` list entries: 3. If breadcrumb is invalid/missing, fall back to newest file by mtime in the session dir (`findMostRecentSession`) 4. If none found, create a new session -Terminal ID derivation prefers TTY path and falls back to env-based identifiers (`KITTY_WINDOW_ID`, `TMUX_PANE`, `TERM_SESSION_ID`, `WT_SESSION`). +Terminal ID derivation prefers TTY path and falls back to env-based identifiers (`KITTY_WINDOW_ID`, `TMUX_PANE`, `TERM_SESSION_ID`, `WT_SESSION`, `CMUX_SURFACE_ID`). Breadcrumb writes are best-effort and non-fatal. From 6eebbb0c91740969fde9ac7cd94dfa51b83a7276 Mon Sep 17 00:00:00 2001 From: basedcorp99 Date: Tue, 2 Jun 2026 12:03:36 +0200 Subject: [PATCH 3/8] Add test for CMUX_SURFACE_ID terminal ID detection --- packages/tui/test/ttyid.test.ts | 52 +++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 packages/tui/test/ttyid.test.ts diff --git a/packages/tui/test/ttyid.test.ts b/packages/tui/test/ttyid.test.ts new file mode 100644 index 000000000..fb09bd43a --- /dev/null +++ b/packages/tui/test/ttyid.test.ts @@ -0,0 +1,52 @@ +import { afterEach, describe, expect, it } from "bun:test"; +import { getTerminalId } from "@oh-my-pi/pi-tui/ttyid"; + +const stdinIsTtyDescriptor = Object.getOwnPropertyDescriptor(process.stdin, "isTTY"); +const terminalEnvKeys = [ + "KITTY_WINDOW_ID", + "CMUX_SURFACE_ID", + "TMUX_PANE", + "TERM_SESSION_ID", + "WT_SESSION", +] as const; +const originalTerminalEnv = Object.fromEntries(terminalEnvKeys.map(key => [key, process.env[key]])); + +function restoreProperty(target: object, key: string, descriptor: PropertyDescriptor | undefined): void { + if (descriptor) { + Object.defineProperty(target, key, descriptor); + return; + } + delete (target as Record)[key]; +} + +function setTerminalEnv(overrides: Partial>): void { + for (const key of terminalEnvKeys) { + const value = overrides[key]; + if (value === undefined) { + delete process.env[key]; + continue; + } + process.env[key] = value; + } +} + +describe("getTerminalId", () => { + afterEach(() => { + restoreProperty(process.stdin, "isTTY", stdinIsTtyDescriptor); + for (const key of terminalEnvKeys) { + const value = originalTerminalEnv[key]; + if (value === undefined) { + delete process.env[key]; + continue; + } + process.env[key] = value; + } + }); + + it("uses CMUX_SURFACE_ID as the terminal identity when stdin is piped", () => { + Object.defineProperty(process.stdin, "isTTY", { value: false, configurable: true }); + setTerminalEnv({ CMUX_SURFACE_ID: "surface-1234" }); + + expect(getTerminalId()).toBe("cmux-surface-1234"); + }); +}); From b93be377ba3e6429696f1c40e3463ec7918a2af2 Mon Sep 17 00:00:00 2001 From: basedcorp99 Date: Tue, 2 Jun 2026 12:10:21 +0200 Subject: [PATCH 4/8] pretty --- docs/environment-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/environment-variables.md b/docs/environment-variables.md index 55b530b27..c759ecce1 100644 --- a/docs/environment-variables.md +++ b/docs/environment-variables.md @@ -372,7 +372,7 @@ These are read as runtime signals; they are usually set by the terminal/OS rathe | `COLORFGBG` | Terminal background light/dark auto-detection | | `TERM_PROGRAM`, `TERM_PROGRAM_VERSION`, `TERMINAL_EMULATOR` | Terminal identity in system prompt/context | | `KDE_FULL_SESSION`, `XDG_CURRENT_DESKTOP`, `DESKTOP_SESSION`, `XDG_SESSION_DESKTOP`, `GDMSESSION`, `WINDOWMANAGER` | Desktop/window-manager detection in system prompt/context | -| `KITTY_WINDOW_ID`, `TMUX_PANE`, `TERM_SESSION_ID`, `WT_SESSION`, `CMUX_SURFACE_ID` | Stable per-terminal session breadcrumb IDs | +| `KITTY_WINDOW_ID`, `TMUX_PANE`, `TERM_SESSION_ID`, `WT_SESSION`, `CMUX_SURFACE_ID` | Stable per-terminal session breadcrumb IDs | | `SHELL`, `ComSpec`, `TERM_PROGRAM`, `TERM` | System info diagnostics | | `APPDATA`, `XDG_CONFIG_HOME` | lspmux config path resolution | | `HOME` | Path shortening in MCP command UI | From dd3c09023cfb824527e1e79a7860984fad861534 Mon Sep 17 00:00:00 2001 From: basedcorp99 Date: Tue, 2 Jun 2026 12:17:50 +0200 Subject: [PATCH 5/8] Prioritize TMUX_PANE over CMUX_SURFACE_ID in env fallback order MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When tmux runs inside a cmux surface, both env vars are set. The innermost multiplexer (tmux) should win so per-pane breadcrumbs are preserved — otherwise every tmux pane in the same cmux surface would share one breadcrumb, regressing omp -c for tmux-inside-cmux users. Review: https://github.com/can1357/oh-my-pi/pull/1702#discussion_r3340387012 --- packages/tui/src/ttyid.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/tui/src/ttyid.ts b/packages/tui/src/ttyid.ts index 2d9a0f7ce..4845f7931 100644 --- a/packages/tui/src/ttyid.ts +++ b/packages/tui/src/ttyid.ts @@ -52,12 +52,13 @@ export function getTerminalId(): string | null { // Fallback to terminal-specific env vars const kittyId = process.env.KITTY_WINDOW_ID; if (kittyId) return `kitty-${kittyId}`; - const cmuxSurface = process.env.CMUX_SURFACE_ID; - if (cmuxSurface) return `cmux-${cmuxSurface}`; const tmuxPane = process.env.TMUX_PANE; if (tmuxPane) return `tmux-${tmuxPane}`; + const cmuxSurface = process.env.CMUX_SURFACE_ID; + if (cmuxSurface) return `cmux-${cmuxSurface}`; + const terminalSessionId = process.env.TERM_SESSION_ID; // macOS Terminal.app if (terminalSessionId) return `apple-${terminalSessionId}`; From 335d29298e0518e56d1fb813e76cbabc29a455f3 Mon Sep 17 00:00:00 2001 From: basedcorp99 Date: Tue, 2 Jun 2026 13:12:02 +0200 Subject: [PATCH 6/8] Address cmux terminal id review --- packages/coding-agent/CHANGELOG.md | 5 ++++- packages/tui/CHANGELOG.md | 1 + packages/tui/test/ttyid.test.ts | 9 ++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index f7467258f..7cc57ae94 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Changed + +- Updated the "each kitty/tmux split" tip to include cmux. + ## [15.8.0] - 2026-06-02 ### Added @@ -18,7 +22,6 @@ - Changed resuming a session that belongs to a different project to switch the process into that project's working directory. `pi --resume` and the in-session `/resume` picker now `chdir` into the resumed session's `cwd` and re-scope every cwd-derived input — project dir, **project settings** (`.claude/settings.yml`, `.omp/settings.json`, path-scoped `enabledModels`/`disabledProviders`), plugin roots, capabilities, slash commands, and the ssh tool — so tools, discovery, configuration, and commands all follow the resumed project. The `SessionManager` adopts the resumed session's own `cwd`/session directory on load (rolled back if the switch fails). - Documented `ANTHROPIC_SEARCH_API_KEY` and `ANTHROPIC_SEARCH_BASE_URL` more thoroughly in `docs/environment-variables.md`, surfaced them in `docs/tools/web_search.md`'s Anthropic provider section, and added `ANTHROPIC_SEARCH_BASE_URL` to `omp --help`'s env-var summary so the search-only overrides are discoverable alongside `ANTHROPIC_SEARCH_API_KEY` ([#1694](https://github.com/can1357/oh-my-pi/issues/1694)). - Migrated the Kagi web search provider to Kagi's V1 Search API (`POST /api/v1/search`), replacing the sunset V0 endpoint while keeping the `kagi` provider id, `KAGI_API_KEY` credential, and `/login kagi` flow unchanged ([#1272](https://github.com/can1357/oh-my-pi/pull/1272) by [@thismat](https://github.com/thismat)) -- Updated the "each kitty/tmux split" tip to include cmux. ### Fixed diff --git a/packages/tui/CHANGELOG.md b/packages/tui/CHANGELOG.md index 053be2f15..19931c3a3 100644 --- a/packages/tui/CHANGELOG.md +++ b/packages/tui/CHANGELOG.md @@ -5,6 +5,7 @@ ### Added - Added `CMUX_SURFACE_ID` environment variable support to `getTerminalId()`, so cmux terminal surfaces get a stable identifier alongside kitty, tmux, macOS Terminal.app, and Windows Terminal — enabling per-surface session breadcrumbs for `omp -c` in cmux. + ## [15.8.0] - 2026-06-02 ### Fixed diff --git a/packages/tui/test/ttyid.test.ts b/packages/tui/test/ttyid.test.ts index fb09bd43a..49936abc2 100644 --- a/packages/tui/test/ttyid.test.ts +++ b/packages/tui/test/ttyid.test.ts @@ -4,8 +4,8 @@ import { getTerminalId } from "@oh-my-pi/pi-tui/ttyid"; const stdinIsTtyDescriptor = Object.getOwnPropertyDescriptor(process.stdin, "isTTY"); const terminalEnvKeys = [ "KITTY_WINDOW_ID", - "CMUX_SURFACE_ID", "TMUX_PANE", + "CMUX_SURFACE_ID", "TERM_SESSION_ID", "WT_SESSION", ] as const; @@ -49,4 +49,11 @@ describe("getTerminalId", () => { expect(getTerminalId()).toBe("cmux-surface-1234"); }); + + it("prefers TMUX_PANE over CMUX_SURFACE_ID when both are present", () => { + Object.defineProperty(process.stdin, "isTTY", { value: false, configurable: true }); + setTerminalEnv({ TMUX_PANE: "%7", CMUX_SURFACE_ID: "surface-1234" }); + + expect(getTerminalId()).toBe("tmux-%7"); + }); }); From 33dbc5306475e653dce53fc5ca9b0e77c0b8cbc0 Mon Sep 17 00:00:00 2001 From: basedcorp99 Date: Tue, 2 Jun 2026 13:12:44 +0200 Subject: [PATCH 7/8] Document terminal id precedence --- packages/tui/src/ttyid.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/tui/src/ttyid.ts b/packages/tui/src/ttyid.ts index 4845f7931..41a71f0d7 100644 --- a/packages/tui/src/ttyid.ts +++ b/packages/tui/src/ttyid.ts @@ -50,6 +50,7 @@ export function getTerminalId(): string | null { } // Fallback to terminal-specific env vars + // Preserve precedence for nested terminals: kitty first, then tmux panes before outer cmux surfaces. const kittyId = process.env.KITTY_WINDOW_ID; if (kittyId) return `kitty-${kittyId}`; From 3bcc02a19e60bfea752f1a29e5de84818fb5c704 Mon Sep 17 00:00:00 2001 From: basedcorp99 Date: Tue, 2 Jun 2026 13:18:01 +0200 Subject: [PATCH 8/8] Prefer cmux surfaces over host terminal ids --- docs/environment-variables.md | 2 +- docs/session-switching-and-recent-listing.md | 2 +- packages/tui/src/ttyid.ts | 8 ++++---- packages/tui/test/ttyid.test.ts | 16 +++++++++++++++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/docs/environment-variables.md b/docs/environment-variables.md index c759ecce1..9256c474e 100644 --- a/docs/environment-variables.md +++ b/docs/environment-variables.md @@ -372,7 +372,7 @@ These are read as runtime signals; they are usually set by the terminal/OS rathe | `COLORFGBG` | Terminal background light/dark auto-detection | | `TERM_PROGRAM`, `TERM_PROGRAM_VERSION`, `TERMINAL_EMULATOR` | Terminal identity in system prompt/context | | `KDE_FULL_SESSION`, `XDG_CURRENT_DESKTOP`, `DESKTOP_SESSION`, `XDG_SESSION_DESKTOP`, `GDMSESSION`, `WINDOWMANAGER` | Desktop/window-manager detection in system prompt/context | -| `KITTY_WINDOW_ID`, `TMUX_PANE`, `TERM_SESSION_ID`, `WT_SESSION`, `CMUX_SURFACE_ID` | Stable per-terminal session breadcrumb IDs | +| `TMUX_PANE`, `CMUX_SURFACE_ID`, `KITTY_WINDOW_ID`, `TERM_SESSION_ID`, `WT_SESSION` | Stable per-terminal session breadcrumb IDs | | `SHELL`, `ComSpec`, `TERM_PROGRAM`, `TERM` | System info diagnostics | | `APPDATA`, `XDG_CONFIG_HOME` | lspmux config path resolution | | `HOME` | Path shortening in MCP command UI | diff --git a/docs/session-switching-and-recent-listing.md b/docs/session-switching-and-recent-listing.md index 1e8d0371f..b8eeecf86 100644 --- a/docs/session-switching-and-recent-listing.md +++ b/docs/session-switching-and-recent-listing.md @@ -67,7 +67,7 @@ For `SessionInfo` list entries: 3. If breadcrumb is invalid/missing, fall back to newest file by mtime in the session dir (`findMostRecentSession`) 4. If none found, create a new session -Terminal ID derivation prefers TTY path and falls back to env-based identifiers (`KITTY_WINDOW_ID`, `TMUX_PANE`, `TERM_SESSION_ID`, `WT_SESSION`, `CMUX_SURFACE_ID`). +Terminal ID derivation prefers TTY path and falls back to env-based identifiers (`TMUX_PANE`, `CMUX_SURFACE_ID`, `KITTY_WINDOW_ID`, `TERM_SESSION_ID`, `WT_SESSION`). Breadcrumb writes are best-effort and non-fatal. diff --git a/packages/tui/src/ttyid.ts b/packages/tui/src/ttyid.ts index 41a71f0d7..5933a7cdc 100644 --- a/packages/tui/src/ttyid.ts +++ b/packages/tui/src/ttyid.ts @@ -50,16 +50,16 @@ export function getTerminalId(): string | null { } // Fallback to terminal-specific env vars - // Preserve precedence for nested terminals: kitty first, then tmux panes before outer cmux surfaces. - const kittyId = process.env.KITTY_WINDOW_ID; - if (kittyId) return `kitty-${kittyId}`; - + // Prefer inner multiplexers over host terminal emulators when stdin has no TTY path. const tmuxPane = process.env.TMUX_PANE; if (tmuxPane) return `tmux-${tmuxPane}`; const cmuxSurface = process.env.CMUX_SURFACE_ID; if (cmuxSurface) return `cmux-${cmuxSurface}`; + const kittyId = process.env.KITTY_WINDOW_ID; + if (kittyId) return `kitty-${kittyId}`; + const terminalSessionId = process.env.TERM_SESSION_ID; // macOS Terminal.app if (terminalSessionId) return `apple-${terminalSessionId}`; diff --git a/packages/tui/test/ttyid.test.ts b/packages/tui/test/ttyid.test.ts index 49936abc2..1fa1df917 100644 --- a/packages/tui/test/ttyid.test.ts +++ b/packages/tui/test/ttyid.test.ts @@ -3,9 +3,9 @@ import { getTerminalId } from "@oh-my-pi/pi-tui/ttyid"; const stdinIsTtyDescriptor = Object.getOwnPropertyDescriptor(process.stdin, "isTTY"); const terminalEnvKeys = [ - "KITTY_WINDOW_ID", "TMUX_PANE", "CMUX_SURFACE_ID", + "KITTY_WINDOW_ID", "TERM_SESSION_ID", "WT_SESSION", ] as const; @@ -56,4 +56,18 @@ describe("getTerminalId", () => { expect(getTerminalId()).toBe("tmux-%7"); }); + + it("prefers CMUX_SURFACE_ID over KITTY_WINDOW_ID when both are present", () => { + Object.defineProperty(process.stdin, "isTTY", { value: false, configurable: true }); + setTerminalEnv({ KITTY_WINDOW_ID: "window-42", CMUX_SURFACE_ID: "surface-1234" }); + + expect(getTerminalId()).toBe("cmux-surface-1234"); + }); + + it("ignores an empty CMUX_SURFACE_ID and falls through to the outer terminal", () => { + Object.defineProperty(process.stdin, "isTTY", { value: false, configurable: true }); + setTerminalEnv({ KITTY_WINDOW_ID: "window-42", CMUX_SURFACE_ID: "" }); + + expect(getTerminalId()).toBe("kitty-window-42"); + }); });