Repository navigation
feat: preview a commit from the API - #664
Merged
xHeaven merged 6 commits intoOct 22, 2026
Merged
Conversation
The app's composer can show a draft as the commit it would become: its body as it would be kept, its segments and excerpt, and its mentions. Nothing is kept, so previews don't count towards the commit limit.
simonhamp
marked this pull request as ready for review
October 20, 2026 00:21
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.
Lets the mobile app preview a draft as the commit it would become, like the web composer's preview. It follows #130 and is one of a few small PRs for the endpoints the app (NativePHP/dev-null-app) uses on top of it.
Endpoint
POST /api/v1/commits/previewtakes abodyand answers200with:{"data": {"body": "Shipped 🚀", "body_segments": [{"type": "text", "text": "Shipped 🚀"}], "preview_segments": null, "mentions": []}}Those are the fields a signed commit has for its body, worked out the same way: blank lines collapsed, emoji shortcodes replaced, code highlighted and mentions found. So the app draws the preview with the code it already draws commits with. The web's
commit-preview.storeonly sendssegments, since the web finds mentions itself.Nothing is kept, and previews don't count towards the 10 commits a minute. The body is required and at most 4,000 characters, as on the web.
Testing
Everything CI runs passes on this branch locally: Pint, Rector, the JS lint, PHPStan, tsc, type coverage, and all 3,253 tests at 100% coverage.
The app side is NativePHP/dev-null-app#24. It ran against all four of these PRs merged together on an iOS simulator: photos from the library with a description, a poll, the preview, a reply with a photo, and a vote.