Skip to content

ci(native): per-component iOS screenshots from the macOS runner - #8027

Open
cixzhang wants to merge 2 commits into
mainfrom
ci/native-screenshots
Open

cixzhang wants to merge 2 commits into
mainfrom
ci/native-screenshots

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer impact

Nothing draws the native SwiftUI components to images. Without building an app, nobody can see a native component's states, or compare them with the web components of the same commit.

Intended invariant

AST-093 FR5: native component changes ship with captures of every state, light and dark. Every pull request that changes native Swift produces those captures from a real iOS Simulator, named by the head commit so they line up with the web screenshots of the same commit.

Change

  • packages/native/apple/Tests/AstryxScreenshotTests/ (new test target, depends only on the Astryx product) draws every component in its key states, in light and dark, through a hosting controller in a shown window. Card is also drawn with Increase Contrast on and at the largest text size, both applied as traits. A test checks that both settings reach the drawn view. ImageRenderer leaves UIKit-backed views such as text fields empty, so the test doesn't use it. Each state must draw a non-empty image. When ASTRYX_SCREENSHOT_DIR is set, each image is also written as <Component>/<state>-<light|dark>.png.
  • .github/scripts/native-swift.sh: when ASTRYX_SCREENSHOT_DIR is set, it is passed to each package's iOS Simulator tests as <dir>/<package> (xcodebuild forwards TEST_RUNNER_*).
  • .github/workflows/ci.yml: test-native-swift sets the directory and uploads it as native-screenshots-<head sha> (30 days), only when native Swift changed.
  • ci-native-swift.test.mjs pins the variable and the artifact name. apple/README.md gets a Screenshots section.

Page templates are a separate package, so they are not captured here.

Evidence

  • Failure before the change: no workflow produces any native component image.
  • Success after the change: this PR's own test-native-swift run uploads native-screenshots-<head sha> with one PNG per state (Button, TextInput, Text, Heading, Card, and Banner states, light and dark, plus Card with Increase Contrast and at the largest text size). At 1cec31f it produced 42 PNGs (21 states, light and dark), each checked by eye. The Increase Contrast capture matches the default until the components honor that setting.
  • Product/runtime behavior verified unchanged: only a test target, CI files, and a README change.

Scope

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split. A Banner text-alignment difference visible in the captures is recorded as a native gap, not fixed here.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm vitest run --project node .github/scripts/ci-native-swift.test.mjs: 6 tests pass.
  • macOS runner (the local machine has no Xcode): this PR's test-native-swift job.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 24, 2026
@vercel

vercel Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 25, 2026 12:12am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟡 Reviewed (for maintainers only) Oct 25, 2026, 12:59 AM UTC

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

46 of 504 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 753,933
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,072
RichTextEditor Markdown parity: side by side probe dark 556,900
RichTextEditor Markdown parity: side by side probe light 538,816
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
Markdown Default neutral dark 7,573
Markdown Default neutral light 7,566

and 26 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@astracat-bot astracat-bot Bot left a comment

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.

Changes requested: the per-commit iOS screenshot pipeline works (this pull request's CI run uploaded all 38 light and dark frames), but the test's emptiness check can never fail. ScreenshotTests.swift:160 only requires the PNG to be larger than 1×1, and every capture is at least 720×64 pixels because of the fixed 360-point width and the 16-point ground padding, so a component that renders blank still passes while the README says each state must draw a non-empty image. Please make the check look at pixels (for example, require at least one pixel that differs from color-background-body) or drop that promise, and consider describing the captures as key states at the default text size in the README tree entry, since AST-093 FR5 also asks for the largest text size.

[Automated review]

for (scheme, name) in [(ColorScheme.light, "light"), (.dark, "dark")] {
let data = try #require(png(of: capture, scheme: scheme), "\(capture.component) \(capture.state) \(name) drew nothing")
let image = try #require(UIImage(data: data))
#expect(image.size.width > 1 && image.size.height > 1, "\(capture.component) \(capture.state) \(name) is empty")

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.

This check can't fail: every capture is 360 pt wide and Ground pads its content by 16 pt on each side, so the PNG is always at least 720×64 px, and a state that draws only the page ground still passes. To back the README's "each state must draw a non-empty image", require at least one pixel that differs from the color-background-body ground (the Pixels.contains(where:) pattern in Tests/AstryxTests/Pixels.swift), or drop that promise.

Comment thread packages/native/apple/README.md Outdated
## Screenshots

`Tests/AstryxScreenshotTests/` draws every component in its key states, in
light and dark, on the iOS Simulator; each state must draw a non-empty image.

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.

The test doesn't enforce this today (see the size check in ScreenshotTests.swift, line 160): either make that check look at pixels or drop "each state must draw a non-empty image".

│ └── Generated/ # generated; do not edit
├── Tests/
│ ├── AstryxTests/
│ ├── AstryxScreenshotTests/ # draws every component state on the iOS Simulator

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.

The target draws key states at the default text size (no capture sets dynamicTypeSize, and TextInput's .sm and .lg are never drawn), while AST-093 FR5 asks for every state at the largest text size too. "key states", as line 144 says, would avoid reading this artifact as FR5-complete.

@astracat-bot astracat-bot Bot left a comment

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.

Changes requested: the per-commit iOS screenshot artifact works (the pull request's CI run uploaded all 42 light and dark frames), but the test's emptiness check still cannot fail. ScreenshotTests.swift:249 only requires the decoded PNG to be larger than 1×1 pixel, while every capture is 720 pixels wide and at least 2 pixels tall by construction (64 with the ground padding), so a component that renders blank still passes even though README line 188 says each state must draw a non-empty image. Please make the check look at pixels (for example, require at least one pixel that differs from color-background-body, as Tests/AstryxTests/Pixels.swift does) or drop that promise, and describe the target as drawing key states on README line 39, since AST-093 FR5 also asks for every state at the largest text size.

[Automated review]

for (scheme, name) in [(ColorScheme.light, "light"), (.dark, "dark")] {
let data = try #require(png(of: capture, scheme: scheme), "\(capture.component) \(capture.state) \(name) drew nothing")
let image = try #require(UIImage(data: data))
#expect(image.size.width > 1 && image.size.height > 1, "\(capture.component) \(capture.state) \(name) is empty")

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.

This check can't fail: every capture is 360 pt wide and hosted() clamps the height to at least 1 pt (line 169), so at format.scale = 2 the decoded PNG is never under 720×2 px (720×64 with Ground's padding), whatever the component draws. To back the README's "each state must draw a non-empty image" (README line 188), require at least one pixel that differs from the color-background-body ground (the Pixels.contains(where:) / close(_:_:within:) pattern in Tests/AstryxTests/Pixels.swift), or drop that promise.

@astracat-bot astracat-bot Bot left a comment

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.

Changes requested: the per-commit iOS screenshot artifact works (this head's CI run uploaded all 42 light and dark frames), but the test's emptiness check still cannot fail. ScreenshotTests.swift:249 only requires the decoded PNG to be larger than 1×1 pixel, while every capture is 720 pixels wide and at least 2 pixels tall by construction (64 with the ground padding), so a component that renders blank still passes even though README line 192 says each state must draw a non-empty image. Please make the check look at pixels (for example, require at least one pixel that differs from the color-background-body ground, as Tests/AstryxTests/Pixels.swift does) or drop that promise, and describe the target as drawing key states on README line 39, since AST-093 FR5 also asks for every state at the largest text size.

[Automated review]

for (scheme, name) in [(ColorScheme.light, "light"), (.dark, "dark")] {
let data = try #require(png(of: capture, scheme: scheme), "\(capture.component) \(capture.state) \(name) drew nothing")
let image = try #require(UIImage(data: data))
#expect(image.size.width > 1 && image.size.height > 1, "\(capture.component) \(capture.state) \(name) is empty")

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.

This check can't fail: every capture is 360 pt wide (line 32) and hosted() clamps the height to at least 1 pt (line 169), so at format.scale = 2 the decoded PNG is never under 720×2 px (720×64 with Ground's padding), whatever the component draws. To back the README's "each state must draw a non-empty image" (README line 192), require at least one pixel that differs from the color-background-body ground beyond a small tolerance (the contains(where:) / close(_:_:within:) comparison in Tests/AstryxTests/Pixels.swift, applied to this image), or drop that promise.

This branch was successfully deployed

1 active deployment
Preview — f760260e Deployed Oct 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant