From 46e0af5eb02a3af64cd691d8d4d8d64c1be2191e Mon Sep 17 00:00:00 2001 From: cmux-loader Date: Tue, 28 Apr 2026 11:12:24 +0000 Subject: [PATCH 1/2] Address https://github.com/manaflow-ai/cmux/issues/3098 Generated by cmux-loader. --- .../shell-integration/cmux-bash-integration.bash | 3 --- .../shell-integration/cmux-zsh-integration.zsh | 2 -- Sources/TerminalController.swift | 15 ++++++++++++--- cmuxTests/GhosttyConfigTests.swift | 16 ++++++++-------- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Resources/shell-integration/cmux-bash-integration.bash b/Resources/shell-integration/cmux-bash-integration.bash index 6218299b070f..890286a6138d 100644 --- a/Resources/shell-integration/cmux-bash-integration.bash +++ b/Resources/shell-integration/cmux-bash-integration.bash @@ -929,7 +929,6 @@ _cmux_preexec_command() { if [[ -z "$_CMUX_TTY_NAME" ]]; then local t t="$(tty 2>/dev/null || true)" - t="${t##*/}" [[ -n "$t" && "$t" != "not a tty" ]] && _CMUX_TTY_NAME="$t" fi @@ -958,7 +957,6 @@ _cmux_prompt_command() { if [[ -z "$_CMUX_TTY_NAME" ]]; then local t t="$(tty 2>/dev/null || true)" - t="${t##*/}" [[ "$t" != "not a tty" ]] && _CMUX_TTY_NAME="$t" fi @@ -995,7 +993,6 @@ _cmux_prompt_command() { if [[ -z "$_CMUX_TTY_NAME" ]]; then local t t="$(tty 2>/dev/null || true)" - t="${t##*/}" [[ "$t" != "not a tty" ]] && _CMUX_TTY_NAME="$t" fi diff --git a/Resources/shell-integration/cmux-zsh-integration.zsh b/Resources/shell-integration/cmux-zsh-integration.zsh index cd69cbffb993..8bc3ba9af58e 100644 --- a/Resources/shell-integration/cmux-zsh-integration.zsh +++ b/Resources/shell-integration/cmux-zsh-integration.zsh @@ -1074,7 +1074,6 @@ _cmux_preexec() { if [[ -z "$_CMUX_TTY_NAME" ]]; then local t t="$(tty 2>/dev/null || true)" - t="${t##*/}" [[ -n "$t" && "$t" != "not a tty" ]] && _CMUX_TTY_NAME="$t" fi @@ -1122,7 +1121,6 @@ _cmux_precmd() { if [[ -z "$_CMUX_TTY_NAME" ]]; then local t t="$(tty 2>/dev/null || true)" - t="${t##*/}" [[ -n "$t" && "$t" != "not a tty" ]] && _CMUX_TTY_NAME="$t" fi diff --git a/Sources/TerminalController.swift b/Sources/TerminalController.swift index eb1900c5c00d..e39f7bd8c7c4 100644 --- a/Sources/TerminalController.swift +++ b/Sources/TerminalController.swift @@ -481,6 +481,12 @@ class TerminalController { return (workspaceId, panelId) } + private static func portScanTTYName(from ttyName: String) -> String { + let trimmed = ttyName.trimmingCharacters(in: .whitespacesAndNewlines) + let candidate = trimmed.split(separator: "/").last.map(String.init) ?? trimmed + return candidate.isEmpty ? trimmed : candidate + } + nonisolated static func normalizeReportedDirectory(_ directory: String) -> String { let trimmed = directory.trimmingCharacters(in: .whitespacesAndNewlines) guard !trimmed.isEmpty else { return directory } @@ -4509,7 +4515,8 @@ class TerminalController { tab.syncRemotePortScanTTYs() _ = tab.applyPendingRemoteSurfacePortKickIfNeeded(to: surfaceId) } else { - PortScanner.shared.registerTTY(workspaceId: workspaceId, panelId: surfaceId, ttyName: ttyName) + let scanTTYName = Self.portScanTTYName(from: ttyName) + PortScanner.shared.registerTTY(workspaceId: workspaceId, panelId: surfaceId, ttyName: scanTTYName) } result = .ok([ @@ -15972,7 +15979,8 @@ class TerminalController { tab.syncRemotePortScanTTYs() _ = tab.applyPendingRemoteSurfacePortKickIfNeeded(to: scope.panelId) } else { - PortScanner.shared.registerTTY(workspaceId: scope.workspaceId, panelId: scope.panelId, ttyName: ttyName) + let scanTTYName = Self.portScanTTYName(from: ttyName) + PortScanner.shared.registerTTY(workspaceId: scope.workspaceId, panelId: scope.panelId, ttyName: scanTTYName) } } return "OK" @@ -16016,7 +16024,8 @@ class TerminalController { tab.syncRemotePortScanTTYs() _ = tab.applyPendingRemoteSurfacePortKickIfNeeded(to: surfaceId) } else { - PortScanner.shared.registerTTY(workspaceId: tab.id, panelId: surfaceId, ttyName: ttyName) + let scanTTYName = Self.portScanTTYName(from: ttyName) + PortScanner.shared.registerTTY(workspaceId: tab.id, panelId: surfaceId, ttyName: scanTTYName) } } return result diff --git a/cmuxTests/GhosttyConfigTests.swift b/cmuxTests/GhosttyConfigTests.swift index 8baa6b90da66..9fd3e9307a67 100644 --- a/cmuxTests/GhosttyConfigTests.swift +++ b/cmuxTests/GhosttyConfigTests.swift @@ -3567,7 +3567,7 @@ final class ZshShellIntegrationHandoffTests: XCTestCase { cmuxLoadGhosttyIntegration: false, cmuxLoadShellIntegration: true, command: """ - _CMUX_TTY_NAME=ttys999 + _CMUX_TTY_NAME=/dev/ttys999 print -r -- "$(_cmux_report_tty_payload)" """, extraEnvironment: [ @@ -3577,7 +3577,7 @@ final class ZshShellIntegrationHandoffTests: XCTestCase { ] ) - XCTAssertEqual(output, "report_tty ttys999 --tab=11111111-1111-1111-1111-111111111111") + XCTAssertEqual(output, "report_tty /dev/ttys999 --tab=11111111-1111-1111-1111-111111111111") } func testShellIntegrationRelayReportTTYUsesWorkspaceIDInZsh() throws { @@ -3604,7 +3604,7 @@ final class ZshShellIntegrationHandoffTests: XCTestCase { cmuxLoadShellIntegration: true, command: """ : > "\(logPath.path)" - _CMUX_TTY_NAME=ttys777 + _CMUX_TTY_NAME=/dev/ttys777 _cmux_report_tty_via_relay cat "\(logPath.path)" """, @@ -3618,7 +3618,7 @@ final class ZshShellIntegrationHandoffTests: XCTestCase { ) XCTAssertTrue( - output.contains(#"rpc surface.report_tty {"workspace_id":"11111111-1111-1111-1111-111111111111","tty_name":"ttys777","surface_id":"22222222-2222-2222-2222-222222222222"}"#), + output.contains(#"rpc surface.report_tty {"workspace_id":"11111111-1111-1111-1111-111111111111","tty_name":"/dev/ttys777","surface_id":"22222222-2222-2222-2222-222222222222"}"#), output ) } @@ -3741,7 +3741,7 @@ final class ZshShellIntegrationHandoffTests: XCTestCase { cmuxLoadShellIntegration: true, command: """ : > "\(logPath.path)" - _CMUX_TTY_NAME=ttys888 + _CMUX_TTY_NAME=/dev/ttys888 _cmux_report_tty_via_relay cat "\(logPath.path)" """, @@ -3755,7 +3755,7 @@ final class ZshShellIntegrationHandoffTests: XCTestCase { ) XCTAssertTrue( - result.stdout.contains(#"rpc surface.report_tty {"workspace_id":"11111111-1111-1111-1111-111111111111","tty_name":"ttys888","surface_id":"22222222-2222-2222-2222-222222222222"}"#), + result.stdout.contains(#"rpc surface.report_tty {"workspace_id":"11111111-1111-1111-1111-111111111111","tty_name":"/dev/ttys888","surface_id":"22222222-2222-2222-2222-222222222222"}"#), result.stdout ) } @@ -3783,7 +3783,7 @@ final class ZshShellIntegrationHandoffTests: XCTestCase { cmuxLoadShellIntegration: true, command: """ : > "\(logPath.path)" - _CMUX_TTY_NAME=ttys889 + _CMUX_TTY_NAME=/dev/ttys889 _CMUX_TTY_REPORTED=0 _cmux_preexec_command "python3 -m http.server 8899" for _cmux_i in $(seq 1 20); do @@ -3802,7 +3802,7 @@ final class ZshShellIntegrationHandoffTests: XCTestCase { ) XCTAssertTrue( - result.stdout.contains(#"rpc surface.report_tty {"workspace_id":"11111111-1111-1111-1111-111111111111","tty_name":"ttys889"}"#), + result.stdout.contains(#"rpc surface.report_tty {"workspace_id":"11111111-1111-1111-1111-111111111111","tty_name":"/dev/ttys889"}"#), result.stdout ) XCTAssertTrue( From e2941431fad118e48ce51ed77c4f7e6b359203d8 Mon Sep 17 00:00:00 2001 From: Lawrence Chen Date: Tue, 28 Apr 2026 15:59:56 -0700 Subject: [PATCH 2/2] Refresh Swift file length budget --- .github/swift-file-length-budget.tsv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/swift-file-length-budget.tsv b/.github/swift-file-length-budget.tsv index fd2496542a15..cf58b9285e17 100644 --- a/.github/swift-file-length-budget.tsv +++ b/.github/swift-file-length-budget.tsv @@ -2,7 +2,7 @@ # Format: max_linesrelative path # Reduce counts as files shrink. CI fails if tracked files exceed this budget. 18705 CLI/cmux.swift -16364 Sources/TerminalController.swift +16373 Sources/TerminalController.swift 15762 Sources/ContentView.swift 13748 Sources/AppDelegate.swift 13702 Sources/Workspace.swift