mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-10-23 23:29:35 +00:00
* feat(cursor): show the cursor.com sync in the apps, with an off switch status --format menubar-json gains an additive cursorSync block (enabled, state, lastSuccessAt, and a fixed errorCode/error on failure), read from the sync sidecar, the config and the Cursor app's login. It never syncs, never makes a request and never carries the token, the account hash or server text. It is absent when Cursor is not signed in and has never synced, and it is attached after the snapshot and per-device payloads. With the Cursor provider selected, the desktop overview, the macOS menu bar and the Windows tray show one line under the total: "Synced from cursor.com 12 min ago", or the error in a muted warning colour. A "Sync Cursor usage from cursor.com" switch writes config cursorSync: Settings > Providers > Cursor on the desktop, the Cursor settings pane on macOS and Windows. Desktop and mac strings are in all six locales; the tray stays English until its localization lands. * fix(cursor): guard config writes, show the env override in the switches The tray's shared config writer now refuses to write over a config.json that does not parse or is not an object (it used to replace it with an empty map plus the one key), which also protects the currency, budget and Claude config directory writers. The desktop writer rejects null and array configs the same way. With CODEBURN_CURSOR_SYNC=0 set, the desktop, mac and tray switches show "Turned off by CODEBURN_CURSOR_SYNC=0" and are disabled. A failed mac save now says so under the switch. The tray hero note uses the warning ink and maps errorCode to its own messages.
39 lines
1.8 KiB
Swift
39 lines
1.8 KiB
Swift
import Foundation
|
|
|
|
/// The CLI's `cursorSync` switch in `~/.config/codeburn/config.json` (absent
|
|
/// means on), written under the same flock as `CLIClaudeConfig`.
|
|
enum CLICursorSyncConfig {
|
|
static let defaultDir = (NSHomeDirectory() as NSString).appendingPathComponent(".config/codeburn")
|
|
|
|
static func load(configDir: String = defaultDir) -> Bool {
|
|
guard
|
|
let data = try? SafeFile.read(from: (configDir as NSString).appendingPathComponent("config.json")),
|
|
let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any]
|
|
else {
|
|
return true
|
|
}
|
|
return (json["cursorSync"] as? Bool) != false
|
|
}
|
|
|
|
/// On clears the key, matching the CLI default. A config that exists but does
|
|
/// not parse is left alone rather than replaced.
|
|
static func persist(enabled: Bool, configDir: String = defaultDir) throws {
|
|
let configPath = (configDir as NSString).appendingPathComponent("config.json")
|
|
try SafeFile.withExclusiveLock(at: (configDir as NSString).appendingPathComponent(".config.lock")) {
|
|
var config: [String: Any] = [:]
|
|
if FileManager.default.fileExists(atPath: configPath) {
|
|
guard let parsed = try JSONSerialization.jsonObject(with: SafeFile.read(from: configPath)) as? [String: Any] else {
|
|
throw CocoaError(.fileReadCorruptFile)
|
|
}
|
|
config = parsed
|
|
}
|
|
if enabled {
|
|
config.removeValue(forKey: "cursorSync")
|
|
} else {
|
|
config["cursorSync"] = false
|
|
}
|
|
let data = try JSONSerialization.data(withJSONObject: config, options: [.prettyPrinted, .sortedKeys])
|
|
try SafeFile.write(data, to: configPath, mode: 0o600)
|
|
}
|
|
}
|
|
}
|