From 7929f57460e465c988a9c0bcad2ef00c3f433db3 Mon Sep 17 00:00:00 2001 From: Artus KG Date: Sat, 17 Jan 2026 18:11:21 +0100 Subject: [PATCH] macos: keep CLI install build suffix --- apps/macos/Sources/Clawdbot/CLIInstaller.swift | 2 +- .../Sources/Clawdbot/GatewayEnvironment.swift | 15 +++++++++++++-- apps/macos/Sources/Clawdbot/Onboarding.swift | 2 +- .../GatewayEnvironmentTests.swift | 1 + 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/apps/macos/Sources/Clawdbot/CLIInstaller.swift b/apps/macos/Sources/Clawdbot/CLIInstaller.swift index 41abb29e6..d967002f5 100644 --- a/apps/macos/Sources/Clawdbot/CLIInstaller.swift +++ b/apps/macos/Sources/Clawdbot/CLIInstaller.swift @@ -35,7 +35,7 @@ enum CLIInstaller { } static func install(statusHandler: @escaping @MainActor @Sendable (String) async -> Void) async { - let expected = GatewayEnvironment.expectedGatewayVersion()?.description ?? "latest" + let expected = GatewayEnvironment.expectedGatewayVersionString() ?? "latest" let prefix = Self.installPrefix() await statusHandler("Installing clawdbot CLI…") let cmd = self.installScriptCommand(version: expected, prefix: prefix) diff --git a/apps/macos/Sources/Clawdbot/GatewayEnvironment.swift b/apps/macos/Sources/Clawdbot/GatewayEnvironment.swift index 6560b1870..c8f6ed621 100644 --- a/apps/macos/Sources/Clawdbot/GatewayEnvironment.swift +++ b/apps/macos/Sources/Clawdbot/GatewayEnvironment.swift @@ -80,8 +80,13 @@ enum GatewayEnvironment { } static func expectedGatewayVersion() -> Semver? { + Semver.parse(self.expectedGatewayVersionString()) + } + + static func expectedGatewayVersionString() -> String? { let bundleVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String - return Semver.parse(bundleVersion) + let trimmed = bundleVersion?.trimmingCharacters(in: .whitespacesAndNewlines) + return (trimmed?.isEmpty == false) ? trimmed : nil } // Exposed for tests so we can inject fake version checks without rewriting bundle metadata. @@ -220,8 +225,14 @@ enum GatewayEnvironment { } static func installGlobal(version: Semver?, statusHandler: @escaping @Sendable (String) -> Void) async { + await self.installGlobal(versionString: version?.description, statusHandler: statusHandler) + } + + static func installGlobal(versionString: String?, statusHandler: @escaping @Sendable (String) -> Void) async { let preferred = CommandResolver.preferredPaths().joined(separator: ":") - let target = version?.description ?? "latest" + let target = versionString? + .trimmingCharacters(in: .whitespacesAndNewlines) + .flatMap { $0.isEmpty ? nil : $0 } ?? "latest" let npm = CommandResolver.findExecutable(named: "npm") let pnpm = CommandResolver.findExecutable(named: "pnpm") let bun = CommandResolver.findExecutable(named: "bun") diff --git a/apps/macos/Sources/Clawdbot/Onboarding.swift b/apps/macos/Sources/Clawdbot/Onboarding.swift index 0af5e94e5..f45eee8ce 100644 --- a/apps/macos/Sources/Clawdbot/Onboarding.swift +++ b/apps/macos/Sources/Clawdbot/Onboarding.swift @@ -155,7 +155,7 @@ struct OnboardingView: View { var canAdvance: Bool { !self.isWizardBlocking } var devLinkCommand: String { - let version = GatewayEnvironment.expectedGatewayVersion()?.description ?? "latest" + let version = GatewayEnvironment.expectedGatewayVersionString() ?? "latest" return "npm install -g clawdbot@\(version)" } diff --git a/apps/macos/Tests/ClawdbotIPCTests/GatewayEnvironmentTests.swift b/apps/macos/Tests/ClawdbotIPCTests/GatewayEnvironmentTests.swift index 069e5b7fa..fb01ea638 100644 --- a/apps/macos/Tests/ClawdbotIPCTests/GatewayEnvironmentTests.swift +++ b/apps/macos/Tests/ClawdbotIPCTests/GatewayEnvironmentTests.swift @@ -44,6 +44,7 @@ import Testing @Test func expectedGatewayVersionFromStringUsesParser() { #expect(GatewayEnvironment.expectedGatewayVersion(from: "v9.1.2") == Semver(major: 9, minor: 1, patch: 2)) + #expect(GatewayEnvironment.expectedGatewayVersion(from: "2026.1.11-4") == Semver(major: 2026, minor: 1, patch: 11)) #expect(GatewayEnvironment.expectedGatewayVersion(from: nil) == nil) } }