Revert "Merge pull request #239 from manaflow-ai/issue-151-ssh-remote-port-proxying"
This reverts commit78e4bd32ba, reversing changes made tocf75da8f8a.
This commit is contained in:
parent
78e4bd32ba
commit
f7cbbad434
60 changed files with 1250 additions and 17140 deletions
|
|
@ -74,47 +74,6 @@ func cmuxAccentColor() -> Color {
|
|||
Color(nsColor: cmuxAccentNSColor())
|
||||
}
|
||||
|
||||
struct SidebarRemoteErrorCopyEntry: Equatable {
|
||||
let workspaceTitle: String
|
||||
let target: String
|
||||
let detail: String
|
||||
}
|
||||
|
||||
enum SidebarRemoteErrorCopySupport {
|
||||
static func menuLabel(for entries: [SidebarRemoteErrorCopyEntry]) -> String? {
|
||||
guard !entries.isEmpty else { return nil }
|
||||
if entries.count == 1 {
|
||||
return String(localized: "contextMenu.copyError", defaultValue: "Copy Error")
|
||||
}
|
||||
return String(localized: "contextMenu.copyErrors", defaultValue: "Copy Errors")
|
||||
}
|
||||
|
||||
static func clipboardText(for entries: [SidebarRemoteErrorCopyEntry]) -> String? {
|
||||
guard !entries.isEmpty else { return nil }
|
||||
if entries.count == 1, let entry = entries.first {
|
||||
return "SSH error (\(entry.target)): \(entry.detail)"
|
||||
}
|
||||
|
||||
return entries.enumerated().map { index, entry in
|
||||
"\(index + 1). \(entry.workspaceTitle) (\(entry.target)): \(entry.detail)"
|
||||
}.joined(separator: "\n")
|
||||
}
|
||||
|
||||
static func parsedTargetAndDetail(from value: String, fallbackTarget: String? = nil) -> (target: String, detail: String)? {
|
||||
let trimmed = value.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
guard trimmed.hasPrefix("SSH error") else { return nil }
|
||||
|
||||
if let match = trimmed.firstMatch(of: /^SSH error \((.+?)\):\s*(.+)$/) {
|
||||
return (String(match.1), String(match.2))
|
||||
}
|
||||
if let match = trimmed.firstMatch(of: /^SSH error:\s*(.+)$/) {
|
||||
guard let fallbackTarget, !fallbackTarget.isEmpty else { return nil }
|
||||
return (fallbackTarget, String(match.1))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func sidebarSelectedWorkspaceBackgroundNSColor(for colorScheme: ColorScheme) -> NSColor {
|
||||
cmuxAccentNSColor(for: colorScheme)
|
||||
}
|
||||
|
|
@ -1970,7 +1929,6 @@ struct ContentView: View {
|
|||
lastSidebarSelectionIndex: $lastSidebarSelectionIndex
|
||||
)
|
||||
.frame(width: sidebarWidth)
|
||||
.frame(maxHeight: .infinity, alignment: .topLeading)
|
||||
}
|
||||
|
||||
/// Space at top of content area for the titlebar. This must be at least the actual titlebar
|
||||
|
|
@ -7338,7 +7296,6 @@ struct VerticalTabsSidebar: View {
|
|||
#endif
|
||||
draggedTabId = nil
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||
}
|
||||
|
||||
private func debugShortSidebarTabId(_ id: UUID?) -> String {
|
||||
|
|
@ -9532,7 +9489,6 @@ private struct TabItemView: View, Equatable {
|
|||
@AppStorage("sidebarShowPullRequest") private var sidebarShowPullRequest = true
|
||||
@AppStorage(BrowserLinkOpenSettings.openSidebarPullRequestLinksInCmuxBrowserKey)
|
||||
private var openSidebarPullRequestLinksInCmuxBrowser = BrowserLinkOpenSettings.defaultOpenSidebarPullRequestLinksInCmuxBrowser
|
||||
@AppStorage("sidebarShowSSH") private var sidebarShowSSH = true
|
||||
@AppStorage("sidebarShowPorts") private var sidebarShowPorts = true
|
||||
@AppStorage("sidebarShowLog") private var sidebarShowLog = true
|
||||
@AppStorage("sidebarShowProgress") private var sidebarShowProgress = true
|
||||
|
|
@ -9635,84 +9591,12 @@ private struct TabItemView: View, Equatable {
|
|||
)
|
||||
}
|
||||
|
||||
private var remoteWorkspaceSidebarText: String? {
|
||||
guard tab.hasActiveRemoteTerminalSessions else { return nil }
|
||||
let trimmedTarget = tab.remoteDisplayTarget?.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
if let trimmedTarget, !trimmedTarget.isEmpty {
|
||||
return trimmedTarget
|
||||
}
|
||||
return String(localized: "sidebar.remote.subtitleFallback", defaultValue: "SSH workspace")
|
||||
}
|
||||
|
||||
private var copyableSidebarSSHError: String? {
|
||||
let trimmedDetail = tab.remoteConnectionDetail?.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
if tab.remoteConnectionState == .error, let trimmedDetail, !trimmedDetail.isEmpty {
|
||||
let target = tab.remoteDisplayTarget ?? "unknown"
|
||||
return "SSH error (\(target)): \(trimmedDetail)"
|
||||
}
|
||||
if let statusValue = tab.statusEntries["remote.error"]?.value
|
||||
.trimmingCharacters(in: .whitespacesAndNewlines),
|
||||
!statusValue.isEmpty {
|
||||
return statusValue
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
private var remoteConnectionStatusText: String {
|
||||
switch tab.remoteConnectionState {
|
||||
case .connected:
|
||||
return String(localized: "remote.status.connected", defaultValue: "Connected")
|
||||
case .connecting:
|
||||
return String(localized: "remote.status.connecting", defaultValue: "Connecting")
|
||||
case .error:
|
||||
return String(localized: "remote.status.error", defaultValue: "Error")
|
||||
case .disconnected:
|
||||
return String(localized: "remote.status.disconnected", defaultValue: "Disconnected")
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var remoteWorkspaceSection: some View {
|
||||
if sidebarShowSSH, let remoteWorkspaceSidebarText {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(String(localized: "sidebar.remote.badge", defaultValue: "SSH"))
|
||||
.font(.system(size: 9, weight: .semibold))
|
||||
.foregroundColor(activeSecondaryColor(0.62))
|
||||
.textCase(.uppercase)
|
||||
|
||||
HStack(spacing: 6) {
|
||||
Text(remoteWorkspaceSidebarText)
|
||||
.font(.system(size: 10, design: .monospaced))
|
||||
.foregroundColor(activeSecondaryColor(0.8))
|
||||
.lineLimit(1)
|
||||
.truncationMode(.middle)
|
||||
|
||||
Spacer(minLength: 0)
|
||||
|
||||
Text(remoteConnectionStatusText)
|
||||
.font(.system(size: 9, weight: .medium))
|
||||
.foregroundColor(activeSecondaryColor(0.58))
|
||||
.lineLimit(1)
|
||||
}
|
||||
}
|
||||
.padding(.top, latestNotificationText == nil ? 1 : 2)
|
||||
.safeHelp(remoteStateHelpText)
|
||||
}
|
||||
}
|
||||
|
||||
private func copyTextToPasteboard(_ text: String) {
|
||||
let pasteboard = NSPasteboard.general
|
||||
pasteboard.clearContents()
|
||||
pasteboard.setString(text, forType: .string)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
let closeWorkspaceTooltip = String(localized: "sidebar.closeWorkspace.tooltip", defaultValue: "Close Workspace")
|
||||
let accessibilityHintText = String(localized: "sidebar.workspace.accessibilityHint", defaultValue: "Activate to focus this workspace. Drag to reorder, or use Move Up and Move Down actions.")
|
||||
let moveUpActionText = String(localized: "sidebar.workspace.moveUpAction", defaultValue: "Move Up")
|
||||
let moveDownActionText = String(localized: "sidebar.workspace.moveDownAction", defaultValue: "Move Down")
|
||||
let latestNotificationSubtitle = latestNotificationText
|
||||
let effectiveSubtitle = latestNotificationSubtitle
|
||||
let orderedPanelIds: [UUID]? = (sidebarShowBranchDirectory || sidebarShowPullRequest)
|
||||
? tab.sidebarOrderedPanelIds()
|
||||
: nil
|
||||
|
|
@ -9816,7 +9700,7 @@ private struct TabItemView: View, Equatable {
|
|||
.frame(width: workspaceHintSlotWidth, height: 16, alignment: .trailing)
|
||||
}
|
||||
|
||||
if let subtitle = effectiveSubtitle {
|
||||
if let subtitle = latestNotificationSubtitle {
|
||||
Text(subtitle)
|
||||
.font(.system(size: 10))
|
||||
.foregroundColor(activeSecondaryColor(0.8))
|
||||
|
|
@ -9825,8 +9709,6 @@ private struct TabItemView: View, Equatable {
|
|||
.multilineTextAlignment(.leading)
|
||||
}
|
||||
|
||||
remoteWorkspaceSection
|
||||
|
||||
if sidebarShowMetadata {
|
||||
let metadataEntries = tab.sidebarStatusEntriesInDisplayOrder()
|
||||
let metadataBlocks = tab.sidebarMetadataBlocksInDisplayOrder()
|
||||
|
|
@ -10086,16 +9968,6 @@ private struct TabItemView: View, Equatable {
|
|||
let isMulti = targetIds.count > 1
|
||||
let tabColorPalette = WorkspaceTabColorSettings.palette()
|
||||
let shouldPin = !tab.isPinned
|
||||
let targetWorkspaces = targetIds.compactMap { id in tabManager.tabs.first(where: { $0.id == id }) }
|
||||
let remoteTargetWorkspaces = targetWorkspaces.filter { $0.isRemoteWorkspace }
|
||||
let reconnectLabel = contextMenuLabel(
|
||||
multi: String(localized: "contextMenu.reconnectWorkspaces", defaultValue: "Reconnect Workspaces"),
|
||||
single: String(localized: "contextMenu.reconnectWorkspace", defaultValue: "Reconnect Workspace"),
|
||||
isMulti: isMulti)
|
||||
let disconnectLabel = contextMenuLabel(
|
||||
multi: String(localized: "contextMenu.disconnectWorkspaces", defaultValue: "Disconnect Workspaces"),
|
||||
single: String(localized: "contextMenu.disconnectWorkspace", defaultValue: "Disconnect Workspace"),
|
||||
isMulti: isMulti)
|
||||
let pinLabel = shouldPin
|
||||
? contextMenuLabel(
|
||||
multi: String(localized: "contextMenu.pinWorkspaces", defaultValue: "Pin Workspaces"),
|
||||
|
|
@ -10145,24 +10017,6 @@ private struct TabItemView: View, Equatable {
|
|||
}
|
||||
}
|
||||
|
||||
if !remoteTargetWorkspaces.isEmpty {
|
||||
Divider()
|
||||
|
||||
Button(reconnectLabel) {
|
||||
for workspace in remoteTargetWorkspaces {
|
||||
workspace.reconnectRemoteConnection()
|
||||
}
|
||||
}
|
||||
.disabled(remoteTargetWorkspaces.allSatisfy { $0.remoteConnectionState == .connecting })
|
||||
|
||||
Button(disconnectLabel) {
|
||||
for workspace in remoteTargetWorkspaces {
|
||||
workspace.disconnectRemoteConnection(clearConfiguration: false)
|
||||
}
|
||||
}
|
||||
.disabled(remoteTargetWorkspaces.allSatisfy { $0.remoteConnectionState == .disconnected })
|
||||
}
|
||||
|
||||
Menu(String(localized: "contextMenu.workspaceColor", defaultValue: "Workspace Color")) {
|
||||
if tab.customColor != nil {
|
||||
Button {
|
||||
|
|
@ -10195,12 +10049,6 @@ private struct TabItemView: View, Equatable {
|
|||
}
|
||||
}
|
||||
|
||||
if let copyableSidebarSSHError {
|
||||
Button(String(localized: "contextMenu.copySshError", defaultValue: "Copy SSH Error")) {
|
||||
copyTextToPasteboard(copyableSidebarSSHError)
|
||||
}
|
||||
}
|
||||
|
||||
Divider()
|
||||
|
||||
Button(String(localized: "contextMenu.moveUp", defaultValue: "Move Up")) {
|
||||
|
|
@ -10476,62 +10324,6 @@ private struct TabItemView: View, Equatable {
|
|||
}
|
||||
}
|
||||
|
||||
private var remoteStateHelpText: String {
|
||||
let target = tab.remoteDisplayTarget ?? String(
|
||||
localized: "sidebar.remote.help.targetFallback",
|
||||
defaultValue: "remote host"
|
||||
)
|
||||
let detail = tab.remoteConnectionDetail?.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
switch tab.remoteConnectionState {
|
||||
case .connected:
|
||||
return String(
|
||||
format: String(
|
||||
localized: "sidebar.remote.help.connected",
|
||||
defaultValue: "SSH connected to %@"
|
||||
),
|
||||
locale: .current,
|
||||
target
|
||||
)
|
||||
case .connecting:
|
||||
return String(
|
||||
format: String(
|
||||
localized: "sidebar.remote.help.connecting",
|
||||
defaultValue: "SSH connecting to %@"
|
||||
),
|
||||
locale: .current,
|
||||
target
|
||||
)
|
||||
case .error:
|
||||
if let detail, !detail.isEmpty {
|
||||
return String(
|
||||
format: String(
|
||||
localized: "sidebar.remote.help.errorWithDetail",
|
||||
defaultValue: "SSH error for %@: %@"
|
||||
),
|
||||
locale: .current,
|
||||
target,
|
||||
detail
|
||||
)
|
||||
}
|
||||
return String(
|
||||
format: String(
|
||||
localized: "sidebar.remote.help.error",
|
||||
defaultValue: "SSH error for %@"
|
||||
),
|
||||
locale: .current,
|
||||
target
|
||||
)
|
||||
case .disconnected:
|
||||
return String(
|
||||
format: String(
|
||||
localized: "sidebar.remote.help.disconnected",
|
||||
defaultValue: "SSH disconnected from %@"
|
||||
),
|
||||
locale: .current,
|
||||
target
|
||||
)
|
||||
}
|
||||
}
|
||||
private func moveWorkspaces(_ workspaceIds: [UUID], toWindow windowId: UUID) {
|
||||
guard let app = AppDelegate.shared else { return }
|
||||
let orderedWorkspaceIds = tabManager.tabs.compactMap { workspaceIds.contains($0.id) ? $0.id : nil }
|
||||
|
|
@ -10733,18 +10525,6 @@ private struct TabItemView: View, Equatable {
|
|||
}
|
||||
}
|
||||
|
||||
private func shortenPath(_ path: String, home: String) -> String {
|
||||
let trimmed = path.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
guard !trimmed.isEmpty else { return path }
|
||||
if trimmed == home {
|
||||
return "~"
|
||||
}
|
||||
if trimmed.hasPrefix(home + "/") {
|
||||
return "~" + trimmed.dropFirst(home.count)
|
||||
}
|
||||
return trimmed
|
||||
}
|
||||
|
||||
private struct PullRequestStatusIcon: View {
|
||||
let status: SidebarPullRequestStatus
|
||||
let color: Color
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue