From 3d576dd08f325e6bca1a044b950c350b4b5d8a54 Mon Sep 17 00:00:00 2001 From: jabradford Date: Fri, 20 Nov 2026 15:39:58 -0800 Subject: [PATCH 1/4] fix(hub): polish prototype browsing and audit controls Keep the gallery steady during navigation, make author links text-sized, and let repository and audit controls accommodate longer names. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../view-models/repository-show-data/index.ts | 1 - .../components/prototype-card/index.tsx | 8 ++----- .../components/prototype-card/styles.css | 8 +++++++ .../components/repository-selector/styles.css | 7 +++++-- .../repositories-show-page/index.test.tsx | 16 ++++++++------ .../pages/repositories-show-page/index.tsx | 1 - .../pages/repositories-show-page/stories.tsx | 8 ------- .../pages/security-audit-page/styles.css | 21 +++++++++++++++++++ .../storybook/fixtures/prototype-listing.ts | 1 - hub/client/utils/prototype-listing/types.ts | 1 - hub/docs/frontend.md | 2 +- 11 files changed, 47 insertions(+), 27 deletions(-) diff --git a/hub/client/application/hub/view-models/repository-show-data/index.ts b/hub/client/application/hub/view-models/repository-show-data/index.ts index b2d95665c..9db436590 100644 --- a/hub/client/application/hub/view-models/repository-show-data/index.ts +++ b/hub/client/application/hub/view-models/repository-show-data/index.ts @@ -129,7 +129,6 @@ export function repositoryShowData( previous: "Previous", next: "Next", pagination: "Prototype pages", - updating: "Updating prototypes", shown: `${data.prototypes.length} shown`, }, }, diff --git a/hub/client/components/prototype-card/index.tsx b/hub/client/components/prototype-card/index.tsx index 7498234b1..1bccb3664 100644 --- a/hub/client/components/prototype-card/index.tsx +++ b/hub/client/components/prototype-card/index.tsx @@ -117,12 +117,8 @@ export function PrototypeCard({

{title}

{prototype.author.url ? ( - - {prototype.author.label} + + {prototype.author.ownerLabel} ) : ( {prototype.author.label} diff --git a/hub/client/components/prototype-card/styles.css b/hub/client/components/prototype-card/styles.css index d17135af0..f69301978 100644 --- a/hub/client/components/prototype-card/styles.css +++ b/hub/client/components/prototype-card/styles.css @@ -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); } diff --git a/hub/client/components/repository-selector/styles.css b/hub/client/components/repository-selector/styles.css index 7a14fac38..acb08dab5 100644 --- a/hub/client/components/repository-selector/styles.css +++ b/hub/client/components/repository-selector/styles.css @@ -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 { diff --git a/hub/client/pages/repositories-show-page/index.test.tsx b/hub/client/pages/repositories-show-page/index.test.tsx index c11133dcd..b221c984e 100644 --- a/hub/client/pages/repositories-show-page/index.test.tsx +++ b/hub/client/pages/repositories-show-page/index.test.tsx @@ -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" @@ -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() - 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( { />, ) - 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() diff --git a/hub/client/pages/repositories-show-page/index.tsx b/hub/client/pages/repositories-show-page/index.tsx index 27626490b..ebd4fbee6 100644 --- a/hub/client/pages/repositories-show-page/index.tsx +++ b/hub/client/pages/repositories-show-page/index.tsx @@ -131,7 +131,6 @@ export function RepositoriesShowPage({ tabIndex={-1} data-prototype-results > - {controls.pending ? {data.listing.copy.updating} : null} {controls.error ? ( 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, +.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; diff --git a/hub/client/storybook/fixtures/prototype-listing.ts b/hub/client/storybook/fixtures/prototype-listing.ts index 1f75d2eb4..0e734d6a3 100644 --- a/hub/client/storybook/fixtures/prototype-listing.ts +++ b/hub/client/storybook/fixtures/prototype-listing.ts @@ -25,7 +25,6 @@ export const prototypeListing: PrototypeListing = { previous: "Previous", next: "Next", pagination: "Prototype pages", - updating: "Updating prototypes", shown: "1 shown", }, } diff --git a/hub/client/utils/prototype-listing/types.ts b/hub/client/utils/prototype-listing/types.ts index 0d0d8a805..06b9cc534 100644 --- a/hub/client/utils/prototype-listing/types.ts +++ b/hub/client/utils/prototype-listing/types.ts @@ -51,7 +51,6 @@ export interface PrototypeListing { previous: string next: string pagination: string - updating: string shown: string } } diff --git a/hub/docs/frontend.md b/hub/docs/frontend.md index 7038bcdba..2e99bd08d 100644 --- a/hub/docs/frontend.md +++ b/hub/docs/frontend.md @@ -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. From 9cfdd8facdc0b94ab3dd413c80b721c2687aed53 Mon Sep 17 00:00:00 2001 From: jabradford Date: Fri, 20 Nov 2026 15:51:58 -0800 Subject: [PATCH 2/4] fix(hub): show saved Build screenshots in the gallery Select one saved image per visible prototype without loading Build history. Keep a usable screenshot when a newer Build fails or its screenshot has not arrived. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- hub/client/application/hub/contracts/index.ts | 3 + .../view-models/repository-show-data/index.ts | 8 +- .../repository-selector/stories.tsx | 3 + .../pages/repositories-show-page/stories.tsx | 6 +- .../pages/security-audit-page/stories.tsx | 18 +++ hub/docs/github-actions-builds.md | 2 + .../find-repository-index/index.ts | 53 +++++++- .../routes/api/product-index/index.db.test.ts | 115 ++++++++++++++++++ .../index.ts | 2 +- .../builds/access/get/index.test.ts | 13 ++ .../prototypes/builds/access/get/index.ts | 30 +++-- hub/test/local-smoke/browser.js | 9 ++ .../local-smoke/seed-local-workspace/index.ts | 30 ++++- 13 files changed, 267 insertions(+), 25 deletions(-) diff --git a/hub/client/application/hub/contracts/index.ts b/hub/client/application/hub/contracts/index.ts index 076e27b24..11a12a396 100644 --- a/hub/client/application/hub/contracts/index.ts +++ b/hub/client/application/hub/contracts/index.ts @@ -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, diff --git a/hub/client/application/hub/view-models/repository-show-data/index.ts b/hub/client/application/hub/view-models/repository-show-data/index.ts index 9db436590..9309e0b99 100644 --- a/hub/client/application/hub/view-models/repository-show-data/index.ts +++ b/hub/client/application/hub/view-models/repository-show-data/index.ts @@ -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 @@ -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 diff --git a/hub/client/components/repository-selector/stories.tsx b/hub/client/components/repository-selector/stories.tsx index 1c1a75831..1c379cf86 100644 --- a/hub/client/components/repository-selector/stories.tsx +++ b/hub/client/components/repository-selector/stories.tsx @@ -49,4 +49,7 @@ export const LongName: Story = { githubEmpty, ], }, + play: async ({ canvas, userEvent }) => { + await userEvent.click(canvas.getByRole("button", { name: /^Choose repository/ })) + }, } diff --git a/hub/client/pages/repositories-show-page/stories.tsx b/hub/client/pages/repositories-show-page/stories.tsx index 27fc7bb15..cdc9bea2a 100644 --- a/hub/client/pages/repositories-show-page/stories.tsx +++ b/hub/client/pages/repositories-show-page/stories.tsx @@ -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, }, { diff --git a/hub/client/pages/security-audit-page/stories.tsx b/hub/client/pages/security-audit-page/stories.tsx index 0332cf626..33049ffc8 100644 --- a/hub/client/pages/security-audit-page/stories.tsx +++ b/hub/client/pages/security-audit-page/stories.tsx @@ -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: { diff --git a/hub/docs/github-actions-builds.md b/hub/docs/github-actions-builds.md index b6c435c11..1fe3df4b9 100644 --- a/hub/docs/github-actions-builds.md +++ b/hub/docs/github-actions-builds.md @@ -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. diff --git a/hub/server/repositories/prototype-index/find-repository-index/index.ts b/hub/server/repositories/prototype-index/find-repository-index/index.ts index 973e6f9e3..3305ca9b5 100644 --- a/hub/server/repositories/prototype-index/find-repository-index/index.ts +++ b/hub/server/repositories/prototype-index/find-repository-index/index.ts @@ -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) }, @@ -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. @@ -145,6 +153,32 @@ 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({ @@ -152,7 +186,7 @@ export async function findRepositoryIndex( select: authorSelect, }) : null - return { records, totalCount, page, selectedAuthor, latestBuilds } + return { records, totalCount, page, selectedAuthor, latestBuilds, reviewBuilds } }, { isolationLevel: "RepeatableRead" }, ) @@ -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, @@ -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: [], } }) diff --git a/hub/server/routes/api/product-index/index.db.test.ts b/hub/server/routes/api/product-index/index.db.test.ts index a8cdfbd49..43203d89f 100644 --- a/hub/server/routes/api/product-index/index.db.test.ts +++ b/hub/server/routes/api/product-index/index.db.test.ts @@ -196,6 +196,121 @@ describe("real product index", () => { }) }) + it("pins the gallery screenshot to the newest eligible Build without returning Build history", async () => { + const applicationOrigin = "http://127.0.0.1:5173" + const previewBaseOrigin = "http://preview.localhost:3001" + const { id: repositoryId } = await prisma.repository.create({ + data: { nameWithOwner: "team/design", defaultBranch: "main" }, + }) + const registeredAt = new Date("2026-10-01") + const entry = { kind: "dist", path: "dist/index.html" } as const + const desktop = { kind: "screenshot", path: "screenshots/desktop.png" } as const + function artifacts(...files: (typeof entry | typeof desktop)[]) { + return { + create: files.map((file) => ({ ...file, storageKey: randomUUID(), byteLength: 80 })), + } + } + + const reviewBuildId = randomUUID() + const { id: prototypeId } = await prisma.prototype.create({ + data: { + repositoryId, + branchName: "prototype/welcome", + name: "Welcome", + registeredAt, + builds: { + create: [ + { + number: 9, + state: "successful", + workflowCreatedAt: new Date("2026-10-02"), + createdAt: new Date("2026-10-07"), + artifacts: artifacts(entry, desktop), + }, + { + id: reviewBuildId, + number: 2, + state: "successful", + createdAt: new Date("2026-10-03"), + artifacts: artifacts(entry, desktop), + }, + { + number: 3, + state: "successful", + createdAt: new Date("2026-10-04"), + artifacts: artifacts(entry), + }, + { + number: 4, + state: "successful", + createdAt: new Date("2026-10-05"), + artifacts: artifacts(desktop), + }, + { + number: 5, + state: "failed", + createdAt: new Date("2026-10-06"), + artifacts: artifacts(entry, desktop), + }, + ], + }, + }, + }) + const { id: previewOnlyPrototypeId } = await prisma.prototype.create({ + data: { + repositoryId, + branchName: "prototype/preview-only", + name: "Preview only", + registeredAt, + builds: { create: { number: 1, state: "successful", artifacts: artifacts(entry) } }, + }, + }) + + const restore = vi.fn().mockResolvedValue({ + membershipId: randomUUID(), + userId: randomUUID(), + provider: "github", + sessionProvider: "github", + login: "mona", + name: "Mona", + role: "MEMBER", + }) + const product = createProductRouteDependencies({ applicationOrigin, previewBaseOrigin }) + await withServer(restore, product, async (baseUrl) => { + const response = await fetch(`${baseUrl}/api/repositories/${repositoryId}`, { + headers: { cookie: "hub_session=member-session" }, + }) + expect(response.status).toBe(200) + const index = (await response.json()) as { + prototypes: { + id: string + reviewBuild: { number: number; desktopScreenshotUrl: string | null } | null + }[] + } + const prototype = index.prototypes.find(({ id }) => id === prototypeId) + expect(prototype).toMatchObject({ + latestBuild: { number: 5, state: "failed" }, + reviewBuild: { number: 2 }, + builds: [], + }) + const desktopScreenshotUrl = prototype?.reviewBuild?.desktopScreenshotUrl + expect(desktopScreenshotUrl).toBeTypeOf("string") + const screenshotUrl = new URL(desktopScreenshotUrl ?? "") + expect(screenshotUrl.origin).toBe(applicationOrigin) + expect(screenshotUrl.pathname).toBe( + `/api/repositories/${repositoryId}/prototypes/${prototypeId}/builds/2/access`, + ) + expect(screenshotUrl.searchParams.get("target")).toBe("desktop") + expect([null, `http://${reviewBuildId}.preview.localhost:3001`]).toContain( + screenshotUrl.searchParams.get("preview_origin"), + ) + expect(index.prototypes.find(({ id }) => id === previewOnlyPrototypeId)).toMatchObject({ + reviewBuild: { number: 1, desktopScreenshotUrl: null }, + builds: [], + }) + }) + }) + it("lists active repositories and only reviewable prototypes for GitHub and Entra members", async () => { const repositoryId = randomUUID() const anotherRepositoryId = randomUUID() diff --git a/hub/server/routes/api/product/create-product-route-dependencies/index.ts b/hub/server/routes/api/product/create-product-route-dependencies/index.ts index 5655a6ae2..398a39ff7 100644 --- a/hub/server/routes/api/product/create-product-route-dependencies/index.ts +++ b/hub/server/routes/api/product/create-product-route-dependencies/index.ts @@ -423,7 +423,7 @@ export function createProductRouteDependencies({ }, findRepositoryIndex: (viewer, repositoryId, filters) => readScoped(viewer, (repositoryScope) => - findRepositoryIndex(prisma, repositoryId, filters, repositoryScope), + findRepositoryIndex(prisma, repositoryId, filters, repositoryScope, buildArtifactUrl), ), findPrototypeDetail: (viewer, repositoryId, prototypeId, buildNumber, buildPage) => readScoped(viewer, (repositoryScope) => diff --git a/hub/server/routes/api/repositories/prototypes/builds/access/get/index.test.ts b/hub/server/routes/api/repositories/prototypes/builds/access/get/index.test.ts index 40b609266..68b75df5d 100644 --- a/hub/server/routes/api/repositories/prototypes/builds/access/get/index.test.ts +++ b/hub/server/routes/api/repositories/prototypes/builds/access/get/index.test.ts @@ -126,6 +126,19 @@ describe("get()", () => { }) }) + it("does not grant screenshot access when the repository is no longer visible", async () => { + await withAccessRoute(async (url, product) => { + vi.mocked(product.isRepositoryVisible).mockResolvedValueOnce(true).mockResolvedValue(false) + const response = await fetch(`${url}?target=desktop`, { + headers: { cookie: "hub_session=member-session" }, + redirect: "manual", + }) + + expect(response.status).toBe(404) + expect(response.headers.get("location")).toBeNull() + }) + }) + it("discards the target when session authority changes during the read", async () => { const viewer = { membershipId: randomUUID(), diff --git a/hub/server/routes/api/repositories/prototypes/builds/access/get/index.ts b/hub/server/routes/api/repositories/prototypes/builds/access/get/index.ts index 4b6e9f616..c752c0f17 100644 --- a/hub/server/routes/api/repositories/prototypes/builds/access/get/index.ts +++ b/hub/server/routes/api/repositories/prototypes/builds/access/get/index.ts @@ -8,6 +8,7 @@ import { hubSessionCookieName } from "../../../../../../../integrations/express/ import { readCookie } from "../../../../../../../integrations/express/read-cookie/index.ts" import type { CurrentSessionDependencies } from "../../../../../auth/types.ts" import { readProductSession } from "../../../../../product/read-product-session/index.ts" +import { readProductWithCurrentAuthority } from "../../../../../product/read-product-with-current-authority/index.ts" import { normalizeStartPage } from "../../../../../../../utils/normalize-start-page/index.ts" import type { ProductRouteDependencies } from "../../../../../product/types.ts" import type { BuildPreviewRouteDependencies } from "../../../../../../build-preview/types.ts" @@ -41,21 +42,28 @@ export function get( response.status(400).json({ error: "Enter a valid Build preview address." }) return } - const target = await product.findBuildPreviewTarget( - repositoryId.data, - prototypeId.data, - buildNumber.data, - query.data.target, + const read = await readProductWithCurrentAuthority( + initial, + cookie, + session, + async (viewer) => { + if (!(await product.isRepositoryVisible(viewer, repositoryId.data))) return null + const target = await product.findBuildPreviewTarget( + repositoryId.data, + prototypeId.data, + buildNumber.data, + query.data.target, + ) + return target && (await product.isRepositoryVisible(viewer, repositoryId.data)) + ? target + : null + }, ) - const current = await readProductSession(cookie, session) - if ( - !current || - current.membershipId !== initial.membershipId || - current.userId !== initial.userId - ) { + if (!read) { response.status(401).json({ error: "Sign in to continue." }) return } + const target = read.result if (!target) { response.status(404).json({ error: "Build preview not found." }) return diff --git a/hub/test/local-smoke/browser.js b/hub/test/local-smoke/browser.js index b1e0892de..114e543de 100644 --- a/hub/test/local-smoke/browser.js +++ b/hub/test/local-smoke/browser.js @@ -30,6 +30,15 @@ Object(async (page) => { const welcome = prototypes.getByRole("link", { name: "Welcome", exact: true }) const noBuild = prototypes.getByRole("link", { name: "No Build", exact: true }) await welcome.waitFor() + const screenshot = prototypes.getByRole("img", { name: "Welcome, Build 1", exact: true }) + await screenshot.scrollIntoViewIfNeeded() + const screenshotLoaded = await screenshot.evaluate(async (image) => { + await image.decode() + return image.naturalWidth === 1 && image.naturalHeight === 1 + }) + if (!screenshotLoaded) { + throw new Error("The gallery did not display the saved Welcome screenshot.") + } const galleryNames = await prototypes.getByRole("link").allTextContents() await admin.getByRole("link", { name: "Edit prototype listings", exact: true }).click() diff --git a/hub/test/local-smoke/seed-local-workspace/index.ts b/hub/test/local-smoke/seed-local-workspace/index.ts index 99e17a95d..edb707f63 100644 --- a/hub/test/local-smoke/seed-local-workspace/index.ts +++ b/hub/test/local-smoke/seed-local-workspace/index.ts @@ -16,6 +16,16 @@ export async function seedLocalWorkspace(root: string, artifactDirectory: string const write = await storage.write(storageKey, bytes) if (write.status !== "ok") throw new Error(`Could not save the smoke Build: ${write.status}.`) + const screenshotKey = "welcome_smoke_desktop" + const screenshot = Buffer.from( + "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVR4AWP4DwQACfsD/c8LaHIAAAAASUVORK5CYII=", + "base64", + ) + const screenshotWrite = await storage.write(screenshotKey, screenshot) + if (screenshotWrite.status !== "ok") { + throw new Error(`Could not save the smoke Build screenshot: ${screenshotWrite.status}.`) + } + const registeredAt = new Date("2026-01-01T00:00:00Z") const templateArtifacts = [ { path: "dist/index.html", kind: "dist", value: "

Default template

" }, @@ -91,12 +101,20 @@ export async function seedLocalWorkspace(root: string, artifactDirectory: string startedAt: registeredAt, finishedAt: registeredAt, artifacts: { - create: { - kind: "dist", - path: "dist/index.html", - storageKey, - byteLength: bytes.byteLength, - }, + create: [ + { + kind: "dist", + path: "dist/index.html", + storageKey, + byteLength: bytes.byteLength, + }, + { + kind: "screenshot", + path: "screenshots/desktop.png", + storageKey: screenshotKey, + byteLength: screenshot.byteLength, + }, + ], }, }, }, From 008ee5de941217f14f103860cb35b7aa2fe79d4a Mon Sep 17 00:00:00 2001 From: jabradford Date: Fri, 20 Nov 2026 16:00:41 -0800 Subject: [PATCH 3/4] fix(hub): let audit scope labels grow before truncating Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- hub/client/pages/security-audit-page/styles.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hub/client/pages/security-audit-page/styles.css b/hub/client/pages/security-audit-page/styles.css index 3a628a4d2..c5667ae6f 100644 --- a/hub/client/pages/security-audit-page/styles.css +++ b/hub/client/pages/security-audit-page/styles.css @@ -28,6 +28,10 @@ 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; From 9ad1f261d0b9372da742815a12370e59816a1b9e Mon Sep 17 00:00:00 2001 From: jabradford Date: Fri, 20 Nov 2026 16:04:02 -0800 Subject: [PATCH 4/4] fix(hub): fit the audit scope button on narrow screens Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- hub/client/pages/security-audit-page/styles.css | 1 + 1 file changed, 1 insertion(+) diff --git a/hub/client/pages/security-audit-page/styles.css b/hub/client/pages/security-audit-page/styles.css index c5667ae6f..1037212db 100644 --- a/hub/client/pages/security-audit-page/styles.css +++ b/hub/client/pages/security-audit-page/styles.css @@ -1,5 +1,6 @@ .security-audit-page { display: grid; + grid-template-columns: minmax(0, 1fr); gap: 1.5rem; max-width: 75rem; margin-inline: auto;