fix(assistant): align SSH status label typography

This commit is contained in:
Kaede Akino committed 2026-10-17 23:10:02 +08:00
1 parent 2d967a7e32
commit dfc1a3171c
4 files changed
+18 -16

No files matched your search

@@ -22,7 +22,7 @@ nonisolated public struct AgentToolDetailPreview: Equatable, Sendable {
private static func text(_ items: [AgentToolDetail.Item]) -> String {
items.map { item in
switch item {
case .field(let field): return field.label + ": " + field.value
case .field(let field): return field.value.isEmpty ? field.label : field.label + ": " + field.value
case .message(let value, _): return value
case .text(let block): return [block.title, block.text].compactMap { $0 }.joined(separator: "\n")
case .list(let list):
@@ -45,16 +45,18 @@ public struct AssistantToolDetails: View {
case .field(let field):
HStack(alignment: .firstTextBaseline, spacing: 8) {
Text(field.label).font(.caption.weight(.medium)).foregroundStyle(.secondary)
if let navigation = field.navigation, let navigate {
Button(field.value) { navigate(navigation) }
.font(field.isMonospaced ? .caption.monospaced() : .caption)
.buttonStyle(.plain)
.foregroundStyle(.tint)
} else if let url = linkURL(field.url) {
Link(field.value, destination: url).font(.caption)
} else {
Text(field.value).font(field.isMonospaced ? .caption.monospaced() : .caption)
.foregroundStyle(isError ? Color.red : .primary)
if !field.value.isEmpty {
if let navigation = field.navigation, let navigate {
Button(field.value) { navigate(navigation) }
.font(field.isMonospaced ? .caption.monospaced() : .caption)
.buttonStyle(.plain)
.foregroundStyle(.tint)
} else if let url = linkURL(field.url) {
Link(field.value, destination: url).font(.caption)
} else {
Text(field.value).font(field.isMonospaced ? .caption.monospaced() : .caption)
.foregroundStyle(isError ? Color.red : .primary)
}
}
}
case .message(let text, let tint): Text(text).foregroundStyle(color(tint))
@@ -22,7 +22,7 @@ nonisolated enum SSHExecToolPresentation {
}
typealias S = AppStrings.SSHExec
func text(_ resource: LocalizedStringResource) -> String { AppLocalization.resolve(resource, locale: locale) }
func field(_ title: LocalizedStringResource, _ value: String, mono: Bool = false) -> AgentToolDetail.Item {
func field(_ title: LocalizedStringResource, _ value: String = "", mono: Bool = false) -> AgentToolDetail.Item {
.field(.init(label: text(title), value: value, isMonospaced: mono))
}
func block(_ title: LocalizedStringResource, _ value: String) -> AgentToolDetail.Item {
@@ -49,8 +49,7 @@ nonisolated enum SSHExecToolPresentation {
var items: [AgentToolDetail.Item] = []
if let command = args["command"]?.stringValue { items.append(block(S.command, command)) }
if card.descriptor.name == "ssh_exec_run" {
items.append(
.message(text(args["run_in_background"]?.boolValue == true ? S.background : S.foreground), .secondary))
items.append(field(args["run_in_background"]?.boolValue == true ? S.background : S.foreground))
}
if let handle = object["handle"]?.stringValue ?? args["handle"]?.stringValue {
items.append(field(S.handle, handle, mono: true))
@@ -64,7 +63,7 @@ nonisolated enum SSHExecToolPresentation {
}
if let count = object["bytes_written"]?.integerValue { items.append(field(S.bytes, String(count), mono: true)) }
if let closed = object["stdin_closed"]?.boolValue {
items.append(.message(text(closed ? S.stdinClosed : S.stdinOpen), .secondary))
items.append(field(closed ? S.stdinClosed : S.stdinOpen))
}
if let error = object["error"]?.stringValue { items.append(.message(error, .failure)) }
if object["remote_termination_confirmed"]?.boolValue == false {
@@ -77,7 +76,7 @@ nonisolated enum SSHExecToolPresentation {
if ["ssh_exec", "ssh_wait", "ssh_exec_run", "ssh_exec_output"].contains(card.descriptor.name),
stdout.isEmpty, stderr.isEmpty
{
items.append(.message(text(card.result == nil ? S.pending : S.noOutput), .secondary))
items.append(card.result == nil ? .message(text(S.pending), .secondary) : field(S.noOutput))
}
if let note = object["note"]?.stringValue { items.append(.message(note, .warning)) }
return .init(items: items)
@@ -1410,6 +1410,7 @@ private enum NativeTranscriptFactory {
font: .systemFont(ofSize: NSFont.smallSystemFontSize, weight: .medium),
color: .secondaryLabelColor
)
if field.value.isEmpty { return key }
key.widthAnchor.constraint(greaterThanOrEqualToConstant: 76).isActive = true
row.addArrangedSubview(key)
let font: NSFont =