Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(lume): preserve background service during updates (#4337)

Iflaq khurshidfaa52c949a6b
diff --git a/docs/content/docs/lume/reference/cli/updates.mdx b/docs/content/docs/lume/reference/cli/updates.mdx
index 306c0593b4..d5259a7102 100644
--- a/docs/content/docs/lume/reference/cli/updates.mdx
+++ b/docs/content/docs/lume/reference/cli/updates.mdx
@@ -54,7 +54,7 @@ lume update [OPTIONS]
| Flag | Type | Default | Description |
| --- | --- | --- | --- |
-| <span id="lume-update--apply"></span>`--apply` | boolean | `false` | Apply the update by re-running the official installer. |
+| <span id="lume-update--apply"></span>`--apply` | boolean | `false` | Apply the update while preserving the current background-service choice. |
| <span id="lume-update--json"></span>`--json` | boolean | `false` | Emit the structured update-state payload as JSON. |
**Examples**
diff --git a/libs/lume/src/Update/VersionCheck.swift b/libs/lume/src/Update/VersionCheck.swift
index 8c0ddcfd6d..4c70f1f703 100644
--- a/libs/lume/src/Update/VersionCheck.swift
+++ b/libs/lume/src/Update/VersionCheck.swift
@@ -10,6 +10,8 @@ enum LumeVersionCheck {
private static let cacheRefreshSeconds: TimeInterval = 20 * 60 * 60
private static let updateCheckEnv = "LUME_UPDATE_CHECK"
private static let installScriptURLEnv = "LUME_INSTALL_SCRIPT_URL"
+ private static let backgroundServicePlistPath =
+ "Library/LaunchAgents/com.trycua.lume_daemon.plist"
struct State: Codable {
let currentVersion: String
@@ -208,18 +210,33 @@ enum LumeVersionCheck {
static func runInstallScript(version: String) throws -> Int32 {
let process = Process()
process.executableURL = URL(fileURLWithPath: "/bin/bash")
- process.arguments = ["-c", manualInstallCommand()]
var environment = ProcessInfo.processInfo.environment
environment["LUME_VERSION"] = version
environment["LUME_INSTALL_CHANNEL"] = "update_apply"
process.environment = environment
+ let homeDirectory = environment["HOME"]
+ .map { URL(fileURLWithPath: $0, isDirectory: true) }
+ ?? FileManager.default.homeDirectoryForCurrentUser
+ process.arguments = installScriptArguments(homeDirectory: homeDirectory)
try process.run()
process.waitUntilExit()
return process.terminationStatus
}
+ static func installScriptArguments(
+ homeDirectory: URL,
+ installCommand: String = manualInstallCommand()
+ ) -> [String] {
+ let servicePlist = homeDirectory.appendingPathComponent(backgroundServicePlistPath)
+ let preserveService = FileManager.default.fileExists(atPath: servicePlist.path)
+ let command = preserveService
+ ? installCommand
+ : "\(installCommand) -s -- --no-background-service"
+ return ["-c", command]
+ }
+
static func isNewer(_ lhs: String, than rhs: String) -> Bool {
compare(lhs, rhs) == .orderedDescending
}
diff --git a/libs/lume/src/Utils/CommandDocExtractor.swift b/libs/lume/src/Utils/CommandDocExtractor.swift
index 46f92f67b4..6c5a93c26c 100644
--- a/libs/lume/src/Utils/CommandDocExtractor.swift
+++ b/libs/lume/src/Utils/CommandDocExtractor.swift
@@ -853,7 +853,7 @@ enum CommandDocExtractor {
arguments: [],
options: [],
flags: [
- FlagDoc(name: "apply", shortName: nil, help: "Apply the update by re-running the official installer", defaultValue: false),
+ FlagDoc(name: "apply", shortName: nil, help: "Apply the update while preserving the current background-service choice", defaultValue: false),
FlagDoc(name: "json", shortName: nil, help: "Emit the structured update-state payload as JSON", defaultValue: false),
],
subcommands: [],
diff --git a/libs/lume/tests/VersionCheckTests.swift b/libs/lume/tests/VersionCheckTests.swift
index 9943d54807..1b826efd83 100644
--- a/libs/lume/tests/VersionCheckTests.swift
+++ b/libs/lume/tests/VersionCheckTests.swift
@@ -22,6 +22,35 @@ struct VersionCheckTests {
)
}
+ @Test func updateInstallerPreservesBackgroundServiceChoice() throws {
+ let home = FileManager.default.temporaryDirectory
+ .appendingPathComponent(UUID().uuidString, isDirectory: true)
+ defer { try? FileManager.default.removeItem(at: home) }
+
+ #expect(
+ LumeVersionCheck.installScriptArguments(
+ homeDirectory: home,
+ installCommand: "install-lume"
+ ) == ["-c", "install-lume -s -- --no-background-service"]
+ )
+
+ let servicePlist = home.appendingPathComponent(
+ "Library/LaunchAgents/com.trycua.lume_daemon.plist"
+ )
+ try FileManager.default.createDirectory(
+ at: servicePlist.deletingLastPathComponent(),
+ withIntermediateDirectories: true
+ )
+ try Data().write(to: servicePlist)
+
+ #expect(
+ LumeVersionCheck.installScriptArguments(
+ homeDirectory: home,
+ installCommand: "install-lume"
+ ) == ["-c", "install-lume"]
+ )
+ }
+
@Test func stableDiscoveryRejectsDraftAndNightlyTags() {
let releases: [[String: Any]] = [
["tag_name": "lume-v0.6.0", "draft": true],
diff --git a/scripts/docs-generators/cli-specs/lume.json b/scripts/docs-generators/cli-specs/lume.json
index d805ff06c0..5c861d210a 100644
--- a/scripts/docs-generators/cli-specs/lume.json
+++ b/scripts/docs-generators/cli-specs/lume.json
@@ -1701,7 +1701,7 @@
"flags": [
{
"default_value": false,
- "help": "Apply the update by re-running the official installer",
+ "help": "Apply the update while preserving the current background-service choice",
"name": "apply"
},
{