From 7568a7303340c888be52b94c3c09c54f97eff3c7 Mon Sep 17 00:00:00 2001 From: Leo Li Date: Wed, 30 Sep 2026 01:03:04 -0700 Subject: [PATCH 1/5] test: cover distinct Cloud machine stale statuses Co-Authored-By: Claude Opus 5 --- .../MachinesListStatusToolbarRowTests.swift | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/cmuxTests/MachinesListStatusToolbarRowTests.swift b/cmuxTests/MachinesListStatusToolbarRowTests.swift index 117cca65063b..01a8cd4a0a3b 100644 --- a/cmuxTests/MachinesListStatusToolbarRowTests.swift +++ b/cmuxTests/MachinesListStatusToolbarRowTests.swift @@ -36,18 +36,21 @@ struct MachinesListStatusToolbarRowTests { } } - /// Each row must carry its own sentence, not merely differ from the other - /// two: a different glyph and a different button already make three - /// identical sentences compare unequal, so pairwise inequality proves - /// nothing. Each rendered row is matched against its own stale line, and - /// the three stale lines are checked to be distinct. Comparing against the - /// catalog rather than English literals keeps a copy edit or a non-`en` - /// host from reddening this for reasons unrelated to the behavior. - @Test("Each failure renders its own line, and the stale one, not the panel headline") + /// Each row must carry its own sentence and symbol, not merely differ from + /// the other two because of its action button. The stale copy is asserted + /// explicitly so punctuation changes cannot make the surfaces drift. + @Test("Each failure renders its own line and symbol, not the panel headline") func failuresReadDifferently() throws { - for problem in Self.problems { + let expected: [(MachinesPanelViewModel.CloudListProblem, String, String)] = [ + (.unreachable, "Machine list unavailable \u{2014} showing last known", "exclamationmark.icloud"), + (.sessionRejected, "Sign-in needs a refresh \u{2014} showing last known", "person.crop.circle.badge.exclamationmark"), + (.requiresPro, "Cloud machines need cmux Pro \u{2014} showing last known", "sparkles"), + ] + for (problem, expectedStale, expectedSymbol) in expected { let presentation = MachineListStatusPresentation(.failed(problem)) let stale = try #require(presentation.staleTitle, "\(problem) has no stale line") + #expect(stale == expectedStale, "\(problem) rendered the wrong stale line") + #expect(presentation.symbolName == expectedSymbol, "\(problem) rendered the wrong symbol") let text = Self.text(of: Self.host(.failed(problem))) #expect(text.contains(stale), "\(problem) rendered \(text), not \(stale)") // The toolbar sits beside cached rows, so it takes the one-line @@ -56,7 +59,7 @@ struct MachinesListStatusToolbarRowTests { let paragraph = try #require(presentation.subtitle, "\(problem) has no panel subtitle") #expect(!text.contains(paragraph), "\(problem) rendered the panel subtitle in the toolbar") } - let lines = Self.problems.compactMap { MachineListStatusPresentation(.failed($0)).staleTitle } + let lines = expected.map(\.1) #expect(Set(lines).count == Self.problems.count, "two failures share a stale line: \(lines)") } From 583b156c4b0bd22dce4ea88828e92a580f778c4c Mon Sep 17 00:00:00 2001 From: Leo Li Date: Wed, 30 Sep 2026 02:10:03 -0700 Subject: [PATCH 2/5] fix: align Cloud machine stale punctuation Co-Authored-By: Claude Opus 5 --- Resources/Localizable.xcstrings | 36 ++++++++++----------- Sources/Cloud/MachinesListStatusViews.swift | 8 ++--- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Resources/Localizable.xcstrings b/Resources/Localizable.xcstrings index d621e4f654a6..5c12fff42ffd 100644 --- a/Resources/Localizable.xcstrings +++ b/Resources/Localizable.xcstrings @@ -569921,55 +569921,55 @@ "en": { "stringUnit": { "state": "translated", - "value": "Cloud machines need cmux Pro, showing last known" + "value": "Cloud machines need cmux Pro — showing last known" } }, "ar": { "stringUnit": { "state": "translated", - "value": "تتطلب الأجهزة السحابية إصدار cmux Pro، يتم عرض آخر حالة معروفة" + "value": "تتطلب الأجهزة السحابية إصدار cmux Pro — يتم عرض آخر حالة معروفة" } }, "de": { "stringUnit": { "state": "translated", - "value": "Cloud-Maschinen erfordern cmux Pro, zeige letzten bekannten Stand" + "value": "Cloud-Maschinen erfordern cmux Pro – zeige letzten bekannten Stand" } }, "es": { "stringUnit": { "state": "translated", - "value": "Las máquinas en la nube requieren cmux Pro, se muestra el último estado conocido" + "value": "Las máquinas en la nube requieren cmux Pro — se muestra el último estado conocido" } }, "fr": { "stringUnit": { "state": "translated", - "value": "Les machines Cloud nécessitent cmux Pro, affichage des dernières informations connues" + "value": "Les machines Cloud nécessitent cmux Pro — affichage des dernières informations connues" } }, "ja": { "stringUnit": { "state": "translated", - "value": "Cloud マシンには cmux Pro が必要です。最後の状態を表示中" + "value": "Cloud マシンには cmux Pro が必要です — 最後の状態を表示中" } }, "ko": { "stringUnit": { "state": "translated", - "value": "클라우드 머신을 사용하려면 cmux Pro가 필요함, 마지막으로 확인된 상태 표시 중" + "value": "클라우드 머신을 사용하려면 cmux Pro가 필요함 — 마지막으로 확인된 상태 표시 중" } }, "zh-Hans": { "stringUnit": { "state": "translated", - "value": "云端机器需要 cmux Pro,显示的是最后已知状态" + "value": "云端机器需要 cmux Pro —— 显示的是最后已知状态" } }, "zh-Hant": { "stringUnit": { "state": "translated", - "value": "雲端機器需要 cmux Pro,顯示上次已知的狀態" + "value": "雲端機器需要 cmux Pro — 顯示上次已知的狀態" } } } @@ -569980,55 +569980,55 @@ "en": { "stringUnit": { "state": "translated", - "value": "Sign-in needs a refresh, showing last known" + "value": "Sign-in needs a refresh — showing last known" } }, "ar": { "stringUnit": { "state": "translated", - "value": "يحتاج تسجيل الدخول إلى تحديث، يتم عرض آخر حالة معروفة" + "value": "يحتاج تسجيل الدخول إلى تحديث — يتم عرض آخر حالة معروفة" } }, "de": { "stringUnit": { "state": "translated", - "value": "Anmeldung muss aktualisiert werden, zeige letzten bekannten Stand" + "value": "Anmeldung muss aktualisiert werden – zeige letzten bekannten Stand" } }, "es": { "stringUnit": { "state": "translated", - "value": "Es necesario actualizar el inicio de sesión, se muestra el último estado conocido" + "value": "Es necesario actualizar el inicio de sesión — se muestra el último estado conocido" } }, "fr": { "stringUnit": { "state": "translated", - "value": "La connexion doit être actualisée, affichage des dernières informations connues" + "value": "La connexion doit être actualisée — affichage des dernières informations connues" } }, "ja": { "stringUnit": { "state": "translated", - "value": "再サインインが必要です。最後の状態を表示中" + "value": "再サインインが必要です — 最後の状態を表示中" } }, "ko": { "stringUnit": { "state": "translated", - "value": "로그인 갱신 필요, 마지막으로 확인된 상태 표시 중" + "value": "로그인 갱신 필요 — 마지막으로 확인된 상태 표시 중" } }, "zh-Hans": { "stringUnit": { "state": "translated", - "value": "登录状态需要刷新,显示的是最后已知状态" + "value": "登录状态需要刷新 —— 显示的是最后已知状态" } }, "zh-Hant": { "stringUnit": { "state": "translated", - "value": "登入狀態需要重新整理,顯示上次已知的狀態" + "value": "登入狀態需要重新整理 — 顯示上次已知的狀態" } } } diff --git a/Sources/Cloud/MachinesListStatusViews.swift b/Sources/Cloud/MachinesListStatusViews.swift index 19b12f37062f..548e812392a0 100644 --- a/Sources/Cloud/MachinesListStatusViews.swift +++ b/Sources/Cloud/MachinesListStatusViews.swift @@ -65,7 +65,7 @@ struct MachineListStatusPresentation { subtitle = String(localized: "machines.offline.subtitle", defaultValue: "Cloud machines load when this Mac is back online.") action = nil isFailure = false - staleTitle = String(localized: "machines.offline.stale", defaultValue: "Offline \u{2014} showing last known") + staleTitle = String(localized: "machines.offline.stale", defaultValue: "Offline — showing last known") case .reconnecting: symbolName = nil title = String(localized: "machines.reconnecting.title", defaultValue: "Reconnecting to Cloud…") @@ -83,7 +83,7 @@ struct MachineListStatusPresentation { ) action = .retry isFailure = true - staleTitle = String(localized: "machines.listUnavailable.stale", defaultValue: "Machine list unavailable \u{2014} showing last known") + staleTitle = String(localized: "machines.listUnavailable.stale", defaultValue: "Machine list unavailable — showing last known") case .failed(.sessionRejected): // HTTP 401: retrying can never fix it, so route to a fresh sign-in. symbolName = "person.crop.circle.badge.exclamationmark" @@ -94,7 +94,7 @@ struct MachineListStatusPresentation { ) action = .signInAgain isFailure = true - staleTitle = String(localized: "machines.sessionRejected.stale", defaultValue: "Sign-in needs a refresh, showing last known") + staleTitle = String(localized: "machines.sessionRejected.stale", defaultValue: "Sign-in needs a refresh — showing last known") case .failed(.requiresPro): // HTTP 402: the fix is an upgrade, not a retry and not a sign-in. symbolName = "sparkles" @@ -105,7 +105,7 @@ struct MachineListStatusPresentation { ) action = .upgrade isFailure = true - staleTitle = String(localized: "machines.requiresPro.stale", defaultValue: "Cloud machines need cmux Pro, showing last known") + staleTitle = String(localized: "machines.requiresPro.stale", defaultValue: "Cloud machines need cmux Pro — showing last known") } } } From 132d1ee2ff07276cfe58e21d2aaafe0f50f892bb Mon Sep 17 00:00:00 2001 From: Leo Li Date: Wed, 30 Sep 2026 09:06:08 -0700 Subject: [PATCH 3/5] test: make Cloud stale assertions locale independent Co-Authored-By: Claude Opus 5 --- .../MachinesListStatusToolbarRowTests.swift | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/cmuxTests/MachinesListStatusToolbarRowTests.swift b/cmuxTests/MachinesListStatusToolbarRowTests.swift index 858ab7399611..9ec004006442 100644 --- a/cmuxTests/MachinesListStatusToolbarRowTests.swift +++ b/cmuxTests/MachinesListStatusToolbarRowTests.swift @@ -41,10 +41,25 @@ struct MachinesListStatusToolbarRowTests { /// explicitly so punctuation changes cannot make the surfaces drift. @Test("Each failure renders its own line and symbol, not the panel headline") func failuresReadDifferently() throws { + // Resolve the expected copy through the catalog using the host locale, + // matching String(localized:defaultValue:) in the presentation. This + // keeps the strong copy assertion green on non-English development Macs. let expected: [(MachinesPanelViewModel.CloudListProblem, String, String)] = [ - (.unreachable, "Machine list unavailable \u{2014} showing last known", "exclamationmark.icloud"), - (.sessionRejected, "Sign-in needs a refresh \u{2014} showing last known", "person.crop.circle.badge.exclamationmark"), - (.requiresPro, "Cloud machines need cmux Pro \u{2014} showing last known", "sparkles"), + ( + .unreachable, + String(localized: "machines.listUnavailable.stale", defaultValue: "Machine list unavailable — showing last known", locale: .current), + "exclamationmark.icloud" + ), + ( + .sessionRejected, + String(localized: "machines.sessionRejected.stale", defaultValue: "Sign-in needs a refresh — showing last known", locale: .current), + "person.crop.circle.badge.exclamationmark" + ), + ( + .requiresPro, + String(localized: "machines.requiresPro.stale", defaultValue: "Cloud machines need cmux Pro — showing last known", locale: .current), + "sparkles" + ), ] for (problem, expectedStale, expectedSymbol) in expected { let presentation = MachineListStatusPresentation(.failed(problem)) @@ -59,7 +74,7 @@ struct MachinesListStatusToolbarRowTests { let paragraph = try #require(presentation.subtitle, "\(problem) has no panel subtitle") #expect(!text.contains(paragraph), "\(problem) rendered the panel subtitle in the toolbar") } - let lines = expected.map(\.1) + let lines = Self.problems.compactMap { MachineListStatusPresentation(.failed($0)).staleTitle } #expect(Set(lines).count == Self.problems.count, "two failures share a stale line: \(lines)") } From fae6198746e2327c684d2a0c2b676730d44ea091 Mon Sep 17 00:00:00 2001 From: Leo Li Date: Wed, 30 Sep 2026 10:54:36 -0700 Subject: [PATCH 4/5] test(cloud): pin the stale status separator, not just its catalog key The stale-copy comparison resolved the same catalog key the presentation resolves, so it could only ever prove which key each failure picks. A revert of these four keys to the comma form would have kept it green while the toolbar drifted back, which is the opposite of what the test's own comment claimed. Assert the separator itself on every stale line, including offline. Every translation of these keys uses an em or en dash (36 values across 4 keys), so the check holds on a non-English Mac; the comma form carries no dash at all. ## Changelog none Co-Authored-By: Claude Opus 5 --- .../MachinesListStatusToolbarRowTests.swift | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/cmuxTests/MachinesListStatusToolbarRowTests.swift b/cmuxTests/MachinesListStatusToolbarRowTests.swift index 9ec004006442..99f662b944db 100644 --- a/cmuxTests/MachinesListStatusToolbarRowTests.swift +++ b/cmuxTests/MachinesListStatusToolbarRowTests.swift @@ -21,6 +21,15 @@ struct MachinesListStatusToolbarRowTests { .unreachable, .sessionRejected, .requiresPro, ] + /// Every stale line joins its cause to "showing last known" with a dash, + /// and every translation of it uses an em or en dash, so this holds on a + /// non-English Mac too. The comma form these keys used to carry has no + /// dash at all, which is the regression this catches and the resolved-copy + /// comparisons above cannot: they read the same catalog the view reads. + private static func hasDashSeparator(_ line: String) -> Bool { + line.contains("\u{2014}") || line.contains("\u{2013}") + } + @Test("Each failure offers the action that can fix it") func failureOffersItsAction() throws { let expected: [(MachinesPanelViewModel.CloudListProblem, String)] = [ @@ -37,8 +46,10 @@ struct MachinesListStatusToolbarRowTests { } /// Each row must carry its own sentence and symbol, not merely differ from - /// the other two because of its action button. The stale copy is asserted - /// explicitly so punctuation changes cannot make the surfaces drift. + /// the other two because of its action button. The copy comparison below + /// resolves the same catalog key as the presentation, so it pins which key + /// each failure picks, not the words in it; the separator assertion at the + /// end is what a revert to the comma form would break. @Test("Each failure renders its own line and symbol, not the panel headline") func failuresReadDifferently() throws { // Resolve the expected copy through the catalog using the host locale, @@ -76,6 +87,9 @@ struct MachinesListStatusToolbarRowTests { } let lines = Self.problems.compactMap { MachineListStatusPresentation(.failed($0)).staleTitle } #expect(Set(lines).count == Self.problems.count, "two failures share a stale line: \(lines)") + for line in lines { + #expect(Self.hasDashSeparator(line), "\(line) separates its cause with something other than a dash") + } } /// Waiting for the network is not a failure: it keeps its own glyph, offers @@ -87,6 +101,7 @@ struct MachinesListStatusToolbarRowTests { #expect(Self.element("CloudMachinesUnavailableRetryButton", in: hosted) == nil) let offline = try #require(MachineListStatusPresentation(.waitingForNetwork).staleTitle) #expect(Self.text(of: hosted).contains(offline)) + #expect(Self.hasDashSeparator(offline), "\(offline) separates its cause with something other than a dash") // The dismiss button is what pins `failure = isFailure ? error : nil`. // Without this, simplifying that line to `let failure = error` leaves // every other case in this suite green while offline gains an orange From bee203abfa2279485f1e6ac283b55f2104fb8880 Mon Sep 17 00:00:00 2001 From: Leo Li Date: Wed, 30 Sep 2026 11:44:00 -0700 Subject: [PATCH 5/5] test(cloud): drop the unverified locale argument from the stale-copy test The test resolved its expected copy through `String(localized:defaultValue:locale:)`, an overload with no other call site in the repo, while the view it checks uses `String(localized:defaultValue:)`. `.current` is that argument's own default, so it changed nothing except adding an API surface that no CI lane had compiled yet. The call now matches the presentation exactly. Two comments also described the file wrongly: the resolved-copy comparisons sit below `hasDashSeparator`, not above it, and calling them a "strong copy assertion" contradicts the doc comment four lines up that says they pin key selection rather than the words. Co-Authored-By: Claude Opus 5 --- cmuxTests/MachinesListStatusToolbarRowTests.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cmuxTests/MachinesListStatusToolbarRowTests.swift b/cmuxTests/MachinesListStatusToolbarRowTests.swift index 99f662b944db..740d44ccdd16 100644 --- a/cmuxTests/MachinesListStatusToolbarRowTests.swift +++ b/cmuxTests/MachinesListStatusToolbarRowTests.swift @@ -25,7 +25,7 @@ struct MachinesListStatusToolbarRowTests { /// and every translation of it uses an em or en dash, so this holds on a /// non-English Mac too. The comma form these keys used to carry has no /// dash at all, which is the regression this catches and the resolved-copy - /// comparisons above cannot: they read the same catalog the view reads. + /// comparisons below cannot: they read the same catalog the view reads. private static func hasDashSeparator(_ line: String) -> Bool { line.contains("\u{2014}") || line.contains("\u{2013}") } @@ -52,23 +52,23 @@ struct MachinesListStatusToolbarRowTests { /// end is what a revert to the comma form would break. @Test("Each failure renders its own line and symbol, not the panel headline") func failuresReadDifferently() throws { - // Resolve the expected copy through the catalog using the host locale, - // matching String(localized:defaultValue:) in the presentation. This - // keeps the strong copy assertion green on non-English development Macs. + // Resolve the expected copy through the catalog exactly as the + // presentation does, so the key-selection assertion stays green on a + // non-English development Mac instead of asserting English words. let expected: [(MachinesPanelViewModel.CloudListProblem, String, String)] = [ ( .unreachable, - String(localized: "machines.listUnavailable.stale", defaultValue: "Machine list unavailable — showing last known", locale: .current), + String(localized: "machines.listUnavailable.stale", defaultValue: "Machine list unavailable — showing last known"), "exclamationmark.icloud" ), ( .sessionRejected, - String(localized: "machines.sessionRejected.stale", defaultValue: "Sign-in needs a refresh — showing last known", locale: .current), + String(localized: "machines.sessionRejected.stale", defaultValue: "Sign-in needs a refresh — showing last known"), "person.crop.circle.badge.exclamationmark" ), ( .requiresPro, - String(localized: "machines.requiresPro.stale", defaultValue: "Cloud machines need cmux Pro — showing last known", locale: .current), + String(localized: "machines.requiresPro.stale", defaultValue: "Cloud machines need cmux Pro — showing last known"), "sparkles" ), ]