Export CMUX_SOCKET alongside CMUX_SOCKET_PATH in terminal env (#1991)

* Export CMUX_SOCKET alongside CMUX_SOCKET_PATH in terminal environment

The app only exported CMUX_SOCKET_PATH when setting up the terminal
environment, but some scripts and hooks (e.g. claude-hook) expect
CMUX_SOCKET. The CLI launcher code already exports both (cmux.swift
lines 9288-9289), but the app-side terminal setup was missing the
alias. This caused claude-hook stop to fail with 'TabManager not
available' when CMUX_SOCKET was empty.

Fixes #1905

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Cache socketPath to avoid redundant call

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Achieve 2026-03-25 11:54:44 +08:00 committed by GitHub
parent 818864dd4a
commit bc9f884e69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3335,7 +3335,10 @@ final class TerminalSurface: Identifiable, ObservableObject {
// Backward-compatible shell integration keys used by existing scripts/tests.
setManagedEnvironmentValue("CMUX_PANEL_ID", id.uuidString)
setManagedEnvironmentValue("CMUX_TAB_ID", tabId.uuidString)
setManagedEnvironmentValue("CMUX_SOCKET_PATH", SocketControlSettings.socketPath())
let socketPath = SocketControlSettings.socketPath()
setManagedEnvironmentValue("CMUX_SOCKET_PATH", socketPath)
// Backward-compatible alias expected by older scripts and third-party integrations.
setManagedEnvironmentValue("CMUX_SOCKET", socketPath)
if let bundledCLIURL = Bundle.main.resourceURL?.appendingPathComponent("bin/cmux"),
FileManager.default.isExecutableFile(atPath: bundledCLIURL.path) {
setManagedEnvironmentValue("CMUX_BUNDLED_CLI_PATH", bundledCLIURL.path)