From aa1671ac245a9a88bab53d71d1cbb6e9a5c99ba5 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Wed, 2 Dec 2026 20:21:26 +1300 Subject: [PATCH] =?UTF-8?q?The=20web=20app's=20reviews=20take=20a=20note?= =?UTF-8?q?=20(sc-8799):=20an=20'Add=20note'=20button=20by=20the=20review?= =?UTF-8?q?=20buttons,=20on=20the=20build=20page=20and=20the=20snapshot=20?= =?UTF-8?q?page,=20opens=20an=20optional=20'Why=3F'=20field=20on=20a=20row?= =?UTF-8?q?=20of=20its=20own,=20with=20an=20=C3=97=20that=20hides=20it=20a?= =?UTF-8?q?gain=20(dropping=20its=20text)=20and=20brings=20'Add=20note'=20?= =?UTF-8?q?back;=20the=20review=20buttons=20and=20the=20title=20don't=20mo?= =?UTF-8?q?ve.=20Approve=20all,=20Reject,=20the=20group=20approvals=20and?= =?UTF-8?q?=20each=20snapshot's=20approve=20or=20reject=20send=20the=20not?= =?UTF-8?q?e=20with=20the=20review;=20it=20shows=20in=20the=20build's=20Re?= =?UTF-8?q?views,=20get=5Fbuild,=20the=20PR=20comment=20and=20the=20check?= =?UTF-8?q?=20summary,=20like=20an=20agent's.=20Docs=20reworded=20(Nathan:?= =?UTF-8?q?=20no=20'kept');=20plugin=200.1.32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/design.md | 3 +- server/frontend/content/docs/agents.md | 2 +- server/frontend/src/api/hooks.ts | 2 +- server/frontend/src/components/ReviewNote.tsx | 61 +++++++++++++++++++ server/frontend/src/pages/BuildPage.tsx | 23 +++++-- server/frontend/src/pages/SnapshotPage.tsx | 10 ++- server/frontend/src/styles.css | 32 ++++++++++ server/src/controllers/ui.rs | 2 +- server/src/mcp.rs | 2 +- skills/visualci-review/SKILL.md | 2 +- 10 files changed, 125 insertions(+), 14 deletions(-) create mode 100644 server/frontend/src/components/ReviewNote.tsx diff --git a/docs/design.md b/docs/design.md index cc1748ca..e9e8f602 100644 --- a/docs/design.md +++ b/docs/design.md @@ -199,7 +199,8 @@ the same way as a screenshot: a change keeps the GitHub check pending instead of that approved it (`baselines.review_id`). Everywhere a review shows (the build's reviews, "approved on main", `get_build`, the PR comment, the check summary) it reads "Claude Code for Ada Lovelace", "Ada Lovelace" (the web app) or "a project token (CI)" (`models::reviews::by`): VisualCI is mostly used by agents, so an agent's approval never - reads as the person's own (Nathan, 2 Dec 2026). + reads as the person's own (Nathan, 2 Dec 2026). In the web app the build page's optional "Why?" field is the note for + whichever review is made from it (sc-8799). - Two pull requests that change the same snapshot and merge separately leave an image neither showed. Between merged approvals in a build's history the nearer merge wins, and a change whose every region is exactly a region a merged PR's build changed and approved (the same box, the same old and new pixels) points at that build diff --git a/server/frontend/content/docs/agents.md b/server/frontend/content/docs/agents.md index 86af8f5d..0b044638 100644 --- a/server/frontend/content/docs/agents.md +++ b/server/frontend/content/docs/agents.md @@ -195,7 +195,7 @@ failing in the repository instead of sending them. **Reviews** -- `review`: approve or reject a build's changes, some snapshots' changes (`snapshots`), or only its new or only its changed snapshots (`only: "added"` or `"changed"`). Add a `note` saying why ("The new header, as the issue asked"): it's kept with the review and shown in the build's reviews, `get_build` and the pull request comment. Every review says who made it and how: "Claude Code for Ada Lovelace" for an agent signed in as its person, "Ada Lovelace" in the web app, or "a project token (CI)", so an agent's approval never reads as the person's own. When two pull requests change the same screen and merge separately, the screen after both is one neither showed, so it shows as changed until someone reviews it. If the change is exactly another pull request's approved change (the same regions, from the same old pixels to the same new ones), `get_build` marks it `matches` ("matches PR #8's approved change"), and `only: "matching"` approves those in one call. On a pull request's build whose base is a default-branch build nobody has reviewed yet, the changes that are main's own unreviewed ones are marked `on_main_unreviewed`, and `get_build`'s `inherited` says how many and which build: review those on main's build, and the pull request's own changes here. +- `review`: approve or reject a build's changes, some snapshots' changes (`snapshots`), or only its new or only its changed snapshots (`only: "added"` or `"changed"`). Add a `note` saying why ("The new header, as the issue asked"): it shows in the build's reviews, `get_build` and the pull request comment. Every review says who made it and how: "Claude Code for Ada Lovelace" for an agent signed in as its person, "Ada Lovelace" in the web app, or "a project token (CI)", so an agent's approval never reads as the person's own. When two pull requests change the same screen and merge separately, the screen after both is one neither showed, so it shows as changed until someone reviews it. If the change is exactly another pull request's approved change (the same regions, from the same old pixels to the same new ones), `get_build` marks it `matches` ("matches PR #8's approved change"), and `only: "matching"` approves those in one call. On a pull request's build whose base is a default-branch build nobody has reviewed yet, the changes that are main's own unreviewed ones are marked `on_main_unreviewed`, and `get_build`'s `inherited` says how many and which build: review those on main's build, and the pull request's own changes here. - `review_page`: accept one page as a variant, or ignore one exact change in later builds too. **Running a comparison** diff --git a/server/frontend/src/api/hooks.ts b/server/frontend/src/api/hooks.ts index 792224d5..423be142 100644 --- a/server/frontend/src/api/hooks.ts +++ b/server/frontend/src/api/hooks.ts @@ -278,7 +278,7 @@ function useBuildAction(org: string, project: string, n: number, fn: (v: V) = } export function useReview(org: string, project: string, n: number) { - return useBuildAction(org, project, n, (v: { action: 'approve' | 'reject'; snapshot_ids?: string[]; only?: 'added' | 'changed' | 'matching' }) => + return useBuildAction(org, project, n, (v: { action: 'approve' | 'reject'; snapshot_ids?: string[]; only?: 'added' | 'changed' | 'matching'; note?: string }) => post(`${buildPath(org, project, n)}/review`, v), ) } diff --git a/server/frontend/src/components/ReviewNote.tsx b/server/frontend/src/components/ReviewNote.tsx new file mode 100644 index 00000000..2645618a --- /dev/null +++ b/server/frontend/src/components/ReviewNote.tsx @@ -0,0 +1,61 @@ +import { NotePencilIcon, XIcon } from '@phosphor-icons/react' +import { useState } from 'react' +import { Button } from './ui' + +/** A review's optional note: why, shown wherever the review appears (sc-8799). */ +export function useReviewNote() { + const [open, setOpen] = useState(false) + const [text, setText] = useState('') + return { + open, + text, + setText, + show: () => setOpen(true), + /** What to send: the trimmed text, or nothing. */ + value: text.trim() || undefined, + /** After a review is made: empty and hidden again. */ + clear: () => { + setText('') + setOpen(false) + }, + } +} + +/** "Add note": shown until it's clicked, then the field ([`ReviewNoteField`]) takes over on a row of its own. */ +export function ReviewNoteButton({ note }: { note: ReturnType }) { + if (note.open) return null + return ( + // On a phone, the pencil alone: the label would push the review buttons onto another row. + + ) +} + +/** The note's field, on a row of its own under the review controls so nothing above it moves. It stays open, with + * what's typed, until a review is sent or its × removes it (which also drops what was typed, so a hidden note is never + * sent). */ +export function ReviewNoteField({ note }: { note: ReturnType }) { + if (!note.open) return null + return ( +
+ + + note.setText(e.target.value)} + /> + + +
+ ) +} diff --git a/server/frontend/src/pages/BuildPage.tsx b/server/frontend/src/pages/BuildPage.tsx index 6154de5b..978cd537 100644 --- a/server/frontend/src/pages/BuildPage.tsx +++ b/server/frontend/src/pages/BuildPage.tsx @@ -19,6 +19,7 @@ import { errorMessage } from '../api/client' import { QueryState } from '../components/QueryState' import { PresignedImg, useExpiredRefetch } from '../components/PresignedImg' import { BuildResult, Button, CodeBlock, Help, Pill, ReviewPill, StatePill, type Tone } from '../components/ui' +import { ReviewNoteButton, ReviewNoteField, useReviewNote } from '../components/ReviewNote' import { fullDate, n, plural, shortSha, timeAgo } from '../lib/format' import { usePersistentState } from '../lib/theme' @@ -67,6 +68,10 @@ export function BuildPage() { const q = useBuild(org, project, number) const projectQ = useProject(org, project) const review = useReview(org, project, number) + // The review's note (sc-8799): every review action on this page sends it, and it clears once one is made. + const note = useReviewNote() + const send = (v: { action: 'approve' | 'reject'; snapshot_ids?: string[]; only?: 'added' | 'changed' | 'matching' }) => + review.mutate({ ...v, note: note.value }, { onSuccess: note.clear }) const onExpired = useExpiredRefetch(q.refetch) const [order, setOrder] = useReviewOrder() @@ -104,23 +109,25 @@ export function BuildPage() { {canReviewBuild && (
+ Approved snapshots become the baseline for later builds on {build.branch}.
)} + {canReviewBuild && } @@ -192,6 +199,7 @@ export function BuildPage() { s={s} onExpired={onExpired} review={review} + send={send} /> ))} @@ -221,7 +229,7 @@ export function BuildPage() { size="sm" variant="ghost" loading={review.isPending && review.variables?.only === g.state} - onClick={() => review.mutate({ action: 'approve', only: g.state as 'changed' | 'added' })} + onClick={() => send({ action: 'approve', only: g.state as 'changed' | 'added' })} > Approve all {g.state} @@ -231,7 +239,7 @@ export function BuildPage() { size="sm" variant="ghost" loading={review.isPending && review.variables?.only === 'matching'} - onClick={() => review.mutate({ action: 'approve', only: 'matching' })} + onClick={() => send({ action: 'approve', only: 'matching' })} title="Changes made only of changes merged pull requests approved" > Approve all matching @@ -248,6 +256,7 @@ export function BuildPage() { s={s} onExpired={onExpired} review={review} + send={send} /> ))} @@ -424,6 +433,7 @@ function SnapshotItem({ s, onExpired, review, + send, }: { org: string project: string @@ -431,6 +441,7 @@ function SnapshotItem({ s: SnapshotRow onExpired: () => void review: ReturnType + send: (v: { action: 'approve' | 'reject'; snapshot_ids?: string[] }) => void }) { const KindIcon = kindIcon[s.kind] ?? FileTextIcon const busy = review.isPending && review.variables?.snapshot_ids?.[0] === s.id @@ -514,7 +525,7 @@ function SnapshotItem({ title="Approve this snapshot" aria-label={`Approve ${s.name}`} disabled={busy} - onClick={() => review.mutate({ action: 'approve', snapshot_ids: [s.id] })} + onClick={() => send({ action: 'approve', snapshot_ids: [s.id] })} > @@ -525,7 +536,7 @@ function SnapshotItem({ title="Reject this snapshot" aria-label={`Reject ${s.name}`} disabled={busy} - onClick={() => review.mutate({ action: 'reject', snapshot_ids: [s.id] })} + onClick={() => send({ action: 'reject', snapshot_ids: [s.id] })} > diff --git a/server/frontend/src/pages/SnapshotPage.tsx b/server/frontend/src/pages/SnapshotPage.tsx index 3ed43ec8..dd65f412 100644 --- a/server/frontend/src/pages/SnapshotPage.tsx +++ b/server/frontend/src/pages/SnapshotPage.tsx @@ -16,6 +16,7 @@ import { CommentButton, CommentHint, CommentsProvider, PageThreads, Pins } from import { QueryState } from '../components/QueryState' import { PresignedImg, useExpiredRefetch } from '../components/PresignedImg' import { Button, Help, Kbd, Pill, ReviewPill, StatePill, type Tone } from '../components/ui' +import { ReviewNoteButton, ReviewNoteField, useReviewNote } from '../components/ReviewNote' import { n, percent, plural } from '../lib/format' import { usePersistentState } from '../lib/theme' import { approvedElsewhereLabel, compareForReview, reviewable, useReviewOrder, type ReviewOrder } from './BuildPage' @@ -155,12 +156,15 @@ export function SnapshotPage() { el.scrollIntoView({ block: 'start', behavior: window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth' }) }, []) + // The review's note (sc-8799): sent with approve or reject, then cleared. + const note = useReviewNote() const doReview = useCallback( (action: 'approve' | 'reject') => { review.mutate( - { action, snapshot_ids: [id] }, + { action, snapshot_ids: [id], note: note.value }, { onSuccess: () => { + note.clear() if (action === 'approve' && nextToReview) { navigate({ to: '/$org/$project/builds/$number/snapshots/$id', @@ -171,7 +175,7 @@ export function SnapshotPage() { }, ) }, - [review, id, nextToReview, navigate, org, project, number], + [review, id, nextToReview, navigate, org, project, number, note], ) // Reset the page cursor when moving to another snapshot. @@ -387,6 +391,7 @@ export function SnapshotPage() { {canReview && ( <> +