Download this file
| 1 | #if DEBUG |
| 2 | import AppKit |
| 3 | import EquipoKit |
| 4 | import SwiftUI |
| 5 | |
| 6 | /// Captures the real AppKit conversation after its asynchronous actions settle. |
| 7 | struct StoppedConversationFixture: View { |
| 8 | @State private var session = StoppedWorkFixture.makeSession() |
| 9 | var body: some View { |
| 10 | TranscriptView(projectSelectionID: nil, projectSelectionNotice: nil, items: Feed.build(session), session: session, focusCard: .constant(nil), openTask: { _ in }) |
| 11 | .frame(minWidth: 800, minHeight: 760) |
| 12 | .task { |
| 13 | await session.refresh() |
| 14 | try? await Task.sleep(for: .seconds(4)) |
| 15 | guard let path = ProcessInfo.processInfo.environment["EQUIPO_FIXTURE_CAPTURE"], |
| 16 | let window = NSApp.windows.first(where: { $0.isVisible && !$0.isSheet }), let view = window.contentView else { return } |
| 17 | window.setContentSize(NSSize(width: 900, height: 900)) |
| 18 | view.layoutSubtreeIfNeeded(); window.displayIfNeeded() |
| 19 | if let bitmap = view.bitmapImageRepForCachingDisplay(in: view.bounds) { |
| 20 | view.cacheDisplay(in: view.bounds, to: bitmap) |
| 21 | if let data = bitmap.representation(using: .png, properties: [:]) { _ = FileManager.default.createFile(atPath: path, contents: data) } |
| 22 | } |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | #endif |
| 27 | |