Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566import AppKitimport Foundationimport ParcelConfigimport ParcelPlatform
@MainActorfunc checkStackCycle(_ session: RealitySession) async throws { try TabViewConsoleSession.requireUnlockedConsole() try requireUncontestedDefaultShortcuts(voiceOverEnabled: VoiceOverStatus.isRunning) try session.configure(cap: 1) let owned = try await session.startingWindows([.textEdit, .textEdit, .textEdit]) try await session.start() try await session.expect("Three real windows occupy the same stack frame") { rows in let frames = try FrameOracle.frames(rows, ids: owned.map(\.id)) guard let first = frames.first else { return false } return frames.allSatisfy { $0.matches(first) } } let before = try session.readFrames(owned) try await session.apps.focus(owned[0]) _ = try await session.driver.send(.focus(pid: owned[0].pid, windowID: owned[0].id)) try await session.expect("Native focus selects the first real stack member") { _ in try stackForegroundID() == owned[0].id } let next = RealityInputDefaults.binding(.stackNext) let previous = RealityInputDefaults.binding(.stackPrevious) try requireUncontestedDefaultShortcuts(voiceOverEnabled: VoiceOverStatus.isRunning) try await session.driver.key(next) var selected: UInt32? try await session.expect("Next stack shortcut changes foreground identity without moving real frames") { rows in let focus = try stackForegroundID() guard focus != owned[0].id, owned.contains(where: { $0.id == focus }), try FrameOracle.frames(rows, ids: owned.map(\.id)) == before else { return false } selected = focus return true } try requireUncontestedDefaultShortcuts(voiceOverEnabled: VoiceOverStatus.isRunning) try await session.driver.key(previous) try await session.expect("Previous stack shortcut reverses selection and preserves frames") { try stackForegroundID() == owned[0].id && FrameOracle.frames($0, ids: owned.map(\.id)) == before } guard let selected, let recent = owned.first(where: { $0.id == selected }) else { throw RealityError("Stack cycle did not independently identify a selected member") } let closing = owned[0] try await session.apps.close(closing) let survivors = owned.filter { $0.id != closing.id } let expected = zip(owned, before).filter { $0.0.id != closing.id }.map(\.1) try await session.expect("Closing visible stack member raises its MRU survivor without moving remaining frames") { try !$0.contains(where: { $0.id == closing.id }) && stackForegroundID() == recent.id && FrameOracle.frames($0, ids: survivors.map(\.id)) == expected }}
@MainActorprivate func stackForegroundID() throws -> UInt32? { guard let pid = NSWorkspace.shared.frontmostApplication?.processIdentifier, let front = try FrameOracle.read(onScreenOnly: true).first(where: { $0.onscreen && $0.layer == 0 && $0.alpha > 0 && $0.frame.isValid }), front.pid == pid else { return nil } return front.id}