feat(prs): show the diff breakdown on the publish approval card #51

Open
glen wants to merge 2 commits from feat/pr-approval-breakdown into main
Collaborator

The "Publish branch …?" approval card now shows the diff breakdown (N files +A −D and the category table) before you approve. The numbers are the same ones the PR pill shows afterwards.

How

  • No native channel. step.ask / ViewQuestion carry only message, schema, secret, url (and expiresAt). I checked the vendored waits.md and custom-ui.md and the installed types, so the breakdown rides in the message:
    • The human text comes first, unchanged.
    • Then one trailing line, <!--breakdown:{json}-->. It's an HTML comment, so it reads as nothing if anything shows the message raw.
    • withBreakdown and splitPublishMessage in lib/prs.ts add and strip it; the match is anchored to the end of the message and validated with isDiffBreakdown.
  • One step, both uses. There's a single diff-breakdown step in runCreatePr.
    • With an ask, it runs before the question, and the result reuses its value. The card and the PR pill can't disagree.
    • With no ask, it runs after the PR opens, as before.
    • Replay returns the recorded value. A numstat failure gives a plain question, and the PR still goes ahead.
    • The result contract is unchanged.
  • UI.
    • New shared components/diff-breakdown-table.tsx, used by both the approval card and the PR pill popover, so they can't drift.
    • The card's <pre> shows only the human text.
    • waitText strips the block for the inbox. Nothing else renders question messages.
  • docs/architecture/git.md is updated (format, single step, and why).

Verification

  • pnpm typecheck and pnpm test pass (1340 passed). New tests cover:
    • the ask carries the breakdown, and it's the same one as in the result;
    • a numstat failure gives a plain ask and the PR still proceeds;
    • no ask keeps the old step order;
    • a declined publication runs numstat once and never pushes;
    • the helpers round-trip and handle a missing, malformed or mid-message block;
    • waitText strips the block.
  • Browser: I rendered the real PrPart with a question built by the real withBreakdown from #50's actual stats.
    • The table read Tests 3 / Docs 2 / Code 5, Total 10 +657 −44.
    • No <!-- or breakdown: text appeared anywhere on the page.
    • The inbox line ends at the human text.
    • A question without a block renders as before. Screenshots below; the bottom card is the fallback.

Not verified

  • A live step.ask round trip. The card assumes the message comes back from the view unchanged, as the existing startsWith/includes matching already does.
  • A publish question already waiting from before this deploy has no block and shows as plain text.

Screenshots

Approval card, light

Approval card, dark

The "Publish branch …?" approval card now shows the diff breakdown (`N files +A −D` and the category table) before you approve. The numbers are the same ones the PR pill shows afterwards. ## How - **No native channel.** `step.ask` / `ViewQuestion` carry only `message`, `schema`, `secret`, `url` (and `expiresAt`). I checked the vendored `waits.md` and `custom-ui.md` and the installed types, so the breakdown rides in the message: - The human text comes first, unchanged. - Then one trailing line, `<!--breakdown:{json}-->`. It's an HTML comment, so it reads as nothing if anything shows the message raw. - `withBreakdown` and `splitPublishMessage` in `lib/prs.ts` add and strip it; the match is anchored to the end of the message and validated with `isDiffBreakdown`. - **One step, both uses.** There's a single `diff-breakdown` step in `runCreatePr`. - With an ask, it runs before the question, and the result reuses its value. The card and the PR pill can't disagree. - With no ask, it runs after the PR opens, as before. - Replay returns the recorded value. A numstat failure gives a plain question, and the PR still goes ahead. - The result contract is unchanged. - **UI.** - New shared `components/diff-breakdown-table.tsx`, used by both the approval card and the PR pill popover, so they can't drift. - The card's `<pre>` shows only the human text. - `waitText` strips the block for the inbox. Nothing else renders question messages. - `docs/architecture/git.md` is updated (format, single step, and why). ## Verification - `pnpm typecheck` and `pnpm test` pass (1340 passed). New tests cover: - the ask carries the breakdown, and it's the same one as in the result; - a numstat failure gives a plain ask and the PR still proceeds; - no ask keeps the old step order; - a declined publication runs numstat once and never pushes; - the helpers round-trip and handle a missing, malformed or mid-message block; - `waitText` strips the block. - **Browser:** I rendered the real `PrPart` with a question built by the real `withBreakdown` from #50's actual stats. - The table read Tests 3 / Docs 2 / Code 5, Total 10 +657 −44. - No `<!--` or `breakdown:` text appeared anywhere on the page. - The inbox line ends at the human text. - A question without a block renders as before. Screenshots below; the bottom card is the fallback. ## Not verified - A live `step.ask` round trip. The card assumes the message comes back from the view unchanged, as the existing `startsWith`/`includes` matching already does. - A publish question already waiting from before this deploy has no block and shows as plain text. ## Screenshots ![Approval card, light](./approval-light.png) ![Approval card, dark](./approval-dark.png)
One diff-breakdown step now runs before the ask and feeds both the question
and the result. step.ask has no data field, so the breakdown rides in the
message as a trailing comment block.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
feat(ui): breakdown table on the publish approval card
Some checks failed
build / build-and-test (pull_request) Failing after 1m2s
build / build-sandbox-image (pull_request) Successful in 1s
build / deploy (pull_request) Has been skipped
4dc995e653
Shared DiffBreakdownTable for the card and the PR pill popover; the inbox
line strips the machine block.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Some checks failed
build / build-and-test (pull_request) Failing after 1m2s
build / build-sandbox-image (pull_request) Successful in 1s
build / deploy (pull_request) Has been skipped
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/pr-approval-breakdown:feat/pr-approval-breakdown
git switch feat/pr-approval-breakdown

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff feat/pr-approval-breakdown
git switch feat/pr-approval-breakdown
git rebase main
git switch main
git merge --ff-only feat/pr-approval-breakdown
git switch feat/pr-approval-breakdown
git rebase main
git switch main
git merge --no-ff feat/pr-approval-breakdown
git switch main
git merge --squash feat/pr-approval-breakdown
git switch main
git merge --ff-only feat/pr-approval-breakdown
git switch main
git merge feat/pr-approval-breakdown
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
chad/tansweat!51
No description provided.