Skip to content

Commit 2ba12c6

Browse files
committed
Make version/build number clickable to check for updates
Split the footer version display into two parts: the app version/build number is now a clickable button that triggers an update check (with tertiary label color to blend in visually), while the llama.cpp version remains static text. Also fixed the update check implementation to use SPUStandardUpdaterController's proper checkForUpdates(_:) method instead of accessing the underlying updater directly, which follows Sparkle 2.8 best practices for user-initiated checks.
1 parent b45404d commit 2ba12c6

File tree

2 files changed

+34
-16
lines changed

2 files changed

+34
-16
lines changed

LlamaBarn/LlamaBarnApp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
6161
updatesObserver = NotificationCenter.default.addObserver(
6262
forName: .LBCheckForUpdates, object: nil, queue: .main
6363
) { [weak self] _ in
64-
self?.updaterController?.updater.checkForUpdates()
64+
self?.updaterController?.checkForUpdates(nil)
6565
}
6666

6767
logger.info("LlamaBarn startup complete")

LlamaBarn/Menu/Sections.swift

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -346,17 +346,27 @@ final class FooterSection {
346346

347347
// Production builds show marketing version without build number;
348348
// dev/test builds (0.0.0) show only build number
349-
let versionText: String
350-
if AppInfo.shortVersion == "0.0.0" {
351-
versionText = "build \(AppInfo.buildNumber) · llama.cpp \(AppInfo.llamaCppVersion)"
352-
} else {
353-
versionText = "\(AppInfo.shortVersion) · llama.cpp \(AppInfo.llamaCppVersion)"
354-
}
355-
356-
let versionLabel = Typography.makePrimaryLabel(versionText)
357-
versionLabel.textColor = .tertiaryLabelColor
358-
versionLabel.lineBreakMode = .byTruncatingMiddle
359-
versionLabel.translatesAutoresizingMaskIntoConstraints = false
349+
let appVersionText =
350+
AppInfo.shortVersion == "0.0.0"
351+
? "build \(AppInfo.buildNumber)"
352+
: AppInfo.shortVersion
353+
354+
let versionButton = NSButton(title: "", target: self, action: #selector(checkForUpdates))
355+
versionButton.isBordered = false
356+
versionButton.translatesAutoresizingMaskIntoConstraints = false
357+
versionButton.lineBreakMode = .byTruncatingMiddle
358+
versionButton.attributedTitle = NSAttributedString(
359+
string: appVersionText,
360+
attributes: [
361+
.font: Typography.primary,
362+
.foregroundColor: NSColor.tertiaryLabelColor,
363+
])
364+
(versionButton.cell as? NSButtonCell)?.highlightsBy = []
365+
366+
let llamaCppLabel = Typography.makePrimaryLabel(" · llama.cpp \(AppInfo.llamaCppVersion)")
367+
llamaCppLabel.textColor = .tertiaryLabelColor
368+
llamaCppLabel.lineBreakMode = .byTruncatingMiddle
369+
llamaCppLabel.translatesAutoresizingMaskIntoConstraints = false
360370

361371
let settingsButton = NSButton(
362372
title: "Settings", target: self, action: #selector(toggleSettings))
@@ -370,7 +380,8 @@ final class FooterSection {
370380
quitButton.bezelStyle = .texturedRounded
371381
quitButton.translatesAutoresizingMaskIntoConstraints = false
372382

373-
container.addSubview(versionLabel)
383+
container.addSubview(versionButton)
384+
container.addSubview(llamaCppLabel)
374385
container.addSubview(settingsButton)
375386
container.addSubview(quitButton)
376387

@@ -379,9 +390,12 @@ final class FooterSection {
379390
NSLayoutConstraint.activate([
380391
container.widthAnchor.constraint(equalToConstant: Layout.menuWidth),
381392
container.heightAnchor.constraint(greaterThanOrEqualToConstant: 28),
382-
versionLabel.leadingAnchor.constraint(
393+
versionButton.leadingAnchor.constraint(
383394
equalTo: container.leadingAnchor, constant: horizontalPadding),
384-
versionLabel.centerYAnchor.constraint(equalTo: container.centerYAnchor),
395+
versionButton.centerYAnchor.constraint(equalTo: container.centerYAnchor),
396+
397+
llamaCppLabel.leadingAnchor.constraint(equalTo: versionButton.trailingAnchor),
398+
llamaCppLabel.centerYAnchor.constraint(equalTo: container.centerYAnchor),
385399

386400
settingsButton.trailingAnchor.constraint(
387401
equalTo: quitButton.leadingAnchor, constant: -8),
@@ -391,7 +405,7 @@ final class FooterSection {
391405
equalTo: container.trailingAnchor, constant: -horizontalPadding),
392406
quitButton.centerYAnchor.constraint(equalTo: container.centerYAnchor),
393407

394-
versionLabel.trailingAnchor.constraint(
408+
llamaCppLabel.trailingAnchor.constraint(
395409
lessThanOrEqualTo: settingsButton.leadingAnchor, constant: -8),
396410
])
397411

@@ -400,6 +414,10 @@ final class FooterSection {
400414
menu.addItem(item)
401415
}
402416

417+
@objc private func checkForUpdates() {
418+
NotificationCenter.default.post(name: .LBCheckForUpdates, object: nil)
419+
}
420+
403421
@objc private func toggleSettings() {
404422
NotificationCenter.default.post(name: .LBToggleSettingsVisibility, object: nil)
405423
}

0 commit comments

Comments
 (0)