Repository navigation
feat: polls on commits - #114
Merged
Merged
Conversation
# Conflicts: # app/Actions/CreateCommit.php # app/Http/Controllers/CommitController.php # app/Http/Requests/CreateCommitRequest.php # app/Models/Commit.php # app/Queries/CommitAncestorsQuery.php # resources/js/components/commit-card.tsx # resources/js/components/commit-composer.tsx # resources/js/types/commit.ts # tests/Unit/Actions/CreateCommitTest.php
# Conflicts: # app/Actions/CreateCommit.php # app/Actions/UpdateCommitStatuses.php # app/Http/Requests/CreateCommitRequest.php # tests/Unit/Actions/ApproveCommitTest.php
This was referenced Oct 15, 2026
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.
feat: polls on commits
git bisectfor opinions. A top-level commit can now carry a poll: the commit body is the question, with 2 to 4 short options (50 characters each) and a length of 1 hour, 1 day, 3 days or 7 days. Signed-in developers pick an option and vote once. Results appear as soon as they have voted, when the poll closes, or straight away for the author.The composer gets an "Add poll" button next to the image button. Replies can't have polls. Moderators see the poll in the queue, so they review the options together with the question.
Behavior and decisions
pollisprohibits:parent_id,imagesinCreateCommitRequest. This keeps the card to one attachment and avoids deciding how a poll and an image grid stack.(poll_id, user_id)index enforces one vote per person. A second vote is refused byCreateCommitPollVoteRequestwith "You have already voted on this poll.". If two requests race past validation,CreateCommitPollVotewrites withinsertOrIgnoreand returnsfalsefor the loser, so the first vote stands and the response is the poll as it is, never a 500.votes_count: nullandtotal_votes: null. Counts are serialized only for voters, the author, or anyone once the poll has closed. No voter identity is ever serialized. Votes stay private, and only the voter's own choice is marked (with a check and a screen-reader "your vote").polls.opened_atis set when the commit is approved, or on creation for admins, whose commits skip moderation. Time spent in the moderation queue doesn't eat into a 1-hour poll. Rejecting and re-approving keeps the originalopened_at. Pending polls show "Voting opens once approved".CreateCommitPollVoteRequest, following the form-request rule inArchTest.CreateCommitPollVoteonly records the vote.authorize()returns 403 for commits the viewer can't see (same rule as stars), and route binding returns 404 for deleted commits. Theoptionmust belong to this commit's poll, and theOpenPollrule (inApp\Rules) refuses with a 422 onoption: "This poll is not open for votes." (pending, rejected or not yet opened), "You can't vote on your own poll.", "This poll has closed." or "You have already voted on this poll.".CreateCommit, in the same transaction as the commit.CreateCommitRequestvalidatespoll.options(a list of 2 to 4, required, max 50, distinct ignoring case),poll.duration(thePollDurationenum, in minutes) andprohibits:parent_id,images. Like the rest of the actions,CreateCommittrusts its caller and does no checks of its own. Emoji shortcodes in options are expanded like the body.polls(one per commit,commit_idunique, cascade on delete),poll_options(ordered byposition) andpoll_votes(FKs to poll, option and user, all cascading). Deleting an account removes that user's votes and, through their commits, their polls. Soft-deleted commits are tombstones, and the existingCommit::toArraytombstone rule already drops every relation, poll included.CommitBuilder::withPollFor($viewer)eager loads polls and their options withwithCount('votes')plus avotedexists flag for the viewer. That is two queries for any page size, covered by a query-count test (1 vs 20 polls with votes). The author flag is set in anafterQuerycallback from the already loadedcommits.user_id, so the polls query has noexists/countsubqueries. The existing "partial reloads don't count anything" assertions stay as they are. Polls load on the logs, the commit page and its ancestors, profiles (pinned and list), saved commits, and moderation. Suggestions only render a truncated body, so they don't load polls.CreateExport) gainspolls(polls on the user's live commits: duration, opened_at, option labels) andpoll_votes(the user's own choices). It never includes other voters.<fieldset>, so arrow keys work and the globalj/kshortcuts don't interfere. An explicit "Vote" button prevents accidental final votes. Results are a list with percentages and ansr-onlyvote count per option. The summary line (39 votes · 2d left/Final results) is arole="status"region, so the result is announced after voting. Bars respectprefers-reduced-motion. Voting goes throughuseHttp(like Save) and swaps in the server's results. I didn't do an optimistic update: counts are hidden until the vote lands, so the button shows "Voting…" for that round trip instead.Screenshots
All content is fictional demo data from a separate local SQLite database.
Composer with a poll
Open poll, before voting (an option selected, no counts shown)
Results after voting (own choice checked, time left)
Closed poll, final results for a viewer who never voted
Moderation queue (pending poll, voting not open yet)
Everyone log with every state: open, author's own live results, voted, closed
Full-page captures
Interactive flow
An admin (no moderation wait) writes a question, adds a poll with three options, picks 1 hour and commits. The poll appears with the author's live
0 votes · 1h left. Then they vote on someone else's poll and the results replace the options. This is the real UI and HTTP flow.Watch the MP4
Validation
productionfour times with merge commits:f81720b(mentions and image uploads): resolved conflicts inCreateCommit,CreateCommitRequest,CommitController,Commit,CommitAncestorsQuery, the composer, the commit card and the commit types. Polls and images now load side by side on every commit query.9ccb16a(authorization and validation only in form requests): the merge was clean. Afterwards the poll checks moved out of the vote action andCreateCommitinto the vote form request plus theOpenPollrule, and intoCreateCommitRequest.db106cc(CRUD-by-design naming): resolved conflicts inCreateCommit,UpdateCommitStatuses(previouslyModerateCommits, which opens the poll clock on approval) andCreateCommitRequest. RenamedVoteOnPolltoCreateCommitPollVoteandCreatePollVoteRequesttoCreateCommitPollVoteRequestto mirrorCommitPollVoteController@store. Moved the two approval-clock tests from the deletedApproveCommitTestintoUpdateCommitStatusTest. Pointed the export test at the renamedexportroute. The export additions now live inCreateExport.b403add(Octane, plus inline code and highlighted code blocks): the merge was clean. Poll questions get the samebody_segmentshighlighting as any other commit, and a feature test covers it. Polls are Octane-safe: there are no static properties or singletons.withPollForcaptures the viewer per query, andOpenPollis built for each request inrules().bun.lockandcomposer.lockare identical to production's.CreateCommitPollVote(records a vote, keeps the first vote on a repeat),CreateCommitandUpdateCommitStatus(poll creation, admin opening, approval clock, re-approval), the vote endpoint (JSON results, every refusal reason, 403/404/422, guests), poll validation (including replies and images plus poll) and display on logs, commit and ancestors, profile, saved and moderation, the query-count bound, guest non-exposure, and the export.tests/Unitandtests/Feature(the whole suite now that browser tests are gone) passed after the latest merge: 1,004 tests / 5,646 assertions, including everyArchTestrule.tests/Browser, so I dropped the browser test I had written for the composer and voting flow. Its backend behavior is covered by the feature tests above. The UI flow is shown in the recording below, which was re-captured after the merge.pest --type-coverage --min=100: 100%. PHPStan (project config, level max), Rector dry run, Pint,bun run test:lint,bun run test:types,bun run buildandgit diff --checkall passed. All media was re-captured after the latest merge, so it shows the new action row and the poll length chevron fix.bun run lintalso reformatted two lines production had left unformatted (resources/css/app.css,commit-thread.tsx). That fix is needed fortest:lintto pass.app/is hit by a test, and CI's--exactly=100.0will confirm.Deployment and limits
devnull commitCLI script. The shared form request accepts them, but the CLI controller ignores them.