Skip to content

feat(shared): read the device out of a session's capabilities - #365

Merged
vishnuv688 merged 7 commits into
mainfrom
fix/345-native-device-metadata
Sep 8, 2026
Merged

feat(shared): read the device out of a session's capabilities#365
vishnuv688 merged 7 commits into
mainfrom
fix/345-native-device-metadata

Conversation

@vishnuv688

@vishnuv688 vishnuv688 commented Sep 8, 2026

Copy link
Copy Markdown
Member

What & why

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Polish (an improvement to an existing feature)
  • Breaking change (existing behavior changes for users)
  • Documentation
  • Internal (build, CI, dependencies, tooling)

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

image

@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown

Greptile Summary

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

  • Adds shared device parsing, validation, and labeling contracts.
  • Captures native viewport and device metadata through the WebdriverIO driver.
  • Preserves device information through trace serialization and reconstruction.
  • Displays the recorded device in the metadata panel.
  • Adds unit, integration, round-trip, and UI coverage.
  • Fixes the previous race by settling metadata capture before trace writes.

Confidence Score: 5/5

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

Important Files Changed

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
Loading

Reviews (2): Last reviewed commit: "fix(service): let finalize wait for the ..." | Re-trigger Greptile

Comment thread packages/service/src/index.ts Outdated
@vishnuv688 vishnuv688 changed the title Fix/345 native device metadata feat(shared): read the device out of a session's capabilities Sep 8, 2026
@vishnuv688
vishnuv688 merged commit da8615f into main Sep 8, 2026
11 checks passed
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.

Native mobile capture carries no viewport, capabilities or device into the trace

1 participant