diff --git a/Resources/Localizable.xcstrings b/Resources/Localizable.xcstrings index 14de005d..9dbe7308 100644 --- a/Resources/Localizable.xcstrings +++ b/Resources/Localizable.xcstrings @@ -64785,6 +64785,40 @@ } } }, + "sidebar.port.label": { + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": ":%lld" + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": ":%lld" + } + } + } + }, + "sidebar.port.openTooltip": { + "extractionState": "manual", + "localizations": { + "en": { + "stringUnit": { + "state": "translated", + "value": "Open localhost:%lld" + } + }, + "ja": { + "stringUnit": { + "state": "translated", + "value": "localhost:%lldを開く" + } + } + } + }, "sidebar.pullRequest.openTooltip": { "extractionState": "manual", "localizations": { diff --git a/Sources/ContentView.swift b/Sources/ContentView.swift index 9065d597..046ce785 100644 --- a/Sources/ContentView.swift +++ b/Sources/ContentView.swift @@ -11486,11 +11486,22 @@ private struct TabItemView: View, Equatable { // Ports row if detailVisibility.showsPorts, !tab.listeningPorts.isEmpty { - Text(tab.listeningPorts.map { ":\($0)" }.joined(separator: ", ")) - .font(.system(size: 10, design: .monospaced)) - .foregroundColor(activeSecondaryColor(0.75)) - .lineLimit(1) - .truncationMode(.tail) + HStack(spacing: 4) { + ForEach(tab.listeningPorts, id: \.self) { port in + Button(action: { + openPortLink(port) + }) { + Text(String(localized: "sidebar.port.label", defaultValue: ":\(port)")) + .underline() + } + .buttonStyle(.plain) + .safeHelp(String(localized: "sidebar.port.openTooltip", defaultValue: "Open localhost:\(port)")) + } + Spacer(minLength: 0) + } + .font(.system(size: 10, design: .monospaced)) + .foregroundColor(activeSecondaryColor(0.75)) + .lineLimit(1) } } .animation(.easeInOut(duration: 0.2), value: tab.logEntries.count) @@ -12206,6 +12217,23 @@ private struct TabItemView: View, Equatable { NSWorkspace.shared.open(url) } + private func openPortLink(_ port: Int) { + guard let url = URL(string: "http://localhost:\(port)") else { return } + updateSelection() + if openSidebarPullRequestLinksInCmuxBrowser { + if tabManager.openBrowser( + inWorkspace: tab.id, + url: url, + preferSplitRight: true, + insertAtEnd: true + ) == nil { + NSWorkspace.shared.open(url) + } + return + } + NSWorkspace.shared.open(url) + } + private func pullRequestStatusLabel( _ status: SidebarPullRequestStatus, checks _: SidebarPullRequestChecksStatus?