Skip to content

[eas-cli] Add simulator session activity command - #4001

Merged
szdziedzic merged 8 commits into
mainfrom
szdziedzic-codex/device-run-session-events-cli
Jul 28, 2026
Merged

[eas-cli] Add simulator session activity command#4001
szdziedzic merged 8 commits into
mainfrom
szdziedzic-codex/device-run-session-events-cli

Conversation

@szdziedzic

@szdziedzic szdziedzic commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Why

Users running remote simulator sessions from EAS CLI need a terminal view of the same structured activity available on the Website.

How

  • Add the hidden experimental eas simulator:events command.
  • Resolve the session ID from --id or the simulator dotenv file.
  • Discover the standard session-events artifact through its __eas_type: session-events metadata and parse its NDJSON records with Zod.
  • Share the canonical event record schema and NDJSON parser through @expo/eas-build-job (deviceRunSession.ts) so producers (worker, agent-device) and consumers (CLI, Website) use a single source of truth; the CLI keeps only the display projection, formatting, and download logic.
  • Keep --json as a raw, lossless snapshot of the canonical event records.
  • Make human-readable output log-like and compact by grouping related operation records, preserving the producer's summary, and including the producer, duration, and screenshot basename when available. Strip ANSI escape sequences and terminal control characters before printing artifact-provided text.
  • Support --follow with five-second updates, withholding incomplete operations until they finish and refreshing twice after the session stops so the worker's final upload is included. Transient poll failures are retried, the first Ctrl-C wakes polling and flushes incomplete events, and a second Ctrl-C force-exits.
  • Ignore malformed records, including invalid timestamps, and treat a not-yet-created artifact or object as an empty event stream.
  • Regenerate the GraphQL schema snapshot and generated types with yarn generate-graphql-code; the only query this PR adds is DeviceRunSessionEventsByIdQuery, which uses pre-existing schema fields.

The command does not read or alter worker runtime logs.

Test Plan

  • yarn test src/simulator/__tests__/events.test.ts src/commands/simulator/__tests__/events.test.ts --runInBand (in packages/eas-cli)
  • yarn test src/__tests__/deviceRunSession.test.ts (in packages/eas-build-job)
  • yarn typecheck
  • yarn lint
  • yarn fmt

Coverage includes artifact discovery, empty snapshots, NDJSON parsing and deduplication, malformed records and timestamps, operation grouping across producers, compact and terminal-safe formatting, screenshot basename handling, post-stop refreshes, transient query and download retries, immediate interrupt wakeup and final flushing, second-interrupt force exit, and the absence of custom SIGINT handling outside follow mode.

Manual staging verification

Tested from ~/expo/testapp-staging against stopped agent-device session 019f8ecd-f874-70ec-8f5d-ef18197681d4, with EXPO_STAGING=1 on every CLI invocation.

EXPO_STAGING=1 <path-to-eas-cli-checkout>/packages/eas-cli/bin/run simulator:events \
  --id 019f8ecd-f874-70ec-8f5d-ef18197681d4

Representative output (55 canonical records condensed to 21 lines):

2026-07-23T11:52:10.177Z  [agent-device] Finished devices (7s)
2026-07-23T11:52:59.819Z  [agent-device] Failed apps: INVALID_ARGS (12ms)
2026-07-23T11:56:09.840Z  [agent-device] Finished install (10s)
2026-07-23T11:56:35.765Z  [agent-device] Opened com.expo.testapp.szymon (8s)
2026-07-23T11:59:27.332Z  [agent-device] Tapped @e13 (1s)
2026-07-23T11:59:50.296Z  [agent-device] Failed press: COMMAND_FAILED (1ms)
2026-07-23T12:08:55.381Z  [agent-device] Ran scroll (985ms)
2026-07-23T12:11:25.056Z  [agent-device] Ran screenshot agent-device-screenshot-1784808684346-7egl5c.png (524ms)

Verified that --json returned all 55 canonical records without applying the text projection:

EXPO_STAGING=1 <path-to-eas-cli-checkout>/packages/eas-cli/bin/run simulator:events \
  --id 019f8ecd-f874-70ec-8f5d-ef18197681d4 --json |
  jq '{deviceRunSessionId, eventCount: (.events | length)}'
{
  "deviceRunSessionId": "019f8ecd-f874-70ec-8f5d-ef18197681d4",
  "eventCount": 55
}

Also ran --follow against the stopped session. It printed the same final 21-line snapshot and exited successfully.

Rollout

Release after expo/universe#28937 and #3999 are deployed. The richer producer summaries from callstack/agent-device#1379 can ship independently and will be displayed automatically.

@szdziedzic szdziedzic added the no changelog PR that doesn't require a changelog entry label Jul 11, 2026
@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.42857% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.06%. Comparing base (83b86b8) to head (c33ccb6).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...s-cli/src/graphql/queries/DeviceRunSessionQuery.ts 0.00% 3 Missing ⚠️
packages/eas-cli/src/simulator/events.ts 95.59% 3 Missing ⚠️
packages/eas-cli/src/commands/simulator/events.ts 97.81% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4001      +/-   ##
==========================================
+ Coverage   61.93%   62.06%   +0.14%     
==========================================
  Files         990      993       +3     
  Lines       44447    44622     +175     
  Branches     9340     9390      +50     
==========================================
+ Hits        27524    27691     +167     
- Misses      15471    15479       +8     
  Partials     1452     1452              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@szdziedzic
szdziedzic force-pushed the szdziedzic-codex/device-run-session-events-cli branch 4 times, most recently from 7ba68b4 to 21855da Compare July 15, 2026 14:58
@szdziedzic
szdziedzic marked this pull request as ready for review July 22, 2026 14:57

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

Subscribed to pull request

File Patterns Mentions
packages/eas-cli/** @douglowder

Generated by CodeMention

Warning: The preamble and epilogue options in commentConfiguration are deprecated. Use template instead.

@szdziedzic szdziedzic removed the no changelog PR that doesn't require a changelog entry label Jul 23, 2026
@szdziedzic
szdziedzic requested review from gwdp and sjchmiela July 23, 2026 21:13
import fetch, { RequestError } from '../fetch';
import { formatMilliseconds } from '../utils/timer';

const DeviceRunSessionEventSchema = z

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i start to think this should be in eas-build-job, shared across the three projects we use it in

@szdziedzic szdziedzic Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved it there

szdziedzic and others added 7 commits July 27, 2026 18:26
Move the DeviceRunSession session-events record schema, type, and NDJSON
parser out of eas-cli into @expo/eas-build-job so producers (worker,
agent-device) and consumers (eas-cli, website) share a single source of
truth for the wire format. eas-cli re-exports the type and keeps the
CLI-only display, formatting, and download logic.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@szdziedzic
szdziedzic force-pushed the szdziedzic-codex/device-run-session-events-cli branch from 4fe4db9 to 2146159 Compare July 27, 2026 16:31
Run `yarn generate-graphql-code` to refresh the committed schema snapshot
and generated types against the current API.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

✅ Thank you for adding the changelog entry!

@szdziedzic
szdziedzic merged commit 1a57367 into main Jul 28, 2026
11 checks passed
@szdziedzic
szdziedzic deleted the szdziedzic-codex/device-run-session-events-cli branch July 28, 2026 09:10
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.

2 participants