← back to Terminal Status
verify_ui.py
29 lines
#!/usr/bin/env python3
"""Capture only the native status menu, excluding terminal contents."""
import json
from pathlib import Path
import subprocess
import terminal_status as ts
project = Path(__file__).resolve().parent
script = '''tell application "System Events" to tell process "ticket-desktop-bar"
click button "◉" of window 2
delay 0.7
set m to menu 1 of button "◉" of window 2
set names to name of menu items of m
set AppleScript's text item delimiters to linefeed
set labels to names as text
set AppleScript's text item delimiters to ","
set rect to (position of m & size of m) as text
return rect & linefeed & labels
end tell'''
result = subprocess.run(['osascript', '-e', script], capture_output=True, text=True, check=True)
rect, labels = result.stdout.split('\n', 1)
coords = ','.join(str(int(x.strip())) for x in rect.split(','))
assert '🟢 TK-11317 · WORKING' in labels
image = project / 'verification/desktop-menu.png'
subprocess.run(['screencapture', '-x', '-R', coords, str(image)], check=True)
ts.atomic_write(project / 'verification/native-menu.json', json.dumps({
'verdict': 'PASS', 'labels': labels.splitlines(), 'capture': str(image)}, ensure_ascii=False, indent=2) + '\n')
print('PASS: actual desktop menu contains TK-11317 and six Codex ticket labels; ' + str(image))