Skip to content

[build-tools][worker][eas-cli] Collect and upload agent-device session artifacts#3853

Draft
szdziedzic wants to merge 2 commits into
mainfrom
szdziedzic/drs-artifacts
Draft

[build-tools][worker][eas-cli] Collect and upload agent-device session artifacts#3853
szdziedzic wants to merge 2 commits into
mainfrom
szdziedzic/drs-artifacts

Conversation

@szdziedzic

Copy link
Copy Markdown
Contributor

Why

Part 2 of persisting the screenshots and screen recordings agent-device produces during AGENT_DEVICE device run sessions, so users can view them after the session ends. Today nothing survives: agent-device deletes media from the VM right after the remote client downloads it, and stopping a session cancels the job, destroying the VM within seconds.

Depends on the www upload endpoint (expo/universe#28121). The www behavior flip that stops cancelling in-progress agent-device jobs (expo/universe#28122) must only ship after this worker change is deployed to builder VMs.

How

No agent-device changes — collection relies only on its existing observable behavior:

  • Media collector (build-tools): agent-device's remote client rewrites media output paths to predictable temp paths (/tmp/agent-device-{screenshot,recording}-*). The step watches /tmp and hardlinks each match into its own artifacts dir — a hardlink shares the inode, so it survives agent-device's delete-after-download cleanup and converges to the final bytes even when linked mid-write. Entirely best-effort; can never fail a session.
  • Graceful stop via a poll loop (build-tools): start_agent_device_remote_session replaces its block-forever tail with a 5s poll of the session status (robot token, same GraphQL client as the remote-config upload). When the session goes final — or a self-deadline ahead of __MAX_RUN_TIME_SECONDS passes, covering the timeout case — it finalizes in-flight recordings through the daemon's own local record stop RPC, uploads each collected file (agent-device/<basename>, individual files so the website can render them inline), and returns normally so the job ends as a regular success. No orchestrator involvement.
  • Upload support (worker): createUploadSessionAsync learns a third endpoint, device-run-sessions/{id}/upload-sessions/, used when only DEVICE_RUN_SESSION_ID is present in the job env.
  • CLI (eas-cli): new eas simulator:artifacts [--id] [--output-dir] [--json] download command; simulator:start/simulator:stop print an artifact summary and download hint after the session stops (skippable, suppressed in non-interactive mode).

Test Plan

  • Typecheck, lint, and fmt:check clean; full unit suites pass locally: build-tools (628), worker (52), eas-cli (1725).
  • New unit tests: collector hardlink semantics (file appears → linked; original deleted → content retained; dot-prefixed temp files ignored), isDeviceRunSessionFinalAsync (final/non-final statuses, query errors keep polling), upload-session endpoint selection for DRS jobs, and simulator command fixtures.
  • End-to-end verification (start session → take screenshots/recording → stop → eas simulator:artifacts) pending the www endpoint deploy; will attach a terminal recording before marking ready.

🤖 Generated with Claude Code

…n artifacts

Device run sessions now persist the screenshots and screen recordings that
agent-device produces in remote mode:

- build-tools: the start_agent_device_remote_session step hardlink-collects
  agent-device media files from /tmp into an artifacts dir while the session
  runs (immune to the daemon's delete-after-download cleanup), and replaces
  its block-forever tail with a poll loop on the session status. When the
  session is stopped (or the job approaches its max runtime, via the
  __MAX_RUN_TIME_SECONDS env injected by the API server), it finalizes
  in-flight recordings through the daemon's local record-stop RPC, uploads
  each collected file as a job artifact, and ends the job as a normal
  success - no cancellation involved.
- worker: createUploadSessionAsync learns a third upload-session endpoint for
  device run sessions (device-run-sessions/{id}/upload-sessions), used when
  only DEVICE_RUN_SESSION_ID is present in the job env.
- eas-cli: new 'eas simulator:artifacts' command downloads session artifacts;
  simulator:start/stop print an artifact summary and download hint after the
  session stops.

Requires the www upload-sessions endpoint and pairs with the www change that
stops cancelling in-progress agent-device jobs on session stop (this worker
change must be deployed before that www change ships).
@github-actions

Copy link
Copy Markdown

❌ It looks like a changelog entry is missing for this PR. Add it manually to CHANGELOG.md.
⏩ If this PR doesn't require a changelog entry, such as if it's an internal change that doesn't affect the user experience, you can add the "no changelog" label to the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant