Skip to content
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cb0767b
Expose file explorer git colors through config
austinywang May 12, 2026
f5ff98a
Merge remote-tracking branch 'origin/main' into issue-3848-file-explo…
austinywang May 12, 2026
f03816c
Merge remote-tracking branch 'origin/main' into issue-3848-file-explo…
austinywang May 12, 2026
d208d19
Avoid render-path git status preference reads
austinywang May 12, 2026
dce2c5d
Merge remote-tracking branch 'origin/main' into issue-3848-file-explo…
austinywang May 12, 2026
ceb09f8
Fix file explorer git color cache refresh
austinywang May 12, 2026
6c38851
Avoid unrelated git color cache reloads
austinywang May 12, 2026
edc3868
Merge remote-tracking branch 'origin/main' into issue-3848-file-explo…
austinywang May 12, 2026
4e979f9
Refactor file explorer git status colors
austinywang May 12, 2026
95c68d9
Harden file explorer git color parsing
austinywang May 12, 2026
f4944c3
Clarify git color cache test warmup
austinywang May 12, 2026
93d3a5d
Merge remote-tracking branch 'origin/main' into issue-3848-file-explo…
austinywang May 12, 2026
fbb6463
Fix file explorer git color actor isolation
austinywang May 12, 2026
f4f9e59
Fix file explorer git color notification isolation
austinywang May 12, 2026
6941e95
Fix git color cache reload ordering
austinywang May 12, 2026
bba8295
Fix git status color cache ownership
austinywang May 12, 2026
098c2c2
Merge remote-tracking branch 'origin/main' into issue-3848-file-explo…
austinywang May 13, 2026
925c342
Merge remote-tracking branch 'origin/main' into issue-3848-file-explo…
austinywang May 14, 2026
7bc332d
fix: address file explorer git color review
austinywang May 14, 2026
1f9b23b
Merge remote-tracking branch 'origin/main' into issue-3848-file-explo…
austinywang May 18, 2026
304d86b
Merge remote-tracking branch 'origin/main' into issue-3848-file-explo…
austinywang May 18, 2026
109dc4e
Merge branch 'main' of https://github.com/manaflow-ai/cmux into issue…
austinywang May 19, 2026
45fb8a6
Merge remote-tracking branch 'origin/main' into issue-3848-file-explo…
austinywang May 19, 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
1 change: 1 addition & 0 deletions Sources/CmuxSettingsJSONPathSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ extension CmuxSettingsFileStore {
"sidebar.showLog",
"sidebar.showProgress",
"sidebar.showCustomMetadata",
"fileExplorer.gitStatusColors",
"workspaceColors.indicatorStyle",
"workspaceColors.selectionColor",
"workspaceColors.notificationBadgeColor",
Expand Down
95 changes: 94 additions & 1 deletion Sources/FileExplorerStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ enum FileExplorerStyle: Int, CaseIterable {
}

func gitColor(for status: GitFileStatus) -> NSColor {
FileExplorerGitStatusColorSettings.resolvedColor(
for: status,
fallback: defaultGitColor(for: status)
)
}

private func defaultGitColor(for status: GitFileStatus) -> NSColor {
switch self {
case .liquidGlass:
switch status {
Expand Down Expand Up @@ -201,6 +208,92 @@ enum FileExplorerStyle: Int, CaseIterable {
}
}

enum FileExplorerGitStatusColorSettings {
static let userDefaultsKey = "fileExplorer.gitStatusColors"

static func normalizedStatusName(_ rawName: String) -> String? {
let name = rawName.trimmingCharacters(in: .whitespacesAndNewlines).lowercased()
guard GitFileStatus(rawValue: name) != nil else { return nil }
return name
}

static func resolvedColor(
for status: GitFileStatus,
fallback: NSColor,
defaults: UserDefaults = .standard
) -> NSColor {
FileExplorerGitStatusColorPalette.shared.color(for: status, fallback: fallback, defaults: defaults)
}
}

private final class FileExplorerGitStatusColorPalette {
static let shared = FileExplorerGitStatusColorPalette()

private let defaults: UserDefaults
private let notificationCenter: NotificationCenter
private let lock = NSLock()
private var colorsByStatus: [String: NSColor] = [:]
private var styleObserver: NSObjectProtocol?

init(
defaults: UserDefaults = .standard,
notificationCenter: NotificationCenter = .default
) {
self.defaults = defaults
self.notificationCenter = notificationCenter
reload()
styleObserver = notificationCenter.addObserver(
forName: .fileExplorerStyleDidChange,
object: nil,
queue: nil
) { [weak self] _ in
self?.reload()
}
}

deinit {
if let styleObserver {
notificationCenter.removeObserver(styleObserver)
}
}

func color(
for status: GitFileStatus,
fallback: NSColor,
defaults requestedDefaults: UserDefaults
) -> NSColor {
guard requestedDefaults === defaults else {
return Self.loadedColors(from: requestedDefaults)[status.rawValue] ?? fallback
}
lock.lock()
defer { lock.unlock() }
let color = colorsByStatus[status.rawValue]
return color ?? fallback
}

private func reload() {
let colors = Self.loadedColors(from: defaults)
lock.lock()
defer { lock.unlock() }
colorsByStatus = colors
}

private static func loadedColors(from defaults: UserDefaults) -> [String: NSColor] {
guard let colors = defaults.dictionary(
forKey: FileExplorerGitStatusColorSettings.userDefaultsKey
) as? [String: String] else {
return [:]
}
return colors.reduce(into: [:]) { result, pair in
guard let status = FileExplorerGitStatusColorSettings.normalizedStatusName(pair.key),
let color = NSColor(hex: pair.value) else {
return
}
result[status] = color
}
}
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

// MARK: - Models

struct FileExplorerEntry: Sendable {
Expand Down Expand Up @@ -1155,7 +1248,7 @@ final class FileExplorerDirectoryWatcher {

// MARK: - Git Status

enum GitFileStatus {
enum GitFileStatus: String, CaseIterable {
case modified, added, deleted, renamed, untracked
}

Expand Down
11 changes: 11 additions & 0 deletions Sources/KeyboardShortcutSettingsFileStore+Template.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ extension CmuxSettingsFileStore {
),
],
],
[
"fileExplorer": [
"gitStatusColors": [
"modified": "#218D8F",
"added": "#2AA54D",
"deleted": "#D24545",
"renamed": "#7C68EF",
"untracked": "#577172",
],
],
],
[
"sidebarAppearance": [
"matchTerminalBackground": false,
Expand Down
41 changes: 41 additions & 0 deletions Sources/KeyboardShortcutSettingsFileStore.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Combine
import Foundation
import os

@MainActor
final class KeyboardShortcutSettingsObserver: ObservableObject {
Expand All @@ -19,6 +20,8 @@ final class KeyboardShortcutSettingsObserver: ObservableObject {
final class CmuxSettingsFileStore {
static let shared = CmuxSettingsFileStore()

private static let logger = Logger(subsystem: "com.cmuxterm.app", category: "CmuxSettingsFileStore")

static let currentSchemaVersion = 1
static let schemaURLString = "https://raw.githubusercontent.com/manaflow-ai/cmux/main/web/data/cmux.schema.json"
private static let legacySchemaURLString = "https://raw.githubusercontent.com/manaflow-ai/cmux/main/web/data/cmux-settings.schema.json"
Expand Down Expand Up @@ -317,6 +320,9 @@ final class CmuxSettingsFileStore {
if let sidebarSection = root["sidebar"] as? [String: Any] {
parseSidebarSection(sidebarSection, sourcePath: sourcePath, snapshot: &snapshot)
}
if let fileExplorerSection = root["fileExplorer"] as? [String: Any] {
parseFileExplorerSection(fileExplorerSection, sourcePath: sourcePath, snapshot: &snapshot)
}
if let workspaceColorsSection = root["workspaceColors"] as? [String: Any] {
parseWorkspaceColorsSection(workspaceColorsSection, sourcePath: sourcePath, snapshot: &snapshot)
}
Expand Down Expand Up @@ -611,6 +617,37 @@ final class CmuxSettingsFileStore {
}
}

private func parseFileExplorerSection(
_ section: [String: Any],
sourcePath: String,
snapshot: inout ResolvedSettingsSnapshot
) {
guard section.keys.contains("gitStatusColors") else { return }
guard let rawColors = section["gitStatusColors"] as? [String: Any] else {
logInvalid("fileExplorer.gitStatusColors", sourcePath: sourcePath)
return
}

var normalizedColors: [String: String] = [:]
for (rawStatus, rawValue) in rawColors {
guard let status = FileExplorerGitStatusColorSettings.normalizedStatusName(rawStatus) else {
Self.logger.warning(
"Ignoring unknown file explorer git status '\(rawStatus, privacy: .public)' in \(sourcePath, privacy: .public)"
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
continue
}
guard let rawHex = jsonString(rawValue),
let hex = WorkspaceTabColorSettings.normalizedHex(rawHex) else {
Self.logger.warning(
"Ignoring invalid file explorer git status color '\(rawStatus, privacy: .public)' in \(sourcePath, privacy: .public)"
)
continue
}
Comment thread
lawrencecchen marked this conversation as resolved.
Resolved
normalizedColors[status] = hex
}
snapshot.managedUserDefaults[FileExplorerGitStatusColorSettings.userDefaultsKey] = .stringDictionary(normalizedColors)
}

private func parseSidebarAppearanceSection(
_ section: [String: Any],
sourcePath: String,
Expand Down Expand Up @@ -1197,10 +1234,14 @@ final class CmuxSettingsFileStore {
let shouldApplyAppearance = defaultsKey == AppearanceSettings.appearanceModeKey
let appearanceRawValue = shouldApplyAppearance ? UserDefaults.standard.string(forKey: defaultsKey) : nil
let appIconMode = defaultsKey == AppIconSettings.modeKey ? AppIconSettings.resolvedMode() : nil
let notifyFileExplorerAppearance = defaultsKey == FileExplorerGitStatusColorSettings.userDefaultsKey
let apply = {
if notifyScrollBar {
TerminalScrollBarSettings.notifyDidChange(notificationCenter: notificationCenter)
}
if notifyFileExplorerAppearance {
notificationCenter.post(name: .fileExplorerStyleDidChange, object: nil)
}

if let language {
LanguageSettings.apply(language)
Expand Down
57 changes: 57 additions & 0 deletions cmuxTests/KeyboardShortcutSettingsFileStoreStartupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,63 @@ final class KeyboardShortcutSettingsFileStoreStartupTests: XCTestCase {
XCTAssertEqual(defaults.object(forKey: key) as? Bool, false)
}

func testSettingsFileStoreAppliesFileExplorerGitStatusColors() throws {
let defaults = UserDefaults.standard
let key = FileExplorerGitStatusColorSettings.userDefaultsKey
defer { NotificationCenter.default.post(name: .fileExplorerStyleDidChange, object: nil) }

try preservingDefaults(keys: [key, settingsFileBackupsDefaultsKey, importedManagedDefaultsKey]) {
defaults.removeObject(forKey: key)
defaults.removeObject(forKey: settingsFileBackupsDefaultsKey)
defaults.removeObject(forKey: importedManagedDefaultsKey)
_ = FileExplorerStyle.highDensity.gitColor(for: .modified)
Comment thread
lawrencecchen marked this conversation as resolved.
Resolved

let directoryURL = try makeTemporaryDirectory()
defer { try? FileManager.default.removeItem(at: directoryURL) }

let settingsFileURL = directoryURL.appendingPathComponent("cmux.json", isDirectory: false)
try writeSettingsFile(
"""
{
"fileExplorer": {
"gitStatusColors": {
"modified": "#218d8f",
"added": "#2aa54d",
"deleted": "#d24545",
"renamed": "#7c68ef",
"untracked": "#577172"
}
}
}
""",
to: settingsFileURL
)

_ = KeyboardShortcutSettingsFileStore(
primaryPath: settingsFileURL.path,
fallbackPath: nil,
additionalFallbackPaths: [],
startWatching: false
)

XCTAssertEqual(
defaults.dictionary(forKey: key) as? [String: String],
[
"modified": "#218D8F",
"added": "#2AA54D",
"deleted": "#D24545",
"renamed": "#7C68EF",
"untracked": "#577172",
]
)
XCTAssertEqual(FileExplorerStyle.highDensity.gitColor(for: .modified).hexString(), "#218D8F")
XCTAssertEqual(FileExplorerStyle.highDensity.gitColor(for: .added).hexString(), "#2AA54D")
XCTAssertEqual(FileExplorerStyle.highDensity.gitColor(for: .deleted).hexString(), "#D24545")
XCTAssertEqual(FileExplorerStyle.highDensity.gitColor(for: .renamed).hexString(), "#7C68EF")
XCTAssertEqual(FileExplorerStyle.highDensity.gitColor(for: .untracked).hexString(), "#577172")
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
Comment thread
lawrencecchen marked this conversation as resolved.
Resolved
}
}

private func makeTemporaryDirectory() throws -> URL {
let url = FileManager.default.temporaryDirectory.appendingPathComponent(
"cmux-settings-startup-\(UUID().uuidString)",
Expand Down
30 changes: 30 additions & 0 deletions web/app/[locale]/docs/configuration/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const sectionOrder = [
"terminal",
"notifications",
"sidebar",
"fileExplorer",
"workspaceColors",
"sidebarAppearance",
"automation",
Expand Down Expand Up @@ -77,6 +78,16 @@ const settingsFileExample = `{
// }
// },

// "fileExplorer": {
// "gitStatusColors": {
// "modified": "#218D8F",
// "added": "#2AA54D",
// "deleted": "#D24545",
// "renamed": "#7C68EF",
// "untracked": "#577172"
// }
// },

// "shortcuts": {
// "bindings": {
// "toggleSidebar": "cmd+b",
Expand Down Expand Up @@ -346,6 +357,25 @@ working-directory = ~/code`}</CodeBlock>
"Neon Mint": "#00F5D4"
}
}
}`}</CodeBlock>
</>
)}
{sectionName === "fileExplorer" && (
<>
<p>
<code>fileExplorer.gitStatusColors</code> overrides the File Explorer label color for
each git status. Leave a status out to keep the active File Explorer style's built-in color.
</p>
<CodeBlock lang="json">{`{
"fileExplorer": {
"gitStatusColors": {
"modified": "#218D8F",
"added": "#2AA54D",
"deleted": "#D24545",
"renamed": "#7C68EF",
"untracked": "#577172"
}
}
}`}</CodeBlock>
</>
)}
Expand Down
36 changes: 36 additions & 0 deletions web/data/cmux.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,42 @@
}
}
},
"fileExplorer": {
"title": "fileExplorer",
"description": "File Explorer appearance settings.",
"type": "object",
"additionalProperties": false,
"properties": {
"gitStatusColors": {
"type": "object",
"description": "Override File Explorer label colors for git statuses. Omit a status to use the current File Explorer style's built-in color.",
"default": {},
"additionalProperties": false,
"properties": {
"modified": {
"$ref": "#/$defs/colorHex",
"description": "Color for modified files and folders."
},
"added": {
"$ref": "#/$defs/colorHex",
"description": "Color for added files."
},
"deleted": {
"$ref": "#/$defs/colorHex",
"description": "Color for deleted files."
},
"renamed": {
"$ref": "#/$defs/colorHex",
"description": "Color for renamed files."
},
"untracked": {
"$ref": "#/$defs/colorHex",
"description": "Color for untracked files and folders."
}
}
}
}
},
"sidebarAppearance": {
"title": "sidebarAppearance",
"description": "Sidebar tint settings from Settings > Sidebar Appearance.",
Expand Down
Loading