Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions hub/client/application/hub/contracts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ export const repositoryResponseSchema = z.object({
prototypeSchema.extend({
authorId: z.string().nullable().optional(),
authorLogin: z.string().min(1).nullable(),
reviewBuild: z
.object({ number: identifier, desktopScreenshotUrl: httpUrl.nullable() })
.nullish(),
}),
),
pagination: paginationSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ export function repositoryShowData(
prototypes: data.prototypes.map((prototype) => {
const builds = [...prototype.builds].sort((first, second) => second.number - first.number)
const latestBuild = prototype.latestBuild === undefined ? builds[0] : prototype.latestBuild
const reviewBuild = builds.find((build) => build.previewUrl && build.desktopScreenshotUrl)
const reviewBuild =
prototype.reviewBuild ??
builds.find((build) => build.previewUrl && build.desktopScreenshotUrl)
const previewAvailable =
Boolean(prototype.reviewBuild) || builds.some((build) => build.previewUrl)
const prototypeAuthor = prototype.authorId
? data.authors.find((item) => item.id === prototype.authorId)
: options.real
Expand Down Expand Up @@ -88,7 +92,7 @@ export function repositoryShowData(
latestBuild: latestBuild
? { state: latestBuild.state, stateLabel: buildStateLabel(latestBuild.state) }
: undefined,
previewFallbackLabel: builds.some((build) => build.previewUrl)
previewFallbackLabel: previewAvailable
? "Preview available. No screenshot was captured."
: "No preview available",
reviewBuild: reviewBuild?.desktopScreenshotUrl
Expand Down Expand Up @@ -129,7 +133,6 @@ export function repositoryShowData(
previous: "Previous",
next: "Next",
pagination: "Prototype pages",
updating: "Updating prototypes",
shown: `${data.prototypes.length} shown`,
},
},
Expand Down
8 changes: 2 additions & 6 deletions hub/client/components/prototype-card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,8 @@ export function PrototypeCard({
<h2 className="prototype-card__branch-name">{title}</h2>

{prototype.author.url ? (
<a
href={prototype.author.url}
className="prototype-card__author-link"
aria-label={prototype.author.label}
>
{prototype.author.label}
<a href={prototype.author.url} className="prototype-card__author-link">
{prototype.author.ownerLabel}
</a>
) : (
<span className="prototype-card__author">{prototype.author.label}</span>
Expand Down
8 changes: 8 additions & 0 deletions hub/client/components/prototype-card/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,17 @@
}

.prototype-card__author-link {
width: fit-content;
max-width: 100%;
text-decoration: none;
}

.prototype-card__author-link:hover,
.prototype-card__author-link:focus-visible {
color: var(--hub-fg-default);
text-decoration: underline;
}

.prototype-card__arrow {
color: var(--hub-fg-muted);
}
Expand Down
3 changes: 3 additions & 0 deletions hub/client/components/repository-selector/stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,7 @@ export const LongName: Story = {
githubEmpty,
],
},
play: async ({ canvas, userEvent }) => {
await userEvent.click(canvas.getByRole("button", { name: /^Choose repository/ }))
},
}
7 changes: 5 additions & 2 deletions hub/client/components/repository-selector/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,14 @@
}

.repository-selector [role="menu"] {
width: min(
width: max-content;
min-width: min(
var(--hub-repository-control-width),
calc(100vw - var(--hub-repository-sidebar-inset) - var(--hub-repository-sidebar-inset))
);
min-width: 0;
max-width: calc(
100vw - var(--hub-repository-sidebar-inset) - var(--hub-repository-sidebar-inset)
);
}

.repository-selector [role="menu"]::before {
Expand Down
16 changes: 10 additions & 6 deletions hub/client/pages/repositories-show-page/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fireEvent, render, screen } from "@testing-library/react"
import { fireEvent, render, screen, within } from "@testing-library/react"
import type { ComponentProps } from "react"
import { describe, it, vi } from "vitest"

Expand Down Expand Up @@ -145,12 +145,13 @@ describe("RepositoriesShowPage()", () => {
expect(delegatedClick).toHaveBeenCalledTimes(1)
})

it("retains known cards during loading and request failure and exposes retry", () => {
it("retains cards without an inline loading message and exposes retry on failure", () => {
const controls = listingControls({ pending: true })
const { rerender } = render(<RepositoriesShowPage data={PAGE_DATA} controls={controls} />)
expect(screen.getByRole("region", { name: "Prototypes" })).toHaveAttribute("aria-busy", "true")
expect(screen.getByRole("status")).toHaveTextContent(prototypeListing.copy.updating)
expect(screen.getByRole("link", { name: "Welcome" })).toBeInTheDocument()
const results = screen.getByRole("region", { name: "Prototypes" })
expect(results).toHaveAttribute("aria-busy", "true")
expect(within(results).queryByText("Updating prototypes")).not.toBeInTheDocument()
expect(within(results).getByRole("link", { name: "Welcome" })).toBeInTheDocument()
rerender(
<RepositoriesShowPage
data={PAGE_DATA}
Expand Down Expand Up @@ -480,7 +481,10 @@ describe("RepositoriesShowPage()", () => {
/>,
)

expect(screen.getAllByText("by @octocat")).toHaveLength(3)
for (const link of screen.getAllByRole("link", { name: "@octocat" })) {
expect(link).toHaveAttribute("href", "https://github.com/octocat")
}
expect(screen.getAllByRole("link", { name: "@octocat" })).toHaveLength(3)
expect(screen.queryByText("Explore a new welcome flow.")).not.toBeInTheDocument()
expect(screen.queryByText("prototype/welcome")).not.toBeInTheDocument()
expect(screen.queryByText("2 builds")).not.toBeInTheDocument()
Expand Down
1 change: 0 additions & 1 deletion hub/client/pages/repositories-show-page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ export function RepositoriesShowPage({
tabIndex={-1}
data-prototype-results
>
{controls.pending ? <Text role="status">{data.listing.copy.updating}</Text> : null}
{controls.error ? (
<HubAlert
title={data.listing.copy.resultsFailed}
Expand Down
14 changes: 2 additions & 12 deletions hub/client/pages/repositories-show-page/stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,8 @@ const realIndexData: RepositoriesShowPageData = {
id: "00000000-0000-4000-8000-000000000201",
branchName: "prototype/welcome",
description: "Explore a new welcome page.",
path: null,
reviewBuild: undefined,
latestBuild: { state: "successful", stateLabel: "Successful" },
previewFallbackLabel: "No preview available",
path: "/repositories/00000000-0000-4000-8000-000000000101/prototypes/00000000-0000-4000-8000-000000000201",
latestBuild: { state: "failed", stateLabel: "Failed" },
author: realPrototypeAuthor,
},
{
Expand Down Expand Up @@ -363,14 +361,6 @@ export const NoMatches: Story = {
},
}

export const Updating: Story = {
...Single,
args: {
...Single.args,
controls: { ...meta.args.controls, pending: true },
},
}

export const RequestFailed: Story = {
...Single,
args: {
Expand Down
18 changes: 18 additions & 0 deletions hub/client/pages/security-audit-page/stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,24 @@ export const RepositoryEmpty: Story = {
data: { ...Repository.args!.data!, events: [] },
},
}

export const LongRepositoryName: Story = {
args: {
data: {
...Repository.args!.data!,
scopes: Repository.args!.data!.scopes.map((scope) =>
scope.id === "2001"
? {
...scope,
label:
"github/prototype-review-for-the-shared-design-system-components-and-interaction-library",
}
: scope,
),
},
},
}

export const RepositoryAndHubAdmin: Story = {
args: {
data: {
Expand Down
26 changes: 26 additions & 0 deletions hub/client/pages/security-audit-page/styles.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.security-audit-page {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 1.5rem;
max-width: 75rem;
margin-inline: auto;
Expand All @@ -19,6 +20,31 @@
gap: var(--base-size-8);
}

.security-audit-page__scope > div {
min-width: 0;
max-width: min(32rem, 100%);
}

.security-audit-page__scope button {
max-width: 100%;
}

.security-audit-page__scope button > span:first-child {
max-width: none;
}

.security-audit-page__scope button > span:first-child,
.security-audit-page__scope button > span:first-child > span {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.security-audit-page__scope button > [data-testid="Button-trailing-visual"] {
flex: none;
}

.security-audit-page__records {
min-width: 0;
overflow-x: auto;
Expand Down
1 change: 0 additions & 1 deletion hub/client/storybook/fixtures/prototype-listing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export const prototypeListing: PrototypeListing = {
previous: "Previous",
next: "Next",
pagination: "Prototype pages",
updating: "Updating prototypes",
shown: "1 shown",
},
}
1 change: 0 additions & 1 deletion hub/client/utils/prototype-listing/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export interface PrototypeListing {
previous: string
next: string
pagination: string
updating: string
shown: string
}
}
2 changes: 1 addition & 1 deletion hub/docs/frontend.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Application code adapts internal links and same-origin GET forms to SPA navigati

### Loading and notifications

Pending page navigation shows a thin green pulse moving to the right, with a screen-reader loading announcement and a static bar for reduced-motion preferences. Loading feedback does not move page content.
Pending page navigation shows a thin green pulse moving to the right, with a screen-reader loading announcement and a static bar for reduced-motion preferences. Loading feedback does not move page content. The Prototypes gallery keeps its current results visible without adding a separate loading message.

Routine notices and successful form results appear as dismissible toasts stacked in the bottom-right corner. They do not take focus, expire on a timer, or occupy space in the page layout. Dismissing a toast hides that message until it changes or its owning page or result remounts. Validation failures, access restrictions, action choices and consequential warnings remain inline beside the affected content.

Expand Down
2 changes: 2 additions & 0 deletions hub/docs/github-actions-builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ Both packages use the same path, size, and entry-count limits as local Builds.

Each pass after the dist import also looks for screenshots. Hub attaches them only when their `distDigest` matches the successful Build. Repeated passes add no duplicates and never replace existing artifact records. Invalid packages are logged and ignored; a digest mismatch leaves screenshots unattached. A Build whose screenshots never arrive stays successful and previewable without them.

The capture job takes the prototype screenshot at `/` and captures declared template routes separately. The Prototypes gallery shows the newest successful Build with a saved desktop screenshot, even if a newer Build is pending, failed, or has not yet imported its screenshot. The current Build status does not change. If a thumbnail is missing, check the `replica-screenshots-v1` upload and Hub import before changing the workflow.

## Recovery

GitHub does not retry failed webhook deliveries, so scheduled jobs recover missed events and stalled imports. Each job is idempotent, and none deletes Builds or artifacts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ export async function findRepositoryIndex(
repositoryId: string,
filters: RepositoryIndexFilters = { query: "", authorId: null, page: 1 },
scope: RepositoryScope = null,
buildArtifactUrl?: (
buildId: string,
repositoryId: string,
prototypeId: string,
buildNumber: number,
target: "desktop",
) => string,
) {
const repository = await database.repository.findFirst({
where: { id: repositoryId, ...visibleRepositoryWhere(scope) },
Expand All @@ -40,6 +47,7 @@ export async function findRepositoryIndex(
page,
selectedAuthor,
latestBuilds: buildSummaries,
reviewBuilds,
} = await database.$transaction(
async (transaction) => {
// Prisma cannot filter by the same COALESCE-ordered Build used by the card.
Expand Down Expand Up @@ -145,14 +153,40 @@ export async function findRepositoryIndex(
AND latest_build.number IS NOT NULL
`)
: []
// Select one preview per card, preferring a saved screenshot over a newer Build without one.
const reviewBuilds =
buildArtifactUrl && records.length > 0
? await transaction.$queryRaw<
{ prototypeId: string; id: string; number: number; hasScreenshot: boolean }[]
>(Prisma.sql`
SELECT prototypes.id AS "prototypeId", review_build.*
FROM prototypes
JOIN LATERAL (
SELECT builds.id, builds.number, (screenshot.id IS NOT NULL) AS "hasScreenshot"
FROM builds
JOIN build_artifacts AS dist
ON dist.build_id = builds.id AND dist.path = 'dist/index.html' AND dist.kind = 'dist'
LEFT JOIN build_artifacts AS screenshot
ON screenshot.build_id = builds.id AND screenshot.path = 'screenshots/desktop.png'
AND screenshot.kind = 'screenshot'
WHERE builds.prototype_id = prototypes.id AND builds.state = 'successful'
ORDER BY (screenshot.id IS NOT NULL) DESC,
COALESCE(builds.workflow_created_at, builds.created_at) DESC, builds.number DESC
LIMIT 1
) AS review_build ON TRUE
WHERE prototypes.id IN (${Prisma.join(
records.map(({ id }) => Prisma.sql`${id}::uuid`),
)})
`)
: []
// Name the selected user even when no card on this page belongs to them.
const selectedAuthor = filters.authorId
? await transaction.user.findFirst({
where: { id: filters.authorId, prototypes: { some: eligible } },
select: authorSelect,
})
: null
return { records, totalCount, page, selectedAuthor, latestBuilds }
return { records, totalCount, page, selectedAuthor, latestBuilds, reviewBuilds }
},
{ isolationLevel: "RepeatableRead" },
)
Expand Down Expand Up @@ -182,10 +216,12 @@ export async function findRepositoryIndex(
const latestBuilds = new Map(
buildSummaries.map(({ prototypeId, ...build }) => [prototypeId, build] as const),
)
const previews = new Map(reviewBuilds.map(({ prototypeId, ...build }) => [prototypeId, build]))
const prototypes = records.map((record) => {
if (!record.name) throw new Error("A registered prototype must have a name.")
addAuthor(record.author)
const latestBuild = latestBuilds.get(record.id)
const preview = previews.get(record.id)
return {
id: record.id,
repositoryId: record.repositoryId,
Expand All @@ -200,6 +236,21 @@ export async function findRepositoryIndex(
: null,
canEdit: false,
latestBuild: latestBuild ? { number: latestBuild.number, state: latestBuild.state } : null,
reviewBuild: preview
? {
number: preview.number,
desktopScreenshotUrl:
preview.hasScreenshot && buildArtifactUrl
? buildArtifactUrl(
preview.id,
record.repositoryId,
record.id,
preview.number,
"desktop",
)
: null,
}
: null,
builds: [],
}
})
Expand Down
Loading
Loading