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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -279,5 +279,5 @@ jobs:
echo "| SHA-256 DMG | \`${DMG_SHA256}\` |"
echo "| SHA-256 ZIP | \`${ZIP_SHA256}\` |"
echo "| Архитектуры | arm64 + x86_64 |"
echo "| Тесты | 161 XCTest |"
echo "| Тесты | 165 XCTest |"
} >> "$GITHUB_STEP_SUMMARY"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ Sources/
DiskScopeKit/
Core/ сканер, дерево, форматирование, treemap-раскладка
UI/ SwiftUI-интерфейс
App/ AppModel — состояние, сканирование, действия
App/ AppModel и feature-модели (search, cleanup, disk, history…)
DiskScope/ точка входа приложения
DiskScopeCLI/ headless-сканер для замеров
DiskScopeSnapshots/ рендер интерфейса в PNG без screen recording
Expand Down Expand Up @@ -371,7 +371,7 @@ Headless-сканер для бенчмарков:

## Тесты

161 тест: сравнение суммы скана с `du`, агрегация мелких файлов, пакеты,
165 тестов: сравнение суммы скана с `du`, агрегация мелких файлов, пакеты,
симлинки, Unicode-имена, отказ доступа, отмена, copy-on-write удаление,
свойства squarified-раскладки, вложенные ячейки, полный цикл `AppModel`
(скан → навигация → фильтры), даты создания и изменения, правила очистки,
Expand Down
8 changes: 4 additions & 4 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Roadmap

**Цикл:** 3.0 · **Релиз:** 2.0.0 · **Обновлено:** 23 октября 2026
**Цикл:** 3.0 · **Релиз:** 2.0.0 · **Обновлено:** 24 октября 2026

**Задачи:** [issues](https://github.com/fso13/DiskScope/issues) · **Этапы:** [milestones](https://github.com/fso13/DiskScope/milestones) · **Новые:** [#57–#72](https://github.com/fso13/DiskScope/issues?q=is%3Aissue+is%3Aopen)

Expand All @@ -23,7 +23,7 @@
| 2.0 — Платформа | 6/6: локализация, notarization/Sparkle/Homebrew, CLI, App Intents, доступность, меню-бар |
| Backlog | 5/5: кэш, параллельный скан, бюджеты, старые файлы, APFS-клоны |

Текущая база: **161 XCTest**, 17,9 тыс. строк исходников, 398 ключей
Текущая база: **165 XCTest**, 17,9 тыс. строк исходников, 398 ключей
локализации, `main` зелёный.

## Принципы
Expand All @@ -39,7 +39,7 @@

| Область | Симптом | Риск |
| --- | --- | --- |
| `AppModel` | 1561 строка, 8 вкладок, cleanup/search/disk/history в одном типе | любая фича замедляет сборку и тесты |
| `AppModel` | 497 строк; состояние разложено на feature-модели, координатор остался тонким | дальнейшие фичи не раздувают центр |
| `DiskScanner` | 1009 строк: bulk/readdir, парсинг, сессия и TreeBuilder вместе | сложно менять под APFS/параллельность |
| Кэш | хранит всё дерево, один корень, FSEvents-тесты со `sleep` | хрупкость и большой файл |
| CI | Dependency review падает, нет coverage/benchmark/release smoke | регрессии ловятся поздно |
Expand Down Expand Up @@ -93,7 +93,7 @@ F9 стартует как research, а не как обещание.

| ID | Задача | Приоритет | Оценка | Когда |
| --- | --- | --- | --- | --- |
| [T1](https://github.com/fso13/DiskScope/issues/66) | **Разложить `AppModel`** на feature-модели (`CleanupStore`, `SearchStore`, `DiskStore`, `BudgetStore`) с инъекцией зависимостей | P1 | L (6 д) | до F1 |
| [T1](https://github.com/fso13/DiskScope/issues/66) | **Разложить `AppModel`** на feature-модели с инъекцией зависимостей — закрыт, 497 строк | P1 | L (6 д) | сделано |
| [T2](https://github.com/fso13/DiskScope/issues/67) | **Разложить `DiskScanner`**: `BulkDirectoryReader`, `ReaddirReader`, `ScanSession`, `TreeBuilder`, протокол + фикстуры | P1 | L (8 д) | до F9/T3 |
| [T3](https://github.com/fso13/DiskScope/issues/68) | **Кэш 2.0**: сжатие/TTL/версии, partial reuse, инъекция FSEvents вместо `sleep` | P1 | L (6 д) | после T2 |
| [T4](https://github.com/fso13/DiskScope/issues/69) | **CI/release**: coverage ≥85% Core, benchmark baseline, snapshot/UI smoke, release/notarization dry-run, починить Dependency review, поднять версию | P1 | M (5 д) | сейчас |
Expand Down
6 changes: 3 additions & 3 deletions Sources/DiskScope/DiskScopeApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ struct DiskScopeApp: App {
Divider()
Button("Наверх") { model.goUp() }
.keyboardShortcut(.upArrow, modifiers: .command)
.disabled(!model.canGoUp)
.disabled(!model.browser.canGoUp)
Button("Показать в Finder") {
if model.selection.isEmpty {
model.revealCurrentFolder()
model.browser.revealCurrentFolder()
} else {
model.revealSelection()
model.browser.revealSelection()
}
}
.keyboardShortcut("r", modifiers: [.command, .shift])
Expand Down
2 changes: 1 addition & 1 deletion Sources/DiskScopeKit/App/AppModel+Folders.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extension AppModel {
}

public func scanHome() {
scan(path: homePath)
scan(path: browser.homePath)
}

public func scanVolume(_ volume: VolumeInfo) {
Expand Down
4 changes: 2 additions & 2 deletions Sources/DiskScopeKit/App/AppModel+SearchActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Foundation
extension AppModel {
public func revealSearchHit(_ hit: SearchHit) {
search.show = false
reveal(indices: [hit.index])
browser.reveal(indices: [hit.index])
}

public func navigateToSearchHit(_ hit: SearchHit) {
Expand All @@ -17,7 +17,7 @@ extension AppModel {
if node.parent >= 0 {
navigate(to: node.parent)
}
reveal(indices: [hit.index])
browser.reveal(indices: [hit.index])
}
}

Expand Down
185 changes: 11 additions & 174 deletions Sources/DiskScopeKit/App/AppModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public final class AppModel: ObservableObject {

@Published public internal(set) var scan: ScanController
@Published public internal(set) var nav = NavigationModel()
@Published public internal(set) var browser = BrowserModel()
@Published public var tab: Tab = .map {
didSet {
if tab == .cleanup {
Expand Down Expand Up @@ -139,7 +140,7 @@ public final class AppModel: ObservableObject {
environmentProvider: { [weak self] in
guard let self else { return .current() }
return CleanupEnvironment(
homePath: self.homePath,
homePath: self.browser.homePath,
runningBundleIdentifiers: self.runningBundleIdentifiers()
)
},
Expand All @@ -163,6 +164,10 @@ public final class AppModel: ObservableObject {
nav.objectWillChange.sink { [weak self] _ in
self?.objectWillChange.send()
}.store(in: &cancellables)
browser.attach(appModel: self)
browser.objectWillChange.sink { [weak self] _ in
self?.objectWillChange.send()
}.store(in: &cancellables)
inspector.attach(
treeProvider: { [weak self] in self?.tree },
currentIndexProvider: { [weak self] in self?.currentIndex ?? 0 },
Expand All @@ -178,8 +183,8 @@ public final class AppModel: ObservableObject {
currentIndexProvider: { [weak self] in self?.currentIndex ?? 0 },
searchProvider: { [weak self] in self?.searchText ?? "" },
categoryProvider: { [weak self] in self?.categoryFilter },
currentNameProvider: { [weak self] in self?.currentName ?? "" },
rootDisplayNameProvider: { [weak self] in self?.rootDisplayName ?? "DiskScope" },
currentNameProvider: { [weak self] in self?.browser.currentName ?? "" },
rootDisplayNameProvider: { [weak self] in self?.browser.rootDisplayName ?? "DiskScope" },
toast: { [weak self] text, symbol in self?.showToast(text, symbol: symbol) },
error: { [weak self] message in self?.errorMessage = message }
)
Expand All @@ -197,7 +202,7 @@ public final class AppModel: ObservableObject {
cleanupOperations.objectWillChange.sink { [weak self] _ in
self?.objectWillChange.send()
}.store(in: &cancellables)
disk.attach { [weak self] in self?.internalVolume }
disk.attach { [weak self] in self?.browser.internalVolume }
diskCancellable = disk.objectWillChange.sink { [weak self] _ in
self?.objectWillChange.send()
}
Expand Down Expand Up @@ -313,13 +318,6 @@ public final class AppModel: ObservableObject {
report.exportReport(format: format, scope: scope)
}

// MARK: - Derived state

public var scanSummary: String {
guard let tree else { return "" }
return "\(ByteFormat.string(tree.totalSize)) · \(Plural.files(tree.totalFiles)) · \(Plural.folders(folderCount))"
}

// MARK: - Scanning

public func scan(path: String) {
Expand Down Expand Up @@ -367,7 +365,7 @@ public final class AppModel: ObservableObject {
} else if let lastScanPath {
scan(path: lastScanPath)
} else {
scan(path: homePath)
scan(path: browser.homePath)
}
}

Expand All @@ -384,7 +382,7 @@ public final class AppModel: ObservableObject {
tab = .map
fileCount = result.totalFiles
folderCount = result.directoryCount()
refreshVolumes()
browser.refreshVolumes()
nav.rebuild()
stats.refresh()
history.record(result)
Expand Down Expand Up @@ -415,49 +413,6 @@ public final class AppModel: ObservableObject {
nav.navigate(to: 0)
}

public func activateRow(_ index: Int32) {
guard let tree, index >= 0, Int(index) < tree.count else { return }
guard tree.node(index).nodeKind != .aggregate else { return }
if tree.node(index).nodeKind == .directory {
navigate(to: index)
} else {
reveal(indices: [index])
}
}

public func openRow(_ index: Int32) {
guard let tree, index >= 0, Int(index) < tree.count else { return }
let node = tree.node(index)
guard node.nodeKind != .aggregate else { return }
if node.nodeKind.isContainer {
navigate(to: index)
} else {
let url = tree.url(of: index)
if !NSWorkspace.shared.open(url) {
errorMessage = "Не удалось открыть «\(tree.name(of: index))»"
}
}
}

public func reveal(indices: [Int32]) {
guard let tree else { return }
let urls = indices.compactMap { index -> URL? in
guard index >= 0, Int(index) < tree.count, !tree.isDeleted(index) else { return nil }
return tree.url(of: index)
}
guard !urls.isEmpty else { return }
NSWorkspace.shared.activateFileViewerSelecting(urls)
}

public func revealSelection() {
reveal(indices: Array(selection))
}

public func revealCurrentFolder() {
guard let tree else { return }
NSWorkspace.shared.activateFileViewerSelecting([tree.url(of: currentIndex)])
}

// MARK: - Trash

func resetTrashUndo() {
Expand Down Expand Up @@ -494,18 +449,6 @@ public final class AppModel: ObservableObject {
nav.clearCategoryFilter()
}

// MARK: - Permissions

public func openFullDiskAccessSettings() {
let candidates = [
"x-apple.systempreferences:com.apple.settings.PrivacySecurity.extension?Privacy_AllFiles",
"x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles",
]
for candidate in candidates {
if let url = URL(string: candidate), NSWorkspace.shared.open(url) { return }
}
}

// MARK: - UI helpers

public func showToast(_ text: String, symbol: String = "checkmark.circle.fill") {
Expand Down Expand Up @@ -550,111 +493,5 @@ extension AppModel {
}

extension AppModel {
public var freeSpaceText: String {
guard let volume = internalVolume else { return "—" }
return ByteFormat.string(volume.freeBytes)
}

public func refreshVolumes() {
volumes = VolumeInfo.loadAll()
}
}

extension AppModel {
public var currentName: String {
guard let tree else { return "" }
if currentIndex == 0 { return rootDisplayName }
let name = tree.name(of: currentIndex)
return name.isEmpty ? rootDisplayName : name
}

public var breadcrumbs: [Int32] {
guard let tree else { return [] }
var chain: [Int32] = []
var cursor = currentIndex
while cursor >= 0, chain.count < 256 {
chain.append(cursor)
let parent = tree.node(cursor).parent
if parent < 0 { break }
cursor = parent
}
return chain.reversed()
}

public var canGoUp: Bool {
guard let tree else { return false }
return tree.node(currentIndex).parent >= 0
}

public var currentSize: Int64 {
tree?.node(currentIndex).size ?? 0
}

public var currentItemCount: Int {
Int(tree?.node(currentIndex).itemCount ?? 0)
}

public var currentDirectCount: Int {
guard let tree, Int(currentIndex) < tree.count else { return 0 }
return Int(tree.node(currentIndex).childrenCount)
}

public var currentPath: String {
tree?.path(of: currentIndex) ?? ""
}

public var selectedSize: Int64 {
guard let tree else { return 0 }
return selection.reduce(Int64(0)) { $0 + tree.node($1).size }
}

public var selectedCount: Int { selection.count }

public var canRevealSelection: Bool {
guard let tree, !selection.isEmpty else { return false }
return selection.contains { !tree.isDeleted($0) }
}

public var hasPermissionIssues: Bool {
(tree?.report.skippedItems ?? 0) > 0
}

public var isScanning: Bool { phase == .scanning }

public var volume: VolumeInfo? {
volumes.first(where: { $0.isInternal }) ?? volumes.first
}

public var internalVolume: VolumeInfo? {
volumes.first(where: { $0.path == "/" }) ?? volumes.first
}

public var currentNode: ScanNode? {
guard let tree, currentIndex >= 0, Int(currentIndex) < tree.count else { return nil }
return tree.node(currentIndex)
}

public var homePath: String {
FileManager.default.homeDirectoryForCurrentUser.path
}

public var rootDisplayName: String {
guard let tree else { return "DiskScope" }
if tree.rootPath == "/" { return internalVolume?.name ?? "Macintosh HD" }
let known: [String: String] = [
homePath: "Домашняя папка",
homePath + "/Applications": "Программы",
"/Applications": "Программы",
homePath + "/Downloads": "Загрузки",
homePath + "/Documents": "Документы",
homePath + "/Desktop": "Рабочий стол",
homePath + "/Library": "Библиотека",
homePath + "/Movies": "Видео",
homePath + "/Music": "Музыка",
homePath + "/Pictures": "Изображения",
]
if let known = known[tree.rootPath] { return known }
let name = URL(fileURLWithPath: tree.rootPath).lastPathComponent
return name.isEmpty ? tree.rootPath : name
}
}
Loading
Loading