import subprocess,pathlib,time
root=pathlib.Path(__file__).parent
def run(*args):
    r=subprocess.run(['agent-device',*args,'--session','queued-preview'],capture_output=True,text=True)
    with (root/'native-base-actions.log').open('a') as f:f.write(' '.join(args)+'\n'+r.stdout+r.stderr+'\n')
    if r.returncode:raise RuntimeError(r.stderr)
# Same seeded two-message queue and same first thumbnail tap as head.
run('record','start',str(root/'ios-base-complete.mp4'))
run('press','55','438','--settle')
time.sleep(3)
run('screenshot',str(root/'ios-base-tap-result.png'))
run('snapshot','-i')
run('record','stop')
