"""Real-device input used for PR 47818. Pair the app and open New thread > fixture first.
Usage: python reproduce.py SESSION android|ios OUTPUT_ROOT
Create fixture/review\\notes.md containing 'review notes' and fixture/notes.md
containing 'plain notes'; add the fixture project through `t3 project add`.
Use the same fixture path on both commits. No provider turn is needed.
"""
import datetime, subprocess, sys
from pathlib import Path
session, platform, root = sys.argv[1:]
out=Path(root)/datetime.datetime.now().strftime('%Y%m%d-%H%M%S')
out.mkdir(parents=True)
fixture='/tmp/factory-pr-47818-evidence-1/fixture'
selector='role=text-field' if platform=='android' else 'role=text-view'
single=f'Inspect @"{fixture}/review\\\\notes.md" '
both=single+f'vs @{fixture}/notes.md '
def device(*args):
    return subprocess.run(['agent-device',*args,'--session',session],text=True,capture_output=True)
for name,text in [('single',single),('both',both)]:
    result=device('fill',selector,text,'--settle')
    # Native chips replace text with attachments in iOS accessibility read-back;
    # inspect the screenshot and snapshot when fill reports a read-back mismatch.
    print(name, result.stdout, result.stderr)
    print(device('snapshot','-i').stdout)
    print(device('screenshot',str(out/f'{name}.png')).stdout)
print('Inspect both chips. Tap the first chip, then confirm the file contains review notes.')
print('Android: focus composer then tap first chip at (380,1330) on Pixel 9, 1080x2424.')
print('iOS: tap first chip at (130,468) on iPhone 18 Pro, 402x874; duplicate AX labels collapse.')
