Skip to content

feat: quote commits - #96

Merged
brendt merged 23 commits into
dev-null-sh:productionfrom
xHeaven:feat/quote-commits
Oct 16, 2026
Merged

brendt merged 23 commits into
dev-null-sh:productionfrom
xHeaven:feat/quote-commits

Conversation

@xHeaven

@xHeaven xHeaven commented Oct 15, 2026

Copy link
Copy Markdown
Member

Summary

Quote a commit. Every commit you can see gets a "Quote" action in its action row, next to the star. It opens a dialog with the commit previewed under a textarea. What you write is a new commit of your own, with the quoted commit embedded under its body as a compact card. Clicking the card opens the quoted commit's page.

Scope note: PRODUCT.md lists reposts under "Deliberately excluded for now", and TODO.md has "reposts (forks)" under Not now. This was requested explicitly, so I built it as quotes only: you always add words of your own, and there is still no plain repost. I updated PRODUCT.md (capabilities, notifications, the excluded list), TODO.md (Not now and the notification keys) and DESIGN.md (a new Quotes entry and the q key). The aside's "No likes, no reposts, no algorithm." now reads "No likes, no algorithm."

How it works

  • Data: a nullable quoted_commit_id on commits. It is a self-referencing FK with nullOnDelete and its own index.
    • Soft delete (the normal "Delete commit"): the row stays, so the quoting commit keeps the id and the embed renders as a [deleted] tombstone. No author or body is sent, because Commit::toArray() already reduces a trashed commit to a tombstone.
    • Hard delete (account erasure): the reference is nulled and the embed disappears. The quoting commit itself is never cascaded.
  • Rules: a quote is a regular commit, so it has the same 3–280 limit, moderation and commits rate limiter. quoted_commit_id goes through VisibleCommit, which now takes a custom message ("That commit is no longer available to quote."). It is also prohibits:parent_id, so a quote is always top-level and lives in logs, not inside threads.
  • No leaks: CommitBuilder::withQuotedCommitFor($viewer) eager-loads the quoted commit with withTrashed()->visibleTo($viewer) plus its author. If the quoted commit is later rejected, or is someone else's pending commit, the viewer gets quoted_commit: null and the card reads [unavailable] This commit isn't available. The author of the quoted commit still sees it, with its status badge. The moderation queue loads it unfiltered so moderators have the context.
  • Eager loading: the quoted commit is loaded in both logs, the profile, the commit page (focused commit and ancestors) and moderation. A new test checks that the query count of a log stays the same with 1 or 6 quotes.
  • Notification: NotificationType::Quoted goes to the quoted commit's author. It follows NotifyAboutReplies exactly:
    • The new NotifyAboutQuotes action works as a pointer, not a copy: commit_id is the quote, the key is quoted:{id}, and it uses insertOrIgnore.
    • It runs from CreateCommit (admins) and ModerateCommits on approval, and never fires for quoting yourself.
    • NotificationBuilder::relevant() treats it like a reply, so it is hidden while the quote is not approved.
    • DeleteCommit removes it when either the quote or the quoted commit is deleted.
  • UI:
    • Quote button: "Quote" (icon only on phones) sits after the star and is hidden wherever the star is.
    • Dialog: "Quote @handle" has its own stash@{0} draft, a counter, ⌘/Ctrl+Enter, and the quote error bag.
    • Keyboard: q works on the focused commit through the existing aria-keyshortcuts lookup, and the ? sheet lists it.
    • Notifications: quotes show as "X quoted your commit".
  • Export: ExportPersonalData now includes quoted_commit_id on each commit (additive, schema_version stays 1).

Decisions worth a look

  • No quote count. DESIGN.md says "The only count on a commit is its stars", and a count would have nowhere to link to, since there is no page listing quotes. If you want one later, the indexed quoted_commit_id already makes it a cheap withCount.
  • One level only. The embed never shows the quoted commit's own quote, link preview or actions. Its body is plain text because the whole card is a single link, and links can't be nested.
  • Quoting your own pending commit is allowed. This matches replies and VisibleCommit. Others see [unavailable] until it is approved.
  • No --quote for the CLI. It doesn't fit cleanly. The signed payload is timestamp\nnonce\nreply_to\nbody, so adding a quote means changing the signed format in VerifySignedCommit and the script, and generalizing FindCommitByReference's reply-specific error messages. That is security-sensitive and better as its own PR.

Video

Quoting a commit from the log, then opening the quoted commit

Quoting a commit from the log

MP4

The demo user isn't an admin, so the new quote lands as pending with the usual review toast.

Screenshots

At 2x. All demo data is seeded locally.

Log with quotes (a long URL in the quoted body)

Desktop light Desktop dark
Log desktop light Log desktop dark
Mobile light Mobile dark
Log mobile light Log mobile dark

[unavailable] (quoted commit rejected after being quoted) and [deleted]

Desktop light Desktop dark
Tombstones desktop light Tombstones desktop dark
Mobile light Mobile dark
Tombstones mobile light Tombstones mobile dark

Quote dialog

Desktop light Desktop dark
Dialog desktop light Dialog desktop dark
Mobile light Mobile dark
Dialog mobile light Dialog mobile dark

Commit page

Desktop light Desktop dark
Commit page desktop light Commit page desktop dark
Mobile light Mobile dark
Commit page mobile light Commit page mobile dark

Notifications

Each page is marked as read once shown, so only the first shot shows the unread state.

Desktop light Desktop dark
Notifications desktop light Notifications desktop dark
Mobile light Mobile dark
Notifications mobile light Notifications mobile dark

q in the shortcut sheet

Keyboard shortcuts

Validation

  • Tests (TDD, written first):
    • Model: the relation and quotes(), soft and force delete behavior, and that a tombstone never carries the quote.
    • NotifyAboutQuotes: approved only, not for deleted quoted commits, not for quoting yourself, idempotent.
    • Actions: CreateCommit, ApproveCommit(s), DeleteCommit and DeleteUser.
    • NotificationBuilder: relevance, and deletion along with either commit.
    • CommitController: quoting; validation for pending, rejected, deleted, unknown, and quote plus reply; the embed, the tombstone and the no-leak case on the commit page.
    • Pages: logs (including the constant query count), profile, moderation, notifications and the export.
    • Browser: tests/Browser/QuoteCommitTest.php, by mouse and with q plus ⌘/Ctrl+Enter.
  • Results:
    • Pest: 541 affected Unit and Feature tests plus 11 browser tests pass.
    • Coverage: 100% on every touched class (run with Xdebug).
    • Type coverage: 100%.
    • Static checks: PHPStan (touched files), Rector, Pint, bun run test:types and bun run test:lint all pass.
  • Screenshots: 0px horizontal overflow and no console errors in every shot.

# Conflicts:
#	app/Actions/CreateCommit.php
#	app/Http/Controllers/ModerationController.php
#	app/Queries/CommitAncestorsQuery.php
#	resources/js/components/commit-card.tsx
# Conflicts:
#	PRODUCT.md
#	app/Actions/CreateCommit.php
#	app/Actions/DeleteCommit.php
#	app/Actions/ModerateCommits.php
#	app/Http/Controllers/CommitController.php
#	app/Http/Controllers/ModerationController.php
#	app/Http/Controllers/UserController.php
#	app/Http/Requests/CreateCommitRequest.php
#	app/Models/Commit.php
#	app/Queries/CommitAncestorsQuery.php
#	app/Queries/LogQueries/EveryoneLogQuery.php
#	app/Queries/LogQueries/FollowingLogQuery.php
#	app/Queries/NotificationBuilder.php
#	database/factories/NotificationFactory.php
#	resources/js/pages/notification/index.tsx
#	resources/js/types/commit.ts
#	resources/js/types/notification.ts
#	tests/Feature/Controllers/NotificationControllerTest.php
#	tests/Unit/Actions/CreateCommitTest.php
#	tests/Unit/Actions/DeleteCommitTest.php
#	tests/Unit/Actions/DeleteUserTest.php
# Conflicts:
#	resources/js/components/commit-card.tsx
@nunomaduro

Copy link
Copy Markdown
Member

Before we consider your pull request today, can you fix the conflicts? Thank you!

@xHeaven

xHeaven commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Before we consider your pull request today, can you fix the conflicts? Thank you!

On it!

# Conflicts:
#	app/Actions/CreateCommit.php
#	app/Actions/UpdateCommitStatuses.php
#	app/Http/Controllers/ModerationController.php
#	app/Http/Requests/CreateCommitRequest.php
#	resources/js/components/commit-card.tsx
#	tests/Unit/Actions/ApproveCommitTest.php
#	tests/Unit/Models/CommitTest.php
@xHeaven

xHeaven commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Fixed, gonna mark it ready for review.

@xHeaven
xHeaven marked this pull request as ready for review October 16, 2026 08:55
@brendt
brendt merged commit d060a82 into dev-null-sh:production Oct 16, 2026
1 check passed
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.

3 participants