Skip to content

Commit 0075bc3

Browse files
add the probe that photographs the panel on screen
screen recording is granted on this machine now, so the panel can be captured where it actually renders rather than composited from the view screencapture is called with -l<windowNumber>, so the frame is the overlay panel and nothing else on the display. all four come out 880x880, the 440pt panel at 2x, against 2704x1756 for a full grab off unless OPENCLAW_TALK_SHOT_DIR is set, same as the render probe
1 parent 2d09b0d commit 0075bc3

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import AppKit
2+
import Foundation
3+
import Testing
4+
@testable import OpenClaw
5+
6+
/// Captures the real on-screen Talk panel after the reported sequence.
7+
/// Window scoped, so only the overlay is photographed. Set OPENCLAW_TALK_SHOT_DIR.
8+
@Suite(.serialized)
9+
@MainActor
10+
struct TalkOverlayScreenshotProbe {
11+
@Test func `photograph the overlay after an interrupted dismissal`() async {
12+
guard let dir = ProcessInfo.processInfo.environment["OPENCLAW_TALK_SHOT_DIR"] else { return }
13+
NSApplication.shared.setActivationPolicy(.accessory)
14+
15+
let controller = TalkOverlayController()
16+
controller.present()
17+
controller.updatePhase(.listening)
18+
controller.updateLevel(0.6)
19+
try? await Task.sleep(nanoseconds: 700_000_000)
20+
Self.shoot(controller, dir: dir, name: "1-presented")
21+
22+
controller.dismiss()
23+
controller.present()
24+
try? await Task.sleep(nanoseconds: 900_000_000)
25+
Self.shoot(controller, dir: dir, name: "2-after-interrupted-dismissal")
26+
}
27+
28+
static func shoot(_ controller: TalkOverlayController, dir: String, name: String) {
29+
guard let panel = controller.window else { return }
30+
let id = panel.windowNumber
31+
print("SHOT \(name): windowNumber=\(id) visible=\(panel.isVisible) alpha=\(panel.alphaValue)")
32+
guard id > 0 else {
33+
print("SHOT \(name): panel is not on screen, nothing to photograph")
34+
return
35+
}
36+
let task = Process()
37+
task.executableURL = URL(fileURLWithPath: "/usr/sbin/screencapture")
38+
// -l<id> restricts the capture to this one window. -o drops the shadow.
39+
task.arguments = ["-x", "-o", "-l\(id)", "\(dir)/\(name).png"]
40+
try? task.run()
41+
task.waitUntilExit()
42+
}
43+
}

0 commit comments

Comments
 (0)