Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ message: >-
permission or a Commercial License from the author.
type: software
title: MacOS Cleaner
version: "3.0.0"
date-released: "2026-11-16"
version: "3.0.1"
date-released: "2026-11-20"
url: "https://github.com/AlexTkDev/MacOSCleaner"
repository-code: "https://github.com/AlexTkDev/MacOSCleaner"
# Custom non-SPDX source-available license; CFF 1.2.0 uses license-url instead of license.
Expand Down
28 changes: 1 addition & 27 deletions MacOSCleaner/App/MacOSCleanerApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
// Licensed under GNU GPLv3 with Commons Clause v1.0 & Non-Commercial Condition (see LICENSE).

import SwiftUI
import OSLog


private let crashLogger = Logger(subsystem: Bundle.main.bundleIdentifier ?? "input.MacOSCleaner", category: "Crash")

class AppDelegate: NSObject, NSApplicationDelegate {
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
Expand Down Expand Up @@ -45,29 +41,7 @@ struct MacOSCleanerApp: App {
}

private static func installCrashHandlers() {
NSSetUncaughtExceptionHandler { exception in
let desc = exception.description
crashLogger.fault("Uncaught exception: \(exception.name.rawValue): \(desc)")
crashLogger.fault("Stack trace: \(exception.callStackSymbols.joined(separator: "\n"))")
fflush(stderr)
abort()
}

signal(SIGABRT) { _ in
crashLogger.fault("Received SIGABRT")
fflush(stderr)
_exit(1)
}
signal(SIGSEGV) { _ in
crashLogger.fault("Received SIGSEGV")
fflush(stderr)
_exit(1)
}
signal(SIGBUS) { _ in
crashLogger.fault("Received SIGBUS")
fflush(stderr)
_exit(1)
}
CrashSignalHandler.install()
}

var body: some Scene {
Expand Down
35 changes: 29 additions & 6 deletions MacOSCleaner/App/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,31 @@ import SwiftUI
struct RootView: View {
@State private var selectedItem: NavigationItem = .dashboard
@State private var privacyFilterBundleID: String? = nil
@State private var workspaceStore: WorkspaceStore
let cleanupViewModel: CleanupViewModel
let journal: TransactionJournal
let appSettings: AppSettings
@Bindable var permissionsManager: PermissionsManager
@Bindable var updatePrompt: UpdatePromptController
@Binding var availableUpdate: AvailableUpdate?

init(
cleanupViewModel: CleanupViewModel,
journal: TransactionJournal,
appSettings: AppSettings,
permissionsManager: PermissionsManager,
updatePrompt: UpdatePromptController,
availableUpdate: Binding<AvailableUpdate?>
) {
self.cleanupViewModel = cleanupViewModel
self.journal = journal
self.appSettings = appSettings
self.permissionsManager = permissionsManager
self.updatePrompt = updatePrompt
self._availableUpdate = availableUpdate
self._workspaceStore = State(initialValue: WorkspaceStore(journal: journal))
}

@Environment(\.colorScheme) private var colorScheme
@Environment(\.layoutDirection) private var layoutDirection
@Environment(\.accessibilityReduceTransparency) private var reduceTransparency
Expand Down Expand Up @@ -101,6 +119,9 @@ struct RootView: View {
presentUpdateIfReady()
}
}
.onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in
permissionsManager.refresh()
}
}

private func presentUpdateIfReady() {
Expand Down Expand Up @@ -186,28 +207,30 @@ struct RootView: View {
private func contentView(for item: NavigationItem) -> some View {
switch item {
case .dashboard:
DashboardView(journal: journal)
DashboardView(viewModel: workspaceStore.dashboardViewModel)
case .cleanup:
CleanupView(
viewModel: cleanupViewModel,
scanLimited: !permissionsManager.hasFullDiskAccess
)
case .diskSpace:
DiskAnalyzerView(settings: appSettings)
DiskAnalyzerView(settings: appSettings, viewModel: workspaceStore.diskAnalyzerViewModel)
case .duplicates:
DuplicatesView(settings: appSettings)
DuplicatesView(settings: appSettings, viewModel: workspaceStore.duplicatesViewModel)
case .processes:
ProcessesView(settings: appSettings)
ProcessesView(settings: appSettings, viewModel: workspaceStore.processesViewModel)
case .startupServices:
StartupServicesView(settings: appSettings)
StartupServicesView(settings: appSettings, viewModel: workspaceStore.startupServicesViewModel)
case .privacy:
PrivacyView(
permissionsManager: permissionsManager,
initialBundleIDFilter: $privacyFilterBundleID
initialBundleIDFilter: $privacyFilterBundleID,
viewModel: workspaceStore.privacyViewModel
)
case .uninstaller:
UninstallerView(
settings: appSettings,
viewModel: workspaceStore.uninstallerViewModel,
navigateToCleanup: { selectedItem = .cleanup },
navigateToPrivacy: { bundleID in
privacyFilterBundleID = bundleID
Expand Down
26 changes: 26 additions & 0 deletions MacOSCleaner/App/WorkspaceStore.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Foundation
import Observation

/// Long-lived workspace state container anchored in `RootView` so tab switches
/// and language reloads preserve cached scan results without re-scanning.
@MainActor
@Observable
final class WorkspaceStore {
let dashboardViewModel: DashboardViewModel
let diskAnalyzerViewModel: DiskAnalyzerViewModel
let duplicatesViewModel: DuplicatesViewModel
let processesViewModel: ProcessesViewModel
let startupServicesViewModel: StartupServicesViewModel
let privacyViewModel: PrivacyViewModel
let uninstallerViewModel: UninstallerViewModel

init(journal: TransactionJournal) {
self.dashboardViewModel = DashboardViewModel(journal: journal)
self.diskAnalyzerViewModel = DiskAnalyzerViewModel()
self.duplicatesViewModel = DuplicatesViewModel()
self.processesViewModel = ProcessesViewModel()
self.startupServicesViewModel = StartupServicesViewModel()
self.privacyViewModel = PrivacyViewModel()
self.uninstallerViewModel = UninstallerViewModel()
}
}
4 changes: 4 additions & 0 deletions MacOSCleaner/Domains/Cleanup/CleanupCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public final class CleanupCoordinator {
public var totalFreedBytes: Int64 = 0
public var apfsDeltaBytes: Int64? = nil
public var usedPermanentDeletion: Bool = false
public var cleanedFontCache: Bool = false
public var cleanedItems: [CleanupResultItem] = []
public var skippedItems: [SkippedCleanupItem] = []
public var lastError: String? = nil
Expand Down Expand Up @@ -135,6 +136,7 @@ public final class CleanupCoordinator {
try self.stateMachine.transition(to: .executing)
self.totalFreedBytes = 0
self.apfsDeltaBytes = nil
self.cleanedFontCache = false
let isImmediatePermanent = self.settings.bypassTrashOnUninstall || self.settings.emptyTrashDuringCleanup
self.usedPermanentDeletion = isImmediatePermanent
let sessionDeletionMode: OperationRecord.DeletionMode = isImmediatePermanent ? .permanent : .trash
Expand Down Expand Up @@ -166,6 +168,7 @@ public final class CleanupCoordinator {
let categories = self.itemManager.selectedCleanupCategories(from: options.categories())
// Review-only categories — never run category-level wipe.
let safeCategories = categories.filter { !CleanupCategory.reviewOnly.contains($0) }
self.cleanedFontCache = safeCategories.contains(.fontCache)
var records: [OperationRecord] = []
var hadPartialFailure = false

Expand Down Expand Up @@ -440,6 +443,7 @@ public final class CleanupCoordinator {
totalFreedBytes = 0
apfsDeltaBytes = nil
usedPermanentDeletion = false
cleanedFontCache = false
currentStep = 0
stepTitle = ""
lastError = nil
Expand Down
Loading
Loading