Skip to content

Commit 1bc6540

Browse files
schisteclaude
andcommitted
style: apply SwiftFormat to recent FDA/telemetry/terminal changes
Wrap long log lines (maxwidth 200), trailing commas, redundant-self/type, operator spacing, and numeric grouping across files touched since v0.2.1 so the pre-push SwiftFormat/SwiftLint gate passes. No behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 1412ed5 commit 1bc6540

20 files changed

Lines changed: 79 additions & 43 deletions

apps/chau7-macos/Sources/Chau7/Logging/IncidentBreadcrumbStore.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,8 @@ final class IncidentBreadcrumbStore {
405405
}()
406406
}
407407

408-
private extension Dictionary where Key == String, Value == String {
408+
private extension [String: String] {
409409
func mapKeys(_ transform: (String) -> String) -> [String: String] {
410-
Dictionary<String, String>(uniqueKeysWithValues: map { (transform($0.key), $0.value) })
410+
[String: String](uniqueKeysWithValues: map { (transform($0.key), $0.value) })
411411
}
412412
}

apps/chau7-macos/Sources/Chau7/Overlay/TabRestoreBundleStore.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,8 @@ enum TabRestoreBundleStore {
464464
)
465465
}
466466

467-
private static func writeContextIfNeeded<T: Encodable>(
468-
_ context: T,
467+
private static func writeContextIfNeeded(
468+
_ context: some Encodable,
469469
hasContent: Bool,
470470
relativePath: String,
471471
bundleRootURL: URL,
@@ -502,7 +502,7 @@ enum TabRestoreBundleStore {
502502
return try? decoder.decode(type, from: data)
503503
}
504504

505-
private static func writeJSON<T: Encodable>(_ value: T, to url: URL) throws {
505+
private static func writeJSON(_ value: some Encodable, to url: URL) throws {
506506
let data = try encoder.encode(value)
507507
try data.write(to: url, options: .atomic)
508508
}

apps/chau7-macos/Sources/Chau7/RustBackend/RustTerminalView.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,11 @@ final class RustTerminalFFI {
13351335
}
13361336
let grid = rawGrid.assumingMemoryBound(to: RustGridSnapshot.self)
13371337
let snapshot = grid.pointee
1338-
Log.traceThrottled("rust-terminal-grid-\(instanceId)", interval: 5.0, "RustTerminalFFI[\(instanceId)]: getGrid - Got snapshot \(snapshot.cols)x\(snapshot.rows), scrollback=\(snapshot.scrollback_rows), offset=\(snapshot.display_offset)")
1338+
Log.traceThrottled(
1339+
"rust-terminal-grid-\(instanceId)",
1340+
interval: 5.0,
1341+
"RustTerminalFFI[\(instanceId)]: getGrid - Got snapshot \(snapshot.cols)x\(snapshot.rows), scrollback=\(snapshot.scrollback_rows), offset=\(snapshot.display_offset)"
1342+
)
13391343
return (grid, {
13401344
Log.traceThrottled("rust-terminal-grid-free", interval: 5.0, "RustTerminalFFI[?]: getGrid - Freeing grid snapshot")
13411345
fns.freeGrid(rawGrid)
@@ -1512,9 +1516,17 @@ final class RustTerminalFFI {
15121516

15131517
if shouldLog {
15141518
if changed {
1515-
Log.traceThrottled("rust-terminal-poll-\(instanceId)", interval: 5.0, "RustTerminalFFI[\(instanceId)]: poll - Grid CHANGED flags=\(rawFlags) (poll #\(Self.pollCounter), timeout=\(timeout)ms)")
1519+
Log.traceThrottled(
1520+
"rust-terminal-poll-\(instanceId)",
1521+
interval: 5.0,
1522+
"RustTerminalFFI[\(instanceId)]: poll - Grid CHANGED flags=\(rawFlags) (poll #\(Self.pollCounter), timeout=\(timeout)ms)"
1523+
)
15161524
} else if hasMetadata {
1517-
Log.traceThrottled("rust-terminal-poll-\(instanceId)", interval: 5.0, "RustTerminalFFI[\(instanceId)]: poll - Metadata changed flags=\(rawFlags) (poll #\(Self.pollCounter), timeout=\(timeout)ms)")
1525+
Log.traceThrottled(
1526+
"rust-terminal-poll-\(instanceId)",
1527+
interval: 5.0,
1528+
"RustTerminalFFI[\(instanceId)]: poll - Metadata changed flags=\(rawFlags) (poll #\(Self.pollCounter), timeout=\(timeout)ms)"
1529+
)
15181530
} else {
15191531
Log.trace("RustTerminalFFI[\(instanceId)]: poll - Status check (poll #\(Self.pollCounter))")
15201532
}

apps/chau7-macos/Sources/Chau7/RustBackend/TerminalEventDrain.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ final class TerminalEventDrain {
116116
DispatchQueue.main.async { [weak self, weak view] in
117117
guard let self else { return }
118118
guard let view, !view.isBeingDeallocated else {
119-
self.finishHandler(view: nil)
119+
finishHandler(view: nil)
120120
return
121121
}
122122
view.handleEventDrainData(drainGridChanged: flags.contains(.gridChanged))
123-
self.finishHandler(view: view)
123+
finishHandler(view: view)
124124
}
125125
}
126126

apps/chau7-macos/Sources/Chau7/Settings/FullDiskAccessGuard.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,17 @@ final class FullDiskAccessGuard {
118118
}
119119

120120
private var deniedDetail: String {
121-
L("permissions.fda.detail",
122-
"Terminal commands and AI agents (codex, claude) running in protected folders like ~/Downloads will fail with \"Operation not permitted\". This usually follows a rebuild or re-sign of Chau7. Re-enable Full Disk Access for Chau7 to fix it.")
121+
L(
122+
"permissions.fda.detail",
123+
"Terminal commands and AI agents (codex, claude) running in protected folders like ~/Downloads will fail with \"Operation not permitted\". This usually follows a rebuild or re-sign of Chau7. Re-enable Full Disk Access for Chau7 to fix it."
124+
)
123125
}
124126

125127
private func childDeniedDetail(root: String) -> String {
126-
L("permissions.fda.childDetail",
127-
"A command just failed with \"Operation not permitted\" in \(root). That is Chau7's Full Disk Access, not a bug in the CLI. Re-enable Full Disk Access for Chau7 to fix it.")
128+
L(
129+
"permissions.fda.childDetail",
130+
"A command just failed with \"Operation not permitted\" in \(root). That is Chau7's Full Disk Access, not a bug in the CLI. Re-enable Full Disk Access for Chau7 to fix it."
131+
)
128132
}
129133

130134
/// Opens System Settings directly to the Full Disk Access pane.

apps/chau7-macos/Sources/Chau7/Settings/Views/ProductivitySettingsView.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,10 @@ private struct PermissionsStatusSection: View {
306306
case .granted:
307307
return L("settings.productivity.permissions.fda.granted.detail", "Child processes (codex, claude, shells) can reach protected folders like ~/Downloads.")
308308
case .denied:
309-
return L("settings.productivity.permissions.fda.denied.detail", "Commands in protected folders fail with \"Operation not permitted\". Re-enable Full Disk Access for Chau7 in System Settings.")
309+
return L(
310+
"settings.productivity.permissions.fda.denied.detail",
311+
"Commands in protected folders fail with \"Operation not permitted\". Re-enable Full Disk Access for Chau7 in System Settings."
312+
)
310313
case .indeterminate:
311314
return L("settings.productivity.permissions.fda.unknown.detail", "Full Disk Access status could not be determined.")
312315
}

apps/chau7-macos/Sources/Chau7/Telemetry/Providers/ClaudeCodeContentProvider.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ final class ClaudeCodeContentProvider: RunContentProvider {
5454
for file in jsonlFiles.sorted(by: { $0.lastPathComponent < $1.lastPathComponent }) {
5555
guard let reading = BoundedTranscriptReader.read(at: file) else { continue }
5656
if let originalBytes = reading.truncatedFromBytes {
57-
Log.warn("ClaudeCodeContentProvider: transcript \(file.lastPathComponent) is \(originalBytes / 1_048_576)MB; parsed last \(BoundedTranscriptReader.defaultMaxBytes / 1_048_576)MB to avoid OOM")
57+
Log
58+
.warn(
59+
"ClaudeCodeContentProvider: transcript \(file.lastPathComponent) is \(originalBytes / 1_048_576)MB; parsed last \(BoundedTranscriptReader.defaultMaxBytes / 1_048_576)MB to avoid OOM"
60+
)
5861
}
5962
ClaudeTranscriptUsageParser.ingest(
6063
jsonl: reading.text,

apps/chau7-macos/Sources/Chau7Core/CommandDetection.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,9 +573,9 @@ public enum CommandDetection {
573573
static func detectJavaScriptPackageRunnerTool(tokens: [String], launcher: String) -> String? {
574574
guard let cmdIndex = tokens.firstIndex(where: { normalizeToken($0) == launcher }) else { return nil }
575575

576-
let directLaunchers: Set<String> = ["npx", "bunx", "pnpm"]
577-
let execLaunchers: Set<String> = ["npm", "pnpm", "yarn", "bun"]
578-
let execVerbs: Set<String> = ["exec", "dlx", "x"]
576+
let directLaunchers: Set = ["npx", "bunx", "pnpm"]
577+
let execLaunchers: Set = ["npm", "pnpm", "yarn", "bun"]
578+
let execVerbs: Set = ["exec", "dlx", "x"]
579579
guard directLaunchers.contains(launcher) || execLaunchers.contains(launcher) else {
580580
return nil
581581
}

apps/chau7-macos/Sources/Chau7Core/FullDiskAccessProbe.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public enum FullDiskAccessProbe {
4141
public static let defaultCanaries: [String] = [
4242
"Library/Application Support/com.apple.TCC/TCC.db",
4343
"Library/Safari/Bookmarks.plist",
44-
"Library/Cookies/Cookies.binarycookies",
44+
"Library/Cookies/Cookies.binarycookies"
4545
]
4646

4747
/// Determines Full Disk Access status from the given canaries.

apps/chau7-macos/Sources/Chau7Core/PermissionDenialClassifier.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public enum PermissionDenialClassifier {
2828
/// (POSIX, Rust/codex, Node, Swift). All matched case-insensitively.
2929
public static let denialMarkers: [String] = [
3030
"operation not permitted",
31-
"os error 1", // Rust std::io EPERM (codex)
31+
"os error 1", // Rust std::io EPERM (codex)
3232
"eperm",
33-
"errno 1",
33+
"errno 1"
3434
]
3535

3636
public static func classify(output: String, cwd: String, protectedRoots: [String]) -> Verdict {
@@ -56,7 +56,9 @@ public enum PermissionDenialClassifier {
5656

5757
private static func normalized(_ path: String) -> String {
5858
var p = path.trimmingCharacters(in: .whitespacesAndNewlines)
59-
while p.count > 1 && p.hasSuffix("/") { p.removeLast() }
59+
while p.count > 1, p.hasSuffix("/") {
60+
p.removeLast()
61+
}
6062
return p
6163
}
6264
}

0 commit comments

Comments
 (0)