Skip to content

[build-tools] Refresh simulator session preview artifacts - #4398

Open
szdziedzic wants to merge 3 commits into
mainfrom
szdziedzic-codex/session-preview-worker
Open

szdziedzic wants to merge 3 commits into
mainfrom
szdziedzic-codex/session-preview-worker

Conversation

@szdziedzic

@szdziedzic szdziedzic commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Why

Keep a current simulator screen image available for future session list-page thumbnails.

How

Capture a WebP up to 320px once the shared preview server and FFmpeg are ready, then refresh it 60 seconds after each attempt completes. Obtain one signed upload URL and reuse it for the entire session; its lifetime already covers the session duration. Stop capture with the session and retry capture or upload failures without failing the session.

The upload-session request preserves worker authentication and combines the attempt and URQL cancellation signals at the fetch boundary. A stalled request is aborted on timeout or shutdown. FFmpeg setup runs in the background on macOS without delaying session readiness; Android retains its existing setup before streaming starts. Stopping a session during setup prevents the thumbnail loop from starting later.

Supports iOS and Android. Because Android readiness currently returns a placeholder ID, resolve the sole connected ADB device and skip capture if selection is ambiguous.

Deploy the API PR first; CI GraphQL schema generation also needs that mutation deployed. The website PR hides preview artifacts without adding thumbnail UI.

Test Plan

Tests

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

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.34884% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.75%. Comparing base (35522e9) to head (daa5e12).

Files with missing lines Patch % Lines
...d-tools/src/steps/utils/deviceRunSessionPreview.ts 96.00% 3 Missing ⚠️
...ld-tools/src/steps/utils/remoteDeviceRunSession.ts 90.91% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4398      +/-   ##
==========================================
+ Coverage   71.70%   71.75%   +0.05%     
==========================================
  Files         963      964       +1     
  Lines       45320    45406      +86     
  Branches     9724     9740      +16     
==========================================
+ Hits        32494    32576      +82     
- Misses      11823    11827       +4     
  Partials     1003     1003              

☔ 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.

@github-actions

Copy link
Copy Markdown

⏩ The changelog entry check has been skipped since the "no changelog" label is present.

@szdziedzic
szdziedzic requested review from gwdp and hirbod September 14, 2026 15:51
@szdziedzic
szdziedzic marked this pull request as ready for review September 14, 2026 15:51
}
} catch (err) {
if (!controller.signal.aborted) {
logger.warn({ err }, 'Could not refresh the session preview; retrying in 60 seconds.');

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.

err could expose a signed url (recall getting this flagged in previous reviews). Maybe we want to log only err.code?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch! Let’s log the type/code and status instead. Just err.code would miss some errors, like timeouts.

.split('\n')
.map(line => line.trim().split(/\s+/))
.filter(([, status]) => status === 'device');
if (devices.length !== 1) {

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 could be off (if the case, disregard), but I believe iOS is mostly always trying to get the first available device, not necessarily stopping/throwing if multiple devices. Could/should we do the same here and allow multiple devices, but only consider the first on the list for now?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

iOS gives us the device ID from the preview server, but Android only returns a placeholder. I’d keep this check so we don’t grab the wrong screen. It only skips the thumbnail, the session keeps running.

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

Labels

no changelog PR that doesn't require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants