Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Peel logs when SwiftUI stops building its views as it expects
Țugui Dragoș64784cc6a69d
diff --git a/Peel/Navigation/ColumnFade.swift b/Peel/Navigation/ColumnFade.swiftindex ae01024b..830b87b7 100644--- a/Peel/Navigation/ColumnFade.swift+++ b/Peel/Navigation/ColumnFade.swift@@ -59,6 +59,16 @@ private struct ColumnFade: NSViewRepresentable {return view}+ /// A column in a split view should find its view; in a sheet there is no split view, and nothing to find.+ override func layout() {+ super.layout()+ if column != nil {+ PrivateStructure.found(.columnFade)+ } else if sequence(first: superview, next: { $0?.superview }).contains(where: { $0 is NSSplitView }) {+ PrivateStructure.check(.columnFade)+ }+ }+override func hitTest(_ point: NSPoint) -> NSView? {nil}diff --git a/Peel/Navigation/SidebarFocus.swift b/Peel/Navigation/SidebarFocus.swiftindex 27cea310..0370456c 100644--- a/Peel/Navigation/SidebarFocus.swift+++ b/Peel/Navigation/SidebarFocus.swift@@ -22,6 +22,7 @@ private struct ListFocus: NSViewRepresentable {final class Anchor: NSView {private var observation: NSKeyValueObservation?+ private var hasFoundTheList = false// Takes the focus at once, never on a later turn of the run loop, so no frame is drawn with the// selection in the unfocused gray first.@@ -37,6 +38,10 @@ private struct ListFocus: NSViewRepresentable {/// before the frame is drawn.override func layout() {super.layout()+ if !hasFoundTheList {+ hasFoundTheList = list(in: enclosingSplitViewItem?.viewController.view) != nil+ hasFoundTheList ? PrivateStructure.found(.sidebarFocus) : PrivateStructure.check(.sidebarFocus)+ }takeFocusIfNothingHasIt()}diff --git a/Peel/Navigation/TitlebarSeparators.swift b/Peel/Navigation/TitlebarSeparators.swiftindex 945093c0..5066c051 100644--- a/Peel/Navigation/TitlebarSeparators.swift+++ b/Peel/Navigation/TitlebarSeparators.swift@@ -66,26 +66,30 @@ private struct TitlebarSeparators: NSViewRepresentable {}-/// Reports when SwiftUI stops building the columns from an `NSSplitViewController`. This file,-/// `FixedSplitViewColumn`, and `ListColumn` rely on that structure, which is not API. If it changes, their fixes-/// stop working without any error: the line under the title bar comes back, the sidebar can be dragged to any-/// width, and the list's title bar section runs past its divider.+/// Reports when SwiftUI stops building its views the way Peel's AppKit adjustments expect. This file,+/// `FixedSplitViewColumn` and `ListColumn` rely on the columns coming from an `NSSplitViewController`, `ColumnFade`+/// on a column's view sitting two levels under the split view, and `SidebarFocus` on the sidebar's list being an+/// `NSOutlineView`. None of that is API, and if it changes, those adjustments stop working without any error.///-/// In Debug builds, a probe that has not found its structure three seconds after its first layout logs a fault,-/// once. It waits because the columns are not connected yet during that first layout. Each probe is tracked on-/// its own, so one that works cannot hide one that has stopped. It only logs and never stops the app.+/// In every build, a probe that has not found its structure three seconds after its first check logs a fault, once.+/// It waits because the columns are not connected yet during the first layout. Each probe is tracked on its own, so+/// one that works cannot hide one that has stopped. It only logs and never stops the app.@MainActorenum PrivateStructure {enum Probe {case titlebarSeparatorscase fixedColumncase listColumn+ case columnFade+ case sidebarFocusvar consequence: String {switch self {case .titlebarSeparators: "the line under the title bar is back"case .fixedColumn: "the sidebar can be dragged to any width"case .listColumn: "with the sidebar aside, the list's title bar runs past its divider"+ case .columnFade: "a list that changes no longer fades in"+ case .sidebarFocus: "the sidebar no longer takes the keyboard focus when nothing holds it"}}}@@ -98,15 +102,13 @@ enum PrivateStructure {}static func check(_ probe: Probe) {- #if DEBUGguard !seen.contains(probe), !watched.contains(probe) else { return }watched.insert(probe)Task {try? await Task.sleep(for: .seconds(3))guard !seen.contains(probe) else { return }Logger(subsystem: "com.tuguidragos.Peel", category: "layout")- .fault("SwiftUI no longer builds the columns from NSSplitViewController: \(probe.consequence, privacy: .public)")+ .fault("SwiftUI no longer builds its views as Peel expects: \(probe.consequence, privacy: .public)")}- #endif}}