feat(shared): read the device out of a session's capabilities - #365
Conversation
Greptile SummaryThe PR derives native-device metadata from session capabilities, persists driver-side metadata in the session capturer, carries device information through trace export and import, and displays it in the workbench. Changes since the previous review address the metadata/export race by tracking the asynchronous capture and handing it to finalization as pending work.
Confidence Score: 5/5The PR appears safe to merge; the previously reported metadata-capture race is fixed and no actionable new failures were identified. Session metadata is now retained by the capturer, its asynchronous resolution is tracked by the service, and finalization settles that pending work before serializing the trace. The prior race is therefore fully addressed, while viewport-read failures and bounded-timeout cases retain the existing graceful fallback behavior.
|
| Filename | Overview |
|---|---|
| packages/service/src/index.ts | Tracks asynchronous session-metadata resolution and supplies it to trace finalization, resolving the previously reported export race. |
| packages/service/src/session-metadata.ts | Resolves desktop or native viewport metadata and derives native-device details while degrading safely when viewport measurement fails. |
| packages/core/src/session-capturer.ts | Adds a single metadata merge path that persists fragments and publishes the merged result. |
| packages/shared/src/device.ts | Defines validated native-device contracts and capability parsing with device-cloud serial handling. |
| packages/trace/src/trace-exporter.ts | Serializes native-device metadata into the trace context-options event while retaining compatible browser naming. |
| packages/backend/src/trace-reader-utils.ts | Validates device data from trace archives and restores native platform information to reconstructed capabilities. |
| packages/app/src/components/workbench/metadata.ts | Adds a Device row for traces containing validated native-device metadata. |
Sequence Diagram
sequenceDiagram
participant WDIO as WDIO service
participant Driver as WebDriver session
participant Capturer as Session capturer
participant Finalizer as Trace finalizer
participant Zip as Trace archive
participant Reader as Backend reader
participant UI as Metadata panel
WDIO->>Driver: Resolve viewport and capabilities
WDIO-->>Finalizer: Track metadata promise
Driver-->>WDIO: Window size / session metadata
WDIO->>Capturer: mergeMetadata(...)
Finalizer->>Finalizer: Settle pending capture
Finalizer->>Capturer: Read accumulated metadata
Finalizer->>Zip: Write context-options.device
Reader->>Zip: Read and validate device
Reader-->>UI: Metadata with device
UI->>UI: Render Device row
Reviews (2): Last reviewed commit: "fix(service): let finalize wait for the ..." | Re-trigger Greptile
What & why
Type of change
Packages touched
shared(types and contracts)core(framework-agnostic capture/reporting)elements(published element/snapshot API —@wdio/elements)service(WebdriverIO adapter)nightwatch-devtools(Nightwatch adapter)selenium-devtools(Selenium adapter)selenium-devtools-py(Selenium Python adapter)backend(server)app(UI)script(page-injected runtime)trace(Trace mode)Notes for reviewers
Screenshots / recordings