From be7ee265b65dd79c6bebd4e09dbf820f5662e00f Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Mon, 2 Nov 2026 08:20:32 -0500 Subject: [PATCH] Preserve preference writes and add capture checks Signed-off-by: Vincent Taverna --- Sources/ParcelUI/Resources/Language.xcstrings | 1 + .../Settings/LanguagePreferences.swift | 12 +- .../PseudoLocalizationScreenshotTests.swift | 448 ++++++++++++++++++ Tests/Reality/LanguageRestartReality.swift | 2 +- 4 files changed, 456 insertions(+), 7 deletions(-) create mode 100644 Tests/ParcelUITests/PseudoLocalizationScreenshotTests.swift diff --git a/Sources/ParcelUI/Resources/Language.xcstrings b/Sources/ParcelUI/Resources/Language.xcstrings index 5537698b..9d82f174 100644 --- a/Sources/ParcelUI/Resources/Language.xcstrings +++ b/Sources/ParcelUI/Resources/Language.xcstrings @@ -5,6 +5,7 @@ "System (%@)": { "comment": "The language macOS chooses, named in the current interface language.", "localizations": { "en": { "stringUnit": { "state": "translated", "value": "System (%@)" } } } }, "Restart Parcel to use %@": { "comment": "The chosen language's native name, or the System choice.", "localizations": { "en": { "stringUnit": { "state": "translated", "value": "Restart Parcel to use %@" } } } }, "Unavailable (%@)": { "comment": "A saved language that is no longer included in this copy of Parcel; this choice cannot be selected.", "localizations": { "en": { "stringUnit": { "state": "translated", "value": "Unavailable (%@)" } } } }, + "Language preference could not be saved.": { "localizations": { "en": { "stringUnit": { "state": "translated", "value": "Language preference could not be saved." } } } }, "Restart Now": { "localizations": { "en": { "stringUnit": { "state": "translated", "value": "Restart Now" } } } }, "Later": { "localizations": { "en": { "stringUnit": { "state": "translated", "value": "Later" } } } }, "Choose a language included with this copy of Parcel.": { "localizations": { "en": { "stringUnit": { "state": "translated", "value": "Choose a language included with this copy of Parcel." } } } }, diff --git a/Sources/ParcelUI/Settings/LanguagePreferences.swift b/Sources/ParcelUI/Settings/LanguagePreferences.swift index 5e8f71f7..292fb6dc 100644 --- a/Sources/ParcelUI/Settings/LanguagePreferences.swift +++ b/Sources/ParcelUI/Settings/LanguagePreferences.swift @@ -8,7 +8,6 @@ public final class LanguagePreferences { public private(set) var selection: String public private(set) var isRestarting = false public var onRestartRequested: (@MainActor () -> Void)? - private let defaults: UserDefaults private let domain: String private let launchSelection: String private var deferred = false @@ -17,7 +16,6 @@ public final class LanguagePreferences { bundle: Bundle = .main, defaults: UserDefaults = .standard, domain: String? = nil, systemLanguages: [String]? = nil ) { - self.defaults = defaults let domain = domain ?? bundle.bundleIdentifier ?? "dev.vinnymac.parcel" self.domain = domain // Development resources are deliberately absent from the app's advertised localizations. @@ -60,13 +58,15 @@ public final class LanguagePreferences { throw SettingsFailure(LanguageText.string("Choose a language included with this copy of Parcel.")) } guard id != selection else { return } - var preferences = defaults.persistentDomain(forName: domain) ?? [:] + guard let destination = UserDefaults(suiteName: domain) else { + throw SettingsFailure(LanguageText.string("Language preference could not be saved.")) + } + // Replacing a domain snapshot can lose concurrent window/UI preference writes. if id.isEmpty { - preferences.removeValue(forKey: "AppleLanguages") + destination.removeObject(forKey: "AppleLanguages") } else { - preferences["AppleLanguages"] = [id] + destination.set([id], forKey: "AppleLanguages") } - defaults.setPersistentDomain(preferences, forName: domain) selection = id deferred = false } diff --git a/Tests/ParcelUITests/PseudoLocalizationScreenshotTests.swift b/Tests/ParcelUITests/PseudoLocalizationScreenshotTests.swift new file mode 100644 index 00000000..4c6923b3 --- /dev/null +++ b/Tests/ParcelUITests/PseudoLocalizationScreenshotTests.swift @@ -0,0 +1,448 @@ +import AppKit +import CoreGraphics +import Foundation +import ParcelConfig +import ParcelCore +import SwiftUI +import Testing + +@testable import ParcelUI + +extension AppKitTestSuite { + @MainActor + struct PseudoLocalizationScreenshotTests { + @Test func captureRequiresBothExplicitEnvironmentValues() { + #expect(!Self.captureEnabled(environment: [:])) + #expect(!Self.captureEnabled(environment: ["PARCEL_PSEUDO_LOCALIZATION": "1"])) + #expect(!Self.captureEnabled(environment: ["PARCEL_PSEUDO_SCREENSHOTS": "/private/output"])) + #expect( + !Self.captureEnabled(environment: [ + "PARCEL_PSEUDO_LOCALIZATION": "0", "PARCEL_PSEUDO_SCREENSHOTS": "/private/output", + ])) + #expect( + !Self.captureEnabled(environment: [ + "PARCEL_PSEUDO_LOCALIZATION": "1", "PARCEL_PSEUDO_SCREENSHOTS": "", + ])) + #expect( + Self.captureEnabled(environment: [ + "PARCEL_PSEUDO_LOCALIZATION": "1", "PARCEL_PSEUDO_SCREENSHOTS": "/private/output", + ])) + } + + nonisolated private static func captureEnabled(environment: [String: String]) -> Bool { + environment["PARCEL_PSEUDO_LOCALIZATION"] == "1" + && environment["PARCEL_PSEUDO_SCREENSHOTS"]?.isEmpty == false + } + + // Run alone with en-XA test resources and CFBundleAllowMixedLocalizations in the host Info.plist. + @Test(.enabled(if: Self.captureEnabled(environment: ProcessInfo.processInfo.environment))) + func nativeSettingsMenuAndTourScreenshots() async throws { + try requireUnlockedConsole() + let path = try #require(ProcessInfo.processInfo.environment["PARCEL_PSEUDO_SCREENSHOTS"]) + try #require(path.hasPrefix("/"), "Screenshot output must be an absolute private directory.") + let output = URL(fileURLWithPath: path, isDirectory: true) + let manager = FileManager.default + if !manager.fileExists(atPath: output.path) { + try manager.createDirectory( + at: output, withIntermediateDirectories: false, attributes: [.posixPermissions: 0o700]) + } + let attributes = try manager.attributesOfItem(atPath: output.path) + try #require(attributes[.type] as? FileAttributeType == .typeDirectory) + let permissions = try #require(attributes[.posixPermissions] as? NSNumber) + try #require(permissions.intValue & 0o077 == 0, "Screenshot directory must not be accessible to others.") + + let defaults = UserDefaults.standard + let hadArguments = defaults.volatileDomainNames.contains(UserDefaults.argumentDomain) + let original = defaults.volatileDomain(forName: UserDefaults.argumentDomain) + var arguments = original + arguments["AppleLanguages"] = ["en-XA"] + defaults.setVolatileDomain(arguments, forName: UserDefaults.argumentDomain) + defer { + if hadArguments { + defaults.setVolatileDomain(original, forName: UserDefaults.argumentDomain) + } else { + defaults.removeVolatileDomain(forName: UserDefaults.argumentDomain) + } + #expect( + NSDictionary(dictionary: defaults.volatileDomain(forName: UserDefaults.argumentDomain)) + == NSDictionary(dictionary: original)) + } + // A locale environment alone does not change Foundation's bundle lookup language. + try #require( + Bundle.module.url(forResource: "en-XA", withExtension: "lproj") != nil, + "Copy the generated pseudo resources into the test process's ParcelUI bundle before launch.") + for sample in [ + SettingsSection.general.title, UIStrings.text("Settings…"), MenuText.text("Automatic tiling"), + TourText.text(TourSetupStep.welcome.title), LanguageText.string("Restart Now"), + ] { + try #require( + sample.hasPrefix("⟦") && sample.hasSuffix("⟧"), + "Pseudo lookup failed or a bundle was accessed before AppleLanguages was set: \(sample)") + } + + let application = NSApplication.shared + let getter = NSSelectorFromString("accessibilityAttributeValue:") + let setter = NSSelectorFromString("accessibilitySetValue:forAttribute:") + let attribute = "AXEnhancedUserInterface" + try #require(application.responds(to: getter) && application.responds(to: setter)) + let enhanced = try #require( + application.perform(getter, with: attribute)?.takeUnretainedValue() as? NSNumber) + _ = application.perform(setter, with: NSNumber(value: true), with: attribute) + defer { + _ = application.perform(setter, with: enhanced, with: attribute) + #expect( + (application.perform(getter, with: attribute)?.takeUnretainedValue() as? NSNumber)?.boolValue + == enhanced.boolValue) + } + try #require( + (application.perform(getter, with: attribute)?.takeUnretainedValue() as? NSNumber)?.boolValue == true) + + let originalAppearance = application.appearance + defer { application.appearance = originalAppearance } + for scheme in [ColorScheme.light, .dark] { + application.appearance = NSAppearance(named: scheme == .light ? .aqua : .darkAqua) + try await captureSettings(scheme: scheme, output: output) + try captureMenus(scheme: scheme, output: output) + for track in TourTrack.allCases { + try await captureTour(track: track, scheme: scheme, output: output) + } + } + } + + private struct ConsoleState: Decodable { + let onConsole: Bool + let loginDone: Bool + let screenLocked: Bool? + + private enum CodingKeys: String, CodingKey { + case onConsole = "kCGSSessionOnConsoleKey" + case loginDone = "kCGSessionLoginDoneKey" + case screenLocked = "CGSSessionScreenIsLocked" + } + } + + private func requireUnlockedConsole() throws { + try #require( + FileManager.default.fileExists(atPath: "/tmp/parcel-m3-free"), + "The user screen guard has not been released for native screenshot work.") + let session = try #require(CGSessionCopyCurrentDictionary(), "Cannot inspect the console session.") + let data = try PropertyListSerialization.data(fromPropertyList: session, format: .binary, options: 0) + let state = try PropertyListDecoder().decode(ConsoleState.self, from: data) + try #require( + state.onConsole && state.loginDone && state.screenLocked != true, + "Console is locked or inactive; do not run native captures until it is unlocked.") + } + + private func captureSettings(scheme: ColorScheme, output: URL) async throws { + let domain = "dev.vinnymac.parcel.pseudo-screenshots.\(UUID())" + let defaults = try #require(UserDefaults(suiteName: domain)) + defer { defaults.removePersistentDomain(forName: domain) } + let scratch = output.appendingPathComponent(".settings-\(UUID())", isDirectory: true) + try FileManager.default.createDirectory(at: scratch, withIntermediateDirectories: false) + defer { + do { try FileManager.default.removeItem(at: scratch) } catch { Issue.record(error) } + } + let bundleURL = scratch.appendingPathComponent("Languages.bundle", isDirectory: true) + try FileManager.default.createDirectory(at: bundleURL, withIntermediateDirectories: false) + let info: [String: any Sendable] = [ + "CFBundleIdentifier": domain, "CFBundleDevelopmentRegion": "en", + "CFBundleLocalizations": ["en", "pt-BR", "zh-Hant", "en-XA"], + ] + try PropertyListSerialization.data(fromPropertyList: info, format: .xml, options: 0) + .write(to: bundleURL.appendingPathComponent("Info.plist")) + let bundle = try #require(Bundle(url: bundleURL)) + let model = SettingsModel(store: ConfigStore(fileURL: scratch.appendingPathComponent("parcel.toml"))) + model.language = LanguagePreferences( + bundle: bundle, defaults: defaults, domain: domain, systemLanguages: ["en"]) + var restarts = 0 + model.language.onRestartRequested = { restarts += 1 } + await model.start() + do { + for pending in [false, true] { + if pending { try model.language.choose("pt-BR") } + for size in [CGSize(width: 800, height: 650), CGSize(width: 680, height: 560)] { + let state = pending ? "restart-pending" : "system" + let name = + "settings-general-\(state)-\(Int(size.width))x\(Int(size.height))-\(appearance(scheme))" + var identifiers = [GeneralSetting.language.control.id, "settings.general.whenDisplayFull"] + if pending { + identifiers += [ + LanguagePreferencesView.restartControl.id, LanguagePreferencesView.laterControl.id, + ] + } + try await capture( + SettingsView(model: model, permissions: AnyView(EmptyView()), initialSection: .general), + size: size, contentSized: false, scheme: scheme, name: name, output: output, + requiredIdentifiers: identifiers, allowsVerticalScrolling: true) + } + } + #expect(restarts == 0) + } catch { + await model.stop() + throw error + } + await model.stop() + } + + private func captureTour(track: TourTrack, scheme: ColorScheme, output: URL) async throws { + let domain = "dev.vinnymac.parcel.pseudo-tour.\(UUID())" + let defaults = try #require(UserDefaults(suiteName: domain)) + defer { defaults.removePersistentDomain(forName: domain) } + let learning = try WindowLearningController(defaults: defaults, onFailure: { Issue.record($0) }) + defer { learning.stop() } + var configuration = ParcelConfiguration.defaults + configuration.motion.enabled = false + learning.update(state: LearningScene.state(), configuration: configuration, active: false) + let setup = learning.setup + var permission = PermissionStatus.missing + var tidyCalls = 0 + let personalization = TourPersonalization( + workspace: LearningScene.key, displayName: "A wide external display with a deliberately long name", + configuration: configuration, portrait: false) + setup.actions = TourSetupActions( + checkShortcuts: { TourShortcutCheck(warnings: []) }, + checkSystem: { TourSystemCheck(stageManager: false, nativeTiling: false) }, + loginStatus: { .disabled }, setOpenAtLogin: { $0 ? .enabled : .disabled }, + personalization: { personalization }, + tidy: { _ in + tidyCalls += 1; return TourTidyUndo {} + }, + openShortcuts: { Issue.record("Screenshot must not open Settings.") }, + openSystemSettings: { Issue.record("Screenshot must not open System Settings.") }, + openLoginSettings: { Issue.record("Screenshot must not modify login settings.") }, + permissionStatus: { permission }) + setup.begin(track, firstRun: true, defaultOpenAtLogin: true) + for (index, step) in TourSetupStep.allCases.enumerated() { + if step == .allow { + try await setup.next() + } else if step == .basics { + permission = .granted + try await setup.refreshPermission() + } else if step == .complete { + try await setup.tidyWorkspace() + } else if step != .welcome { + try await setup.next() + } + try #require(setup.step == step) + let name = "tour-setup-\(index + 1)-\(step.rawValue)-\(track.rawValue)-\(appearance(scheme))" + let identifiers = ["tour.title", step == .tidy ? "tour.tidy" : "tour.continue"] + try await capture( + TourView(controller: learning), scheme: scheme, name: name, output: output, + requiredIdentifiers: identifiers) + if step == .allow || step == .personalize || step == .powerMoves { + try await capture( + TourView(controller: learning), scheme: scheme, typeSize: .accessibility3, + name: name + "-ax3", output: output, requiredIdentifiers: identifiers) + } + } + #expect(tidyCalls == 1, "Only the independent test action should have been called.") + setup.dismiss() + learning.update(state: LearningScene.state(), configuration: configuration, active: true) + learning.begin(track) + for (index, step) in TourStep.allCases.enumerated() { + try #require(learning.tour.step == step && learning.tour.progress.phase == .running) + try await capture( + TourView(controller: learning), scheme: scheme, + name: "tour-practice-\(index + 1)-\(step.rawValue)-\(track.rawValue)-\(appearance(scheme))", + output: output) + learning.skip() + } + #expect(learning.tour.progress.phase == .completed) + } + + @MainActor + private final class MenuCapture { + let menu: NSMenu + let capture: () throws -> Void + private(set) var result: Result? + + init(menu: NSMenu, capture: @escaping () throws -> Void) { + self.menu = menu + self.capture = capture + } + + func run() { + defer { menu.cancelTrackingWithoutAnimation() } + result = Result(catching: capture) + } + } + + private func captureMenus(scheme: ColorScheme, output: URL) throws { + try requireUnlockedConsole() + let controller = try MenuBarController(invoke: { _ in Issue.record("Screenshot must not invoke commands.") } + ) + defer { controller.stop() } + let snapshot = LayoutSnapshot( + layout: .columns, bounds: CGRect(x: 0, y: 0, width: 800, height: 600), tiles: []) + for state in ["normal", "permission-missing", "update-ready"] { + controller.update( + snapshot: snapshot, configuration: .defaults, + permission: state == "permission-missing" ? .missing : .granted, + reduceMotion: true, increaseContrast: false, + updateReady: state == "update-ready", updateVersion: "1.2.3") + controller.menuNeedsUpdate(controller.menu) + let menu = controller.menu + try #require(menu.items.contains { $0.title.hasPrefix("⟦") && $0.title.hasSuffix("⟧") }) + let anchor = NSView(frame: CGRect(x: 0, y: 0, width: 1, height: 1)) + let window = NSWindow( + contentRect: CGRect(x: 100, y: 100, width: 1, height: 1), + styleMask: [.borderless], backing: .buffered, defer: false) + window.isReleasedWhenClosed = false + window.contentView = anchor + window.appearance = NSAppearance(named: scheme == .light ? .aqua : .darkAqua) + window.orderFront(nil) + defer { window.close() } + // AppKit attaches the production summary view to its menu window while tracking. + let capture = MenuCapture(menu: menu) { + let menuWindow = try #require( + menu.items.first?.view?.window, + "Native menu did not expose its own window.") + try #require(menuWindow.isVisible) + let content = try #require(menuWindow.contentView) + content.layoutSubtreeIfNeeded() + try self.save( + content, name: "menu-\(state)-\(self.appearance(scheme))", output: output, + requiredIdentifiers: [], allowsVerticalScrolling: false) + } + let timer = Timer(timeInterval: 0.2, repeats: false) { _ in + MainActor.assumeIsolated { capture.run() } + } + RunLoop.main.add(timer, forMode: .eventTracking) + defer { timer.invalidate() } + try requireUnlockedConsole() + _ = menu.popUp(positioning: nil, at: .zero, in: anchor) + try #require(capture.result, "Menu closed before native capture completed.").get() + } + } + + private func capture( + _ view: Content, size: CGSize = CGSize(width: 440, height: 1), contentSized: Bool = true, + scheme: ColorScheme, typeSize: DynamicTypeSize = .large, name: String, output: URL, + requiredIdentifiers: [String] = [], allowsVerticalScrolling: Bool = false + ) async throws { + try requireUnlockedConsole() + let host = NSHostingView( + rootView: view.environment(\.locale, Locale(identifier: "en-XA")) + .environment(\.colorScheme, scheme).environment(\.dynamicTypeSize, typeSize)) + host.appearance = NSAppearance(named: scheme == .light ? .aqua : .darkAqua) + host.frame = CGRect(origin: .zero, size: size) + if contentSized { + host.sizingOptions = [.preferredContentSize, .intrinsicContentSize] + for _ in 0..<3 { + host.layoutSubtreeIfNeeded() + host.frame.size = host.fittingSize + } + #expect(abs(host.bounds.width - size.width) < 1, "\(name): panel expanded horizontally.") + #expect( + host.bounds.height < (typeSize.isAccessibilitySize ? 1600 : 1000), + "\(name): expanded text makes the panel impractically tall.") + } + let window = NSWindow( + contentRect: CGRect(origin: CGPoint(x: 100, y: 100), size: host.frame.size), + styleMask: [.titled], backing: .buffered, defer: false) + window.isReleasedWhenClosed = false + window.contentView = host + defer { + window.contentView = nil + window.close() + } + window.orderFront(nil) + host.layoutSubtreeIfNeeded() + window.displayIfNeeded() + await Task.yield() + host.layoutSubtreeIfNeeded() + window.displayIfNeeded() + try save( + host, name: name, output: output, requiredIdentifiers: requiredIdentifiers, + allowsVerticalScrolling: allowsVerticalScrolling) + } + + private func save( + _ content: NSView, name: String, output: URL, requiredIdentifiers: [String], allowsVerticalScrolling: Bool + ) throws { + try requireUnlockedConsole() + let bitmap = try #require(content.bitmapImageRepForCachingDisplay(in: content.bounds)) + content.cacheDisplay(in: content.bounds, to: bitmap) + try #require(bitmap.pixelsWide > 100 && bitmap.pixelsHigh > 100) + let png = try #require(bitmap.representation(using: .png, properties: [:])) + try writePrivate(png, to: output.appendingPathComponent(name + ".png")) + + let window = try #require(content.window) + let screenBounds = window.convertToScreen(content.convert(content.bounds, to: nil)) + let root = SettingsAccessibilityElement(object: content) + let elements = root.descendants() + let navigation = root.descendants(navigation: true) + var report = ["surface\t\(name)", "bounds\t\(screenBounds)", "role\tidentifier\tframe\tkeyboard\tlabel"] + var violations: [String] = [] + var pseudoLabels = 0 + for element in elements { + let label = element.accessibilityLabel() ?? element.accessibilityTitle() ?? "" + if label.contains("⟦") && label.contains("⟧") { pseudoLabels += 1 } + let role = element.accessibilityRole() + guard [.button, .checkBox, .popUpButton, .textField, .staticText].contains(role) else { continue } + let identifier = element.accessibilityIdentifier() ?? "" + let reachable = navigation.contains { $0.isEqual(element) } + let frame: CGRect? + if element.object.responds(to: NSSelectorFromString("accessibilityFrame")) { + frame = (element.object.value(forKey: "accessibilityFrame") as? NSValue)?.rectValue + } else { + frame = nil + } + report.append( + "\(role?.rawValue ?? "")\t\(identifier)\t\(frame.map(String.init(describing:)) ?? "missing")\t\(reachable)\t\(label.replacingOccurrences(of: "\n", with: " "))" + ) + guard let frame, !frame.isEmpty else { continue } + let tolerance = screenBounds.insetBy(dx: -2, dy: -2) + if frame.minX < tolerance.minX || frame.maxX > tolerance.maxX + || (!allowsVerticalScrolling && (frame.minY < tolerance.minY || frame.maxY > tolerance.maxY)) + { + violations.append( + "\(identifier.isEmpty ? label : identifier) extends outside the capture: \(frame)") + } + } + for identifier in requiredIdentifiers { + let matches = elements.filter { $0.accessibilityIdentifier() == identifier } + if matches.isEmpty { violations.append("Missing accessibility control: \(identifier)") } + for element in matches { + if element.isAccessibilityEnabled() && !navigation.contains(where: { $0.isEqual(element) }) { + violations.append("Enabled control is not keyboard reachable: \(identifier)") + } + if element.object.responds(to: NSSelectorFromString("accessibilityFrame")) { + let frame = (element.object.value(forKey: "accessibilityFrame") as? NSValue)?.rectValue + if frame == nil || frame?.isEmpty == true { + violations.append("Empty accessibility bounds: \(identifier)") + } + } else { + violations.append("Missing accessibility bounds: \(identifier)") + } + } + } + inspectNativeLabels(content, violations: &violations) + report += violations.map { "CHECK\t\($0)" } + try writePrivate( + Data(report.joined(separator: "\n").utf8), + to: output.appendingPathComponent(name + "-accessibility.txt")) + #expect(pseudoLabels > 0, "\(name): rendered accessibility tree has no pseudo-localized text.") + #expect(violations.isEmpty, "\(name): \(violations.joined(separator: "; "))") + } + + private func inspectNativeLabels(_ view: NSView, violations: inout [String]) { + if let label = view as? NSTextField, !label.isEditable, !label.isHidden, label.stringValue.contains("⟦") { + if label.fittingSize.height > label.bounds.height + 2 { + violations.append("Native label is too short: \(label.stringValue)") + } + if label.cell?.wraps == false && label.attributedStringValue.size().width > label.bounds.width + 2 { + violations.append("Native label truncates horizontally: \(label.stringValue)") + } + } + for child in view.subviews { inspectNativeLabels(child, violations: &violations) } + } + + private func writePrivate(_ data: Data, to url: URL) throws { + try data.write(to: url, options: .atomic) + try FileManager.default.setAttributes([.posixPermissions: 0o600], ofItemAtPath: url.path) + } + + private func appearance(_ scheme: ColorScheme) -> String { scheme == .light ? "light" : "dark" } + } +} diff --git a/Tests/Reality/LanguageRestartReality.swift b/Tests/Reality/LanguageRestartReality.swift index 1b11672e..e7eb32ce 100644 --- a/Tests/Reality/LanguageRestartReality.swift +++ b/Tests/Reality/LanguageRestartReality.swift @@ -39,7 +39,7 @@ func checkLanguageRestart(_ session: RealitySession) async throws { let receiptURL = session.directory.appendingPathComponent("language-relaunch.json") if !replacements.isEmpty, FileManager.default.fileExists(atPath: receiptURL.path) { let receipt = try JSONDecoder().decode(LanguageRelaunchReceipt.self, from: Data(contentsOf: receiptURL)) - if replacements.contains(where: { $0.processIdentifier == receipt.replacement }) { break } + if replacements.count == 1, replacements.first?.processIdentifier == receipt.replacement { break } } try await Task.sleep(for: .milliseconds(40)) } -- knotmirror 0.0.1