Repository navigation
feat(artifacts): compare two versions of an artifact side by side - #37657
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change only adds things, reuses the existing [DESIGN-REVIEWED] 2e01fdb Description read[DESCRIPTION-READ] deb28a64c3c7b181c0e22a73dfbc40e063734fafbf2a8cc07754c9059e3d96dd That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS This adds a comparison you have to choose to use. It builds on the existing Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: let a reader see what changed between two states of an artifact without flipping the version picker back and forth. ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 2e01fdb Description read[DESCRIPTION-READ] 7e3674e34a9927fd65246a9ea52f5fbc4231c0c32af0693c73473b46982baf56 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks. The blind reader read "Compare with" and "Stop comparing" correctly and would use both. Screenshots cover every state the diff adds: the menu, split, narrow, loading, error, and light and dark themes. Notes
[UX-REVIEWED] 2e01fdb Description read[DESCRIPTION-READ] 72fa0da4f5590a637be8c33c7d903448f747769c85726ebf97ffad20c8d89a36 That sha256 names everything this verdict read: the PR description, plus the 12 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Code change approver recommendation: A person should decideWhy: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, but it changes 633 lines, more than the 400 it may approve on its own. This PR adds an opt-in, front-end-only view that compares two states of an artifact. It reuses DiffPanel and the existing artifactVersion query. State lifecycle checks out: the compare state resets when the slug changes, clears when an edit starts or the viewed version becomes the compared one, and is ignored for images, web apps and edit mode. A version that can't be drawn falls back to the normal body. The older state always goes on the left. The view follows the shared mft-diff-split layout setting and drops to one column on a narrow screen. Strings were added to every catalog, and there are tests for each behaviour (page-level and pure helpers). CI and all review lanes are green. The one sibling-path concern was that the Compare select skips the comment-draft guard. It turned out not to lose anything, because the composer draft store keeps the text through an unguarded teardown. Nothing blocks. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
c585b04 to
d7dfd99
Compare
|
Blocking, First principles, the "Live / vN" label was spelled twice. Fixed in d7dfd99. UX, the two panes have no labels. Fixed in d7dfd99. In two-column mode a caption row names the older state over the left column and the newer over the right ("v1", "Live"), using the existing state labels (no new string). Test UX, missing resting and open-list screenshots. Added UX, "Stop comparing" scrolls away. Not changed. The page header is already sticky and holds the "Compare with" select; its first row ("Compare with") returns to the document, so a way back stays on screen while the diff scrolls. A second sticky row would sit under the page header (both are top-0), and a second stop button in the header would break UX, "Version Live" and "Compare with v1" look alike; loading and error states unseen. The column captions answer the first. The loading and error states are pinned by tests ( |
d7dfd99 to
6982e7b
Compare
|
CI, CI, "Render Benchmark (counter budgets)". Not changed. The job fails with "Playwright does not support chromium on ubuntu26.04-x64", which is the runner image; it does not run any code from this PR. The branch is rebased onto the current main as a single commit. |
6982e7b to
3437a05
Compare
|
BLOCKING, |
3437a05 to
29e0fa9
Compare
|
UX lane (screenshots of the narrow, loading and error views): captured on this head from the real artifact page on loopback with the version fetch mocked. Narrow view: 390 px viewport at 2x, clipped to the compare region so the changed lines and their text are readable ( Code change approver, item 2 (unified layout ignored): it did. On the previous head Code change approver, item 1 (no narrow branch): fixed in round 1; the test is CI: |
29e0fa9 to
2e01fdb
Compare
|
Rebased onto current main ( |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approving. On this head the review checked these points. The compare query shares the version picker's cache key and stays off for Live. Revert, Back to live, the version picker, an edit start and a slug change all clear a comparison that can no longer be shown. Images and web apps get no Compare control. The narrow view falls back to one column. Artifact text reaches the diff viewer as plain text, and the diff adds no new endpoint and no raw HTML path. Each fix round added a page test that pins its change.
Done well: the feature is built from what already exists (the artifact version API, DiffPanel and the shared diff layout preference), and the choice logic lives in small pure helpers with their own unit tests.
Optional:
src/kiro_crew/docs/artifacts.md:35sends readers to Display settings, but the diff layout toggle ("Split (side-by-side) diffs") is in Settings > Chat. The comment atArtifactVersionCompare.tsx:35names the same wrong tab.ArtifactDetailPageHeader.tsx:326still builds the picker's "Live" / "vN" labels inline. Mapping them throughstateLabelwould make its doc comment true.- The Compare select's
onChange(ArtifactDetailPageHeader.tsx:540) could go throughguardCommentDraft, the same way the Version picker's does, so an open anchored-comment box is not closed without asking.
Problem / Motivation
Goal: from an artifact's page, set any two of its states (Live or a numbered version) side by side with the changed lines marked, so "what did the agent change" is answered by looking, not by flipping the version picker back and forth.
The artifact page lists versions in a picker and can revert to one, but it shows only one state at a time. Comparing two means switching between them and holding the first in memory. Chat file changes already draw a side-by-side diff with the shared diff viewer, and the versions API already returns each version's text, so the pieces exist.
Why it matters
Agents edit saved artifacts repeatedly. A reader who wants to know what changed since version 2 has no way to see it, and a revert is a leap without it.
Not a goal
What changed (motivation → approach → change)
website/src/lib/artifactCompare.ts: pure helpers, including the onestateLabelthe select and the view both use. Which states the select offers, whether a request can be drawn, which side is older (Live is newest), and the file name given to the viewer.website/src/components/ArtifactVersionCompare.tsx: the comparison view. It hands the two texts to the existingDiffPanel(the viewer computes the diff), with a heading and a "Stop comparing" button. Round 1: a narrow screen gets the one-column diff, and the two-column view names each column ("v1", "Live"). Round 4: the layout also follows the shared diff layout preference (useDiffSplit, themc-diff-splitsetting in Display settings) that the chat diff surfaces read, so a reader who chose unified gets one column (no captions) on a wide screen too.website/src/pages/useArtifactDetailPageDocument.ts: the chosen state, reset when the artifact changes, and a fetch of the other snapshot through the existingartifactVersioncall (Live reuses the record already loaded). Round 3: the request is cleared where it stops being drawable (the viewed state becomes the compared one, or an edit starts), so it never returns later while the select shows none.website/src/pages/ArtifactDetailPageHeader.tsx: a "Compare with" select beside the version picker. A select, not a button, so the row keeps its two-action limit.website/src/pages/ArtifactDetailPageBody.tsx: shows the comparison in place of the body while one is active.website/src/i18n/locales/en.json,en-XA.jsonand the eleven translated catalogs (bn,de,es,fr,hi,it,ja,ko,pt,ru,zh-CN): six strings each. Round 2: the translated catalogs were missing, socatalogParity.test.tsfailed; each language now has its own translation.src/kiro_crew/docs/artifacts.md: a paragraph on the feature (round 4: names the Display setting).Round 4 (this head): narrow view, 390 px wide, one column:
Loading the other version, light and dark (
loading-light.png,loading-dark.png):Other version failed to load, light and dark (
error-light.png,error-dark.png):Backwards compatibility
Nothing changes until "Compare with" is used. A request that cannot be drawn (the state already on screen, a version no longer listed, an image or web app, an edit in progress) is dropped: the page shows the document exactly as before, with no refusal. A snapshot that fails to load shows the page's standard error notice and keeps the page.
Tests
website/src/test/ArtifactDetailPage.compare.test.tsxfail (no "Compare with" control); the three that pin today's behavior pass.website/src/lib/artifactCompare.test.tsneeds the new module.mc-diff-splitoff gives the unified diff with no captions, on gives split with captions) fails on the previous source (ArtifactVersionCompare.tsxas of 3437a05, forced split) and passes now. The artifact page and diff panel suites: 20 files, 385 tests pass;ArtifactDetailPage.compare.test.tsx14 tests.vitest run src/i18n/withI18N_BASE_REFset to the merge base: 81 files, 1,261 tests passed (the 11has no key missing relative to enfailures are gone).eslint,tsc -p tsconfig.app.json,i18n:check(RC=0) and the theme, class and string lints pass.cd website && npx vitest run src/test/ArtifactDetailPage.compare.test.tsx src/lib/artifactCompare.test.tsManual verification
Rendered the real artifact page on loopback with three versions of a markdown file and Live, chose "Compare with v1", and captured the resting header, the open option list, and the comparison in light and dark, plus the narrow, loading and error views (above; also
shots/resting-light.png,shots/resting-dark.png,shots/options-light.png,shots/options-dark.png). The older text is on the left, removed lines are red, added lines green, with the changed words marked inside each line.Sibling sweep
Sibling:
website/src/components/ArtifactBody.tsx-- not affected -- the normal body renders unchanged when no comparison is activeSibling:
website/src/pages/RemoteArtifactDetailPage.tsx-- not affected -- a remote listing has no local versionsPattern harvest
Rule candidate: review-prompt
Pattern: a picker that swaps the whole view gives no way to see a change; offer a diff against the other states.
Related Issues
None.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement