Skip to content

[AI Gateway] Surface ZDR on AI model catalog#31309

Open
superhighfives wants to merge 2 commits into
productionfrom
feat/aig-1205-zdr-badge
Open

[AI Gateway] Surface ZDR on AI model catalog#31309
superhighfives wants to merge 2 commits into
productionfrom
feat/aig-1205-zdr-badge

Conversation

@superhighfives

Copy link
Copy Markdown
Contributor

Ref: https://jira.cfdata.org/browse/AIG-1205

Threads the Zero Data Retention flag from the catalog API through the docs site so /ai/models cards display a "Zero data retention" badge when a model supports it. The catalog JSON files on disk already carry zdr and zdr_comment (the API returns them natively), but the zod schema was silently dropping both fields at content-collection load time.

Changes

  • src/schemas/catalog-models.ts — declare optional zdr and zdr_comment so Astro stops stripping them at content-collection load time.
  • src/util/model-resolver.ts — in catalogToResolved, push { property_id: "zdr", value: "true" } when model.zdr === true, and surface zdr_comment as zdrComment on the resolved model. Also propagated through toModelCardData so the slimmed card data carries it.
  • src/util/model-properties.ts — register zdr in CAPABILITY_PROPERTIES with the model category (gray default variant) so ModelBadges, the sidebar filters, and the badge list pick it up automatically alongside Function calling / Reasoning / Vision.
  • src/components/models/ModelBadges.tsx — read zdrComment off the model when present and attach it as the HTML title attribute on the ZDR badge span (tooltip on hover when the catalog row carries a comment, bare badge otherwise). Preserves the existing providerBadge row introduced after the original work was prepared.
  • src/util/model-types.ts — extend ResolvedModel and ModelCardData with optional zdrComment so the resolver → card → badge data flow is type-safe end-to-end.
  • bin/fetch-catalog-models.ts — declare zdr and zdr_comment on the local CatalogModel interface so future refreshes keep round-trip type safety with the upstream API.

Backwards compatibility

Older catalog rows that omit zdr entirely are treated the same as zdr: false — the badge stays hidden. Legacy Workers AI models never set zdrComment, so their badge rendering is unchanged.

Validation (run locally on the prior worktree before the canonical clone was migrated to this repo)

  • pnpm run sync ✓ — Astro types regenerated for the schema additions
  • pnpm run check ✓ — 362 files, 0 errors, 0 warnings
  • pnpm run lint
  • pnpm run format:core:check ✓ — "All matched files use Prettier code style"
  • pnpm run test ✓ — 40 passing across the Node + Astro suites; one pre-existing worker/index.worker.test.ts failure on the production branch is unrelated to this PR (reproduces with no changes).

The ModelBadges.tsx merge that combines the new providerBadge block with the ZDR tooltip wiring was prepared by diffing the worktree version against the latest production and folding both into a single file. Both branches are preserved; the Badge type was lifted out so it can carry the optional title field without union noise at the JSX site.

Threads the Zero Data Retention flag from the catalog API through
the docs site so /ai/models cards display a Zero data retention
badge when a model supports it. The catalog JSON files on disk
already carry zdr and zdr_comment (the API returns them natively),
but the zod schema was silently dropping both fields at content-
collection load time.

Changes:
- src/schemas/catalog-models.ts: declare optional zdr and
  zdr_comment so Astro stops stripping them at load time
- src/util/model-resolver.ts: in catalogToResolved, push
  { property_id: 'zdr', value: 'true' } when model.zdr === true
  and surface zdr_comment as zdrComment on the resolved model
- src/util/model-properties.ts: register zdr in
  CAPABILITY_PROPERTIES with the model category (gray default
  variant) so ModelBadges, the sidebar filters, and the badge
  list pick it up automatically
- src/components/models/ModelBadges.tsx: read zdrComment off the
  model when present and attach it as the HTML title attribute on
  the ZDR badge span — tooltip on hover when the catalog row
  carries a comment, bare badge otherwise. Preserves the existing
  providerBadge (Cloudflare-hosted vs Third-party) row.
- src/util/model-types.ts: extend ResolvedModel and ModelCardData
  with optional zdrComment so the resolver -> card -> badge data
  flow is type-safe end-to-end
- bin/fetch-catalog-models.ts: declare zdr and zdr_comment on the
  local CatalogModel interface so future refreshes keep round-trip
  type safety with the upstream API

Backwards-compatible: older catalog rows without zdr are treated
the same as zdr=false (badge stays hidden). Legacy Workers AI
models never set zdrComment so their badge rendering is unchanged.

Ref: https://jira.cfdata.org/browse/AIG-1205
Copilot AI review requested due to automatic review settings June 8, 2026 17:09
@cloudflare-docs-bot

cloudflare-docs-bot Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Review

✅ No style-guide issues found in commit b7e1034.

Commands

Only codeowners can run commands. Post a comment with the command to trigger it.

Command Description
/review Runs a review now. Incremental if a prior review exists, full if not.
/full-review Re-reviews the entire PR diff from scratch, ignoring incremental history. Useful after a rebase, when you want a fresh review, or if the bot gets out of sync and reports issues that no longer exist.

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
/bin/fetch-catalog-models.ts @abhishekkankani, @palashgo, @thebongy, @roerohan, @kathayl, @mchenco, @zeke, @superhighfives, @bfirsh, @mattrothenberg, @ethulia, @cloudflare/content-engineering, @cloudflare/product-owners, @kodster28
/src/components/ @cloudflare/content-engineering, @kodster28
*.ts @cloudflare/content-engineering, @kodster28

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.

Pull request overview

This PR threads the catalog API’s Zero Data Retention (ZDR) fields (zdr, zdr_comment) through the docs site’s model pipeline so /ai/models can display a “Zero data retention” badge, optionally with a tooltip sourced from zdr_comment. This fits into the existing model catalog ingestion/resolution flow (Astro content collections → resolved models → card data → React badges/filters).

Changes:

  • Extend the catalog Zod schema to retain zdr / zdr_comment during content collection loading.
  • Surface ZDR as a boolean capability property (property_id: "zdr") and propagate zdr_comment as zdrComment through ResolvedModelModelCardData.
  • Update ModelBadges to attach zdrComment as an HTML title tooltip on the ZDR badge when present.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/schemas/catalog-models.ts Adds optional zdr and zdr_comment to the catalog schema so Astro doesn’t strip them.
src/util/model-resolver.ts Converts zdr into a "zdr" capability property and carries zdr_comment through as zdrComment into card data.
src/util/model-properties.ts Registers zdr in CAPABILITY_PROPERTIES so badge/filter logic can pick it up.
src/components/models/ModelBadges.tsx Adds optional title support on badges and applies it to the ZDR badge using zdrComment.
src/util/model-types.ts Adds optional zdrComment to ResolvedModel and ModelCardData for end-to-end type safety.
bin/fetch-catalog-models.ts Updates the local CatalogModel interface to include optional zdr / zdr_comment for type-safe refreshes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ask-bonk ask-bonk Bot added the product:ai-gateway AI Gateway: https://developers.cloudflare.com/ai-gateway/ label Jun 8, 2026
@ask-bonk

ask-bonk Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

No issues found.

@ask-bonk ask-bonk Bot added the product:workers-ai Workers AI: https://developers.cloudflare.com/workers-ai/ label Jun 8, 2026
@ask-bonk

ask-bonk Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Verdict: No issues found. Code changes are clean and ready to merge.

Labels applied: product:ai-gateway, product:workers-ai

What this PR changes:

  • Adds Zero Data Retention (ZDR) badge support to the AI model catalog (/ai/models)
  • Threads two new fields from the catalog API (zdr, zdr_comment) through the entire data pipeline:
    • Schema declaration in catalog-models.ts so Astro/Zod stops stripping them
    • Type definitions in model-types.ts for type-safe flow from resolver → card → badge
    • Resolver logic in model-resolver.ts to convert zdr into a property badge and surface zdr_comment as zdrComment
    • Property registry in model-properties.ts so the badge/filter system picks up ZDR automatically
    • Badge component in ModelBadges.tsx to render the badge and attach zdrComment as an HTML title tooltip
    • Fetcher script interface in fetch-catalog-models.ts to preserve type safety during future catalog refreshes
  • Maintains backwards compatibility: models without zdr show no badge, legacy models are unaffected

Issues flagged: None. The type changes are consistent, the merge integration with the existing providerBadge logic is clean, and the PR description accurately describes the diff.

github run

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product:ai-gateway AI Gateway: https://developers.cloudflare.com/ai-gateway/ product:workers-ai Workers AI: https://developers.cloudflare.com/workers-ai/ size/m

Projects

None yet

Development

Successfully merging this pull request may close these issues.