Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
27 changes: 27 additions & 0 deletions Packages/CmuxSettings/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// swift-tools-version: 5.9

import PackageDescription

let package = Package(
name: "CmuxSettings",
platforms: [
.macOS(.v13)
],
products: [
.library(
name: "CmuxSettings",
targets: ["CmuxSettings"]
),
],
targets: [
.target(
name: "CmuxSettings",
path: "Sources/CmuxSettings"
),
.testTarget(
name: "CmuxSettingsTests",
dependencies: ["CmuxSettings"],
path: "Tests/CmuxSettingsTests"
),
]
)
142 changes: 142 additions & 0 deletions Packages/CmuxSettings/Sources/CmuxSettings/CmuxSettingsCatalog.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import Foundation

public struct CmuxSettingsJSONPathDescriptor: Equatable, Hashable, Sendable {
public let path: String
public let section: String

public init(path: String, section: String? = nil) {
self.path = path
self.section = section ?? path.split(separator: ".", maxSplits: 1).first.map(String.init) ?? path
}
}

public enum CmuxSettingsCatalog {
public static let currentSchemaVersion = 1

public static let schemaURLString =
"https://raw.githubusercontent.com/manaflow-ai/cmux/main/web/data/cmux.schema.json"

public static func defaultPrimaryURL(homeDirectoryURL: URL = FileManager.default.homeDirectoryForCurrentUser) -> URL {
homeDirectoryURL
.appendingPathComponent(".config", isDirectory: true)
.appendingPathComponent("cmux", isDirectory: true)
.appendingPathComponent("cmux.json", isDirectory: false)
}

public static func defaultLegacyURL(homeDirectoryURL: URL = FileManager.default.homeDirectoryForCurrentUser) -> URL {
homeDirectoryURL
.appendingPathComponent(".config", isDirectory: true)
.appendingPathComponent("cmux", isDirectory: true)
.appendingPathComponent("settings.json", isDirectory: false)
}

public static func defaultApplicationSupportLegacyURL(
applicationSupportDirectoryURL: URL,
releaseBundleIdentifier: String = "com.cmuxterm.app"
) -> URL {
applicationSupportDirectoryURL
.appendingPathComponent(releaseBundleIdentifier, isDirectory: true)
.appendingPathComponent("settings.json", isDirectory: false)
}

public static let supportedJSONPathDescriptors: [CmuxSettingsJSONPathDescriptor] =
supportedJSONPathValues.map { CmuxSettingsJSONPathDescriptor(path: $0) }

public static let supportedJSONPaths: Set<String> = Set(supportedJSONPathValues)

Comment on lines +3 to +46

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add DocC comments for all public API in this package file.

This new package source exports public types/members without /// documentation, which violates the package API documentation requirement.

As per coding guidelines: Packages/**/Sources/**/*.swift: “Every public symbol in any new Swift package under Packages/ must be documented with a Swift-DocC triple-slash comment…”.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Packages/CmuxSettings/Sources/CmuxSettings/CmuxSettingsCatalog.swift` around
lines 3 - 46, Add Swift-DocC triple-slash comments to every public symbol in
this file: document the CmuxSettingsJSONPathDescriptor type (describe its
purpose), its stored properties path and section, and its public
init(path:section:) (explain behavior when section is nil); document the
CmuxSettingsCatalog enum and each public member: currentSchemaVersion,
schemaURLString, defaultPrimaryURL(_:), defaultLegacyURL(_:),
defaultApplicationSupportLegacyURL(applicationSupportDirectoryURL:releaseBundleIdentifier:),
supportedJSONPathDescriptors, and supportedJSONPaths — each comment should
briefly explain what the symbol represents, its parameters/return value and any
important behavior or defaults so the package meets the DocC requirement.

private static let supportedJSONPathValues: [String] = [
"app.language",
"app.appearance",
"app.appIcon",
"app.menuBarOnly",
"app.newWorkspacePlacement",
"app.workspaceInheritWorkingDirectory",
"app.minimalMode",
"app.keepWorkspaceOpenWhenClosingLastSurface",
"app.focusPaneOnFirstClick",
"app.preferredEditor",
"app.openSupportedFilesInCmux",
"app.openMarkdownInCmuxViewer",
"app.iMessageMode",
"app.reorderOnNotification",
"app.sendAnonymousTelemetry",
"app.confirmQuit",
"app.warnBeforeQuit",
"app.warnBeforeClosingTab",
"app.warnBeforeClosingTabXButton",
"app.hideTabCloseButton",
"app.renameSelectsExistingName",
"app.commandPaletteSearchesAllSurfaces",
"terminal.showScrollBar",
"terminal.copyOnSelect",
"terminal.autoResumeAgentSessions",
"terminal.agentHibernation.enabled",
"terminal.agentHibernation.idleSeconds",
"terminal.agentHibernation.maxLiveTerminals",
"terminal.textBoxMaxLines",
"terminal.resumeCommands",
"notifications.dockBadge",
"notifications.showInMenuBar",
"notifications.unreadPaneRing",
"notifications.paneFlash",
"notifications.sound",
"notifications.customSoundFilePath",
"notifications.command",
"notifications.hooks",
"notifications.hooksMode",
"sidebar.hideAllDetails",
"sidebar.wrapWorkspaceTitles",
"sidebar.showWorkspaceDescription",
"sidebar.branchLayout",
"sidebar.stackBranchDirectory",
"sidebar.pathLastSegmentOnly",
"sidebar.showNotificationMessage",
"sidebar.showBranchDirectory",
"sidebar.showPullRequests",
"sidebar.watchGitStatus",
"sidebar.makePullRequestsClickable",
"sidebar.openPullRequestLinksInCmuxBrowser",
"sidebar.openPortLinksInCmuxBrowser",
"sidebar.showSSH",
"sidebar.showPorts",
"sidebar.showLog",
"sidebar.showProgress",
"sidebar.showCustomMetadata",
"workspaceColors.indicatorStyle",
"workspaceColors.selectionColor",
"workspaceColors.notificationBadgeColor",
"workspaceColors.colors",
"workspaceColors.paletteOverrides",
"workspaceColors.customColors",
"sidebarAppearance.matchTerminalBackground",
"sidebarAppearance.tintColor",
"sidebarAppearance.lightModeTintColor",
"sidebarAppearance.darkModeTintColor",
"sidebarAppearance.tintOpacity",
"automation.socketControlMode",
"automation.socketPassword",
"automation.claudeCodeIntegration",
"automation.claudeBinaryPath",
"automation.ripgrepBinaryPath",
"automation.suppressSubagentNotifications",
"automation.cursorIntegration",
"automation.geminiIntegration",
"automation.portBase",
"automation.portRange",
"browser.defaultSearchEngine",
"browser.customSearchEngineName",
"browser.customSearchEngineURLTemplate",
"browser.showSearchSuggestions",
"browser.theme",
"browser.discardHiddenWebViews",
"browser.hiddenWebViewDiscardDelaySeconds",
"browser.openTerminalLinksInCmuxBrowser",
"browser.interceptTerminalOpenCommandInCmuxBrowser",
"browser.hostsToOpenInEmbeddedBrowser",
"browser.urlsToAlwaysOpenExternally",
"browser.insecureHttpHostsAllowedInEmbeddedBrowser",
"browser.showImportHintOnBlankTabs",
"browser.reactGrabVersion",
"shortcuts.bindings",
]
}
127 changes: 127 additions & 0 deletions Packages/CmuxSettings/Sources/CmuxSettings/CmuxSettingsStore.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import Dispatch
import Foundation

public struct CmuxSettingsFileSnapshot: Equatable, Sendable {
public var url: URL
public var contents: String

public init(url: URL, contents: String) {
self.url = url
self.contents = contents
}
}

public enum CmuxSettingsStoreError: Error, Equatable {
case unreadableData(URL)
}

public actor CmuxSettingsStore {
public let primaryURL: URL
public let fallbackURLs: [URL]

private let fileManager: FileManager

public init(
primaryURL: URL = CmuxSettingsCatalog.defaultPrimaryURL(),
fallbackURLs: [URL] = [CmuxSettingsCatalog.defaultLegacyURL()],
fileManager: FileManager = .default
) {
self.primaryURL = primaryURL
self.fallbackURLs = fallbackURLs
self.fileManager = fileManager
}

public func readActiveSnapshot() throws -> CmuxSettingsFileSnapshot {
let activeURL = ([primaryURL] + fallbackURLs).first { url in
fileManager.fileExists(atPath: url.path)
} ?? primaryURL
return try readSnapshot(at: activeURL)
}

public func readPrimarySnapshot() throws -> CmuxSettingsFileSnapshot {
try readSnapshot(at: primaryURL)
}

public func writePrimaryContents(_ contents: String) throws {
try fileManager.createDirectory(
at: primaryURL.deletingLastPathComponent(),
withIntermediateDirectories: true
)
try contents.write(to: primaryURL, atomically: true, encoding: .utf8)
}

public nonisolated func primaryChanges() -> AsyncStream<CmuxSettingsFileSnapshot> {
fileChanges(at: primaryURL)
}

public nonisolated func fileChanges(at url: URL) -> AsyncStream<CmuxSettingsFileSnapshot> {
AsyncStream { continuation in
let watcher = CmuxSettingsFileWatcher(url: url) {
guard let contents = try? String(contentsOf: url, encoding: .utf8) else { return }
continuation.yield(CmuxSettingsFileSnapshot(url: url, contents: contents))
}
continuation.onTermination = { _ in watcher.cancel() }
}
Comment on lines +57 to +64

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the watcher implementation and the store method
rg -n "class CmuxSettingsFileWatcher|struct CmuxSettingsFileWatcher|CmuxSettingsFileWatcher" -S Packages/CmuxSettings/Sources/CmuxSettings || true
rg -n "nonisolated func fileChanges\\(at url: URL\\)" -S Packages/CmuxSettings/Sources/CmuxSettings || true

# Show the cited regions
sed -n '1,140p' Packages/CmuxSettings/Sources/CmuxSettings/CmuxSettingsStore.swift | cat -n

# If the watcher is in another file, print that too
WATCHER_FILE="$(rg -l "CmuxSettingsFileWatcher" Packages/CmuxSettings/Sources/CmuxSettings | head -n 20)"
echo "Watcher files:"
echo "$WATCHER_FILE"
for f in $WATCHER_FILE; do
  echo "---- $f ----"
  # Avoid huge output: print first ~220 lines or until match region
  sed -n '1,220p' "$f" | cat -n
done

# Also inspect around lines mentioned "Also applies to: 90-111"
# (These are within the same file; we already printed to 140 with line numbers.)

Repository: manaflow-ai/cmux

Length of output: 10504


Fix CmuxSettingsStore fileChanges watcher to emit cleared/created states (missing-at-subscription + delete/rename)

  • CmuxSettingsFileWatcher returns immediately when open(url.path, O_EVTONLY) fails, so create/recreate after subscription produces no updates.
  • For .delete/.rename events, the handler runs but the try? String(contentsOf:) + guard drops the event, so consumers never receive the “missing/cleared” snapshot (unlike readSnapshot, which returns contents: "" when absent).
  • Update the watcher to observe the parent directory and (re)arm or retry reading on create/rename/delete, yielding an empty snapshot when the file is missing.
Suggested direction
- let descriptor = open(url.path, O_EVTONLY)
+ // Watch parent directory when file may not exist yet, and (re)arm file-specific watch
+ // after create/rename. Emit an empty snapshot when file is missing/deleted.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Packages/CmuxSettings/Sources/CmuxSettings/CmuxSettingsStore.swift` around
lines 57 - 64, The fileChanges watcher currently ignores missing or deleted
files and fails to notify subscribers on create/rename because
CmuxSettingsFileWatcher aborts if open(url.path, O_EVTONLY) fails and the
closure drops events when String(contentsOf:) fails; update
CmuxSettingsStore.fileChanges to watch the parent directory (not just the file)
via CmuxSettingsFileWatcher, emit an initial CmuxSettingsFileSnapshot reflecting
the current readSnapshot (empty contents when missing), and in the watch
callback attempt to read the file and on failure (file not found) yield a
CmuxSettingsFileSnapshot(url: url, contents: "") so create/rename/delete events
produce an empty/cleared snapshot; also make the watcher re-arm or retry opening
when the initial open fails so post-subscription creates trigger updates (keep
continuation.onTermination to call watcher.cancel()).

}

private func readSnapshot(at url: URL) throws -> CmuxSettingsFileSnapshot {
guard fileManager.fileExists(atPath: url.path) else {
return CmuxSettingsFileSnapshot(url: url, contents: "")
}
guard let contents = try? String(contentsOf: url, encoding: .utf8) else {
throw CmuxSettingsStoreError.unreadableData(url)
}
return CmuxSettingsFileSnapshot(url: url, contents: contents)
}
}
Comment on lines +4 to +76

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Document the public store API with Swift-DocC comments.

All exported symbols in this new package source file need /// docs (summary + callouts where applicable).

As per coding guidelines: Packages/**/Sources/**/*.swift: “Every public symbol in any new Swift package under Packages/ must be documented with a Swift-DocC triple-slash comment…”.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Packages/CmuxSettings/Sources/CmuxSettings/CmuxSettingsStore.swift` around
lines 4 - 76, Add Swift-DocC triple-slash documentation to every public symbol
in this file: CmuxSettingsFileSnapshot (describe purpose and fields url,
contents), CmuxSettingsStoreError (document the unreadableData case and when it
is thrown), CmuxSettingsStore (summary of the actor’s responsibility and
threading/Sendable behavior) and each public method:
init(primaryURL:fallbackURLs:fileManager:), readActiveSnapshot(),
readPrimarySnapshot(), writePrimaryContents(_:), primaryChanges(),
fileChanges(at:). For each method include a brief summary, parameters, return
value, and documented errors/behavior (e.g., when
CmuxSettingsStoreError.unreadableData is thrown, that fileChanges returns an
AsyncStream of CmuxSettingsFileSnapshot, and that primaryChanges is
nonisolated). Keep comments concise and use triple-slash (///) Swift-DocC style
directly above each public declaration.


private final class CmuxSettingsFileWatcher: @unchecked Sendable {
private let queue: DispatchQueue
private let source: DispatchSourceFileSystemObject?
private let fileDescriptor: CInt
private let onChange: @Sendable () -> Void
private let lock = NSLock()
private var isCancelled = false

init(url: URL, onChange: @escaping @Sendable () -> Void) {
self.queue = DispatchQueue(label: "com.cmux.settings.file-watcher.\(UUID().uuidString)")
self.onChange = onChange

let descriptor = open(url.path, O_EVTONLY)
guard descriptor >= 0 else {
fileDescriptor = -1
Comment on lines +82 to +92

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Stream silently goes dead after atomic write or file deletion

CmuxSettingsFileWatcher's event handler calls onChange() unconditionally on every event but never restarts the watcher. When writePrimaryContents writes atomically (temp file + rename), the .rename event fires once and the DispatchSource continues watching the now-stale file descriptor of the original inode — all subsequent writes are missed. The same happens after an external editor's atomic save or a plain .delete. ShortcutSettingsFileWatcher (the pre-existing watcher) avoids this by calling self.start() inside the handler on .delete/.rename events to re-attach to the new inode. Without equivalent restart logic here, any consumer of primaryChanges() or fileChanges(at:) will silently stop receiving events after the first atomic write.

source = nil
return
}

fileDescriptor = descriptor
let source = DispatchSource.makeFileSystemObjectSource(
fileDescriptor: descriptor,
eventMask: [.write, .delete, .rename, .revoke],
queue: queue
)
self.source = source
source.setEventHandler { [weak self] in
self?.onChange()
}
source.setCancelHandler {
close(descriptor)
}
source.resume()
}
Comment on lines +99 to +111

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Stream delivers zero events when watched file does not yet exist

If the cmux.json file does not exist when primaryChanges() is first observed (e.g., on a fresh install before bootstrapPrimaryTemplateIfNeeded runs), open(url.path, O_EVTONLY) returns -1, source is nil, and no DispatchSource is ever installed. The stream will never deliver an event, even if the file is created moments later. The pre-existing ShortcutSettingsFileWatcher handles this case by falling back to watching the parent directory and calling start() once the file appears. CmuxSettingsFileWatcher has no such directory fallback.


deinit {
cancel()
}

func cancel() {
lock.lock()
defer { lock.unlock() }
guard !isCancelled else { return }
isCancelled = true
source?.cancel()
if source == nil, fileDescriptor >= 0 {
close(fileDescriptor)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import XCTest
@testable import CmuxSettings

final class CmuxSettingsCatalogTests: XCTestCase {
func testSupportedJSONPathsContainCurrentSettingsSurface() {
XCTAssertTrue(CmuxSettingsCatalog.supportedJSONPaths.contains("app.appearance"))
XCTAssertTrue(CmuxSettingsCatalog.supportedJSONPaths.contains("terminal.autoResumeAgentSessions"))
XCTAssertTrue(CmuxSettingsCatalog.supportedJSONPaths.contains("browser.defaultSearchEngine"))
XCTAssertTrue(CmuxSettingsCatalog.supportedJSONPaths.contains("shortcuts.bindings"))
}

func testDefaultPrimaryURLUsesCmuxJSON() {
let home = URL(fileURLWithPath: "/tmp/cmux-settings-home", isDirectory: true)
XCTAssertEqual(
CmuxSettingsCatalog.defaultPrimaryURL(homeDirectoryURL: home).path,
"/tmp/cmux-settings-home/.config/cmux/cmux.json"
)
}
}
Comment on lines +1 to +19

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="Packages/CmuxSettings/Tests/CmuxSettingsTests/CmuxSettingsCatalogTests.swift"

echo "=== File exists? ==="
ls -la "$FILE" || true

echo "=== First 120 lines of file ==="
sed -n '1,120p' "$FILE" | cat -n

echo "=== Search for XCTest usage in Packages/CmuxSettings/Tests ==="
rg -n --hidden --glob 'Packages/CmuxSettings/Tests/**/*.swift' 'import XCTest|XCTestCase|XCTAssert' || true

echo "=== Search for Swift Testing usage in Packages/CmuxSettings/Tests ==="
rg -n --hidden --glob 'Packages/CmuxSettings/Tests/**/*.swift' 'import Testing|`@Suite`|`@Test`|`#expect`|`#require`' || true

echo "=== Locate review-bot rules for Swift Testing guidance ==="
ls -la .github/review-bot-rules || true
rg -n --hidden 'Swift Testing framework|import Testing|`@Suite`|`@Test`|`#expect`|`#require`' .github/review-bot-rules || true

Repository: manaflow-ai/cmux

Length of output: 4406


Migrate package tests from XCTest to Swift Testing

Packages/CmuxSettings/Tests/CmuxSettingsTests/CmuxSettingsCatalogTests.swift still uses import XCTest / XCTestCase and XCTAssert* APIs; switch it to Swift Testing (import Testing, @Suite, @Test, #expect, try #require``). The same issue exists in Packages/CmuxSettings/Tests/CmuxSettingsTests/CmuxSettingsStoreTests.swift.

🧰 Tools
🪛 SwiftLint (0.63.2)

[Warning] 4-4: Classes should have an explicit deinit method

(required_deinit)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Packages/CmuxSettings/Tests/CmuxSettingsTests/CmuxSettingsCatalogTests.swift`
around lines 1 - 19, Replace XCTest usage with Swift Testing: change `import
XCTest` to `import Testing`, mark the test container `CmuxSettingsCatalogTests`
with `@Suite` and annotate each test function
(`testSupportedJSONPathsContainCurrentSettingsSurface` and
`testDefaultPrimaryURLUsesCmuxJSON`) with `@Test`; replace
`XCTAssertTrue(CmuxSettingsCatalog.supportedJSONPaths.contains(...))` with `try
`#expect`(CmuxSettingsCatalog.supportedJSONPaths.contains(...)).toBeTrue()` and
replace `XCTAssertEqual(CmuxSettingsCatalog.defaultPrimaryURL(homeDirectoryURL:
home).path, "...")` with `try
`#expect`(CmuxSettingsCatalog.defaultPrimaryURL(homeDirectoryURL:
home).path).toEqual("...")`; apply the same changes for the other file
`CmuxSettingsStoreTests.swift` (import, `@Suite/`@Test annotations, and replace
XCTAssert* with `try `#expect``/`try `#require`` as appropriate).

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import XCTest
@testable import CmuxSettings

final class CmuxSettingsStoreTests: XCTestCase {
func testWriteAndReadPrimarySnapshot() async throws {
let directory = FileManager.default.temporaryDirectory
.appendingPathComponent("cmux-settings-\(UUID().uuidString)", isDirectory: true)
let primaryURL = directory.appendingPathComponent("cmux.json", isDirectory: false)
let store = CmuxSettingsStore(primaryURL: primaryURL, fallbackURLs: [])

try await store.writePrimaryContents("{\"schemaVersion\":1}")
let snapshot = try await store.readPrimarySnapshot()

XCTAssertEqual(snapshot.url, primaryURL)
XCTAssertEqual(snapshot.contents, "{\"schemaVersion\":1}")
}

func testActiveSnapshotFallsBackWhenPrimaryIsMissing() async throws {
let directory = FileManager.default.temporaryDirectory
.appendingPathComponent("cmux-settings-\(UUID().uuidString)", isDirectory: true)
try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)

let primaryURL = directory.appendingPathComponent("cmux.json", isDirectory: false)
let fallbackURL = directory.appendingPathComponent("settings.json", isDirectory: false)
try "{\"legacy\":true}".write(to: fallbackURL, atomically: true, encoding: .utf8)

let store = CmuxSettingsStore(primaryURL: primaryURL, fallbackURLs: [fallbackURL])
let snapshot = try await store.readActiveSnapshot()

XCTAssertEqual(snapshot.url, fallbackURL)
XCTAssertEqual(snapshot.contents, "{\"legacy\":true}")
}
}
Comment on lines +1 to +33

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="Packages/CmuxSettings/Tests/CmuxSettingsTests/CmuxSettingsStoreTests.swift"
echo "=== File: $FILE ==="
if [ -f "$FILE" ]; then
  wc -l "$FILE"
  sed -n '1,200p' "$FILE" | cat -n
else
  echo "Missing: $FILE"
  exit 1
fi

echo
echo "=== Search for Swift Testing usage in Packages/CmuxSettings/Tests ==="
rg -n --hidden --no-ignore-vcs "import Testing|`#expect`\\(|`@Test`|`@Suite`" Packages/CmuxSettings/Tests || true

echo
echo "=== Search for XCTest usage in Packages/CmuxSettings/Tests ==="
rg -n --hidden --no-ignore-vcs "import XCTest|XCTestCase|XCTAssert" Packages/CmuxSettings/Tests || true

echo
echo "=== Search for Swift Testing usage across repo tests (quick check) ==="
rg -n --hidden --no-ignore-vcs "import Testing" Packages/**/Tests/**/*.swift | head -n 50 || true

Repository: manaflow-ai/cmux

Length of output: 5164


Replace XCTest with Swift Testing in CmuxSettings package tests

Packages/CmuxSettings/Tests/CmuxSettingsTests/CmuxSettingsStoreTests.swift uses import XCTest, subclasses XCTestCase, and calls XCTAssertEqual. Update it to Swift Testing (import Testing, @Test/@Suite, and #expect(...)).

🧰 Tools
🪛 SwiftLint (0.63.2)

[Warning] 4-4: Classes should have an explicit deinit method

(required_deinit)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Packages/CmuxSettings/Tests/CmuxSettingsTests/CmuxSettingsStoreTests.swift`
around lines 1 - 33, Tests currently use XCTest APIs; replace XCTest with the
project's Swift Testing style by changing import XCTest to import Testing,
convert the CmuxSettingsStoreTests XCTestCase subclass into a `@Suite` (or
top-level struct/class per project convention) and convert each test method
(testWriteAndReadPrimarySnapshot,
testActiveSnapshotFallsBackWhenPrimaryIsMissing) into `@Test` functions that use
`#expect`(...) assertions instead of XCTAssertEqual; ensure async/throws
signatures are preserved and that CmuxSettingsStore, writePrimaryContents,
readPrimarySnapshot, and readActiveSnapshot are invoked the same way, and update
assertion calls to `#expect`(snapshot.url).toBe(primaryURL) and
`#expect`(snapshot.contents).toBe(...) (or equivalent `#expect` syntax used in the
codebase).

31 changes: 31 additions & 0 deletions Packages/CmuxSettingsUI/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// swift-tools-version: 5.9

import PackageDescription

let package = Package(
name: "CmuxSettingsUI",
platforms: [
.macOS(.v13)
],
products: [
.library(
name: "CmuxSettingsUI",
targets: ["CmuxSettingsUI"]
),
],
dependencies: [
.package(path: "../CmuxSettings"),
],
targets: [
.target(
name: "CmuxSettingsUI",
dependencies: ["CmuxSettings"],
path: "Sources/CmuxSettingsUI"
),
.testTarget(
name: "CmuxSettingsUITests",
dependencies: ["CmuxSettingsUI"],
path: "Tests/CmuxSettingsUITests"
),
]
)
Loading
Loading