Skip to content

feat: preview a commit from the API - #664

Merged
xHeaven merged 6 commits into
dev-null-sh:productionfrom
simonhamp:feat/api-commit-previews
Oct 22, 2026
Merged

xHeaven merged 6 commits into
dev-null-sh:productionfrom
simonhamp:feat/api-commit-previews

Conversation

@simonhamp

@simonhamp simonhamp commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

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/preview takes a body and answers 200 with:

{"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.store only sends segments, 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.

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
simonhamp marked this pull request as ready for review October 20, 2026 00:21
@xHeaven
xHeaven merged commit 8572c2d into dev-null-sh:production Oct 22, 2026
5 checks passed
@simonhamp
simonhamp deleted the feat/api-commit-previews branch October 22, 2026 10:10
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.

2 participants