mirror of
https://github.com/expo/explore.git
synced 2026-11-15 13:18:16 -10:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ffd22a5af | ||
|
|
2943c63313 | ||
|
|
63199bf3d9 | ||
|
|
e291be651b | ||
|
|
593e3ba689 | ||
|
|
2419d57eb7 |
No files matched your search
+14
@@ -143,6 +143,20 @@ A failure at any stage is recorded in `state.failure`, a partial report is writt
|
||||
| Only app-wide inputs changed (`app-wide`) | Modified | Unchanged (one line in the PR comment) | Needs review |
|
||||
| No source change (`none`) | Screen variant (listed apart from Changes) | Unchanged | Unchanged |
|
||||
|
||||
A screen whose source changed but whose screenshots were not compared (it is outside the capture scope) has no
|
||||
verdict: the PR comment does not list it, the agent API reports `not-compared`, and the Viewer marks it Not compared.
|
||||
Earlier versions listed it as Source-affected. A planned capture that failed is counted as unavailable and named under
|
||||
Validation.
|
||||
|
||||
"Differs" means the screenshots differ or the accessibility tree does. A Modified screen whose screenshots match is
|
||||
**Accessibility only**: what screen readers and voice control read changed (a label, a role, an element added to the tree)
|
||||
but nothing shows in the capture. It is still a change: the PR comment counts it apart ("3 visual changes · 12
|
||||
accessibility only") under 🟦 Accessibility only, the Viewer marks it blue and Compare steps through it, and the agent API
|
||||
reports `status: "accessibility-only"` with `sourceStatus: "modified"`. The report contract is unchanged (its review
|
||||
status stays `modified`), so earlier reports read the same way. The accessibility tree can include content outside the
|
||||
screenshot, such as rows scrolled below the fold or elements under a sheet, so an accessibility-only change is not always
|
||||
invisible on a device.
|
||||
|
||||
A pixel mismatch that rounds to 0.00% is noise and counts as "same". Diff regions inside the status-bar band are excluded from the verdict and reported as `ignoredStatusBarRegions`; the Viewer marks that band in Compare.
|
||||
|
||||
## 7. Local CI test
|
||||
|
||||
@@ -387,7 +387,7 @@ The same link answers differently depending on who asks. It already carries the
|
||||
|
||||
- A browser gets the Viewer.
|
||||
- Anything that does not ask for HTML (`curl`, `fetch`, agents' URL tools) gets a Markdown index of the report, also at `/llms.txt`.
|
||||
- The index links to a read-only JSON API under `/api/v1`: `/screens?status=modified,added,removed`, `/screens/<id>`, `/transitions`, and `/raw` for the report file.
|
||||
- The index links to a read-only JSON API under `/api/v1`: `/screens?status=modified,accessibility-only,added,removed`, `/screens/<id>`, `/transitions`, and `/raw` for the report file.
|
||||
- Reports without source also expose `/journeys`, `/gaps`, and `/frontier`.
|
||||
- Multi-platform reports take `?platform=ios|android`. Expired links answer `410`.
|
||||
|
||||
|
||||
@@ -172,13 +172,16 @@ imported source changed), `app-wide` (only app-wide inputs such as dependencies,
|
||||
| --- | --- |
|
||||
| Added / Removed | Route presence differs between source inventories |
|
||||
| Modified | The screen's source changed and comparable evidence differs |
|
||||
| Accessibility only | Modified, but the screenshots match: only the accessibility tree (what screen readers and voice control read) differs. Counted as a change and listed apart from the visual ones |
|
||||
| Needs review | The screen's source changed and the comparison could not tell whether it looks different; a review target |
|
||||
| Screen variant | No source change reaches the screen, but its captures differ in runtime UI state (balances, timestamps, loaded content). Listed apart from changes |
|
||||
| Source-affected | Source impact without a comparison |
|
||||
| Unchanged | No visible difference, whether or not the screen's source changed. Explore reports visual changes; reports before 0.19.1 called a source change with no visible difference Needs review |
|
||||
| Not compared | No comparison was performed |
|
||||
| Not compared | No comparison was performed, including for a screen whose source changed. Not counted as a change: Explore reports what the captures show, not what the code might do. Earlier versions listed these as Source-affected |
|
||||
|
||||
A difference that rounds to 0.00% of pixels is rendering noise and counts as no difference.
|
||||
Accessibility only is how readers present a `modified` verdict whose visual verdict is `unchanged`; the contract has no
|
||||
separate status for it, so reports from earlier versions show it too. The accessibility tree can include content outside
|
||||
the screenshot (rows below the fold, elements under a sheet), so such a change may still be visible on a device.
|
||||
A runtime difference is not proof that the code change caused it. Deterministic mode uses template notes and evidence facts. Agent mode adds AI explanations from the captured evidence and source changes through a separate CLI session; those explanations cannot override fixed verdicts. Structural flows describe possible source navigation; semantic business grouping remains deferred.
|
||||
|
||||
## Artifacts and cache
|
||||
|
||||
@@ -88,8 +88,8 @@ export function visibleRuns(state: PickerState): SavedRun[] {
|
||||
|
||||
function counts(run: SavedRun, paint: Paint): string {
|
||||
if (run.explored) return `${paint.text(String(run.explored.screens))} ${paint.dim("screens")} ${paint.dim(`${run.explored.unexplored} unexplored`)}`;
|
||||
const parts = ([["modified", paint.amber, "modified"], ["added", paint.green, "added"], ["removed", paint.red, "removed"], ["needs-review", paint.yellow, "need review"],
|
||||
["source-affected", paint.yellow, "source-affected"]] as const)
|
||||
const parts = ([["modified", paint.amber, "modified"], ["accessibility-only", paint.blue, "accessibility only"], ["added", paint.green, "added"], ["removed", paint.red, "removed"],
|
||||
["needs-review", paint.yellow, "need review"]] as const)
|
||||
.filter(([group]) => run.changes?.[group]).map(([group, colour, label]) => `${colour(String(run.changes![group]))} ${paint.dim(label)}`);
|
||||
return parts.length ? parts.join(" ") : paint.dim("no visible changes");
|
||||
}
|
||||
|
||||
@@ -32,6 +32,14 @@ function hasVerifiedPair(surface: Surface): boolean {
|
||||
&& surface[`${side}Outcome`]?.landing === "verified");
|
||||
}
|
||||
|
||||
/**
|
||||
* A modified screen whose verified screenshots match: only what assistive technology reads (its accessibility tree)
|
||||
* changed. Screen readers and voice control see it, so it is a change to review, listed apart from the visual ones.
|
||||
*/
|
||||
export function isAccessibilityOnlyChange(surface: Surface): boolean {
|
||||
return surface.review?.status === "modified" && surface.visual?.verdict === "unchanged" && hasVerifiedPair(surface);
|
||||
}
|
||||
|
||||
function assertReviewFields(surface: Surface, enforceComparisonEvidence: boolean): void {
|
||||
const assertVerifiedPair = () => {
|
||||
if (enforceComparisonEvidence && !hasVerifiedPair(surface)) {
|
||||
|
||||
+39
-4
@@ -124,15 +124,50 @@ const edgeItem = (edge: Json): Json => defined({ from: str(edge.from), to: str(e
|
||||
/**
|
||||
* A screen's status as the Viewer and the PR comment show it: the review's verdict where there is one, so `modified`
|
||||
* means a visible change. A screen whose source changed but whose captures match is unchanged, including in reports
|
||||
* from before 0.19.1, which called it "needs review".
|
||||
* from before 0.19.1, which called it "needs review". A modified screen whose screenshots match changed only in what
|
||||
* assistive technology reads: `accessibility-only`. A screen whose capture failed is `unavailable`, and one whose
|
||||
* source changed but that has no verdict was not compared: `not-compared`.
|
||||
*/
|
||||
/** Both sides captured at their verified destination route, as a verdict requires (isAccessibilityOnlyChange in the contract). */
|
||||
function verifiedPair(surface: Json): boolean {
|
||||
return (["base", "head"] as const).every(side => str(rec(surface[side]).kind) === "screen" && Boolean(surface[`${side}Image`])
|
||||
&& str(rec(surface[`${side}Outcome`]).status) === "captured" && str(rec(surface[`${side}Outcome`]).landing) === "verified");
|
||||
}
|
||||
|
||||
/** The side's planned capture ended without a screenshot, or captured another screen than the route (the Viewer's Unavailable). */
|
||||
function captureUnavailable(surface: Json, side: "base" | "head"): boolean {
|
||||
const outcome = surface[`${side}Outcome`];
|
||||
if (str(rec(surface[side]).kind) !== "screen" || outcome === undefined) return false;
|
||||
const image = Boolean(surface[`${side}Image`]);
|
||||
if (!image) return str(rec(outcome).status) !== "captured";
|
||||
return str(rec(outcome).status) === "captured" && str(rec(outcome).landing) !== "verified" && rec(outcome).observed !== undefined;
|
||||
}
|
||||
|
||||
function verdictOf(surface: Json): string | undefined {
|
||||
// A capture that failed is unavailable, as the Viewer says, whatever the source or an older verdict claims.
|
||||
if (str(surface.status) !== "removed" && captureUnavailable(surface, "head")) return "unavailable";
|
||||
if (["modified", "unchanged"].includes(str(surface.status) ?? "") && captureUnavailable(surface, "base")) return "unavailable";
|
||||
const review = rec(surface.review);
|
||||
const status = str(review.status);
|
||||
if (status === "needs-review" && str(review.description) === "Source changed; no visible difference was captured.") return "unchanged";
|
||||
if (status === "modified" && str(rec(surface.visual).verdict) === "unchanged" && verifiedPair(surface)) return "accessibility-only";
|
||||
// A source change nobody compared is not a change Explore saw.
|
||||
if (status === undefined && str(surface.status) === "modified") return "not-compared";
|
||||
return status ?? str(surface.status);
|
||||
}
|
||||
|
||||
const STATUS_ORDER = ["modified", "accessibility-only", "added", "removed", "needs-review", "unavailable", "not-compared", "unchanged", "variant"];
|
||||
const STATUS_WORDS: Record<string, string> = { "accessibility-only": "accessibility only (screenshots match, the accessibility tree does not)",
|
||||
"needs-review": "need review", "not-compared": "not compared", variant: "screen variants" };
|
||||
|
||||
/** "3 modified, 1 added, 1 removed, 30 unchanged": every status counted, so the parts add up to the total. */
|
||||
function screenCounts(screens: Json): string {
|
||||
const statuses = Object.keys(screens).filter(status => status !== "total")
|
||||
.sort((left, right) => (STATUS_ORDER.indexOf(left) + 1 || 99) - (STATUS_ORDER.indexOf(right) + 1 || 99));
|
||||
const parts = statuses.flatMap(status => (num(screens[status]) ? [`${num(screens[status])} ${STATUS_WORDS[status] ?? status}`] : []));
|
||||
return parts.length ? parts.join(", ") : "none";
|
||||
}
|
||||
|
||||
function reviewSummary(context: AgentContext, review: Json): Json {
|
||||
const surfaces = arr(review.surfaces).map(rec);
|
||||
const counts: Record<string, number> = {};
|
||||
@@ -145,7 +180,7 @@ function reviewSummary(context: AgentContext, review: Json): Json {
|
||||
createdAt: str(review.createdAt), mode: str(review.mode), platforms: context.platforms, expiresAt: context.expiresAt,
|
||||
screens: { total: surfaces.length, ...counts },
|
||||
links: {
|
||||
screens: withPlatform(context, apiUrl(context, "/screens")), changed: withPlatform(context, apiUrl(context, "/screens?status=modified,added,removed")),
|
||||
screens: withPlatform(context, apiUrl(context, "/screens")), changed: withPlatform(context, apiUrl(context, "/screens?status=modified,accessibility-only,added,removed")),
|
||||
transitions: withPlatform(context, apiUrl(context, "/transitions")), raw: withPlatform(context, apiUrl(context, "/raw")),
|
||||
viewer: viewerUrl(context), viewerChanges: viewerUrl(context, { focus: "modified", inspect: "diff" }), markdown: `${context.pageUrl}/llms.txt`,
|
||||
},
|
||||
@@ -229,10 +264,10 @@ export function agentIndexMarkdown(context: AgentContext, loaded: LoadedReport):
|
||||
// A comparison of two commits, or a local review on someone's machine, has no pull request: its title names both refs.
|
||||
const compared = pr.origin === "compare" || pr.origin === "local";
|
||||
lines.push(`# Expo Explore report: ${escapeMd(app.name ?? pr.repository)} ${compared ? escapeMd(pr.title) : `PR #${escapeMd(pr.number)}`}${app.platform ? ` (${escapeMd(app.platform)})` : ""}`, "",
|
||||
`> Visual review of ${compared ? `${escapeMd(pr.repository)} ${escapeMd(pr.title)}` : `pull request ${escapeMd(pr.repository)}#${escapeMd(pr.number)}`} by Expo Explore. ${screens.total} screens captured: ${screens.modified ?? 0} modified, ${screens.added ?? 0} added, ${screens.removed ?? 0} removed, ${screens.unchanged ?? 0} unchanged.${context.expiresAt ? ` This link stops serving the report after ${context.expiresAt}.` : ""}`, "",
|
||||
`> Visual review of ${compared ? `${escapeMd(pr.repository)} ${escapeMd(pr.title)}` : `pull request ${escapeMd(pr.repository)}#${escapeMd(pr.number)}`} by Expo Explore. ${screens.total} screens: ${screenCounts(screens)}.${context.expiresAt ? ` This link stops serving the report after ${context.expiresAt}.` : ""}`, "",
|
||||
"This URL is the human Viewer. The same report is available as read-only JSON (no credentials beyond this URL):", "",
|
||||
`- [Summary](${links.summary ?? withPlatform(context, apiUrl(context))}): kind, counts by status, app and PR identity, links`,
|
||||
`- [Changed screens](${links.changed}): the modified, added and removed screens with the review description, visual verdict and mismatch percentage; \`status=\` filters, \`limit=\`/\`cursor=\` page`,
|
||||
`- [Changed screens](${links.changed}): the modified, accessibility-only (screenshots match, the accessibility tree does not), added and removed screens with the review description, visual verdict and mismatch percentage; \`status=\` filters, \`limit=\`/\`cursor=\` page`,
|
||||
`- [All screens](${links.screens}): every captured screen; \`${links.screens}/{id}\` (the \`id\` field of a screen) adds source files and navigation in and out`,
|
||||
`- [Transitions](${links.transitions}): navigation edges between screens (\`?from=\`/\`?to=\` take a screen id or route)`,
|
||||
`- Screenshots: each screen's \`headImage\`/\`baseImage\` URL returns the PNG`,
|
||||
|
||||
@@ -5,7 +5,7 @@ import { assertPublicReview, projectPublicReviewForReport } from "../contracts/r
|
||||
import { createHash } from "node:crypto";
|
||||
import type { ArtifactReport } from "../contracts/artifact-report.js";
|
||||
import { compareTitleMarkdown, projectReviewPresentation, type CompareReviewPresentation } from "../contracts/review.js";
|
||||
import { renderPublicComment, platformSectionMerge, type PublicCommentState } from "./pr-comment-body.js";
|
||||
import { renderPublicComment, platformSectionMerge, reviewChangeCount, type PublicCommentState } from "./pr-comment-body.js";
|
||||
import type { ExplorePlatform } from "../config/explore-config.js";
|
||||
import { upsertStickyComment } from "./pr-comment.js";
|
||||
import { previewLinks, viewerLinks } from "./viewer-links.js";
|
||||
@@ -214,7 +214,7 @@ async function publishCompareSummary(input: CiReportInput, options: { artifactUr
|
||||
runAttempt: review.runAttempt, configPath: input.commentState.configPath, artifactUrl: options.artifactUrl,
|
||||
...(options.platform ? { platform: options.platform } : {}) });
|
||||
const changes = input.commentState.review ?? review;
|
||||
const count = changes.surfaces.filter(surface => surface.review ? surface.review.status !== "unchanged" && surface.review.status !== "variant" : surface.status !== "unchanged").length;
|
||||
const count = reviewChangeCount({ review: changes }) ?? 0;
|
||||
const platform = (options.platform ?? review.runtime.platform) === "android" ? "Android" : "iOS";
|
||||
if (environment.GITHUB_STEP_SUMMARY) {
|
||||
await appendFile(environment.GITHUB_STEP_SUMMARY, `- ${platform} report of ${compareTitleMarkdown(comparison)}: [Open](${links.viewer!.open}) · [zip](${links.download!}) · ${count} ${count === 1 ? "change" : "changes"}\n`);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { PublicReview } from "../contracts/capture.js";
|
||||
import type { SimulatorRuntimeMetadata } from "../capture/run.js";
|
||||
import { CI_COMMENT_MARKER } from "./pr-comment.js";
|
||||
import { CHANGE_GROUPS, foldRecord, historyLine, readCommentRecords, recordLine, recordSummary, type ChangeGroup, type CommentPlatform, type CommentRecords, type HistoryEntry, type PlatformRecord } from "./pr-comment-record.js";
|
||||
import { sourceImpactSentences } from "../contracts/source-change.js";
|
||||
import { CHANGE_GROUPS, changeCountText, foldRecord, strongerGroup, historyLine, readCommentRecords, recordLine, recordSummary, type ChangeGroup, type CommentPlatform, type CommentRecords, type HistoryEntry, type PlatformRecord } from "./pr-comment-record.js";
|
||||
import { isAccessibilityOnlyChange } from "../contracts/review-validation.js";
|
||||
import type { PublicCaptureHealth, PublicEvidenceSummary } from "../review/evidence-assessment.js";
|
||||
import type { ReviewPresentation } from "../contracts/review.js";
|
||||
import type { ViewerLinks } from "./viewer-links.js";
|
||||
@@ -60,8 +60,8 @@ const GROUP_LABEL: Record<ReviewGroup, string> = {
|
||||
added: "🟩 Added",
|
||||
modified: "🟧 Modified",
|
||||
removed: "🟥 Removed",
|
||||
"accessibility-only": "🟦 Accessibility only",
|
||||
"needs-review": "🟨 Needs review",
|
||||
"source-affected": "🟨 Source-affected",
|
||||
};
|
||||
|
||||
/** The body is HTML, so no blank lines are needed and the block keeps its natural spacing. */
|
||||
@@ -121,16 +121,32 @@ function plural(count: number, noun: string): string {
|
||||
|
||||
type Surface = PublicReview["surfaces"][number];
|
||||
|
||||
/** Evidence-based group when the run produced verdicts; otherwise the source-based status. */
|
||||
function groupOf(surface: Surface, evidenceBased: boolean): ReviewGroup | "unchanged" | "variant" {
|
||||
/**
|
||||
* The group a surface is listed under, from the run's verdicts. A screen without one (its source changed but no
|
||||
* screenshots were compared) is not listed: Explore reports what the captures show. A capture that failed is counted as
|
||||
* unavailable in the result and named under Validation instead.
|
||||
*/
|
||||
function groupOf(surface: Surface, evidenceBased: boolean): ReviewGroup | "unlisted" {
|
||||
if (surface.status === "added" || surface.status === "removed") return surface.status;
|
||||
const verified = (["base", "head"] as const).every(side => surface[`${side}Image`]
|
||||
&& surface[`${side}Outcome`]?.status === "captured" && surface[`${side}Outcome`]?.landing === "verified");
|
||||
if (evidenceBased && verified && surface.review && surface.visual?.reason !== "diff-failed") return surface.review.status;
|
||||
switch (surface.status) {
|
||||
case "modified": return "source-affected";
|
||||
case "unchanged": return "unchanged";
|
||||
if (evidenceBased && verified && surface.review && surface.visual?.reason !== "diff-failed") {
|
||||
const status = surface.review.status;
|
||||
if (status === "unchanged" || status === "variant") return "unlisted";
|
||||
return isAccessibilityOnlyChange(surface) ? "accessibility-only" : status;
|
||||
}
|
||||
return "unlisted";
|
||||
}
|
||||
|
||||
/**
|
||||
* A screen whose source changed and whose captures were both verified, but that has no verdict: the comparison did
|
||||
* not run or failed. Not a change, but not a screen that looks the same either, so the result says how many.
|
||||
*/
|
||||
function notComparedChange(surface: Surface): boolean {
|
||||
if (surface.status !== "modified" || (surface.head ?? surface.base)?.kind === "redirect") return false;
|
||||
const verified = (["base", "head"] as const).every(side => surface[`${side}Image`]
|
||||
&& surface[`${side}Outcome`]?.status === "captured" && surface[`${side}Outcome`]?.landing === "verified");
|
||||
return verified && (!surface.review || surface.visual?.reason === "diff-failed");
|
||||
}
|
||||
|
||||
function routeOf(surface: Surface): string {
|
||||
@@ -143,9 +159,6 @@ function descriptionOf(surface: Surface, group: ReviewGroup): string {
|
||||
if (group === "added") return `Added ${route} screen`;
|
||||
if (group === "removed") return `Removed ${route} screen`;
|
||||
// A group's own label already says added or removed; the route makes the line readable alone.
|
||||
if (group === "source-affected") {
|
||||
return sourceImpactSentences(surface.sourceImpact) ?? "Source-affected; not compared";
|
||||
}
|
||||
if (surface.review) return plainText(surface.review.description, MAX_DESCRIPTION_LENGTH);
|
||||
return "No visible change";
|
||||
}
|
||||
@@ -270,10 +283,12 @@ export function platformRecordOf(state: PublicCommentState, platform?: CommentPl
|
||||
for (const surface of state.review.surfaces) {
|
||||
if ((surface.head ?? surface.base)?.kind === "redirect") continue;
|
||||
const group = groupOf(surface, evidenceBased);
|
||||
if (group === "unchanged" || group === "variant") continue;
|
||||
if (group === "unlisted") continue;
|
||||
const scheme = schemeOf(surface.id);
|
||||
record.changes.push({ id: surface.id, route: routeOf(surface), group, description: descriptionOf(surface, group), ...(scheme ? { scheme } : {}) });
|
||||
}
|
||||
const notCompared = state.review.surfaces.filter(notComparedChange).length;
|
||||
if (notCompared) record.notCompared = notCompared;
|
||||
record.context = contextLines(state.review).filter(line => line.length);
|
||||
const diagnostics = [...(state.evidence?.diagnostics ?? [])];
|
||||
for (const surface of state.review.surfaces) {
|
||||
@@ -318,12 +333,12 @@ function resultCell(record: PlatformRecord): string {
|
||||
}
|
||||
case "failed": return `🟥 failed · ${inlineText(record.failure?.step ?? "capture", 48)}`;
|
||||
case "ready": {
|
||||
const changes = record.changes?.length ?? 0;
|
||||
const unavailable = record.health ? record.health.base.unavailable + record.health.head.unavailable : 0;
|
||||
const unverified = record.health ? record.health.base.unverified + record.health.head.unverified : 0;
|
||||
const failed = (record.validation?.visual?.failed ?? 0) + (record.validation?.accessibility?.failed ?? 0);
|
||||
const icon = unavailable || unverified || failed ? "🟨" : "🟩";
|
||||
return [`${icon} ${plural(changes, "change")}`, unavailable ? `${unavailable} unavailable` : undefined, unverified ? `${unverified} unattributed` : undefined,
|
||||
const notCompared = record.notCompared ?? 0;
|
||||
const icon = unavailable || unverified || failed || notCompared ? "🟨" : "🟩";
|
||||
return [`${icon} ${changeCountText(record.changes?.map(change => change.group) ?? [])}`, notCompared ? `${notCompared} not compared` : undefined, unavailable ? `${unavailable} unavailable` : undefined, unverified ? `${unverified} unattributed` : undefined,
|
||||
failed ? `${failed} comparison${failed === 1 ? "" : "s"} failed` : undefined, duration(record.startedAt, record.updatedAt)].filter(Boolean).join(" · ");
|
||||
}
|
||||
}
|
||||
@@ -363,6 +378,8 @@ function changeRows(records: PlatformRecord[]): Map<ReviewGroup, ChangeRow[]> {
|
||||
for (const change of record.changes ?? []) {
|
||||
const href = record.links.report ? surfaceLink(record.links.report, change.id) : undefined;
|
||||
const row = rows.get(change.id) ?? { id: change.id, route: change.route, group: change.group, description: change.description, perPlatform: {}, ...(change.scheme ? { scheme: change.scheme } : {}) };
|
||||
// A screen accessibility-only on one platform and visibly changed on another is listed as the visible change.
|
||||
if (strongerGroup(row.group, change.group) !== row.group) Object.assign(row, { group: change.group, description: change.description });
|
||||
row.perPlatform[record.platform] = { group: change.group, ...(href ? { href } : {}) };
|
||||
rows.set(change.id, row);
|
||||
}
|
||||
@@ -390,12 +407,14 @@ function changesSection(records: PlatformRecord[], platforms: CommentPlatform[],
|
||||
const lines: string[] = [];
|
||||
const total = [...groups.values()].reduce((sum, rows) => sum + rows.length, 0);
|
||||
lines.push(`**Changes** · ${plural(total, "screen")}${platforms.length > 1 && ready.length > 1 ? " · a screen is listed once, with a link per platform" : ""}`, "");
|
||||
if (total === 0) lines.push("No screen changed on the reviewed platforms.", "");
|
||||
// With screens left uncompared, nothing changed only among the ones compared.
|
||||
if (total === 0) lines.push(ready.some(record => record.notCompared) ? "No compared screen changed on the reviewed platforms." : "No screen changed on the reviewed platforms.", "");
|
||||
for (const group of GROUP_ORDER) {
|
||||
const rows = groups.get(group) ?? [];
|
||||
if (!rows.length) continue;
|
||||
const shown = rows.slice(0, rowCap);
|
||||
const content = ["", ...shown.map(row => renderChangeRow(row, platforms))];
|
||||
const content = ["", ...(group === "accessibility-only" ? ["Before and After look the same. What screen readers and voice control read changed.", ""] : []),
|
||||
...shown.map(row => renderChangeRow(row, platforms))];
|
||||
if (rows.length > shown.length) {
|
||||
const report = ready.find(record => record.links.report)?.links.report;
|
||||
content.push(`- ${rows.length - shown.length} more${report ? ` — ${link("Explore report", report)}` : ""}`);
|
||||
@@ -606,19 +625,28 @@ export function reviewChanges(review: PublicReview): Map<string, ChangeGroup> {
|
||||
for (const surface of review.surfaces) {
|
||||
if ((surface.head ?? surface.base)?.kind === "redirect") continue;
|
||||
const group = groupOf(surface, evidenceBased);
|
||||
if (group !== "unchanged" && group !== "variant") changes.set(surface.id, group);
|
||||
if (group !== "unlisted") changes.set(surface.id, group);
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
/** Surfaces the review calls changed (reviewer verdicts first, raw status otherwise); undefined before the review exists. */
|
||||
/** How many screens the comment lists as changed; undefined before the review exists. */
|
||||
export function reviewChangeCount(state: Pick<PublicCommentState, "review">): number | undefined {
|
||||
return state.review?.surfaces.filter(surface => surface.review ? surface.review.status !== "unchanged" && surface.review.status !== "variant"
|
||||
: surface.status !== "unchanged").length;
|
||||
return state.review ? reviewChanges(state.review).size : undefined;
|
||||
}
|
||||
|
||||
export { recordSummary, readCommentRecords };
|
||||
|
||||
/** A surface's status in the local text summary, named as the comment groups it. */
|
||||
function localStatus(surface: Surface): string {
|
||||
if (isAccessibilityOnlyChange(surface)) return "accessibility only";
|
||||
if (surface.review) return surface.review.status;
|
||||
if (surface.status === "added" || surface.status === "removed") return surface.status;
|
||||
const failed = (["base", "head"] as const).some(side => surface[side]?.kind === "screen" && !surface[`${side}Image`]
|
||||
&& surface[`${side}Outcome`] && surface[`${side}Outcome`]?.status !== "captured");
|
||||
return failed ? "unavailable" : "not compared";
|
||||
}
|
||||
|
||||
function renderLocalText(state: PublicCommentState): string {
|
||||
const pr = state.pullRequest as Extract<ReviewPresentation, { origin: "local" }>;
|
||||
const counts = state.capture;
|
||||
@@ -630,6 +658,6 @@ function renderLocalText(state: PublicCommentState): string {
|
||||
...(counts && counts.planned.base + counts.planned.head === 0 ? ["No captures selected; visual comparison was not required.", ""] : []),
|
||||
...(state.review?.surfaces.filter(s => (s.status === "added" || s.status === "removed"
|
||||
|| s.baseOutcome || s.headOutcome || s.review) && s.review?.status !== "unchanged" && s.review?.status !== "variant").map(s =>
|
||||
`- ${inlineText((s.head ?? s.base)?.route ?? s.id, 160)}: ${s.review?.status ?? (s.status === "added" || s.status === "removed" ? s.status : "not compared")}${s.note ? ` — ${inlineText(s.note.text, 500)}` : ""}`) ?? []),
|
||||
`- ${inlineText((s.head ?? s.base)?.route ?? s.id, 160)}: ${localStatus(s)}${s.note ? ` — ${inlineText(s.note.text, 500)}` : ""}`) ?? []),
|
||||
"", ...(state.review ? contextLines(state.review) : []), "Report: artifacts/report.zip", "Details: README.md, agent-mode-cost.md, issues.md", ""].join("\n");
|
||||
}
|
||||
@@ -13,8 +13,32 @@ import { deflateRawSync, inflateRawSync } from "node:zlib";
|
||||
*/
|
||||
export type CommentPlatform = "ios" | "android";
|
||||
export type RecordPhase = "pending" | "capturing" | "ready" | "failed";
|
||||
export type ChangeGroup = "added" | "modified" | "removed" | "needs-review" | "source-affected";
|
||||
export const CHANGE_GROUPS: ChangeGroup[] = ["added", "removed", "modified", "needs-review", "source-affected"];
|
||||
/**
|
||||
* `accessibility-only`: modified, but the screenshots match; only what assistive technology reads changed. A screen
|
||||
* whose source changed but that was not compared is no group: Explore reports what the captures show, not what the code
|
||||
* might do.
|
||||
*/
|
||||
export type ChangeGroup = "added" | "modified" | "removed" | "accessibility-only" | "needs-review";
|
||||
export const CHANGE_GROUPS: ChangeGroup[] = ["added", "removed", "modified", "accessibility-only", "needs-review"];
|
||||
|
||||
/**
|
||||
* "12 changes", or "3 visual changes · 12 accessibility only" when some changed only for assistive technology: those
|
||||
* are changes too (screen readers and voice control see them), but not ones a screenshot shows.
|
||||
*/
|
||||
/**
|
||||
* The group of a screen that changed on several platforms. Accessibility only says the screenshots match, so it
|
||||
* yields to any other group; otherwise the first platform's group stands, as it always has.
|
||||
*/
|
||||
export function strongerGroup(first: ChangeGroup, other: ChangeGroup): ChangeGroup {
|
||||
return first === "accessibility-only" ? other : first;
|
||||
}
|
||||
|
||||
export function changeCountText(groups: readonly ChangeGroup[]): string {
|
||||
const accessibility = groups.filter(group => group === "accessibility-only").length;
|
||||
const visual = groups.length - accessibility;
|
||||
if (!accessibility) return `${visual} change${visual === 1 ? "" : "s"}`;
|
||||
return [visual ? `${visual} visual change${visual === 1 ? "" : "s"}` : undefined, `${accessibility} accessibility only`].filter(Boolean).join(" · ");
|
||||
}
|
||||
|
||||
export type SideHealth = { planned: number; captured: number; verified: number; unverified: number; unavailable: number };
|
||||
|
||||
@@ -41,6 +65,8 @@ export type PlatformRecord = {
|
||||
};
|
||||
/** The review's changed surfaces, one per surface; `scheme` for a secondary appearance (`<route>@<scheme>`). */
|
||||
changes?: { id: string; route: string; group: ChangeGroup; description: string; scheme?: string }[];
|
||||
/** Screens whose source changed and whose captures were verified, but that got no verdict: the comparison did not run or failed. */
|
||||
notCompared?: number;
|
||||
/** Differences stated once rather than per screen (variants, app-wide source changes). */
|
||||
context?: string[];
|
||||
diagnostics?: { side?: "base" | "head"; route: string; code: string; message: string; nextAction: string }[];
|
||||
@@ -166,6 +192,7 @@ export function parsePlatformRecord(value: unknown): PlatformRecord | undefined
|
||||
&& isString(entry.message) && isString(entry.nextAction)
|
||||
? [{ ...(isSide(entry.side) ? { side: entry.side } : {}), route: entry.route, code: entry.code, message: entry.message, nextAction: entry.nextAction }] : []).slice(0, 20);
|
||||
}
|
||||
if (isCount(value.notCompared) && value.notCompared > 0) record.notCompared = value.notCompared;
|
||||
if (isCount(value.diagnosticCount)) record.diagnosticCount = value.diagnosticCount;
|
||||
if (isRecord(value.failure) && isString(value.failure.step, 200) && isString(value.failure.message)) record.failure = { step: value.failure.step, message: value.failure.message };
|
||||
if (value.superseded === true) record.superseded = true;
|
||||
@@ -207,13 +234,12 @@ export function readCommentRecords(body: string | undefined): CommentRecords {
|
||||
|
||||
/** A short result for a run that is no longer current: "🟩 34 changes", "🟨 12 changes · 4 unavailable", "🟥 failed · capture". */
|
||||
export function recordSummary(record: PlatformRecord): string {
|
||||
const changes = record.changes?.length;
|
||||
switch (record.phase) {
|
||||
case "failed": return `🟥 failed · ${record.failure?.step ?? "capture"}`;
|
||||
case "ready": {
|
||||
const unavailable = record.health ? record.health.base.unavailable + record.health.head.unavailable : 0;
|
||||
const icon = unavailable > 0 || (record.validation?.visual?.failed ?? 0) > 0 ? "🟨" : "🟩";
|
||||
return `${icon} ${changes ?? 0} change${changes === 1 ? "" : "s"}${unavailable > 0 ? ` · ${unavailable} unavailable` : ""}`;
|
||||
const icon = unavailable > 0 || (record.validation?.visual?.failed ?? 0) > 0 || record.notCompared ? "🟨" : "🟩";
|
||||
return `${icon} ${changeCountText(record.changes?.map(change => change.group) ?? [])}${unavailable > 0 ? ` · ${unavailable} unavailable` : ""}${record.notCompared ? ` · ${record.notCompared} not compared` : ""}`;
|
||||
}
|
||||
default: return "⏳ did not finish";
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { exploreCacheRoot } from "../shared/cache-root.js";
|
||||
import { MAX_METADATA_BYTES } from "./agent-api.js";
|
||||
import { normalizePublicReviewForReading } from "../contracts/review-validation.js";
|
||||
import { reviewChanges, reviewDevice } from "./pr-comment-body.js";
|
||||
import type { ChangeGroup } from "./pr-comment-record.js";
|
||||
import { strongerGroup, type ChangeGroup } from "./pr-comment-record.js";
|
||||
import { readZipDirectory, readZipEntry } from "./zip-reader.js";
|
||||
|
||||
/**
|
||||
@@ -100,9 +100,12 @@ export async function describeReports(reports: SavedReport[], extra: { subjects?
|
||||
const review = reviews[0];
|
||||
const pr = review?.pullRequest;
|
||||
if (!review || !pr) throw new Error("Not an Explore review report");
|
||||
// One surface changed on two platforms is one change, under the first platform's group, as the PR comment lists it.
|
||||
// One surface changed on two platforms is one change, under the group the PR comment lists it in (strongerGroup).
|
||||
const merged = new Map<string, ChangeGroup>();
|
||||
for (const each of reviews) if (each) for (const [id, group] of reviewChanges(normalizePublicReviewForReading(each))) if (!merged.has(id)) merged.set(id, group);
|
||||
for (const each of reviews) if (each) for (const [id, group] of reviewChanges(normalizePublicReviewForReading(each))) {
|
||||
const first = merged.get(id);
|
||||
merged.set(id, first ? strongerGroup(first, group) : group);
|
||||
}
|
||||
const changes: Partial<Record<ChangeGroup, number>> = {};
|
||||
for (const group of merged.values()) changes[group] = (changes[group] ?? 0) + 1;
|
||||
const devices = [...new Set(reviews.map(each => each ? reviewDevice({ runtime: { deviceModel: each.runtime?.device?.model ?? "", osVersion: each.runtime?.device?.osVersion ?? "",
|
||||
|
||||
@@ -1005,7 +1005,7 @@ test("a docs-only report with zero images and no EAS build opens Screens without
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test("unverified capture diagnostics stay separate from verified Needs review and source impact filters", async t => {
|
||||
test("unverified capture diagnostics stay separate from verified Needs review, and source changes nobody compared are not changes", async t => {
|
||||
const report = reportFixture();
|
||||
const home = report.review.surfaces[0];
|
||||
const uncertain = structuredClone(home);
|
||||
@@ -1029,12 +1029,13 @@ test("unverified capture diagnostics stay separate from verified Needs review an
|
||||
await expect(page.locator(".app-shell")).toBeVisible();
|
||||
await page.getByRole("button", { name: "Screens", exact: true }).click();
|
||||
await expect(page.locator(".screens-page .diff-frame.diff-needs-review")).toHaveCount(1);
|
||||
await expect(page.locator(".screens-page .diff-frame.diff-source-affected")).toHaveCount(2);
|
||||
await expect(page.locator(".screens-page .diff-frame.diff-not-compared")).toHaveCount(1);
|
||||
// The unverified /home and the never-captured /candidate changed in source only: not compared, like /untouched.
|
||||
await expect(page.locator(".screens-page .diff-frame.diff-source-affected")).toHaveCount(0);
|
||||
await expect(page.locator(".screens-page .diff-frame.diff-not-compared")).toHaveCount(3);
|
||||
await expect(page.locator(".screens-page .diff-frame.diff-modified")).toHaveCount(0);
|
||||
const menu = await openChangesMenu(page);
|
||||
const chips = menu.getByRole("group", { name: "Filter changes" }).getByRole("button");
|
||||
await expect(chips).toHaveText(["Modified 0", "No visible change 1", "Source-affected 2"]);
|
||||
await expect(chips).toHaveText(["Modified 0", "No visible change 1"]);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
@@ -1068,8 +1069,8 @@ test("an existing report with operational verdicts opens as diagnostics without
|
||||
const { page, errors } = await harness(t, await archive(report), { app: true });
|
||||
await expect(page.locator(".app-shell")).toBeVisible();
|
||||
await page.getByRole("button", { name: "Screens", exact: true }).click();
|
||||
await expect(page.locator(".screens-page .diff-frame.diff-source-affected")).toHaveCount(1);
|
||||
await expect(page.locator(".screens-page .diff-frame.diff-not-compared")).toHaveCount(1);
|
||||
await expect(page.locator(".screens-page .diff-frame.diff-source-affected")).toHaveCount(0);
|
||||
await expect(page.locator(".screens-page .diff-frame.diff-not-compared")).toHaveCount(2);
|
||||
await expect(page.locator(".screens-page .diff-frame.diff-unavailable")).toHaveCount(1, "an added route whose capture failed has nothing to show");
|
||||
await expect(page.locator(".screens-page .diff-frame.diff-removed")).toHaveCount(1);
|
||||
await expect(page.locator(".diff-frame.diff-needs-review, .diff-frame.diff-modified, .diff-frame.diff-unchanged, .diff-frame.diff-added")).toHaveCount(0);
|
||||
|
||||
@@ -103,7 +103,7 @@ const Navigation=createStaticNavigation(Root); export default function App(){ret
|
||||
const pullRequestPath = join(root, 'pull-request.json'); await writeFile(pullRequestPath, JSON.stringify(pr));
|
||||
const environment = { PATH: process.env.PATH, HOME: root, RUNNER_TEMP: root, EXPO_TOKEN: 'test-expo-secret', GITHUB_TOKEN: 'test-github-secret',
|
||||
GITHUB_RUN_ID: '1234', GITHUB_RUN_ATTEMPT: '1', GITHUB_REPOSITORY: pr.repository, TOOLS_COMMIT: 'c'.repeat(40), EXPLORE_VIEWER_ORIGIN: 'https://viewer.example' };
|
||||
const requests = []; const comments = []; const sessions = new Map(); let currentSession; let currentPath = '/'; let sessionCounter = 0; let repackedSha; let openFailed = false; let currentScheme = 'light';
|
||||
const requests = []; const comments = []; const sessions = new Map(); let currentSession; const idleDevice = { path: '/', scheme: 'light' }; let sessionCounter = 0; let repackedSha; let openFailed = false;
|
||||
const identity = () => ({ session: 'expo-explore-runtime', appBundleId: config.app.bundleId,
|
||||
device: { id: 'device-1', name: config.device.name, platform, target: 'mobile', osVersion: '26.0', locale: 'en-US', orientation: 'portrait', colorScheme: 'light' },
|
||||
identifiers: { session: 'expo-explore-runtime', appBundleId: config.app.bundleId, deviceId: 'device-1', deviceName: config.device.name } });
|
||||
@@ -140,8 +140,8 @@ const Navigation=createStaticNavigation(Root); export default function App(){ret
|
||||
return json({ jobs: [{ key: 'repack', status: 'SUCCESS', outputs: { build_id: `repacked-${repackedSha}`, platform } }] });
|
||||
}
|
||||
if (command === 'simulator:start') {
|
||||
const id = `session-${++sessionCounter}`; currentSession = id; currentPath = '/'; openFailed = false;
|
||||
const session = { id, name: value(request, '--name'), build: value(request, '--build-id') }; sessions.set(id, session);
|
||||
const id = `session-${++sessionCounter}`; currentSession = id; openFailed = false;
|
||||
const session = { id, name: value(request, '--name'), build: value(request, '--build-id'), path: '/', scheme: 'light' }; sessions.set(id, session);
|
||||
writeFileSync(join(request.cwd, '.env.eas-simulator'), `${HEADER}EAS_SIMULATOR_SESSION_ID='${id}'\nAGENT_DEVICE_DAEMON_BASE_URL='https://controller.example/${id}'\nAGENT_DEVICE_DAEMON_AUTH_TOKEN='controller-private-token'\n`);
|
||||
return { stdout: 'ready', stderr: '' };
|
||||
}
|
||||
@@ -155,6 +155,9 @@ const Navigation=createStaticNavigation(Root); export default function App(){ret
|
||||
return { stdout: '', stderr: '' };
|
||||
}
|
||||
if (basename(request.command) === 'agent-device') {
|
||||
// Base and head capture in parallel, each on its own simulator: a request names its session in the daemon URL,
|
||||
// so the route, appearance and build it sees are that session's, not whichever session started last.
|
||||
const device = sessions.get(/\/([^/]+)$/.exec(request.environment?.AGENT_DEVICE_DAEMON_BASE_URL ?? '')?.[1]) ?? sessions.get(currentSession) ?? idleDevice;
|
||||
if (command === '--version') return { stdout: AGENT_DEVICE_VERSION, stderr: '' };
|
||||
if (command === 'open') {
|
||||
if (request.args[2]?.startsWith('sample://')) {
|
||||
@@ -162,7 +165,7 @@ const Navigation=createStaticNavigation(Root); export default function App(){ret
|
||||
openFailed = true;
|
||||
return json({ success: false, error: { code: 'COMMAND_FAILED', message: 'The app is not ready for this link yet.' } });
|
||||
}
|
||||
currentPath = '/' + request.args[2].slice('sample://'.length);
|
||||
device.path = '/' + request.args[2].slice('sample://'.length);
|
||||
}
|
||||
return ok(identity());
|
||||
}
|
||||
@@ -170,17 +173,17 @@ const Navigation=createStaticNavigation(Root); export default function App(){ret
|
||||
if (command === 'wait') return ok({});
|
||||
if (command === 'alert' && request.args[1] === 'get') return json({ success: false, error: { code: 'COMMAND_FAILED', message: 'alert not found' } });
|
||||
if (command === 'snapshot') {
|
||||
const dynamic = currentPath.startsWith('/item/');
|
||||
const dynamic = device.path.startsWith('/item/');
|
||||
const destination = provider === 'expo-router'
|
||||
? { provider, pathname: currentPath, segments: dynamic ? ['item', '[id]'] : currentPath.split('/').filter(Boolean), parameters: dynamic ? { id: currentPath.slice('/item/'.length) } : {} }
|
||||
: { provider, segments: [currentPath.slice(1).replace(/^./, first => first.toUpperCase())], parameters: {} };
|
||||
? { provider, pathname: device.path, segments: dynamic ? ['item', '[id]'] : device.path.split('/').filter(Boolean), parameters: dynamic ? { id: device.path.slice('/item/'.length) } : {} }
|
||||
: { provider, segments: [device.path.slice(1).replace(/^./, first => first.toUpperCase())], parameters: {} };
|
||||
return ok({ truncated: false, nodes: [
|
||||
{ index: 0, type: 'StaticText', label: currentPath, identifier: 'screen-title', enabled: true, visible: true, rect: { x: 0, y: 0, width: 16, height: 24 } },
|
||||
...(currentPath === observerFailurePath ? [] : [{ index: 1, type: 'StaticText', label: JSON.stringify(destination), identifier: CAPTURE_OBSERVER_IDENTIFIER, enabled: true, visible: true }]),
|
||||
{ index: 0, type: 'StaticText', label: device.path, identifier: 'screen-title', enabled: true, visible: true, rect: { x: 0, y: 0, width: 16, height: 24 } },
|
||||
...(device.path === observerFailurePath ? [] : [{ index: 1, type: 'StaticText', label: JSON.stringify(destination), identifier: CAPTURE_OBSERVER_IDENTIFIER, enabled: true, visible: true }]),
|
||||
] });
|
||||
}
|
||||
if (command === 'settings') { if (request.args[1] === 'appearance') currentScheme = request.args[2]; return ok({ setting: request.args[1], value: request.args[2] }); }
|
||||
if (command === 'screenshot') { const color = createHash('sha256').update(`${currentPath}:${currentScheme}:${currentPath === '/home' ? sessions.get(currentSession).build : 'unchanged-source'}`).digest(); const data = Buffer.alloc(16 * 24 * 4); for (let i = 0; i < data.length; i += 4) { data[i] = color[0]; data[i + 1] = color[1]; data[i + 2] = color[2]; data[i + 3] = 255; } writeFileSync(request.args[1], PNG.sync.write({ width: 16, height: 24, data })); return ok({ path: request.args[1] }); }
|
||||
if (command === 'settings') { if (request.args[1] === 'appearance') device.scheme = request.args[2]; return ok({ setting: request.args[1], value: request.args[2] }); }
|
||||
if (command === 'screenshot') { const color = createHash('sha256').update(`${device.path}:${device.scheme}:${device.path === '/home' ? device.build : 'unchanged-source'}`).digest(); const data = Buffer.alloc(16 * 24 * 4); for (let i = 0; i < data.length; i += 4) { data[i] = color[0]; data[i + 1] = color[1]; data[i + 2] = color[2]; data[i + 3] = 255; } writeFileSync(request.args[1], PNG.sync.write({ width: 16, height: 24, data })); return ok({ path: request.args[1] }); }
|
||||
}
|
||||
throw new Error(`Unexpected mocked command: ${request.command} ${request.args.join(' ')}`);
|
||||
};
|
||||
|
||||
@@ -2,16 +2,44 @@ import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
const { tsImport } = await import("tsx/esm/api");
|
||||
const { isVisibleChange } = await tsImport("../../viewer/src/utils/changed-screens.ts", import.meta.url);
|
||||
const { isCapturedChange } = await tsImport("../../viewer/src/utils/changed-screens.ts", import.meta.url);
|
||||
|
||||
test("only a change the captures show counts for Compare and Screens' Changed filter", () => {
|
||||
assert.equal(isVisibleChange({ status: "added" }), true);
|
||||
assert.equal(isVisibleChange({ status: "removed" }), true);
|
||||
assert.equal(isVisibleChange({ status: "modified" }), true);
|
||||
// The source changed but the captures look the same.
|
||||
assert.equal(isVisibleChange({ status: "modified", notVisible: true }), false);
|
||||
assert.equal(isVisibleChange({ status: "needs-review" }), false);
|
||||
assert.equal(isVisibleChange({ status: "source-affected" }), false);
|
||||
assert.equal(isVisibleChange({ status: "unchanged" }), false);
|
||||
assert.equal(isVisibleChange(undefined), false);
|
||||
assert.equal(isCapturedChange({ status: "added" }), true);
|
||||
assert.equal(isCapturedChange({ status: "removed" }), true);
|
||||
assert.equal(isCapturedChange({ status: "modified" }), true);
|
||||
// The screenshots match but the accessibility tree changed: screen readers see it, so it is reviewed.
|
||||
assert.equal(isCapturedChange({ status: "modified", accessibilityOnly: true }), true);
|
||||
// The source changed but the captures show nothing different.
|
||||
assert.equal(isCapturedChange({ status: "needs-review" }), false);
|
||||
assert.equal(isCapturedChange({ status: "source-affected" }), false);
|
||||
assert.equal(isCapturedChange({ status: "unchanged" }), false);
|
||||
assert.equal(isCapturedChange(undefined), false);
|
||||
});
|
||||
|
||||
const { splitForAssistiveTechnology } = await tsImport("../../viewer/src/utils/presented-changes.ts", import.meta.url);
|
||||
|
||||
test("What changed lists what assistive technology reads under its own heading", () => {
|
||||
const change = (id, category) => ({ id, copy: id, fact: { id, category, templateId: `${category}.x`, priority: 0, evidenceRefs: [] } });
|
||||
const changes = [change("Added button “Play”.", "element"), change("Changed accessibility label.", "accessibility")];
|
||||
const ids = ({ visible, assistive }) => [visible.map(entry => entry.id), assistive.map(entry => entry.id)];
|
||||
// Pixels differ: an added element may be visible, a label is not.
|
||||
assert.deepEqual(ids(splitForAssistiveTechnology(changes, { status: "modified" })), [["Added button “Play”."], ["Changed accessibility label."]]);
|
||||
// The screenshots match: nothing on the screen looks different, so every finding is for assistive technology.
|
||||
assert.deepEqual(ids(splitForAssistiveTechnology(changes, { status: "modified", accessibilityOnly: true })), [[], ["Added button “Play”.", "Changed accessibility label."]]);
|
||||
// A reviewer note is not a finding about the accessibility tree.
|
||||
assert.deepEqual(ids(splitForAssistiveTechnology([{ id: "review-note", copy: "Note" }], { status: "modified", accessibilityOnly: true })), [["review-note"], []]);
|
||||
});
|
||||
|
||||
const { focusCounts, focusStatusOf } = await tsImport("../../viewer/src/utils/changed-screens.ts", import.meta.url);
|
||||
|
||||
test("the Changes filter counts Accessibility only apart from Modified", () => {
|
||||
const screens = new Map([
|
||||
["a", { status: "modified" }], ["b", { status: "modified", accessibilityOnly: true }], ["c", { status: "modified", accessibilityOnly: true }],
|
||||
["d", { status: "added" }], ["e", { status: "not-compared" }], ["f", { status: "unchanged" }],
|
||||
]);
|
||||
assert.deepEqual(focusCounts({ screens }), { added: 1, modified: 1, "accessibility-only": 2, removed: 0, "needs-review": 0, "source-affected": 0 });
|
||||
assert.equal(focusStatusOf({ status: "modified", accessibilityOnly: true }), "accessibility-only");
|
||||
assert.equal(focusStatusOf({ status: "modified" }), "modified");
|
||||
assert.equal(focusStatusOf(undefined), undefined);
|
||||
});
|
||||
@@ -196,14 +196,15 @@ test('an OS version the simulator did not report is omitted, not shown as unknow
|
||||
assert.doesNotMatch(body, /unknown/i);
|
||||
});
|
||||
|
||||
test('without evidence the comment falls back to source statuses and says comparisons did not run', () => {
|
||||
test('without evidence the comment lists only added and removed screens and says comparisons did not run', () => {
|
||||
const plain = review([surface('care-guide', 'added'), surface('sweet-bee', 'removed'), surface('settings', 'modified'), surface('cats', 'unchanged')]);
|
||||
const body = renderPublicComment(reviewOnlyState(plain));
|
||||
assert.match(body, /<summary>🟨 Source-affected \(1\)<\/summary>/);
|
||||
assert.match(body, /\n- `\/settings` — Source\\-affected; not compared · \[iOS\]/);
|
||||
// A source change nobody compared is not a change the captures show.
|
||||
assert.deepEqual(summaries(body).slice(0, 2), ['🟩 Added (1)', '🟥 Removed (1)']);
|
||||
assert.doesNotMatch(body, /Source-affected|screen=settings/);
|
||||
assert.equal(checkRow(body, 'Visual comparison'), '| Visual comparison | 🟨 not run |');
|
||||
assert.equal(checkRow(body, 'Accessibility comparison'), '| Accessibility comparison | 🟨 not run |');
|
||||
assert.match(platformRow(body, 'iOS'), /^\| iOS \| Example 1\\\.4\\\.0 \\\(27\\\) \| 🟩 3 changes · 0s \|/);
|
||||
assert.match(platformRow(body, 'iOS'), /^\| iOS \| Example 1\\\.4\\\.0 \\\(27\\\) \| 🟨 2 changes · 1 not compared · 0s \|/, 'the uncompared /settings is counted, not hidden');
|
||||
assert.doesNotMatch(body, /Needs review|Unchanged|screen=cats/);
|
||||
});
|
||||
|
||||
@@ -261,8 +262,10 @@ test('capture problems are listed as diagnostics inside the validation block wit
|
||||
flagged.surfaces[2].headOutcome.landing = 'unverified';
|
||||
flagged.surfaces[2].review = { status: 'needs-review', description: 'old destination failure' };
|
||||
const body = renderPublicComment(state({ review: flagged, capture: { planned: { base: 3, head: 3 }, done: { base: 1, head: 2 }, baseFromCache: false } }));
|
||||
assert.deepEqual(summaries(body), ['🟩 Added (1)', '🟥 Removed (1)', '🟨 Source-affected (1)', 'Validation · iOS 🟨 3/6 captured']);
|
||||
assert.match(platformRow(body, 'iOS'), /\| 🟨 3 changes · 3 unavailable · 1 unattributed · 6m 12s \|/);
|
||||
// /settings could not be compared, so it is no change: its failures are named under Validation.
|
||||
assert.deepEqual(summaries(body), ['🟩 Added (1)', '🟥 Removed (1)', 'Validation · iOS 🟨 3/6 captured']);
|
||||
assert.match(platformRow(body, 'iOS'), /\| 🟨 2 changes · 3 unavailable · 1 unattributed · 6m 12s \|/);
|
||||
assert.match(body, /\n- Base · \/settings · /);
|
||||
assert.match(body, /\*\*iOS\*\* · base 1\/3 verified · 2 unavailable · head 1\/3 verified · 1 unattributed · 1 unavailable/);
|
||||
assert.match(body, /\n- Base · \/cats\/sweet\\-bee · BASE\\_SESSION\\_FAILED: base simulator disconnected; token=\\\[redacted\\\] Next action: Restart the base simulator session and rerun capture\\\./);
|
||||
assert.match(body, /\n- Head · \/cats\/care\\-guide · HEAD\\_SESSION\\_FAILED/);
|
||||
@@ -284,7 +287,7 @@ test('zero eligible pairs are visibly skipped instead of successful comparisons'
|
||||
assert.equal(checkRow(body, 'Route verification'), '| Route verification | 🟨 0/6 verified · 6 unattributed |');
|
||||
assert.equal(checkRow(body, 'Visual comparison'), '| Visual comparison | 🟨 0 compared · threshold 0.1 · 2 skipped |');
|
||||
assert.equal(checkRow(body, 'Accessibility comparison'), '| Accessibility comparison | 🟨 0 compared · 0 descriptions |');
|
||||
assert.match(platformRow(body, 'iOS'), /\| 🟨 4 changes · 6 unattributed · 6m 12s \|/);
|
||||
assert.match(platformRow(body, 'iOS'), /\| 🟨 2 changes · 6 unattributed · 6m 12s \|/, 'the uncompared modified screens are not changes');
|
||||
});
|
||||
|
||||
test('the review-only comment counts failed outcomes in planned coverage and lists the reason', () => {
|
||||
@@ -450,3 +453,64 @@ test('a report whose hosted preview is still deploying says so instead of linkin
|
||||
assert.equal(record.links.report, undefined, 'the record carries no report link while deploying');
|
||||
assert.equal(parsePlatformRecord(record).links.deploying, true, 'the deploying flag survives the comment round trip');
|
||||
});
|
||||
|
||||
test('a screen whose screenshots match but whose accessibility tree changed is listed as accessibility only, apart from the visual changes', () => {
|
||||
const accessibilityOnly = (id) => surface(id, 'modified', { extra: {
|
||||
review: { status: 'modified', description: 'Added button “Edit tempo”.', facts: [
|
||||
{ category: 'element', templateId: 'element.added', bullet: 'Added button “Edit tempo”.' },
|
||||
{ category: 'accessibility', templateId: 'accessibility.label-changed', bullet: 'Changed accessibility label from “lane-row-title-3” to “Clap”.' },
|
||||
] },
|
||||
visual: { verdict: 'unchanged', reason: 'matched', mismatchPercentage: 0, threshold: 0.1, tool: '[email protected]' },
|
||||
sourceChange: sourceChange('Labelled the lane rows.'),
|
||||
} });
|
||||
const withAccessibility = review([...evidenceReview().surfaces, accessibilityOnly('device-picker'), accessibilityOnly('enable-midi')]);
|
||||
const body = renderPublicComment(state({ review: withAccessibility, artifactOnly: true }));
|
||||
assert.match(platformRow(body, 'iOS'), /\| 🟩 3 visual changes · 2 accessibility only · 6m 12s \|/);
|
||||
assert.deepEqual(summaries(body), ['🟩 Added (1)', '🟥 Removed (1)', '🟧 Modified (1)', '🟦 Accessibility only (2)', 'Validation · iOS 🟩 10/10 captured']);
|
||||
assert.match(body, /\n\*\*Changes\*\* · 5 screens\n/);
|
||||
assert.match(body, /<summary>🟦 Accessibility only \(2\)<\/summary>\n\nBefore and After look the same\. What screen readers and voice control read changed\.\n\n- `\/device-picker` — Added button “Edit tempo”\\\. · \[iOS\]/);
|
||||
const record = parsePlatformRecord(JSON.parse(JSON.stringify(platformRecordOf(state({ review: withAccessibility, artifactOnly: true })))));
|
||||
assert.deepEqual(record.changes.filter(change => change.group === 'accessibility-only').map(change => change.id), ['device-picker', 'enable-midi'],
|
||||
'the group survives the comment round trip');
|
||||
// A comment with no accessibility-only screen keeps its plain count.
|
||||
assert.match(platformRow(renderPublicComment(state({ artifactOnly: true })), 'iOS'), /\| 🟩 3 changes · 6m 12s \|/);
|
||||
});
|
||||
|
||||
test('a comment whose only changes are for assistive technology counts just those', () => {
|
||||
const only = review([surface('device-picker', 'modified', { extra: {
|
||||
review: { status: 'modified', description: 'Changed “Play” from a text to a button.', facts: [{ category: 'accessibility', templateId: 'accessibility.role-changed', bullet: 'Changed “Play” from a text to a button.' }] },
|
||||
visual: { verdict: 'unchanged', reason: 'matched', mismatchPercentage: 0, threshold: 0.1, tool: '[email protected]' },
|
||||
sourceChange: sourceChange('Made Play a button.'),
|
||||
} })]);
|
||||
assert.match(platformRow(renderPublicComment(state({ review: only, artifactOnly: true })), 'iOS'), /\| 🟩 1 accessibility only · 6m 12s \|/);
|
||||
});
|
||||
|
||||
test('a screen accessibility-only on iOS and visibly modified on Android is listed as Modified, whichever platform comes first', async () => {
|
||||
const { platformSectionMerge } = await import('../../dist/report/pr-comment-body.js');
|
||||
const settings = (verdict) => {
|
||||
const changed = evidenceReview();
|
||||
changed.surfaces[2].visual = { ...changed.surfaces[2].visual, verdict, mismatchPercentage: verdict === 'modified' ? 3.2 : 0 };
|
||||
return changed;
|
||||
};
|
||||
const androidState = overrides => state({ artifactOnly: true, build: { ...state().build, platform: 'android' },
|
||||
runtime: { ...state().runtime, platform: 'android', deviceModel: 'EasAndroidDevice01', osVersion: '15.0' }, ...overrides });
|
||||
const ios = renderPublicComment(state({ review: settings('unchanged'), artifactOnly: true }));
|
||||
assert.ok(summaries(ios).includes('🟦 Accessibility only (1)'), 'iOS alone: the screenshots match');
|
||||
const both = platformSectionMerge(androidState({ review: settings('modified') }), 'android').merge(ios);
|
||||
assert.deepEqual(summaries(both).slice(0, 3), ['🟩 Added (1)', '🟥 Removed (1)', '🟧 Modified (1)']);
|
||||
assert.doesNotMatch(both, /Accessibility only \(|Before and After look the same/);
|
||||
assert.match(both, /\n- `\/settings` — [^\n]+ · \[iOS \(accessibility only\)\]\(<[^>]+>\) · \[Android\]\(<[^>]+>\)\n/);
|
||||
});
|
||||
|
||||
test('screens whose comparison did not run are counted as not compared, never as a green "no change"', () => {
|
||||
const uncompared = review([surface('settings', 'modified'), surface('tempo', 'modified')]);
|
||||
const body = renderPublicComment(state({ review: uncompared, artifactOnly: true }));
|
||||
assert.match(platformRow(body, 'iOS'), /\| 🟨 0 changes · 2 not compared · 6m 12s \|/);
|
||||
assert.match(body, /\nNo compared screen changed on the reviewed platforms\.\n/);
|
||||
// A screen that was never captured (outside the capture scope) stays out of the count.
|
||||
const outOfScope = surface('channel', 'modified');
|
||||
for (const key of ['baseImage', 'headImage', 'baseOutcome', 'headOutcome']) delete outOfScope[key];
|
||||
const quiet = renderPublicComment(state({ review: review([outOfScope]), artifactOnly: true, evidence: undefined, capture: { planned: { base: 0, head: 0 }, done: { base: 0, head: 0 }, baseFromCache: false } }));
|
||||
assert.match(platformRow(quiet, 'iOS'), /\| 🟩 0 changes · 6m 12s \|/);
|
||||
assert.match(quiet, /\nNo screen changed on the reviewed platforms\.\n/);
|
||||
});
|
||||
@@ -211,7 +211,7 @@ test("public inventory preserves source classification while unverified images s
|
||||
const workspace = publicReviewToWorkspace(review);
|
||||
const { baseline, current } = workspaceSides(workspace);
|
||||
assert.deepEqual(workspace.comparison.entries.map(({ id, status }) => ({ id, status })), [
|
||||
{ id: "games-free", status: "source-affected" }, { id: "games-pro", status: "not-compared" },
|
||||
{ id: "games-free", status: "not-compared" }, { id: "games-pro", status: "not-compared" },
|
||||
{ id: "care-guide", status: "added" }, { id: "sweet-bee", status: "removed" },
|
||||
{ id: "scan-mood", status: "not-compared" }, { id: "scan-breed", status: "not-compared" },
|
||||
{ id: "home", status: "not-compared" }, { id: "camera-alias", status: "not-compared" },
|
||||
@@ -231,9 +231,9 @@ test("public inventory preserves source classification while unverified images s
|
||||
assert.ok(payload.map.screens.every((screen) => !screen.start && !screen.terminal));
|
||||
}
|
||||
const diff = diffFor(review);
|
||||
assert.equal(diff.screens.get("games-free").status, "source-affected", "Equal PNG hashes cannot prove verified destinations");
|
||||
assert.equal(diff.screens.get("games-free").status, "not-compared", "Equal PNG hashes cannot prove verified destinations");
|
||||
assert.equal(diff.screens.get("games-pro").status, "not-compared", "Different PNG hashes cannot prove a route modification");
|
||||
assert.deepEqual(diff.counts, { added: 1, modified: 0, removed: 1, unchanged: 0, "needs-review": 0, "source-affected": 1, "not-compared": 5, unavailable: 0, variant: 0 });
|
||||
assert.deepEqual(diff.counts, { added: 1, modified: 0, removed: 1, unchanged: 0, "needs-review": 0, "source-affected": 0, "not-compared": 6, unavailable: 0, variant: 0 });
|
||||
assert.equal(workspace.review, undefined, "The adapter must not fabricate semantic review evidence");
|
||||
assert.deepEqual(review, before, "The source publication remains immutable");
|
||||
});
|
||||
@@ -281,7 +281,7 @@ test("existing route-family presentation groups query variants without losing th
|
||||
assert.equal(scan.observationIds.length, 2);
|
||||
assert.deepEqual(scan.variantIds.map((id) => presentation.index.variants.get(id).name), ["mood", "breed"]);
|
||||
const displayed = presentBuildDiff(diff, presentation);
|
||||
assert.deepEqual(displayed.counts, { added: 1, modified: 0, removed: 1, unchanged: 0, "needs-review": 0, "source-affected": 1, "not-compared": 3, unavailable: 0, variant: 0 });
|
||||
assert.deepEqual(displayed.counts, { added: 1, modified: 0, removed: 1, unchanged: 0, "needs-review": 0, "source-affected": 0, "not-compared": 4, unavailable: 0, variant: 0 });
|
||||
assert.equal(presentation.map.screens.length, 6);
|
||||
assert.equal(scan.title, "Scan — Instruction");
|
||||
const graph = buildObservedGraph(presentation.map, presentation.index);
|
||||
@@ -455,7 +455,7 @@ test("What changed uses commit-bound Git summaries without changing screenshot i
|
||||
review.surfaces[0].sourceChange = summary;
|
||||
const diff = diffFor(review).screens.get("games-free");
|
||||
assert.equal(diff.changeSummary, summary.summary);
|
||||
assert.equal(diff.status, "source-affected");
|
||||
assert.equal(diff.status, "not-compared");
|
||||
assert.equal(diff.beforeScreenshot, review.surfaces[0].baseImage.url);
|
||||
assert.equal(diff.afterScreenshot, review.surfaces[0].headImage.url);
|
||||
assert.doesNotMatch(diff.changeSummary, /Visual changes have not been classified/);
|
||||
@@ -583,16 +583,16 @@ test("public notes survive viewer projection without changing deterministic verd
|
||||
});
|
||||
|
||||
|
||||
test("source-only impact and untouched uncaptured inventory stay distinct from runtime verdicts", () => {
|
||||
test("a source change without a comparison is not compared, as untouched uncaptured inventory is: it is no change the captures show", () => {
|
||||
const review = fixture("changes");
|
||||
delete review.surfaces[0].baseImage;
|
||||
delete review.surfaces[0].headImage;
|
||||
const diff = diffFor(review);
|
||||
assert.equal(diff.screens.get("games-free").status, "source-affected");
|
||||
assert.equal(diff.screens.get("games-free").status, "not-compared");
|
||||
assert.equal(diff.screens.get("games-pro").status, "not-compared");
|
||||
assert.equal(diff.counts.modified, 0);
|
||||
assert.equal(diff.counts.unchanged, 0);
|
||||
assert.equal(diff.counts["source-affected"], 1);
|
||||
assert.equal(diff.counts["source-affected"], 0);
|
||||
assert.equal(review.surfaces[0].status, "modified", "source classification is retained without inventing a visual verdict");
|
||||
});
|
||||
|
||||
@@ -657,7 +657,7 @@ test("unverified captures on either side remain diagnostics and cannot become ap
|
||||
assert.equal(affected.coverage.observations, 6, "an unverified image is retained as diagnostic evidence");
|
||||
assert.match(affected.map.gaps.find(gap => gap.screenId === surface.id).message, /destination unverified/);
|
||||
const diff = diffFor(review);
|
||||
assert.equal(diff.screens.get(surface.id).status, "source-affected");
|
||||
assert.equal(diff.screens.get(surface.id).status, "not-compared");
|
||||
assert.equal(diff.screens.get(surface.id).noVisibleChange, false);
|
||||
assert.deepEqual(diff.screens.get(surface.id).reviewerChanges, []);
|
||||
assert.equal(diff.counts["needs-review"], 0);
|
||||
@@ -710,7 +710,7 @@ test("direct reads of existing operational verdicts preserve diagnostics without
|
||||
deepFreeze(input);
|
||||
publicReviewToWorkspace(input);
|
||||
const diff = diffFor(input);
|
||||
assert.equal(diff.screens.get(surface.id).status, "source-affected");
|
||||
assert.equal(diff.screens.get(surface.id).status, "not-compared");
|
||||
assert.equal(diff.counts["needs-review"], 0);
|
||||
assert.deepEqual(diff.screens.get(surface.id).reviewerChanges, []);
|
||||
assert.equal(surface.review.status, "needs-review", "the original report is not mutated by reading");
|
||||
|
||||
@@ -51,7 +51,7 @@ test('round trip: iOS and Android jobs of one run share a single comment: one ro
|
||||
assert.equal(comment.match(/^### Explore review/gm).length, 1, 'one header');
|
||||
const routeLines = comment.split('\n').filter(line => /^- `\/(added|removed|home)`/.test(line));
|
||||
assert.ok(routeLines.length >= 1, `the comment lists changed routes once:\n${comment}`);
|
||||
assert.equal(routeLines.length, 6, 'each changed screen is listed once');
|
||||
assert.equal(routeLines.length, 6, `each changed screen is listed once:\n${comment}`);
|
||||
for (const line of routeLines) assert.ok(/\[iOS\]\(/.test(line) && /\[Android\]\(/.test(line), `each changed route carries both platforms once: ${line}`);
|
||||
const projection = publicReviewProjection(android.report.review);
|
||||
for (const surface of android.report.review.surfaces) assert.ok(projection.surfaces[surface.id], `the Viewer projects the Android surface ${surface.id}`);
|
||||
|
||||
@@ -180,3 +180,29 @@ test('cached captures go after 30 days unused, then the least recently used past
|
||||
assert.deepEqual((await readdir(join(environment.EXPLORE_CACHE_DIR, 'captures', 'ios'))), ['c'.repeat(40)]);
|
||||
assert.ok(newest);
|
||||
});
|
||||
|
||||
test('a screen accessibility-only on one platform and visibly modified on the other counts as modified, whatever the order', async t => {
|
||||
const { readZipDirectory, readZipEntry } = await import('../../dist/report/zip-reader.js');
|
||||
const directory = readZipDirectory(review);
|
||||
const original = JSON.parse(new TextDecoder().decode(await readZipEntry(review, directory.get('review.json'), 50_000_000)));
|
||||
const variant = async (platform, verdict) => {
|
||||
const report = structuredClone(original);
|
||||
report.review.runtime.platform = platform;
|
||||
const surface = report.review.surfaces.find(entry => entry.id === 'expo-cats-add-9b770c554b11');
|
||||
surface.review = { status: 'modified', description: 'Changed accessibility label from “Add” to “Add a cat”.',
|
||||
facts: [{ category: 'accessibility', templateId: 'accessibility.label-changed', bullet: 'Changed accessibility label from “Add” to “Add a cat”.' }] };
|
||||
surface.visual = { ...surface.visual, verdict, mismatchPercentage: verdict === 'modified' ? 2.4 : 0 };
|
||||
const folder = await mkdtemp(join(tmpdir(), 'explore-saved-a11y-'));
|
||||
t.after(() => rm(folder, { recursive: true, force: true }));
|
||||
await writeFile(join(folder, 'review.json'), JSON.stringify(report));
|
||||
return zipReportDirectory(folder);
|
||||
};
|
||||
const ios = { platform: 'ios', zip: await variant('ios', 'unchanged') };
|
||||
const android = { platform: 'android', zip: await variant('android', 'modified') };
|
||||
const alone = (await describeReports([ios])).changes;
|
||||
assert.equal(alone['accessibility-only'], 1, 'on iOS alone the screenshots match');
|
||||
const both = (await describeReports([ios, android])).changes;
|
||||
assert.equal(both['accessibility-only'], undefined);
|
||||
assert.equal(both.modified, alone.modified + 1, 'the Android visual change is what the run counts');
|
||||
assert.deepEqual((await describeReports([android, ios])).changes, both);
|
||||
});
|
||||
@@ -327,3 +327,27 @@ test("keeps source provenance while reducing the viewer to route-level screens",
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test("a route family is accessibility-only only when every changed member is", () => {
|
||||
const family = (statuses) => {
|
||||
// Screens recorded on one router path are one family.
|
||||
const members = statuses.map((_, index) => screen(`screen-${index}`, `Policy ${index}`, "/policies", [`variant-${index}`]));
|
||||
const sourceMap = mapWith(members);
|
||||
const presentation = presentationModel.presentScreensByPath(sourceMap);
|
||||
const screens = new Map(members.map((member, index) => {
|
||||
const [status, accessibilityOnly] = statuses[index];
|
||||
return [member.id, { status, changeSummary: "", reviewerChanges: [], runtimeEvidenceRefs: [], noVisibleChange: false,
|
||||
...(status !== "added" ? { beforeScreenshot: `before-${index}.png` } : {}), afterScreenshot: `after-${index}.png`,
|
||||
...(accessibilityOnly ? { accessibilityOnly: true } : {}) }];
|
||||
}));
|
||||
const presented = presentationModel.presentBuildDiff({ baselineId: "build-1", map: sourceMap, index: indexMap(sourceMap), screens,
|
||||
counts: { added: 0, modified: 0, removed: 0, unchanged: 0 } }, presentation);
|
||||
assert.equal(presented.screens.size, 1, "the members are one family");
|
||||
return [...presented.screens.values()][0];
|
||||
};
|
||||
assert.equal(family([["modified", true], ["modified", true]]).accessibilityOnly, true);
|
||||
assert.equal(family([["modified", true], ["unchanged", false]]).accessibilityOnly, true);
|
||||
// An added or visibly modified member is a visible change, so the family is not accessibility-only.
|
||||
assert.equal(family([["modified", true], ["added", false]]).accessibilityOnly, undefined);
|
||||
assert.equal(family([["modified", true], ["modified", false]]).accessibilityOnly, undefined);
|
||||
});
|
||||
@@ -4,7 +4,7 @@ import { webcrypto, createHash } from "node:crypto";
|
||||
import { deflateRawSync } from "node:zlib";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { PREVIEW_CIPHER, previewResponse, type PreviewEnvironment } from "../src/server/preview";
|
||||
import { agentApiReply, loadReport, prefersHtml, prefersMarkdown } from "../../src/report/agent-api";
|
||||
import { agentApiReply, agentIndexMarkdown, loadReport, prefersHtml, prefersMarkdown } from "../../src/report/agent-api";
|
||||
import { readZipDirectory } from "../../src/report/zip-reader";
|
||||
|
||||
const subtle = webcrypto.subtle as SubtleCrypto;
|
||||
@@ -105,7 +105,7 @@ test("the token page negotiates: browsers get the shell carrying the agent index
|
||||
const shell = await browser.text();
|
||||
assert.ok(shell.startsWith("<!doctype html>"));
|
||||
assert.match(shell, /<div id="root"><section data-explore-agent-index style="[^"]*clip:rect\(0 0 0 0\)[^"]*"><h1>Expo Explore report: .* PR #\d+/);
|
||||
assert.match(shell, new RegExp(`href="${origin}/p/${token}/api/v1/screens\\?status=modified,added,removed"`));
|
||||
assert.match(shell, new RegExp(`href="${origin}/p/${token}/api/v1/screens\\?status=modified,accessibility-only,added,removed"`));
|
||||
assert.match(shell, /<\/section><\/div><script type="module"/);
|
||||
assert.equal(browser.headers.get("vary"), "Accept");
|
||||
assert.equal(browser.headers.get("link"), `<${origin}/p/${token}/api/v1>; rel="alternate"; type="application/json", <${origin}/p/${token}/llms.txt>; rel="alternate"; type="text/markdown"`);
|
||||
@@ -119,7 +119,7 @@ test("the token page negotiates: browsers get the shell carrying the agent index
|
||||
const body = await response.text();
|
||||
assert.match(body, /^# Expo Explore report: /, String(accept));
|
||||
assert.match(body, /This link stops serving the report after 2030-01-01T00:00:00.000Z/);
|
||||
assert.ok(body.includes(`(${origin}/p/${token}/api/v1/screens?status=modified,added,removed)`), body);
|
||||
assert.ok(body.includes(`(${origin}/p/${token}/api/v1/screens?status=modified,accessibility-only,added,removed)`), body);
|
||||
assert.equal(response.headers.get("content-security-policy"), browser.headers.get("content-security-policy"));
|
||||
}
|
||||
const llms = await site.get("/llms.txt", "text/html");
|
||||
@@ -306,3 +306,31 @@ test("screens count and filter by what changed visibly: a source change with mat
|
||||
const midi = all.items.find((item: { id: string }) => item.id === "enable-midi");
|
||||
assert.deepEqual([midi.status, midi.sourceStatus], ["unchanged", "modified"], "its source status is still there");
|
||||
});
|
||||
|
||||
test("statuses follow the Viewer: accessibility-only, unavailable for a failed or misattributed capture, not-compared for the rest", async () => {
|
||||
const side = (id: string) => ({ route: `/${id}`, kind: "screen" });
|
||||
const verified = { status: "captured", landing: "verified", attempts: 1 };
|
||||
const surface = (id: string, verdict: string) => ({ id, status: "modified", sourceScope: "screen", head: side(id), base: side(id),
|
||||
headImage: { sha256: "c".repeat(64) }, baseImage: { sha256: "c".repeat(64) }, headOutcome: verified, baseOutcome: verified,
|
||||
review: { status: "modified", description: "Added button “Edit tempo”." }, visual: { verdict, reason: "matched", threshold: 0.1, tool: "agent-device" } });
|
||||
const report = { kind: "explore.report", review: { contract: "explore.review", pullRequest: { origin: "local", repository: "a/b", title: "HEAD vs main", base: { ref: "main", sha: "a".repeat(40) }, head: { ref: "HEAD", sha: "b".repeat(40) } },
|
||||
runtime: { platform: "ios" }, surfaces: [surface("tempo", "modified"), surface("device-picker", "unchanged"),
|
||||
// Its source changed but nothing was compared: not a change Explore saw.
|
||||
{ id: "c-explore", status: "modified", sourceScope: "screen", head: side("c/_explore"), base: side("c/_explore") },
|
||||
// Its head capture failed, and another landed on the wrong screen: both unavailable, as the Viewer says.
|
||||
{ id: "cards", status: "modified", sourceScope: "screen", head: side("cards"), base: side("cards"), baseImage: { sha256: "c".repeat(64) },
|
||||
baseOutcome: verified, headOutcome: { status: "failed", attempts: 1, landing: "unverified" } },
|
||||
{ id: "login", status: "modified", sourceScope: "screen", head: side("login"), base: side("login"), ...{ baseImage: { sha256: "c".repeat(64) }, headImage: { sha256: "c".repeat(64) } },
|
||||
baseOutcome: verified, headOutcome: { status: "captured", attempts: 2, landing: "unverified", observed: { reason: "landing-mismatch", route: "/home", attempts: 2 } } }] }, assets: [] };
|
||||
const loaded = (await loadReport(zip({ "review.json": new TextEncoder().encode(JSON.stringify(report)) })))!;
|
||||
const context = { pageUrl: "http://127.0.0.1:1/p/t", platforms: ["ios"], expiresAt: null };
|
||||
const summary = JSON.parse((await agentApiReply(context, loaded, "", new URLSearchParams(), "application/json")).body as string);
|
||||
assert.deepEqual(summary.screens, { total: 5, modified: 1, "accessibility-only": 1, "not-compared": 1, unavailable: 2 });
|
||||
const unavailable = JSON.parse((await agentApiReply(context, loaded, "/screens", new URLSearchParams("status=unavailable"), "application/json")).body as string);
|
||||
assert.deepEqual(unavailable.items.map((item: { id: string }) => item.id), ["cards", "login"]);
|
||||
// The index sentence names every status, so its parts add up to the total.
|
||||
assert.match(agentIndexMarkdown(context, loaded), /5 screens: 1 modified, 1 accessibility only \(screenshots match, the accessibility tree does not\), 2 unavailable, 1 not compared\./);
|
||||
assert.match(summary.links.changed, /status=modified,accessibility-only,added,removed/);
|
||||
const only = JSON.parse((await agentApiReply(context, loaded, "/screens", new URLSearchParams("status=accessibility-only"), "application/json")).body as string);
|
||||
assert.deepEqual(only.items.map((item: { id: string; status: string; sourceStatus: string }) => [item.id, item.status, item.sourceStatus]), [["device-picker", "accessibility-only", "modified"]]);
|
||||
});
|
||||
+3
-9
@@ -12,7 +12,7 @@ import { AppLoading } from "./components/shared/app-loading";
|
||||
import { ReportLoadingShell } from "./components/shared/report-loading-shell";
|
||||
import { screenLabel } from "./utils/screen-path";
|
||||
import { AppPill, PLATFORM_NAMES } from "./components/panels/app-pill";
|
||||
import { changedScreens, isVisibleChange, type ChangedScreen } from "./utils/changed-screens";
|
||||
import { changedScreens, focusCounts as countFocusStatuses, isCapturedChange, type ChangedScreen } from "./utils/changed-screens";
|
||||
import { MapView } from "./components/views/semantic-map";
|
||||
import { RightPanel } from "./components/panels/right";
|
||||
import { SearchCommand } from "./components/search-command";
|
||||
@@ -1181,16 +1181,10 @@ function ViewerApp() {
|
||||
), [presentedMap, workspace]);
|
||||
// Focus singles out diff states, so it means nothing without a baseline to diff against.
|
||||
const focusFilter = diff ? route.focus : [];
|
||||
const focusCounts = {
|
||||
added: diff?.counts.added ?? 0,
|
||||
modified: diff?.counts.modified ?? 0,
|
||||
removed: diff?.counts.removed ?? 0,
|
||||
"needs-review": diff?.counts["needs-review"] ?? 0,
|
||||
"source-affected": diff?.counts["source-affected"] ?? 0,
|
||||
};
|
||||
const focusCounts = useMemo(() => countFocusStatuses(diff), [diff]);
|
||||
const index = diff?.index ?? screenPresentation?.index;
|
||||
const compareOrder = useMemo(
|
||||
() => (diff && index ? changedScreens(diff, index).filter(entry => isVisibleChange(diff.screens.get(entry.id))) : []),
|
||||
() => (diff && index ? changedScreens(diff, index).filter(entry => isCapturedChange(diff.screens.get(entry.id))) : []),
|
||||
[diff, index],
|
||||
);
|
||||
compareOrderRef.current = compareOrder;
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import { diffLabel, type DiffStatus } from "../../utils/build-diff";
|
||||
import { diffClass, diffLabel, type DiffStatus } from "../../utils/build-diff";
|
||||
|
||||
/**
|
||||
* Colour ring + label chip around a screenshot item on any canvas. It sits outside the
|
||||
* item's box (negative margins) so layout geometry is untouched. Renders as a span so it can
|
||||
* sit inside a button.
|
||||
*/
|
||||
export function DiffFrame(props: { status?: DiffStatus | undefined; notVisible?: boolean | undefined; children: React.ReactNode }) {
|
||||
export function DiffFrame(props: { status?: DiffStatus | undefined; accessibilityOnly?: boolean | undefined; children: React.ReactNode }) {
|
||||
const status = props.status ?? "unchanged";
|
||||
const label = diffLabel({ status, ...(props.notVisible ? { notVisible: true as const } : {}) });
|
||||
const diff = { status, ...(props.accessibilityOnly ? { accessibilityOnly: true as const } : {}) };
|
||||
const label = diffLabel(diff);
|
||||
return (
|
||||
<span className={`diff-frame diff-${status}`}>
|
||||
<span className={`diff-frame ${diffClass(diff)}`}>
|
||||
{status !== "unchanged" && (
|
||||
<span className="diff-label" aria-label={`${label} in this build`}>
|
||||
{label}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { CSSProperties, MouseEventHandler, ReactNode } from "react";
|
||||
import { ImageOff, PanelRight } from "lucide-react";
|
||||
import type { DiffStatus } from "../../utils/build-diff";
|
||||
import { diffClass, type DiffStatus } from "../../utils/build-diff";
|
||||
import { ScreenPathText } from "../shared/screen-path-text";
|
||||
import { DEFAULT_SCREENSHOT_SIZE, ScreenshotImage } from "../shared/screenshot-image";
|
||||
import { CanvasActiveFrame } from "./active-frame";
|
||||
@@ -15,8 +15,8 @@ export type ScreenScreenshotCardProps = {
|
||||
/** Shown in place of the image when the run recorded why there is none. */
|
||||
missingReason?: string;
|
||||
diff?: DiffStatus;
|
||||
/** A modified screen whose screenshots match: the label says the change is not visible. */
|
||||
notVisible?: boolean;
|
||||
/** A modified screen whose screenshots match: the label says only what assistive technology reads changed. */
|
||||
accessibilityOnly?: boolean;
|
||||
className?: string;
|
||||
style?: CSSProperties;
|
||||
selected?: boolean;
|
||||
@@ -56,7 +56,7 @@ export function ScreenScreenshotCard(props: ScreenScreenshotCardProps) {
|
||||
"screen-screenshot-card",
|
||||
props.className,
|
||||
// The status class carries the frame colour to the card, so its handles can share it.
|
||||
props.diff ? `diff-${props.diff}` : undefined,
|
||||
props.diff ? diffClass({ status: props.diff, ...(props.accessibilityOnly ? { accessibilityOnly: true as const } : {}) }) : undefined,
|
||||
props.selected ? "selected" : undefined,
|
||||
props.highlighted ? "highlighted" : undefined,
|
||||
].filter(Boolean).join(" ");
|
||||
@@ -92,7 +92,7 @@ export function ScreenScreenshotCard(props: ScreenScreenshotCardProps) {
|
||||
aria-label={props.ariaLabel ?? `Open ${props.plainTitle ? props.title : props.path}`}
|
||||
{...(props.ariaPressed !== undefined ? { "aria-pressed": props.ariaPressed } : {})}
|
||||
onClick={props.onClick}>
|
||||
<DiffFrame status={props.diff} notVisible={props.notVisible}>
|
||||
<DiffFrame status={props.diff} accessibilityOnly={props.accessibilityOnly}>
|
||||
<span className={`screen-node-image${props.screenshot ? " has-screenshot" : " is-missing"}`}>
|
||||
{props.screenshot ? (
|
||||
<ScreenshotImage
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useEffect, useId, useRef } from "react";
|
||||
import { ChevronLeft, ChevronRight, List } from "lucide-react";
|
||||
import { ChangesMenu } from "../panels/changes-menu";
|
||||
import { StatusGlyph } from "../shared/status-icon";
|
||||
@@ -15,6 +15,8 @@ import type { ComparePicker } from "./compare-section";
|
||||
*/
|
||||
export function CompareNav(props: {
|
||||
status: DiffStatus;
|
||||
/** Modified only in what assistive technology reads: the mark takes that status's colour and shape. */
|
||||
accessibilityOnly?: boolean | undefined;
|
||||
route: string;
|
||||
title: string;
|
||||
/** Zero-based; below zero when the screen is not in the order. */
|
||||
@@ -39,7 +41,7 @@ export function CompareNav(props: {
|
||||
disabled={!desktop || picker.open}>
|
||||
<button type="button" className="compare-nav-picker" aria-haspopup="true"
|
||||
aria-expanded={picker.open} onClick={() => picker.onOpenChange(!picker.open)}>
|
||||
<StatusGlyph status={props.status} label={props.statusLabel ?? DIFF_LABELS[props.status]} />
|
||||
<StatusGlyph status={props.status} accessibilityOnly={props.accessibilityOnly} label={props.statusLabel ?? DIFF_LABELS[props.status]} />
|
||||
{/* A route that does not fit loses its start, not the end that names the screen. */}
|
||||
<code className="compare-nav-route" title={props.title}><bdi>{props.route}</bdi></code>
|
||||
</button>
|
||||
@@ -87,9 +89,12 @@ export function CompareSteps(props: {
|
||||
|
||||
/**
|
||||
* What changed on a screen, as the phone's sheet and the desktop popover both list it: CI's
|
||||
* findings as bullets, then the notes about the comparison under a hairline.
|
||||
* findings as bullets, then what changed for assistive technology under its own heading, then the
|
||||
* notes about the comparison under a hairline.
|
||||
*/
|
||||
export function WhatChangedContent(props: { facts: string[]; notes: string[] }) {
|
||||
export function WhatChangedContent(props: { facts: string[]; assistive?: string[]; accessibilityOnly?: boolean | undefined; notes: string[] }) {
|
||||
const assistive = props.assistive ?? [];
|
||||
const assistiveTitle = useId();
|
||||
return (
|
||||
<div className="what-changed-content" role="region" aria-label="What changed on this screen">
|
||||
{props.facts.length > 0 ? (
|
||||
@@ -97,6 +102,22 @@ export function WhatChangedContent(props: { facts: string[]; notes: string[] })
|
||||
{props.facts.map((fact) => <li key={fact}>{fact}</li>)}
|
||||
</ul>
|
||||
) : null}
|
||||
{assistive.length > 0 ? (
|
||||
<section className="what-changed-assistive" aria-labelledby={assistiveTitle}>
|
||||
<h4 id={assistiveTitle} className="what-changed-assistive-title">
|
||||
<span className="status-glyph-dot diff-accessibility-only" aria-hidden="true" />
|
||||
For assistive technology
|
||||
</h4>
|
||||
<p className="what-changed-assistive-context">
|
||||
{props.accessibilityOnly
|
||||
? "Before and After look the same. Only what screen readers and voice control read changed."
|
||||
: "Read by screen readers and voice control, not shown in the screenshot."}
|
||||
</p>
|
||||
<ul className="what-changed-content-list">
|
||||
{assistive.map((fact) => <li key={fact}>{fact}</li>)}
|
||||
</ul>
|
||||
</section>
|
||||
) : null}
|
||||
{props.notes.length > 0 ? (
|
||||
<div className="what-changed-content-notes">
|
||||
{props.notes.map((note) => <p key={note}>{note}</p>)}
|
||||
@@ -113,13 +134,15 @@ export function WhatChangedContent(props: { facts: string[]; notes: string[] })
|
||||
*/
|
||||
export function WhatChangedPopover(props: {
|
||||
facts: string[];
|
||||
assistive?: string[];
|
||||
accessibilityOnly?: boolean | undefined;
|
||||
notes: string[];
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
}) {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
const { open, onOpenChange } = props;
|
||||
const empty = props.facts.length === 0 && props.notes.length === 0;
|
||||
const empty = props.facts.length === 0 && !props.assistive?.length && props.notes.length === 0;
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
const onPointerDown = (event: PointerEvent) => {
|
||||
@@ -149,8 +172,11 @@ export function WhatChangedPopover(props: {
|
||||
</Tooltip>
|
||||
{open ? (
|
||||
<div className="compare-what-changed-popover" role="dialog" aria-modal="false" aria-label="What changed">
|
||||
<strong className="compare-what-changed-popover-title">What changed</strong>
|
||||
<WhatChangedContent facts={props.facts} notes={props.notes} />
|
||||
{/* A screen that changed only for assistive technology has nothing else to title. */}
|
||||
{props.facts.length > 0 || props.notes.length > 0
|
||||
? <strong className="compare-what-changed-popover-title">What changed</strong> : null}
|
||||
<WhatChangedContent facts={props.facts} {...(props.assistive ? { assistive: props.assistive } : {})}
|
||||
accessibilityOnly={props.accessibilityOnly} notes={props.notes} />
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
@@ -196,6 +196,13 @@
|
||||
}
|
||||
.what-changed-content-list > li::marker { color: var(--tertiary); }
|
||||
.what-changed-content-notes { display: flex; flex-direction: column; gap: 6px; }
|
||||
/* What changed for assistive technology: its own heading, led by Accessibility only's blue square. */
|
||||
.what-changed-assistive { display: flex; flex-direction: column; gap: 6px; }
|
||||
.what-changed-content-list + .what-changed-assistive { padding-top: 12px; border-top: 1px solid var(--panel-line); }
|
||||
.what-changed-assistive-title { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text); font-size: 13px; font-weight: 600; line-height: 18px; }
|
||||
.what-changed-assistive-title > .status-glyph-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--diff); }
|
||||
.what-changed-assistive-context { margin: 0; color: var(--secondary); font-size: 12px; line-height: 17px; }
|
||||
.what-changed-assistive + .what-changed-content-notes { padding-top: 12px; border-top: 1px solid var(--panel-line); }
|
||||
.what-changed-content-list + .what-changed-content-notes { padding-top: 12px; border-top: 1px solid var(--panel-line); }
|
||||
.what-changed-content-notes > p { margin: 0; color: var(--secondary); font-size: 12px; line-height: 17px; }
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, type CSSProperties, type ReactNode, type RefObject } from "react";
|
||||
import { ImageOff, ScanSearch } from "lucide-react";
|
||||
import type { ChangesMenuData } from "../panels/changes-menu";
|
||||
import { diffLabel, NOT_VISIBLE_HIGHLIGHT, type BuildDiff, type ScreenDiff } from "../../utils/build-diff";
|
||||
import { diffLabel, ACCESSIBILITY_ONLY_HIGHLIGHT, type BuildDiff, type ScreenDiff } from "../../utils/build-diff";
|
||||
import type { MapIndex } from "../../utils/model";
|
||||
import type { ChangedScreen } from "../../utils/changed-screens";
|
||||
import { groupVisualRegions, type VisualChange } from "../../utils/visual-diff";
|
||||
@@ -13,7 +13,7 @@ import { ToggleGroup } from "../shared/toggle-group";
|
||||
import { Tooltip } from "../shared/tooltip";
|
||||
import { DEFAULT_SCREENSHOT_RATIO, ScreenshotImage, ScreenshotPlaceholder } from "../shared/screenshot-image";
|
||||
import { ChangeOutlines, HomeIndicatorBand, StatusBarBand, SwipeCompare, SWIPE_STEP } from "../panels/visual-diff";
|
||||
import { placeholderFor, presentedChanges } from "../../utils/presented-changes";
|
||||
import { placeholderFor, presentedChanges, splitForAssistiveTechnology } from "../../utils/presented-changes";
|
||||
import { CompareNav, WhatChangedPopover } from "./compare-header";
|
||||
import "./compare-section.css";
|
||||
|
||||
@@ -105,6 +105,8 @@ export function useCompareController(options: CompareControllerOptions) {
|
||||
() => presentedChanges(screenDiff).filter((change) => change.id !== "legacy-summary"),
|
||||
[screenDiff],
|
||||
);
|
||||
// What changed for assistive technology is listed under its own heading.
|
||||
const split = useMemo(() => splitForAssistiveTechnology(facts, screenDiff), [facts, screenDiff]);
|
||||
|
||||
const phone = usePhoneLayout();
|
||||
const [desktopMode, setDesktopMode] = useState<CompareMode>(() => storedMode(MODE_STORAGE_KEY, "split"));
|
||||
@@ -239,7 +241,7 @@ export function useCompareController(options: CompareControllerOptions) {
|
||||
const chosenMode: CompareMode = phone ? phoneMode : desktopMode;
|
||||
const modesDisabled = !comparable;
|
||||
return {
|
||||
screen, screenDiff, route, position, previous, next, comparable, areas, facts,
|
||||
screen, screenDiff, route, position, previous, next, comparable, areas, facts, split,
|
||||
mode, chosenMode, modesDisabled, chooseMode, modeOptions, outlines, shownOutlines, statusBarIgnored, homeIndicatorIgnored, toggleOutlines,
|
||||
activeArea, setActiveArea, stepArea, flipSide, flip, swipePosition, setSwipePosition,
|
||||
aspect, setAspect, factsOpen, setFactsOpen,
|
||||
@@ -318,8 +320,9 @@ export function CompareSection(props: CompareSectionProps) {
|
||||
</>
|
||||
) : null;
|
||||
|
||||
const factCopies = facts.map((fact) => fact.copy);
|
||||
const notes = compareNotes(screenDiff, factCopies.length, statusBarIgnored, homeIndicatorIgnored);
|
||||
const factCopies = compare.split.visible.map((fact) => fact.copy);
|
||||
const assistive = compare.split.assistive.map((fact) => fact.copy);
|
||||
const notes = compareNotes(screenDiff, facts.length, statusBarIgnored, homeIndicatorIgnored);
|
||||
|
||||
return (
|
||||
<section ref={sectionRef} className="compare-section" aria-label={`Compare ${route}`}
|
||||
@@ -328,7 +331,7 @@ export function CompareSection(props: CompareSectionProps) {
|
||||
how to look at it, and what to look for. The bottom toolbar stays the same on every section. */}
|
||||
<header className="compare-top">
|
||||
<div className="compare-bar">
|
||||
<CompareNav variant="desktop" status={screenDiff.status} statusLabel={diffLabel(screenDiff)} route={route} title={title}
|
||||
<CompareNav variant="desktop" status={screenDiff.status} accessibilityOnly={screenDiff.accessibilityOnly} statusLabel={diffLabel(screenDiff)} route={route} title={title}
|
||||
position={compare.position} count={props.order.length} picker={props.picker}
|
||||
onPrevious={compare.previous ? () => props.onSelectScreen(compare.previous!.id) : undefined}
|
||||
onNext={compare.next ? () => props.onSelectScreen(compare.next!.id) : undefined} />
|
||||
@@ -345,13 +348,14 @@ export function CompareSection(props: CompareSectionProps) {
|
||||
/>
|
||||
</div>
|
||||
<span className="toolbar-divider" aria-hidden="true" />
|
||||
<Tooltip label={screenDiff.notVisible ? NOT_VISIBLE_HIGHLIGHT : "Highlight changes"} shortcut={formatShortcut(SHORTCUTS.compare.outlines)} placement="bottom">
|
||||
<Tooltip label={screenDiff.accessibilityOnly ? ACCESSIBILITY_ONLY_HIGHLIGHT : "Highlight changes"} shortcut={formatShortcut(SHORTCUTS.compare.outlines)} placement="bottom">
|
||||
<button type="button" className="toolbar-button compare-outlines" aria-label="Highlight changes"
|
||||
aria-pressed={outlines} disabled={areas.length === 0} onClick={toggleOutlines}>
|
||||
<ScanSearch aria-hidden="true" />
|
||||
</button>
|
||||
</Tooltip>
|
||||
<WhatChangedPopover facts={factCopies} notes={notes} open={factsOpen} onOpenChange={setFactsOpen} />
|
||||
<WhatChangedPopover facts={factCopies} assistive={assistive} accessibilityOnly={screenDiff.accessibilityOnly}
|
||||
notes={notes} open={factsOpen} onOpenChange={setFactsOpen} />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
@@ -44,11 +44,14 @@ function ReviewModes(props: {
|
||||
*/
|
||||
function WhatChangedAccordion(props: {
|
||||
facts: string[];
|
||||
assistive?: string[];
|
||||
accessibilityOnly?: boolean | undefined;
|
||||
notes: string[];
|
||||
open: boolean;
|
||||
onOpenChange?: (open: boolean) => void;
|
||||
}) {
|
||||
const empty = !props.onOpenChange || (props.facts.length === 0 && props.notes.length === 0);
|
||||
const count = props.facts.length + (props.assistive?.length ?? 0);
|
||||
const empty = !props.onOpenChange || (count === 0 && props.notes.length === 0);
|
||||
const open = props.open && !empty;
|
||||
return (
|
||||
<section className="what-changed-accordion">
|
||||
@@ -60,7 +63,7 @@ function WhatChangedAccordion(props: {
|
||||
onClick={() => props.onOpenChange?.(!props.open)}>
|
||||
<span className="what-changed-toggle-title">
|
||||
What changed
|
||||
{props.facts.length > 0 ? <span className="what-changed-toggle-count">{props.facts.length}</span> : null}
|
||||
{count > 0 ? <span className="what-changed-toggle-count">{count}</span> : null}
|
||||
</span>
|
||||
<ChevronDown aria-hidden="true" />
|
||||
</button>
|
||||
@@ -68,7 +71,8 @@ function WhatChangedAccordion(props: {
|
||||
</div>
|
||||
{open ? (
|
||||
<div className="what-changed-accordion-content" id="what-changed-accordion-content">
|
||||
<WhatChangedContent facts={props.facts} notes={props.notes} />
|
||||
<WhatChangedContent facts={props.facts} {...(props.assistive ? { assistive: props.assistive } : {})}
|
||||
accessibilityOnly={props.accessibilityOnly} notes={props.notes} />
|
||||
</div>
|
||||
) : null}
|
||||
</section>
|
||||
@@ -109,7 +113,8 @@ export function SidebarReview(props: CompareControllerOptions) {
|
||||
</>
|
||||
)
|
||||
: null;
|
||||
const facts = compare.facts.map((fact) => fact.copy);
|
||||
const facts = compare.split.visible.map((fact) => fact.copy);
|
||||
const assistive = compare.split.assistive.map((fact) => fact.copy);
|
||||
const notes = compareNotes(screenDiff, compare.facts.length, compare.statusBarIgnored, compare.homeIndicatorIgnored);
|
||||
|
||||
return (
|
||||
@@ -140,7 +145,8 @@ export function SidebarReview(props: CompareControllerOptions) {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<WhatChangedAccordion facts={facts} notes={notes} open={compare.factsOpen} onOpenChange={compare.setFactsOpen} />
|
||||
<WhatChangedAccordion facts={facts} assistive={assistive} accessibilityOnly={screenDiff.accessibilityOnly} notes={notes}
|
||||
open={compare.factsOpen} onOpenChange={compare.setFactsOpen} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import { formatShortcut, SHORTCUTS } from "../../utils/shortcuts";
|
||||
import { changedScreens, compareText } from "../../utils/changed-screens";
|
||||
import "./changes.css";
|
||||
|
||||
const STATUSES: FocusStatus[] = ["added", "modified", "removed", "needs-review", "source-affected"];
|
||||
const STATUSES: FocusStatus[] = ["added", "modified", "accessibility-only", "removed", "needs-review", "source-affected"];
|
||||
|
||||
export type ChangesPanelProps = {
|
||||
diff: BuildDiff;
|
||||
@@ -176,10 +176,10 @@ export function ChangesPanel(props: ChangesPanelProps) {
|
||||
<button
|
||||
type="button"
|
||||
className={`changes-screen-row diff-${screen.status}`}
|
||||
aria-label={`Open ${screen.title}, ${DIFF_LABELS[screen.status]}, ${screen.route}`}
|
||||
aria-label={`Open ${screen.title}, ${FOCUS_LABELS[screen.status]}, ${screen.route}`}
|
||||
aria-current={screen.id === props.selectedScreenId ? "true" : undefined}
|
||||
onClick={() => props.onOpenScreen(screen.id)}>
|
||||
<StatusGlyph status={screen.status} />
|
||||
<StatusGlyph status={screen.status === "accessibility-only" ? "modified" : screen.status} accessibilityOnly={screen.status === "accessibility-only"} />
|
||||
<code className="changes-screen-path" title={screen.title}>{screen.route}</code>
|
||||
</button>
|
||||
</li>
|
||||
|
||||
@@ -23,7 +23,8 @@ import { copyImageToClipboard } from "../../utils/copy-image";
|
||||
import type { NavigationEdge } from "../../../../src/contracts/navigation-graph";
|
||||
import { navigationEdgeKey } from "../../utils/source-navigation";
|
||||
import {
|
||||
DIFF_LABELS,
|
||||
diffClass,
|
||||
diffLabel,
|
||||
type BuildDiff,
|
||||
type ScreenDiff,
|
||||
} from "../../utils/build-diff";
|
||||
@@ -111,7 +112,8 @@ function TransitionRow(props: {
|
||||
const { screen, sources, observed } = props.item;
|
||||
const targetId = screen.id;
|
||||
const screenshot = artifactUrl(screenshotForScreen(screen, props.index));
|
||||
const status = props.diff?.screens.get(targetId)?.status ?? "unchanged";
|
||||
const targetDiff = props.diff?.screens.get(targetId);
|
||||
const status = targetDiff?.status ?? "unchanged";
|
||||
const kinds = [...new Set(sources.length
|
||||
? sources.map(({ edge }) => edge.kind)
|
||||
: observed.map(transition => transition.actionKind))].sort();
|
||||
@@ -141,7 +143,7 @@ function TransitionRow(props: {
|
||||
<span className="transition-copy">
|
||||
<strong className="transition-path">{screenLabel(screen, props.index)}</strong>
|
||||
</span>
|
||||
<span className={`diff-dot diff-${status}`} title={DIFF_LABELS[status]} />
|
||||
<span className={`diff-dot ${diffClass(targetDiff ?? { status })}`} title={diffLabel(targetDiff ?? { status })} />
|
||||
<ChevronRight size={13} aria-hidden="true" />
|
||||
</button>
|
||||
</Tooltip>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Tooltip } from "../shared/tooltip";
|
||||
import { formatShortcut, SHORTCUTS } from "../../utils/shortcuts";
|
||||
import { InspectorPanel } from "./inspector";
|
||||
import type { ChangedScreen } from "../../utils/changed-screens";
|
||||
import { diffLabel, NOT_VISIBLE_HIGHLIGHT, type BuildDiff } from "../../utils/build-diff";
|
||||
import { diffLabel, ACCESSIBILITY_ONLY_HIGHLIGHT, type BuildDiff } from "../../utils/build-diff";
|
||||
import type { MapIndex, Screen } from "../../utils/model";
|
||||
import type { TransitionDirection } from "../../utils/navigation";
|
||||
import { displayPathForScreen } from "../../utils/screen-path";
|
||||
@@ -93,7 +93,7 @@ export function RightPanel(props: RightPanelProps) {
|
||||
{/* The screen's status as Compare's header and the Changes list mark it: a dot (+ or −
|
||||
for added or removed) in the status colour, named for screen readers. */}
|
||||
{screenDiff ? (
|
||||
<StatusGlyph status={screenDiff.status} label={diffLabel(screenDiff)}
|
||||
<StatusGlyph status={screenDiff.status} accessibilityOnly={screenDiff.accessibilityOnly} label={diffLabel(screenDiff)}
|
||||
className="inspector-diff-status" />
|
||||
) : null}
|
||||
{props.index.plainTitles ? (
|
||||
@@ -114,7 +114,7 @@ export function RightPanel(props: RightPanelProps) {
|
||||
both in place, off. */}
|
||||
{props.screen && props.diff && props.onOpenCompare ? (
|
||||
<>
|
||||
<Tooltip label={screenDiff?.notVisible ? NOT_VISIBLE_HIGHLIGHT : "Highlight changes"} shortcut={formatShortcut(SHORTCUTS.compare.outlines)} placement="bottom-end">
|
||||
<Tooltip label={screenDiff?.accessibilityOnly ? ACCESSIBILITY_ONLY_HIGHLIGHT : "Highlight changes"} shortcut={formatShortcut(SHORTCUTS.compare.outlines)} placement="bottom-end">
|
||||
<button type="button" className="icon-button inspector-highlight" aria-label="Highlight changes"
|
||||
aria-pressed={outlinable ? outlines : false} disabled={!outlinable}
|
||||
onClick={() => setOutlinesShown(!outlines)}>
|
||||
|
||||
@@ -45,8 +45,9 @@ export function PhoneCompare(props: CompareControllerOptions & {
|
||||
{compare.homeIndicatorIgnored ? <HomeIndicatorBand /> : null}
|
||||
</>
|
||||
) : null;
|
||||
const facts = compare.facts.map((fact) => fact.copy);
|
||||
const notes = compareNotes(screenDiff, facts.length, compare.statusBarIgnored, compare.homeIndicatorIgnored);
|
||||
const facts = compare.split.visible.map((fact) => fact.copy);
|
||||
const assistive = compare.split.assistive.map((fact) => fact.copy);
|
||||
const notes = compareNotes(screenDiff, compare.facts.length, compare.statusBarIgnored, compare.homeIndicatorIgnored);
|
||||
const previous = compare.previous ? () => props.onSelectScreen(compare.previous!.id) : undefined;
|
||||
const next = compare.next ? () => props.onSelectScreen(compare.next!.id) : undefined;
|
||||
// A tap near either side of the stage steps through the screens, like the stepper in the header. It runs
|
||||
@@ -67,14 +68,14 @@ export function PhoneCompare(props: CompareControllerOptions & {
|
||||
return (
|
||||
<section className="phone-compare" aria-label={`Compare ${route}`}>
|
||||
<header className="phone-compare-head">
|
||||
<CompareNav variant="phone" status={screenDiff.status} statusLabel={diffLabel(screenDiff)} route={route} title={screen.title}
|
||||
<CompareNav variant="phone" status={screenDiff.status} accessibilityOnly={screenDiff.accessibilityOnly} statusLabel={diffLabel(screenDiff)} route={route} title={screen.title}
|
||||
position={compare.position} count={props.order.length} picker={props.picker} stepsApart />
|
||||
<button type="button" className="phone-icon-button" aria-label="Outlines" aria-pressed={compare.outlines}
|
||||
disabled={areas.length === 0} onClick={compare.toggleOutlines}>
|
||||
<ScanSearch aria-hidden="true" />
|
||||
</button>
|
||||
<button type="button" className="phone-icon-button" aria-label="What changed" aria-haspopup="dialog"
|
||||
disabled={facts.length === 0 && notes.length === 0} onClick={() => compare.setFactsOpen(true)}>
|
||||
disabled={compare.facts.length === 0 && notes.length === 0} onClick={() => compare.setFactsOpen(true)}>
|
||||
<List aria-hidden="true" />
|
||||
</button>
|
||||
{props.headerAction}
|
||||
@@ -121,7 +122,7 @@ export function PhoneCompare(props: CompareControllerOptions & {
|
||||
</div>
|
||||
|
||||
<PhoneSheet title="What changed" open={compare.factsOpen} onClose={() => compare.setFactsOpen(false)}>
|
||||
<WhatChangedContent facts={facts} notes={notes} />
|
||||
<WhatChangedContent facts={facts} assistive={assistive} accessibilityOnly={screenDiff.accessibilityOnly} notes={notes} />
|
||||
</PhoneSheet>
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
import { Minus, Plus } from "lucide-react";
|
||||
import type { DiffStatus } from "../../utils/build-diff";
|
||||
import { diffClass, type DiffStatus } from "../../utils/build-diff";
|
||||
|
||||
/**
|
||||
* A screen's diff status as a bare glyph in the status colour: + added, − removed, a dot for the
|
||||
* rest. The Changes list marks its rows with it; a header that names the same screen uses it too.
|
||||
* With a label it is an image of that name; without one it is decoration beside text that says it.
|
||||
* An accessibility-only change is a square in its own colour, so it does not rest on colour alone.
|
||||
*/
|
||||
export function StatusGlyph(props: { status: DiffStatus; label?: string; className?: string }) {
|
||||
export function StatusGlyph(props: { status: DiffStatus; accessibilityOnly?: boolean | undefined; label?: string; className?: string }) {
|
||||
const glyph = props.status === "added" ? <Plus />
|
||||
: props.status === "removed" ? <Minus />
|
||||
: <span className="status-glyph-dot" />;
|
||||
return (
|
||||
<span className={`status-glyph diff-${props.status}${props.className ? ` ${props.className}` : ""}`}
|
||||
<span className={`status-glyph ${diffClass({ status: props.status, ...(props.accessibilityOnly ? { accessibilityOnly: true as const } : {}) })}${props.className ? ` ${props.className}` : ""}`}
|
||||
{...(props.label ? { role: "img", "aria-label": props.label } : { "aria-hidden": true })}>
|
||||
{glyph}
|
||||
</span>
|
||||
|
||||
@@ -136,6 +136,7 @@ button.screens-tree-row:hover { color: var(--text); background: var(--panel-hove
|
||||
cursor: pointer;
|
||||
}
|
||||
.screens-tree-dot[class*="diff-"] { background: var(--diff); }
|
||||
.screens-tree-dot.diff-accessibility-only { border-radius: 2px; }
|
||||
.screens-tree-dot.elsewhere { background: color-mix(in srgb, var(--modified) 50%, transparent); }
|
||||
.screens-tree-legend {
|
||||
display: flex;
|
||||
|
||||
@@ -2,8 +2,8 @@ import { useEffect, useMemo, useRef, useState, type CSSProperties, type Keyboard
|
||||
import { ChevronRight, ChevronsDownUp, ChevronsUpDown, ListTree } from "lucide-react";
|
||||
import { artifactUrl, isLaunchScreen, type ExploreMap, type MapIndex, type Screen } from "../../utils/model";
|
||||
import { primaryScreenshotForScreen, screenshotSize } from "../../utils/screen-images";
|
||||
import type { BuildDiff, DiffStatus } from "../../utils/build-diff";
|
||||
import { isVisibleChange } from "../../utils/changed-screens";
|
||||
import { diffClass, type BuildDiff, type DiffStatus } from "../../utils/build-diff";
|
||||
import { focusStatusOf, isCapturedChange } from "../../utils/changed-screens";
|
||||
import { displayPathForScreen, screenLabel } from "../../utils/screen-path";
|
||||
import { screenTree, treeIndex, treeNodeKey, type ScreenTree, type ScreenTreeNode } from "../../utils/screen-tree";
|
||||
import type { Appearance } from "../../utils/appearance";
|
||||
@@ -13,7 +13,7 @@ import { useCanvasVisibleFrame } from "../canvas/visible-frame-provider";
|
||||
import { PhoneSheet } from "../phone/phone-chrome";
|
||||
import "./screens.css";
|
||||
|
||||
/** The statuses a tree dot marks. The Changed filter keeps only the screens that look different (isVisibleChange). */
|
||||
/** The statuses a tree dot marks. The Changed filter keeps only the screens whose captures differ (isCapturedChange). */
|
||||
const CHANGED_STATUSES = new Set<DiffStatus>(["modified", "added", "removed", "needs-review", "source-affected"]);
|
||||
|
||||
type Filter = "changed" | "all";
|
||||
@@ -45,13 +45,13 @@ function statusOf(diff: BuildDiff | undefined, id: string): DiffStatus | undefin
|
||||
}
|
||||
|
||||
function isChanged(diff: BuildDiff | undefined, id: string): boolean {
|
||||
return isVisibleChange(diff?.screens.get(id));
|
||||
return isCapturedChange(diff?.screens.get(id));
|
||||
}
|
||||
|
||||
/** The dot beside a tree row: changed here, changed only in another appearance, or nothing. */
|
||||
function dotClass(diff: BuildDiff | undefined, elsewhere: ReadonlyMap<string, Appearance[]> | undefined, id: string): string | undefined {
|
||||
const status = statusOf(diff, id);
|
||||
if (status && CHANGED_STATUSES.has(status)) return `diff-${status}`;
|
||||
const screen = diff?.screens.get(id);
|
||||
if (screen && CHANGED_STATUSES.has(screen.status)) return diffClass(screen);
|
||||
if (elsewhere?.get(id)?.length) return "elsewhere";
|
||||
return undefined;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ function ScreenCell(props: {
|
||||
{...(url ? { screenshot: url } : {})}
|
||||
{...(size ? size : {})}
|
||||
{...(status ? { diff: status } : {})}
|
||||
{...(props.diff?.screens.get(props.screen.id)?.notVisible ? { notVisible: true } : {})}
|
||||
{...(props.diff?.screens.get(props.screen.id)?.accessibilityOnly ? { accessibilityOnly: true } : {})}
|
||||
selected={props.selected}
|
||||
ariaPressed={props.selected}
|
||||
loading="lazy"
|
||||
@@ -188,14 +188,15 @@ function TreeRows(props: {
|
||||
});
|
||||
}
|
||||
|
||||
/** Changed and Accessibility only always: a reader learns the kinds even on a report without one. */
|
||||
function Legend(props: { others: Appearance[] }) {
|
||||
return (
|
||||
<div className="screens-tree-legend">
|
||||
<span><span className="screens-tree-dot diff-modified" aria-hidden="true" />Changed</span>
|
||||
<span><span className="screens-tree-dot diff-modified diff-accessibility-only" aria-hidden="true" />Accessibility only</span>
|
||||
{props.others.length ? (
|
||||
<span><span className="screens-tree-dot elsewhere" aria-hidden="true" />Changed in {props.others.join(" and ")} only</span>
|
||||
) : null}
|
||||
<span><span className="screens-tree-dot diff-source-affected" aria-hidden="true" />Source-affected</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -392,7 +393,7 @@ export function ScreensView(props: ScreensViewProps) {
|
||||
elsewhere={isChanged(props.diff, id) ? undefined : props.changedElsewhere?.get(id)}
|
||||
via={tree.via.get(id)}
|
||||
selected={props.selectedScreenId === id}
|
||||
dimmed={Boolean(props.focus?.length) && !props.focus!.some((state) => state === statusOf(props.diff, id))}
|
||||
dimmed={Boolean(props.focus?.length) && !props.focus!.some((state) => state === focusStatusOf(props.diff?.screens.get(id)))}
|
||||
onSelect={() => props.onSelectScreen(id)} />
|
||||
) : null;
|
||||
})}
|
||||
|
||||
@@ -23,6 +23,7 @@ import type { BuildDiff, DiffStatus } from "../../utils/build-diff";
|
||||
import { CANVAS_MAX_ZOOM } from "../../utils/canvas-zoom";
|
||||
import { usePhoneLayout } from "../../utils/phone-layout";
|
||||
import type { FocusBehavior, FocusRequest, FocusStatus, MapDirection } from "../../utils/navigation";
|
||||
import { focusStatusOf } from "../../utils/changed-screens";
|
||||
import { displayPathForScreen } from "../../utils/screen-path";
|
||||
import { shortcutsLive } from "../../utils/shortcuts";
|
||||
import { mapKeyDirection, mapKeyTarget } from "../../utils/map-keyboard";
|
||||
@@ -58,7 +59,7 @@ type ScreenNodeData = {
|
||||
highlighted: boolean;
|
||||
direction: MapDirection;
|
||||
diff?: DiffStatus;
|
||||
notVisible?: boolean;
|
||||
accessibilityOnly?: boolean;
|
||||
projectionDelayMs?: number;
|
||||
projectionScreenScale?: number;
|
||||
projectionMotion: ProjectionMotionMetadata;
|
||||
@@ -93,7 +94,7 @@ function ScreenNodeCard({ data, selected }: NodeProps<ScreenGraphNode>) {
|
||||
{...(data.screenshot ? { screenshot: data.screenshot } : {})}
|
||||
{...(data.missingReason ? { missingReason: data.missingReason } : {})}
|
||||
{...(data.diff ? { diff: data.diff } : {})}
|
||||
{...(data.notVisible ? { notVisible: true } : {})}
|
||||
{...(data.accessibilityOnly ? { accessibilityOnly: true } : {})}
|
||||
selected={selected}
|
||||
highlighted={data.highlighted}
|
||||
style={{
|
||||
@@ -287,7 +288,8 @@ function projectionElements(
|
||||
const screenshot = structure.screenshots.get(screen.id);
|
||||
const highlighted = false;
|
||||
const status = diff?.screens.get(screen.id)?.status;
|
||||
const muted = focus.length > 0 && !focus.some((state) => state === status);
|
||||
const focusStatus = focusStatusOf(diff?.screens.get(screen.id));
|
||||
const muted = focus.length > 0 && !focus.some((state) => state === focusStatus);
|
||||
const projectionMotion: ProjectionMotionMetadata = {
|
||||
motionKey: `screen:${screen.id}`,
|
||||
role: "screen",
|
||||
@@ -318,7 +320,7 @@ function projectionElements(
|
||||
highlighted,
|
||||
direction: structure.horizontal ? "LR" : "TB",
|
||||
...(status ? { diff: status } : {}),
|
||||
...(diff?.screens.get(screen.id)?.notVisible ? { notVisible: true } : {}),
|
||||
...(diff?.screens.get(screen.id)?.accessibilityOnly ? { accessibilityOnly: true } : {}),
|
||||
projectionMotion,
|
||||
onSelect: onSelectScreen,
|
||||
onHover: onHoverScreen,
|
||||
|
||||
@@ -50,7 +50,8 @@ function comparisonStatus(surface: Surface): BuildComparisonEntry["status"] {
|
||||
if (captureUnavailable(surface, "base") || unattributed("base")) return "unavailable";
|
||||
}
|
||||
if (surface.status === "added" || surface.status === "removed") return surface.status;
|
||||
return comparisonReview(surface)?.status ?? (surface.status === "modified" ? "source-affected" : "not-compared");
|
||||
// A source change with no comparison is not a change the captures show: not compared, whatever the source did.
|
||||
return comparisonReview(surface)?.status ?? "not-compared";
|
||||
}
|
||||
|
||||
/** The side's route exists and was planned, but its capture ended without a screenshot. */
|
||||
|
||||
@@ -64,6 +64,9 @@
|
||||
/* Modified is orange in both themes, as in the PR comment (🟧). Yellow means "needs review". */
|
||||
--modified: #ea580c;
|
||||
--modified-soft: #ffefd6;
|
||||
/* Accessibility only is blue, as in the PR comment (🟦), deeper than the accent a screen variant uses. */
|
||||
--accessibility: #2f6feb;
|
||||
--accessibility-soft: #e8f0fe;
|
||||
--graph-dot: #d9d9e0;
|
||||
--graph-line: #8b8d98;
|
||||
--graph-line-soft: #c5c7ce;
|
||||
@@ -181,6 +184,8 @@
|
||||
--purple-soft: #301c3b;
|
||||
--modified: #ff9a3c;
|
||||
--modified-soft: #331e0b;
|
||||
--accessibility: #8fa8ff;
|
||||
--accessibility-soft: #17224a;
|
||||
--graph-dot: #212225;
|
||||
--graph-line: #696e77;
|
||||
--graph-line-soft: #3f4349;
|
||||
@@ -1665,6 +1670,11 @@ code {
|
||||
/* Modified reads orange everywhere: the Changes list, the canvas chip and border, the Inspector badge. */
|
||||
.diff-modified { --diff: var(--modified); --diff-soft: var(--modified-soft); }
|
||||
.diff-removed { --diff: var(--danger); --diff-soft: var(--danger-soft); }
|
||||
/* Accessibility only: modified for assistive technology, with matching screenshots. It keeps Modified's frame
|
||||
(it carries diff-modified too) in blue, and its marks are squares, so it does not rest on colour alone. */
|
||||
.diff-accessibility-only { --diff: var(--accessibility); --diff-soft: var(--accessibility-soft); }
|
||||
.diff-accessibility-only.diff-dot,
|
||||
.diff-accessibility-only .status-glyph-dot { border-radius: 2px; }
|
||||
.diff-unchanged { --diff: var(--tertiary); --diff-soft: var(--element); }
|
||||
.diff-needs-review { --diff: var(--tertiary); --diff-soft: var(--element); }
|
||||
.diff-source-affected { --diff: var(--purple); --diff-soft: var(--purple-soft); }
|
||||
|
||||
@@ -67,16 +67,28 @@ export type ScreenDiff = {
|
||||
reviewerChanges: ReviewerChangeFact[];
|
||||
runtimeEvidenceRefs: string[];
|
||||
noVisibleChange: boolean;
|
||||
/** Modified in what the review read (the accessibility tree, text), with no pixel difference: nothing to outline. */
|
||||
notVisible?: true;
|
||||
/**
|
||||
* Modified only in what assistive technology reads (the accessibility tree): the screenshots match, so there is
|
||||
* nothing to outline. Screen readers and voice control still see the change, so it is reviewed like any other.
|
||||
*/
|
||||
accessibilityOnly?: true;
|
||||
};
|
||||
|
||||
/** Why Highlight changes is off for a change that is not visible. */
|
||||
export const NOT_VISIBLE_HIGHLIGHT = "Nothing to highlight: the screenshots match";
|
||||
/** Why Highlight changes is off for an accessibility-only change. */
|
||||
export const ACCESSIBILITY_ONLY_HIGHLIGHT = "Nothing to highlight: only what assistive technology reads changed";
|
||||
|
||||
/** A screen's status as the Viewer names it: a modified screen whose screenshots match says the change is not visible. */
|
||||
export function diffLabel(diff: Pick<ScreenDiff, "status" | "notVisible">): string {
|
||||
return diff.notVisible && diff.status === "modified" ? "Changed (not visible)" : DIFF_LABELS[diff.status];
|
||||
/** A screen's status as the Viewer names it: a modified screen whose screenshots match changed for assistive technology only. */
|
||||
export function diffLabel(diff: Pick<ScreenDiff, "status" | "accessibilityOnly">): string {
|
||||
return isAccessibilityOnly(diff) ? "Accessibility only" : DIFF_LABELS[diff.status];
|
||||
}
|
||||
|
||||
export function isAccessibilityOnly(diff: Pick<ScreenDiff, "status" | "accessibilityOnly"> | undefined): boolean {
|
||||
return diff?.status === "modified" && Boolean(diff.accessibilityOnly);
|
||||
}
|
||||
|
||||
/** The class that colours a screen's status: an accessibility-only change keeps Modified's frame in its own colour. */
|
||||
export function diffClass(diff: Pick<ScreenDiff, "status" | "accessibilityOnly">): string {
|
||||
return isAccessibilityOnly(diff) ? "diff-modified diff-accessibility-only" : `diff-${diff.status}`;
|
||||
}
|
||||
|
||||
export type BuildDiff = {
|
||||
@@ -355,7 +367,7 @@ export function buildDiff(options: {
|
||||
reviewerChanges: reviewSurface?.reviewerChanges ?? [],
|
||||
runtimeEvidenceRefs: reviewSurface?.runtimeEvidenceRefs ?? [],
|
||||
noVisibleChange: screen.status === "unchanged" && (reviewSurface?.noVisibleChange ?? false),
|
||||
...(screen.status === "modified" && reviewSurface?.pixelsUnchanged ? { notVisible: true as const } : {}),
|
||||
...(screen.status === "modified" && reviewSurface?.pixelsUnchanged ? { accessibilityOnly: true as const } : {}),
|
||||
...(before ?? borrowed.before ? { beforeScreenshot: (before ?? borrowed.before)! } : {}),
|
||||
...(after ?? borrowed.after ? { afterScreenshot: (after ?? borrowed.after)! } : {}),
|
||||
...(redirectTo && (borrowed.before || borrowed.after) ? { redirectTo } : {}),
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
import type { BuildDiff, DiffStatus, ScreenDiff } from "./build-diff";
|
||||
import { isAccessibilityOnly, type BuildDiff, type DiffStatus, type ScreenDiff } from "./build-diff";
|
||||
import type { MapIndex } from "./model";
|
||||
import { isLaunchScreen } from "./model";
|
||||
import type { FocusStatus } from "./navigation";
|
||||
import { displayPathForScreen } from "./screen-path";
|
||||
|
||||
/** Review order: the visible changes first, then what changed only for assistive technology. */
|
||||
const STATUS_ORDER: Record<FocusStatus, number> = {
|
||||
added: 0,
|
||||
modified: 1,
|
||||
removed: 2,
|
||||
"needs-review": 3,
|
||||
"source-affected": 4,
|
||||
"accessibility-only": 3,
|
||||
"needs-review": 4,
|
||||
"source-affected": 5,
|
||||
};
|
||||
|
||||
export type ChangedScreen = {
|
||||
@@ -19,17 +21,33 @@ export type ChangedScreen = {
|
||||
route: string;
|
||||
};
|
||||
|
||||
export function isChangedStatus(status: DiffStatus): status is FocusStatus {
|
||||
/** The status the Changes filter and focus match a screen on: Accessibility only apart from Modified. */
|
||||
export function focusStatusOf(diff: Pick<ScreenDiff, "status" | "accessibilityOnly"> | undefined): DiffStatus | "accessibility-only" | undefined {
|
||||
return isAccessibilityOnly(diff) ? "accessibility-only" : diff?.status;
|
||||
}
|
||||
|
||||
/** Each focus status's count: Modified counts only the visible changes, Accessibility only the rest. */
|
||||
export function focusCounts(diff: BuildDiff | undefined): Record<FocusStatus, number> {
|
||||
const counts: Record<FocusStatus, number> = { added: 0, modified: 0, "accessibility-only": 0, removed: 0, "needs-review": 0, "source-affected": 0 };
|
||||
for (const screen of diff?.screens.values() ?? []) {
|
||||
const status = focusStatusOf(screen);
|
||||
if (status && status in counts) counts[status as FocusStatus] += 1;
|
||||
}
|
||||
return counts;
|
||||
}
|
||||
|
||||
export function isChangedStatus(status: DiffStatus): status is Exclude<FocusStatus, "accessibility-only"> {
|
||||
return status !== "unchanged" && status !== "not-compared" && status !== "unavailable" && status !== "variant";
|
||||
}
|
||||
|
||||
/**
|
||||
* A change the captures show: an added or removed screen, or a modified one whose pixels differ. A screen whose
|
||||
* source changed but whose captures look the same ("No visible change", source-affected, or modified with
|
||||
* unchanged pixels) stays in the Changes list, but Compare does not step through it and Screens' Changed hides it.
|
||||
* A change the captures show: an added, removed or modified screen, including one modified only in what assistive
|
||||
* technology reads (its screenshots match, its accessibility tree does not). A screen whose source changed but whose
|
||||
* captures show nothing different ("No visible change") stays in the Changes list, but Compare does
|
||||
* not step through it and Screens' Changed hides it.
|
||||
*/
|
||||
export function isVisibleChange(diff: Pick<ScreenDiff, "status" | "notVisible"> | undefined): boolean {
|
||||
return diff !== undefined && (diff.status === "added" || diff.status === "removed" || (diff.status === "modified" && !diff.notVisible));
|
||||
export function isCapturedChange(diff: Pick<ScreenDiff, "status"> | undefined): boolean {
|
||||
return diff !== undefined && (diff.status === "added" || diff.status === "removed" || diff.status === "modified");
|
||||
}
|
||||
|
||||
export function compareText(left: string, right: string): number {
|
||||
@@ -58,7 +76,7 @@ export function changedScreens(diff: BuildDiff, index: MapIndex): ChangedScreen[
|
||||
if (!isChangedStatus(screenDiff.status)) continue;
|
||||
const screen = index.screens.get(id);
|
||||
if (!screen) continue;
|
||||
result.push({ id, status: screenDiff.status, title: screen.title, route: displayPathForScreen(screen) });
|
||||
result.push({ id, status: isAccessibilityOnly(screenDiff) ? "accessibility-only" : screenDiff.status, title: screen.title, route: displayPathForScreen(screen) });
|
||||
}
|
||||
return result.sort(compareChangedScreens);
|
||||
}
|
||||
@@ -8,7 +8,8 @@ export type ThemePreference = "light" | "dark" | "system";
|
||||
export type MapDirection = "TB" | "LR";
|
||||
/** The explicitly selected amount of Map hierarchy, independent from camera zoom. */
|
||||
/** The diff states the canvas can single out. An empty selection is "All": nothing drops back. */
|
||||
export type FocusStatus = "added" | "modified" | "removed" | "needs-review" | "source-affected";
|
||||
/** `accessibility-only`: a modified screen whose screenshots match, filtered apart from the visible changes. */
|
||||
export type FocusStatus = "added" | "modified" | "accessibility-only" | "removed" | "needs-review" | "source-affected";
|
||||
/** The right panel shows Session and Diff. */
|
||||
export type InspectView = "session" | "diff";
|
||||
/** Which way the inspector's transition list reads: into the screen, or out of it. */
|
||||
@@ -83,7 +84,7 @@ export type FocusRequest = {
|
||||
const CANVASES: CanvasView[] = ["map", "screens", "compare"];
|
||||
const INSPECTS: InspectView[] = ["session", "diff"];
|
||||
const DIRECTIONS: TransitionDirection[] = ["in", "out"];
|
||||
const FOCUSES: FocusStatus[] = ["added", "modified", "removed", "needs-review", "source-affected"];
|
||||
const FOCUSES: FocusStatus[] = ["added", "modified", "accessibility-only", "removed", "needs-review", "source-affected"];
|
||||
|
||||
function isCanvas(value: string | null | undefined): value is CanvasView {
|
||||
return CANVASES.includes(value as CanvasView);
|
||||
@@ -326,6 +327,7 @@ export const CANVAS_DESCRIPTIONS: Record<CanvasView, string> = {
|
||||
export const FOCUS_LABELS: Record<FocusStatus, string> = {
|
||||
added: "Added",
|
||||
modified: "Modified",
|
||||
"accessibility-only": "Accessibility only",
|
||||
removed: "Removed",
|
||||
"needs-review": "No visible change",
|
||||
"source-affected": "Source-affected",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { DiffStatus, ScreenDiff } from "./build-diff";
|
||||
import { isAccessibilityOnly, type DiffStatus, type ScreenDiff } from "./build-diff";
|
||||
import { formatReviewerChange, sortReviewerChanges, type CaptureNotes, type ReviewerChangeFact } from "./review-model";
|
||||
|
||||
/** One line of "What changed": a reviewer note, a CI finding, or the legacy summary. */
|
||||
@@ -25,6 +25,19 @@ export function presentedChanges(diff: ScreenDiff | undefined): PresentedChange[
|
||||
return legacy ? [{ id: "legacy-summary", copy: legacy }] : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* What changed, split by who sees it. On a screen whose screenshots match, every finding is for assistive technology:
|
||||
* nothing on it looks different. Elsewhere only the accessibility findings (labels, roles) are, since an added
|
||||
* element or new text may well be visible.
|
||||
*/
|
||||
export function splitForAssistiveTechnology(changes: PresentedChange[], diff: Pick<ScreenDiff, "status" | "accessibilityOnly"> | undefined): {
|
||||
visible: PresentedChange[];
|
||||
assistive: PresentedChange[];
|
||||
} {
|
||||
const assistive = (change: PresentedChange) => Boolean(change.fact) && (isAccessibilityOnly(diff) || change.fact?.category === "accessibility");
|
||||
return { visible: changes.filter((change) => !assistive(change)), assistive: changes.filter(assistive) };
|
||||
}
|
||||
|
||||
/** What a missing side of a comparison shows instead of a screenshot. */
|
||||
export function placeholderFor(side: "before" | "after", status: DiffStatus, notes?: CaptureNotes): string {
|
||||
if (side === "before" && status === "added") return "Not in baseline";
|
||||
|
||||
@@ -98,7 +98,7 @@ export type ReviewSurface = {
|
||||
reviewerChanges: ReviewerChangeFact[];
|
||||
runtimeEvidenceRefs: string[];
|
||||
noVisibleChange: boolean;
|
||||
/** CI compared both verified screenshots and found no pixel difference: whatever changed is not visible. */
|
||||
/** CI compared both verified screenshots and found no pixel difference: anything that changed is in the accessibility tree. */
|
||||
pixelsUnchanged?: true;
|
||||
/** Route this surface declares instead of rendering a screen of its own. */
|
||||
redirectTo?: string;
|
||||
|
||||
@@ -218,6 +218,11 @@ function aggregateStatus(statuses: readonly DiffStatus[]): DiffStatus {
|
||||
return "modified";
|
||||
}
|
||||
|
||||
function accessibilityOnlyFamily(diffs: readonly ScreenDiff[]): boolean {
|
||||
const changed = diffs.filter((diff) => diff.status === "added" || diff.status === "removed" || diff.status === "modified");
|
||||
return changed.length > 0 && changed.every((diff) => diff.status === "modified" && diff.accessibilityOnly);
|
||||
}
|
||||
|
||||
function firstDiffWithScreenshot(
|
||||
diffs: readonly ScreenDiff[],
|
||||
side: "beforeScreenshot" | "afterScreenshot",
|
||||
@@ -241,7 +246,7 @@ function familyEvidence(diffs: readonly ScreenDiff[]): {
|
||||
reviewerChanges: ScreenDiff["reviewerChanges"];
|
||||
runtimeEvidenceRefs: string[];
|
||||
noVisibleChange: boolean;
|
||||
notVisible?: true;
|
||||
accessibilityOnly?: true;
|
||||
} {
|
||||
const first = diffs[0];
|
||||
if (!first) throw new Error("Cannot present an empty diff family");
|
||||
@@ -251,7 +256,6 @@ function familyEvidence(diffs: readonly ScreenDiff[]): {
|
||||
const beforeDiff = firstDiffWithScreenshot(diffs, "beforeScreenshot");
|
||||
const afterDiff = firstDiffWithScreenshot(diffs, "afterScreenshot");
|
||||
const primary = paired ?? afterDiff ?? beforeDiff ?? first;
|
||||
const modified = diffs.filter((diff) => diff.status === "modified");
|
||||
const reviewerChanges = [...new Map(diffs
|
||||
.flatMap((diff) => diff.reviewerChanges ?? [])
|
||||
.map((change) => [change.id, change])).values()];
|
||||
@@ -263,8 +267,8 @@ function familyEvidence(diffs: readonly ScreenDiff[]): {
|
||||
reviewerChanges,
|
||||
runtimeEvidenceRefs,
|
||||
noVisibleChange: diffs.some((diff) => diff.noVisibleChange),
|
||||
// Not visible only when no modified member of the family shows a difference.
|
||||
...(modified.length > 0 && modified.every((diff) => diff.notVisible) ? { notVisible: true as const } : {}),
|
||||
// Accessibility only when every changed member is: an added, removed or visibly modified member is a visible change.
|
||||
...(accessibilityOnlyFamily(diffs) ? { accessibilityOnly: true as const } : {}),
|
||||
...(primary.captureNotes ? { captureNotes: primary.captureNotes } : {}),
|
||||
// A redirect's screenshots belong to the route it declares; the panel must keep saying so.
|
||||
...(primary.redirectTo ? { redirectTo: primary.redirectTo } : {}),
|
||||
|
||||
Reference in new issue
Block a user