native macOS codings agent orchestrator prowl.onev.cat
Something went wrong. Try again.
1.7 kB · 55 lines
Swift
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556import AppKitimport ComposableArchitectureimport SwiftUI
#if DEBUG
/// Manages the singleton Debug Window. This debug-only auxiliary surface /// caches its `NSWindow`, deminiaturises and fronts it on subsequent shows, /// and is configured once during app bootstrap with the root store so it can /// mirror the user's appearance setting. @MainActor final class DebugWindowManager { static let shared = DebugWindowManager()
private var window: NSWindow? private var store: StoreOf<AppFeature>?
private init() {}
func configure(store: StoreOf<AppFeature>) { self.store = store }
func show() { if let existing = window { if existing.isMiniaturized { existing.deminiaturize(nil) } existing.makeKeyAndOrderFront(nil) return }
guard let store else { return } let host = NSHostingController(rootView: DebugView(store: store)) let new = NSWindow(contentViewController: host) new.title = "Prowl Debug" new.identifier = NSUserInterfaceItemIdentifier("debug") new.styleMask = [.titled, .closable, .miniaturizable, .resizable] new.tabbingMode = .disallowed new.collectionBehavior = [.moveToActiveSpace] new.toolbarStyle = .unified new.toolbar = NSToolbar(identifier: "DebugToolbar") if #unavailable(macOS 15.0) { new.toolbar?.showsBaselineSeparator = false } new.isReleasedWhenClosed = false new.setContentSize(NSSize(width: 800, height: 600)) new.minSize = NSSize(width: 700, height: 500) new.center() new.makeKeyAndOrderFront(nil) window = new } }
#endif