diff options
Diffstat (limited to 'menubar/panel.swift')
| -rw-r--r-- | menubar/panel.swift | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/menubar/panel.swift b/menubar/panel.swift index 5347ceb..174d30e 100644 --- a/menubar/panel.swift +++ b/menubar/panel.swift @@ -313,9 +313,17 @@ final class PanelRowView: ClickView { self.onClick = { onClick(row.paneId) } let title = singleLine(NSTextField( labelWithAttributedString: titleText ?? rowTitle(row, primary: mochaText, secondary: mochaSubtext))) - let placeLabel = NSTextField(labelWithString: row.place) - placeLabel.font = .systemFont(ofSize: 11) - placeLabel.textColor = mochaSubtext + // A failed run's "failed 3m · why" in red. + let small = NSFont.systemFont(ofSize: 11) + let placeText = NSMutableAttributedString( + string: row.placeBase, attributes: [.font: small, .foregroundColor: mochaSubtext]) + if let failure = row.failure { + placeText.append(NSAttributedString(string: " · ", attributes: [.font: small, .foregroundColor: mochaSubtext])) + placeText.append(NSAttributedString(string: failure, attributes: [.font: small, .foregroundColor: mochaRed])) + } + let placeLabel = NSTextField(labelWithAttributedString: placeText) + // Its own font too, or it lays out as 13 pt (the colors stay). + placeLabel.font = small let place = singleLine(placeLabel) let cost = NSTextField(labelWithString: row.cost >= 0.005 ? dollars(row.cost) : "") cost.font = .monospacedDigitSystemFont(ofSize: 11, weight: .regular) @@ -777,6 +785,17 @@ func panelSelftest() -> [String] { check(full.plainText.hasSuffix("[Show less ▴]") && !compact.plainText.contains("Show"), "toggle offered only when allowed, labelled by layout") + // A failed run. + var broken = row("b", .done) + broken.error = "401: invalid x-api-key" + broken.cost = 1.5 + check(broken.failed && broken.place.hasPrefix("s · b · pi · failed ") && broken.place.hasSuffix(" · 401: invalid x-api-key"), + "failed: in place of the wait, with why") + check(broken.subtitle.hasSuffix("401: invalid x-api-key · $1.50"), "failed: the menu's text, then the cost") + var seen = row("b", .idle) + seen.error = broken.error + check(!seen.failed && seen.place == "s · b · pi", "failed: once seen, plain idle") + // Context use. var filling = row("f", .idle) filling.cost = 3.12 |
