Skip to content

feat(hub): serve private Builds on canonical paths - #332

Open
weastler wants to merge 3 commits into
build/hub/newfrom
weastler-private-path-previews
Open

weastler wants to merge 3 commits into
build/hub/newfrom
weastler-private-path-previews

Conversation

@weastler

@weastler weastler commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Why

Private Build previews should work on the Hub's existing hostname. Requiring a separate wildcard preview domain currently leaves preview and screenshot URLs unavailable on installations that have artifact storage but no wildcard configuration.

What changes

  • Previews and screenshots use the Hub's existing website address. They no longer need a separate preview domain, wildcard DNS, or certificate setup. Each successful GitHub Build has its own URL under /previews/github/<repository-id>/<workflow-run-id>/.
  • Every file request checks sign-in and repository access. If Hub cannot identify exactly one Build for a URL, it refuses the request rather than showing the wrong prototype. When a later workflow run reuses an existing Build, that Build keeps its original URL.
  • Gallery screenshots, templates, Controls, and review links use these URLs. Existing screenshots can be served without rebuilding the prototype. The gallery and author fixes already on the target branch are preserved.
  • The old private-preview machinery is removed. The separate-domain redirects, temporary access tokens, preview cookies, and related URL settings are no longer used for private previews. Existing public sharing is unchanged and still uses its separate-domain configuration; the proposed sharing service is not part of this PR.
  • Large-file safeguards are preserved. Both private previews and existing public sharing use the same memory budget from fix(build): allow 100 MiB prototype static files #329. Unchanged cached assets can be reused after access is checked again.

Compatibility: prototypes must be built for their preview URL, or use relative asset URLs and hash routing as Starter now does. Older prototypes built for / need a new commit and rebuild to load correctly; their saved Builds and files are not modified. Local Builds and other Builds without GitHub repository/run IDs do not receive private preview URLs.

Browser trust: prototype JavaScript runs on the same website address as Hub and can act with the viewer's Hub permissions. This relies on trusting the people who publish prototypes.

This PR does not deploy Hub, update Mini Foundry's workflow, or repair author data. Production behavior has not been verified end-to-end. The optional Linux browser smoke check was not run because its playwright-cli prerequisite is unavailable.

@weastler
weastler requested review from a team and nshki as code owners November 21, 2026 00:40
Copilot AI adaptive review requested due to automatic review settings November 21, 2026 00:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The ownership lookup can treat an ambiguous run as uniquely owned after branch retirement, causing a retired prototype’s preview URL to serve another prototype’s content.

9 open issues
6 files not reviewed
  • .github/extensions/replica-prototype/assets/canvas-bridge.js: Generated file
  • .github/extensions/replica-prototype/assets/renderer-improvement-notes-prototype.js: Generated file
  • .github/extensions/replica-prototype/assets/renderer-prototype-canvas-improvement-threads.js: Generated file
  • .github/extensions/replica-prototype/assets/renderer.js: Generated file
  • hub/.storybook/preview-fixtures/build-controls/controls.js: Generated file
  • hub/client/features/install-replica-controls-bridge/bridge.js: Generated file
What changed in this PR

Moves private GitHub Build previews onto Hub’s existing hostname using fixed repository and owning-run paths. This connects saved artifacts to Hub’s preview, template, Controls, and review flows without requiring wildcard infrastructure. Public sharing retains its separate configuration; local Builds no longer receive private previews.

Changes:

  • Adds session-authorized path serving and reuses the shared 100 MiB response allowance introduced in #329.
  • Preserves preview prefixes across templates, Controls, review anchors, navigation, and copied URLs.
  • Adds screenshot capture at the original compiled base, switches Starter to relative output, and removes private wildcard authorization.
File Description
starter/​vite.config.ts Emits relative asset URLs.
starter/​README.md Explains preview-base compatibility and rebuilding.
hub/​vite.config.ts Proxies private preview requests locally.
hub/​test/​local-smoke/​browser.js Checks unavailable local-preview states.
hub/​server/​utils/​create-build-preview-path/​index.ts Constructs canonical GitHub preview paths.
hub/​server/​routes/​index.ts Registers private mounts and retained public serving.
hub/​server/​routes/​build-preview/​types.ts Defines path-target dependencies and optional wildcard origin.
hub/​server/​routes/​build-preview/​share-authorize/​get/​index.ts Guards public authorization without wildcard configuration.
hub/​server/​routes/​build-preview/​share-authorize/​get/​index.test.ts Removes obsolete private-preview fixture dependencies.
hub/​server/​routes/​build-preview/​serve/​get/​index.ts Retains public-only wildcard serving.
hub/​server/​routes/​build-preview/​serve/​get/​index.test.ts Updates public serving and revocation coverage.
hub/​server/​routes/​build-preview/​path/​get/​index.ts Serves private resources with live access checks.
hub/​server/​routes/​build-preview/​path/​get/​index.db.test.ts Covers composed URLs, sessions, and repository access.
hub/​server/​routes/​build-preview/​create-preview-response-reservation/​index.ts Shares byte-reservation lifecycle handling.
hub/​server/​routes/​build-preview/​create-build-preview-route-dependencies/​index.ts Enables private serving without a wildcard origin.
hub/​server/​routes/​build-preview/​create-build-preview-route-dependencies/​index.test.ts Covers wildcard-free preview composition.
hub/​server/​routes/​build-preview/​authorize/​get/​index.ts Removes private grant exchange.
hub/​server/​routes/​build-preview/​authorize/​get/​index.test.ts Removes obsolete grant-exchange tests.
hub/​server/​routes/​api/​repositories/​templates/​index.ts Redirects template access to canonical mounts.
hub/​server/​routes/​api/​repositories/​templates/​index.test.ts Covers mounted and identifier-less templates.
hub/​server/​routes/​api/​repositories/​templates/​index.db.test.ts Updates persisted template preview coverage.
hub/​server/​routes/​api/​repositories/​prototypes/​builds/​access/​get/​index.ts Redirects Build access to its fixed prefix.
hub/​server/​routes/​api/​repositories/​prototypes/​builds/​access/​get/​index.test.ts Covers canonical redirects and denied access.
hub/​server/​routes/​api/​public-sharing/​hosted-sharing.db.test.ts Separates product URLs from wildcard configuration.
hub/​server/​routes/​api/​product/​create-product-route-dependencies/​index.ts Generates canonical artifact URLs.
hub/​server/​repositories/​prototype-index/​find-prototype-detail/​index.ts Projects preview URLs from GitHub identifiers.
hub/​server/​repositories/​prototype-index/​find-prototype-detail/​index.db.test.ts Covers canonical detail URLs.
hub/​server/​repositories/​build-artifacts/​find-path-preview-targets/​index.ts Resolves owning runs and detects ambiguous targets.
hub/​server/​repositories/​build-artifacts/​find-path-preview-targets/​index.db.test.ts Covers ownership, eligibility, and exact identifiers.
hub/​server/​repositories/​build-artifacts/​find-default-template-build/​index.ts Adds canonical mounts to template snapshots.
hub/​server/​repositories/​build-artifacts/​find-build-preview-target/​index.ts Returns mount paths for Build access.
hub/​server/​integrations/​express/​create-preview-cookie/​index.ts Removes private wildcard cookie creation.
hub/​server/​index.ts Composes private previews whenever storage is available.
hub/​server/​index.test.ts Covers startup without wildcard configuration.
hub/​server/​domains/​local-builds/​synchronize-local-builds/​index.db.test.ts Expects no canonical mount for local Builds.
hub/​server/​domains/​build-preview/​read-preview-session/​index.ts Removes private wildcard session decoding.
hub/​server/​domains/​build-preview/​read-preview-session/​index.test.ts Removes obsolete private-session tests.
hub/​server/​domains/​build-preview/​read-preview-grant/​index.ts Removes private preview grant decoding.
hub/​server/​domains/​build-preview/​read-preview-grant/​index.test.ts Removes obsolete private-grant tests.
hub/​server/​domains/​build-preview/​read-build-preview-file/​types.ts Accepts a preview mount prefix.
hub/​server/​domains/​build-preview/​read-build-preview-file/​index.ts Passes the prefix into bridge injection.
hub/​server/​domains/​build-preview/​inject-preview-bridge/​index.ts Injects the bridge beneath the active mount.
hub/​server/​domains/​build-preview/​create-preview-session/​index.ts Removes private wildcard session creation.
hub/​server/​domains/​build-preview/​create-preview-grant/​index.ts Removes private preview grant creation.
hub/​server/​create-app/​index.ts Applies security middleware to private preview paths.
hub/​server/​create-app/​index.test.ts Updates authorization logging and serving fixtures.
hub/​docs/​testing-and-operations.md Describes revised local smoke behavior.
hub/​docs/​share-links.md Clarifies the retained public-preview boundary.
hub/​docs/​github-actions-builds.md Documents compiled bases and screenshot inputs.
hub/​docs/​frontend.md Describes canonical previews and local limitations.
hub/​docs/​development.md Updates proxy guidance and local-preview availability.
hub/​docs/​build-previews.md Defines serving, trust, compatibility, and rollout contracts.
hub/​docs/​architecture.md Describes same-origin private preview architecture.
hub/​client/​utils/​prototype-controls/​preview-base-path.mjs Extracts canonical preview prefixes.
hub/​client/​utils/​prototype-controls/​preview-base-path.d.mts Types the prefix helper.
hub/​client/​utils/​prototype-controls/​browser-entry.mjs Derives the screenshot adapter’s base path.
hub/​client/​utils/​prototype-controls/​bindings.mjs Loads Controls definitions beneath the preview base.
hub/​client/​utils/​prototype-controls/​bindings.d.mts Types optional Controls base paths.
hub/​client/​utils/​get-url-origin/​index.ts Removes private wildcard origin hints.
hub/​client/​utils/​get-url-origin/​index.test.ts Covers canonical Hub origins.
hub/​client/​utils/​create-preview-prototype-prompt/​index.ts Uses logical routes in prototype prompts.
hub/​client/​pages/​replica-browse-page/​index.tsx Preserves mounts in displayed template addresses.
hub/​client/​pages/​replica-browse-page/​index.test.tsx Covers template addresses after navigation.
hub/​client/​pages/​prototypes-show-page/​index.tsx Preserves canonical prefixes in preview links.
hub/​client/​pages/​prototypes-show-page/​index.test.tsx Covers copying the current canonical route.
hub/​client/​hooks/​use-prototype-viewer-url/​index.ts Stores logical return routes without mount prefixes.
hub/​client/​hooks/​use-preview-bridge/​index.ts Matches logical routes during fragment restoration.
hub/​client/​hooks/​use-canvas-preview-navigation/​index.ts Reapplies mounts during navigation and history changes.
hub/​client/​hooks/​use-canvas-preview-navigation/​index.test.tsx Covers prefixed navigation and history travel.
hub/​client/​features/​prototype-canvas-improvement-notes/​index.tsx Keeps note navigation within the preview mount.
hub/​client/​features/​install-replica-preview-bridge/​index.test.ts Covers anchors across owning-run mounts.
hub/​client/​features/​install-replica-preview-bridge/​index.js Reports and compares logical review paths.
hub/​client/​features/​install-replica-preview-bridge/​create-preview-bridge-test-harness/​index.ts Supports custom mounted preview URLs.
hub/​client/​application/​prototype-preview-bridge/​index.ts Recognizes prefixed hosted bridges and logical routes.
hub/​client/​application/​prototype-preview-bridge/​index.test.ts Covers hosted bridge ownership at both bases.
hub/​client/​application/​hub/​view-models/​product-share-links-data/​index.ts Keeps sharing independent of private-preview availability.
hub/​client/​application/​hub/​view-models/​product-share-links-data/​index.test.ts Covers sharing without a private mount.
hub/​client/​application/​hub/​routes/​real-local-review-flow.test.tsx Uses canonical URLs in review-flow fixtures.
hub/​client/​application/​hub/​routes/​expanded-flows.test.tsx Updates successful-Build sharing expectations.
hub/​.env.example Clarifies the wildcard setting in comments.
actions/​build/​scripts/​normalize-base-path/​index.mjs Validates screenshot capture base paths.
actions/​build/​scripts/​create-static-server/​index.test.mjs Covers prefixed static serving and template routes.
actions/​build/​scripts/​create-static-server/​index.mjs Mounts captured output beneath its compiled base.
actions/​build/​scripts/​capture-screenshots/​index.test.mjs Covers fixed-base apps, lazy modules, and Controls.
actions/​build/​scripts/​capture-screenshots/​index.mjs Applies the original base throughout capture.
actions/​build/​scripts/​action-contract/​index.test.mjs Covers forwarding the capture base input.
actions/​build/​screenshots/​action.yml Exposes base-path for separate capture.
actions/​build/​action.yml Exposes base-path for inline capture.
.github/​extensions/​replica-prototype/​assets/​renderer-prototype-canvas-improvement-threads.js Refreshes generated renderer imports.
.github/​extensions/​replica-prototype/​assets/​renderer-improvement-notes-prototype.js Includes mount-aware note navigation in generated output.

Review effort: Max (adaptive)

Comment thread hub/server/routes/index.ts Resolved
weastler and others added 3 commits November 20, 2026 19:25
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@weastler
weastler force-pushed the weastler-private-path-previews branch from 6fa5d05 to ab9cc77 Compare November 21, 2026 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants