Skip to content

feat: expose orientation in the Viewer snapshot screen payload - #71

Merged
onevcat merged 1 commit into
mainfrom
feat/viewer-snapshot-orientation
Jul 28, 2026
Merged

onevcat merged 1 commit into
mainfrom
feat/viewer-snapshot-orientation

Conversation

@onevcat

@onevcat onevcat commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #57.

GET /api/snapshot now forwards the CLI's calibrated interface orientation (data.orientation from describe-ui --json, carried since #38) into the screen payload verbatim — no parsing of the (landscape-right) suffix out of the outline text:

{
  "screen": {
    "appLabel": "Safari",
    "width": 874,
    "height": 402,
    "orientation": "landscape-left"
  }
}
  • The key is omitted whenever the CLI reports none (Android, legacy daemons), matching the CLI envelope semantics.
  • The SPA Screen type gains the optional orientation field, and the toolbar tags a rotated screen next to the W×H readout, e.g. 874×402 (landscape-left). Portrait earns no tag, mirroring the outline header behaviour.

One nuance vs. the issue text: the CLI emits "portrait" (not nil) when calibration resolves upright — only the outline header tag is suppressed for portrait. The handler therefore forwards verbatim (key present iff data.orientation is present) and the portrait suppression lives in the SPA display layer.

Changes

  • Sources/SimUse/Viewer/ViewerAPIHandlers.swift — forward data.orientation into the parsed screen dict at the parseScreenFromOutline call site.
  • Tools/Viewer/src/types.ts — Screen.orientation?: string (documented canonical values, widened for forward-compat like Device.platform).
  • Tools/Viewer/src/App.tsx — rotation tag next to the W×H readout.
  • Tests/ViewerAPIHandlersTests.swift — new forwarding case + omitted-key assertion in the existing rotated-outline case.
  • CHANGELOG.md, Tools/Viewer/README.md — docs.

Testing

  • make build clean, make test passes (1157 tests), tsc -b clean.
  • Live spot-check against a booted iPhone 17 Pro (iOS 26.4) via sim-use viewer: portrait Settings reports "orientation": "portrait"; after rotating with Safari foreground the payload flips to "orientation": "landscape-left" with 874×402, byte-consistent with the outline header App: Safari 874x402 (landscape-left).

🤖 Generated with Claude Code

https://claude.ai/code/session_011M3T94iAdsJisr6oH7ynof

Forward `data.orientation` from `describe-ui --json` (the calibrated
interface orientation, carried since #38) into the `screen` object of
`GET /api/snapshot`, instead of leaving the SPA to spot the
`(landscape-right)` suffix in the outline text. The key is omitted
whenever the CLI reports none (Android, legacy daemons), matching the
CLI envelope semantics.

The SPA `Screen` type gains the optional `orientation` field, and the
toolbar tags a rotated screen next to the W×H readout — portrait earns
no tag, mirroring the outline header behaviour.

Closes #57

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011M3T94iAdsJisr6oH7ynof

Signed-off-by: onevcat <onevcat@gmail.com>
@onevcat
onevcat merged commit 3118ca4 into main Jul 28, 2026
4 checks passed
@onevcat
onevcat deleted the feat/viewer-snapshot-orientation branch July 28, 2026 01:44
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.

Viewer: expose orientation in the snapshot screen payload

1 participant