From b2da4901f7ca6a27c8c96b9dc6836cec2f02403f Mon Sep 17 00:00:00 2001
From: Ethan <39577870+ethanndickson@users.noreply.github.com>
Date: Tue, 27 May 2025 13:29:52 +1000
Subject: [PATCH 1/3] fix: don't create http client if signed out (#166)
If the session item in the keychain is missing but `hasSession` is true, the app will force unwrap the session token optional and crash on launch. Encountered this today.
---
Coder-Desktop/Coder-Desktop/State.swift | 1 +
1 file changed, 1 insertion(+)
diff --git a/Coder-Desktop/Coder-Desktop/State.swift b/Coder-Desktop/Coder-Desktop/State.swift
index 902d5a12..faf15e05 100644
--- a/Coder-Desktop/Coder-Desktop/State.swift
+++ b/Coder-Desktop/Coder-Desktop/State.swift
@@ -120,6 +120,7 @@ class AppState: ObservableObject {
_sessionToken = Published(initialValue: keychainGet(for: Keys.sessionToken))
if sessionToken == nil || sessionToken!.isEmpty == true {
clearSession()
+ return
}
client = Client(
url: baseAccessURL!,
From 7af0cdc24934196c1ff35cbe657c04f36cc0fcdb Mon Sep 17 00:00:00 2001
From: Ethan <39577870+ethanndickson@users.noreply.github.com>
Date: Wed, 28 May 2025 15:25:02 +1000
Subject: [PATCH 2/3] fix: conform CFBundleVersion to documentation (#167)
Second PR for #47.
Previously, we were setting [`CFBundleVersion`](https://developer.apple.com/documentation/bundleresources/information-property-list/cfbundleversion) to the output of `git describe --tags` (`vX.Y.Z` or `vX.Y.Z-N-gHASH` for preview builds).
To support Sparkle, and potentially to avoid a breakage with macOS failing to update an installed `LaunchDaemon` when it can't parse `CFBundleVersion`, we'll conform the string to the specification.
Given that:
> You can include more integers but the system ignores them.
We set `CFBundleVersion` to a value of the form `X.Y.Z[.N]` where N is the number of commits since the `X.Y.Z` tag (omitted if 0)
Sparkle did previously allow you to supply a manual version comparator, but it was deprecated to help require `CFBundleVersion` start with `X.Y.Z` https://github.com/sparkle-project/Sparkle/issues/2585
That issue recommends instead putting marketing version information in `CFBundleShortVersionString`, but that actually has even stricter requirements: https://developer.apple.com/documentation/bundleresources/information-property-list/cfbundleshortversionstring
Though not documented, from testing & reading the [Sparkle source](https://github.com/sparkle-project/Sparkle/blob/2.x/Sparkle/SUStandardVersionComparator.m), I discovered that `X.Y.Z.N+1` will be deemed a later version than `X.Y.Z.N`, which is what we'll do for the preview stream of auto-updates.
For non-preview builds (i.e. builds on a tag), both version strings will be `X.Y.Z`.
Since we're no longer including the commit hash in a version string, we instead embed it separately in the `Info.plist` so we can continue to display it in the UI:
---
Coder-Desktop/Coder-Desktop/About.swift | 7 +++
Coder-Desktop/Coder-Desktop/Info.plist | 4 +-
Coder-Desktop/project.yml | 1 +
Makefile | 15 ++++++-
scripts/version.sh | 60 +++++++++++++++++++++++++
5 files changed, 84 insertions(+), 3 deletions(-)
create mode 100755 scripts/version.sh
diff --git a/Coder-Desktop/Coder-Desktop/About.swift b/Coder-Desktop/Coder-Desktop/About.swift
index 8849c9bd..902ef409 100644
--- a/Coder-Desktop/Coder-Desktop/About.swift
+++ b/Coder-Desktop/Coder-Desktop/About.swift
@@ -31,11 +31,18 @@ enum About {
return coder
}
+ private static var version: NSString {
+ let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown"
+ let commitHash = Bundle.main.infoDictionary?["CommitHash"] as? String ?? "Unknown"
+ return "Version \(version) - \(commitHash)" as NSString
+ }
+
@MainActor
static func open() {
appActivate()
NSApp.orderFrontStandardAboutPanel(options: [
.credits: credits,
+ .applicationVersion: version,
])
}
}
diff --git a/Coder-Desktop/Coder-Desktop/Info.plist b/Coder-Desktop/Coder-Desktop/Info.plist
index c1bf929a..bb759f6b 100644
--- a/Coder-Desktop/Coder-Desktop/Info.plist
+++ b/Coder-Desktop/Coder-Desktop/Info.plist
@@ -32,6 +32,8 @@
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: