Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ee8b0fb
Add regression for stale nightly theme cleanup
austinywang May 21, 2026
ee3229e
Clean stale release theme override for channel builds
austinywang May 21, 2026
e88d25e
Cover stale release cleanup on theme set
austinywang May 21, 2026
a975b91
Sanitize stale theme cleanup errors
austinywang May 21, 2026
fcf0009
Localize stale theme cleanup error
austinywang May 21, 2026
83a4481
Sanitize localized cleanup failure
austinywang May 21, 2026
d7dfde9
Add regression for interactive stale theme cleanup
austinywang May 21, 2026
21ee1da
Clean stale release theme before interactive picker
austinywang May 21, 2026
ce24396
Merge remote-tracking branch 'origin/main' into issue-4501-stale-them…
austinywang May 23, 2026
0ebe621
Fix stale release theme cleanup for Nightly
austinywang May 23, 2026
8360a48
Narrow stale theme fallback cleanup
austinywang May 23, 2026
368959d
Fix stale theme cleanup warning
austinywang May 23, 2026
673ab87
Fail theme set when fallback cleanup fails
austinywang May 23, 2026
90bf992
Fix paired theme appearance reloads
austinywang May 23, 2026
558c3d7
Use current checkout in activation perf workflow
austinywang May 23, 2026
72ae935
Avoid blocking paired theme reload preparation
austinywang May 23, 2026
febdd98
Fix cleared cmux theme appearance reloads
austinywang May 23, 2026
606987a
Resolve paired cmux themes before startup config
austinywang May 23, 2026
01a3e25
Merge remote-tracking branch 'origin/main' into issue-4501-stale-them…
austinywang May 23, 2026
9c65efb
Preserve terminal scheme during resolved appearance reloads
austinywang May 23, 2026
0f1ccae
Wire resolved scheme for paired cmux config loads
austinywang May 23, 2026
3c5b75e
Merge remote-tracking branch 'origin/main' into issue-4501-stale-them…
austinywang May 26, 2026
923ce7a
Fix cmux theme reload review issues
austinywang May 26, 2026
7391484
Localize stale theme cleanup fallback error
austinywang May 26, 2026
8421841
Fix theme clear cleanup review issues
austinywang May 26, 2026
e3f0378
Add legacy release theme cleanup regression
austinywang May 26, 2026
747a3bd
Strip legacy release theme cleanup blocks
austinywang May 26, 2026
1c13f5a
Use multi-root cmux config loading in app
austinywang May 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions CLI/CMUXCLI+ThemeSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ extension CMUXCLI {
rawThemeValue: String,
targetBundleIdentifier: String
) throws -> URL {
try removeStaleReleaseManagedThemeOverrideIfNeeded()

let fileManager = FileManager.default
let configURL = try cmuxThemeOverrideConfigURL(targetBundleIdentifier: targetBundleIdentifier)
let directoryURL = configURL.deletingLastPathComponent()
Expand All @@ -258,6 +260,8 @@ extension CMUXCLI {
}

func clearManagedThemeOverride(targetBundleIdentifier: String) throws -> URL {
try removeStaleReleaseManagedThemeOverrideIfNeeded()

let fileManager = FileManager.default
let configURL = try cmuxThemeOverrideConfigURL(targetBundleIdentifier: targetBundleIdentifier)
guard let existingContents = try readOptionalThemeOverrideContents(at: configURL) else {
Expand All @@ -283,6 +287,41 @@ extension CMUXCLI {
return configURL
}

private func removeStaleReleaseManagedThemeOverrideIfNeeded() throws {
guard let activeBundleIdentifier = currentCmuxAppBundleIdentifier()?
.trimmingCharacters(in: .whitespacesAndNewlines),
!activeBundleIdentifier.isEmpty,
activeBundleIdentifier != Self.cmuxThemeOverrideBundleIdentifier else {
return
}

let releaseConfigURL = try cmuxThemeOverrideConfigURL(
targetBundleIdentifier: Self.cmuxThemeOverrideBundleIdentifier
)
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
guard let existingContents = try readOptionalThemeOverrideContents(at: releaseConfigURL) else {
return
}

let strippedContents = removingManagedThemeOverride(from: existingContents)
guard strippedContents != existingContents else {
return
}

let normalizedContents = strippedContents.trimmingCharacters(in: .whitespacesAndNewlines)
if normalizedContents.isEmpty {
do {
try FileManager.default.removeItem(at: releaseConfigURL)
} catch {
guard !isThemeOverrideFileNotFoundError(error) else {
return
}
throw error
}
} else {
try normalizedContents.appending("\n").write(to: releaseConfigURL, atomically: true, encoding: .utf8)
}
}
Comment thread
austinywang marked this conversation as resolved.
Resolved

private func readOptionalThemeOverrideContents(at url: URL) throws -> String? {
do {
return try String(contentsOf: url, encoding: .utf8)
Expand Down
83 changes: 83 additions & 0 deletions cmuxTests/CMUXCLIErrorOutputRegressionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,89 @@ final class CMUXCLIErrorOutputRegressionTests: XCTestCase {
XCTAssertEqual(appReadablePaths, [expectedConfigURL.path])
}

func testThemesClearNightlyRemovesStaleReleaseManagedBlock() throws {
let cliPath = try bundledCLIPath()
let fileManager = FileManager.default
let root = fileManager.temporaryDirectory
.appendingPathComponent("cmux-themes-nightly-stale-release-\(UUID().uuidString)", isDirectory: true)
try fileManager.createDirectory(at: root, withIntermediateDirectories: true)
defer { try? fileManager.removeItem(at: root) }

let appSupportDirectory = root
.appendingPathComponent("Library", isDirectory: true)
.appendingPathComponent("Application Support", isDirectory: true)
let releaseConfigURL = appSupportDirectory
.appendingPathComponent("com.cmuxterm.app", isDirectory: true)
.appendingPathComponent("config.ghostty", isDirectory: false)
let nightlyConfigURL = appSupportDirectory
.appendingPathComponent("com.cmuxterm.app.nightly", isDirectory: true)
.appendingPathComponent("config.ghostty", isDirectory: false)
try fileManager.createDirectory(
at: releaseConfigURL.deletingLastPathComponent(),
withIntermediateDirectories: true
)
try fileManager.createDirectory(
at: nightlyConfigURL.deletingLastPathComponent(),
withIntermediateDirectories: true
)
try """
font-size = 13

# cmux themes start
theme = light:Old Release,dark:Old Release
# cmux themes end
""".appending("\n").write(to: releaseConfigURL, atomically: true, encoding: .utf8)
try """
# cmux themes start
theme = light:Current Nightly,dark:Current Nightly
# cmux themes end
""".appending("\n").write(to: nightlyConfigURL, atomically: true, encoding: .utf8)

var environment = ProcessInfo.processInfo.environment
for key in Array(environment.keys) where key.hasPrefix("CMUX_") {
environment.removeValue(forKey: key)
}
environment["CFFIXED_USER_HOME"] = root.path
environment["HOME"] = root.path
environment["CMUX_SOCKET_PATH"] = "/tmp/cmux-nightly.sock"
environment["CMUX_BUNDLE_ID"] = "com.cmuxterm.app.nightly"
environment["CMUX_CLI_SENTRY_DISABLED"] = "1"

let clearResult = runProcess(
executablePath: cliPath,
arguments: ["--json", "themes", "clear"],
environment: environment,
timeout: 5
)

XCTAssertFalse(clearResult.timedOut, clearResult.stdout)
XCTAssertEqual(clearResult.status, 0, clearResult.stdout)

let releaseContents = try String(contentsOf: releaseConfigURL, encoding: .utf8)
XCTAssertTrue(releaseContents.contains("font-size = 13"), releaseContents)
XCTAssertFalse(releaseContents.contains("# cmux themes start"), releaseContents)
XCTAssertFalse(releaseContents.contains("Old Release"), releaseContents)

let listResult = runProcess(
executablePath: cliPath,
arguments: ["--json", "themes", "list"],
environment: environment,
timeout: 5
)

XCTAssertFalse(listResult.timedOut, listResult.stdout)
XCTAssertEqual(listResult.status, 0, listResult.stdout)

let payload = try XCTUnwrap(
JSONSerialization.jsonObject(with: Data(listResult.stdout.utf8)) as? [String: Any],
listResult.stdout
)
let current = try XCTUnwrap(payload["current"] as? [String: Any], listResult.stdout)
XCTAssertTrue(current["raw_value"] is NSNull, listResult.stdout)
XCTAssertTrue(current["light"] is NSNull, listResult.stdout)
XCTAssertTrue(current["dark"] is NSNull, listResult.stdout)
}
Comment thread
austinywang marked this conversation as resolved.
Resolved

func testBareInteractiveThemesReloadsRunningAppAfterPickerExits() throws {
let cliPath = try bundledCLIPath()
let fileManager = FileManager.default
Expand Down
Loading