Support native preview arguments#167
Merged
Merged
Conversation
BarredEwe
force-pushed
the
codex/native-preview-arguments
branch
2 times, most recently
from
July 9, 2026 08:35
85e4123 to
d569f34
Compare
BarredEwe
force-pushed
the
codex/native-preview-arguments
branch
from
July 9, 2026 08:42
d569f34 to
e551dc0
Compare
BarredEwe
marked this pull request as ready for review
July 9, 2026 08:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for native SwiftUI parameterized previews using the
#Preview(..., arguments: ...)API. Prefire now parses thearguments:expression and the preview closure parameter pattern, then expands each argument into a distinct generated snapshot and Playbook preview.The issue was that Prefire treated every
#Previewmacro as a single preview body. With native SwiftUI argument previews, that would only generate one snapshot/playbook entry even though SwiftUI presents the preview as a family of variants. The parser also previously depended on first-line string parsing for preview metadata, which becomes brittle whenarguments:and multiline signatures are involved.The fix extends
RawPreviewModelwith argument metadata parsed via SwiftSyntax, keeps compatibility with existing trait parsing, and updates both generated templates to iterate over preview arguments. Each generated variant gets a distinct name based on the base preview name, argument index, and argument description.Changes
#Preview(..., arguments: values) { argument in ... }syntax.{ prefix, suffix in ... }by destructuring each argument value in generated code.Validation
swift testinPrefireExecutableafter rebasing onorigin/main.