Skip to content

feat(templates): read templates from api instead of dashboard-api - #539

Draft
nalekseev-e2b wants to merge 2 commits into
mainfrom
templates-from-api
Draft

nalekseev-e2b wants to merge 2 commits into
mainfrom
templates-from-api

Conversation

@nalekseev-e2b

Copy link
Copy Markdown

Why

api now serves the template routes the dashboard reads from dashboard-api: the template search, the default templates, the template tag reads and the template detail fields. This moves the templates module onto api, so dashboard-api's template routes can be removed later without breaking the dashboard.

Changes

Call dashboard-api today api
Template list (listTeamTemplates) GET /templates GET /unstable/templates/search
Template detail (getTemplate) GET /templates/{templateID} GET /templates/{templateID}?limit=1
Tags tab (groups, count, assignments, exists) GET /templates/{templateID}/tags/... same paths
Default templates (getDefaultTemplatesCached) GET /templates/defaults GET /default-templates
  • Spec sync (first commit): spec/openapi.infra.yaml copied from e2b-dev/infra main, as the daily sync workflow does, and infra-api.types.ts regenerated. This overlaps with the open sync PR chore: sync infra OpenAPI specs #520; whichever merges second rebases with a regen.
  • Template list: same search, sort, public, limit and cursor options and the same {data, nextCursor} response. A default template's description comes from description instead of defaultDescription.
  • Template detail: limit=1 keeps the builds page small, because the overview doesn't use builds. api returns names and aliases unordered while the list orders them by alias, so getTemplate sorts both and the title (the first plain name) matches the list row. api reports a build with no recorded disk size as 0, so the specs line hides a disk size of 0, as it hid dashboard-api's null.
  • Default templates: api returns Template items with names already as namespace/alias, so the mapping no longer rebuilds names. Defaults without a successful build are listed too, as api's list does.
  • Models (TemplateDetail, TemplatesSort, ListTeamTemplatesOptions, tag types) come from api's types. The templates module no longer uses the dashboard-api client. Sandboxes and builds still use it.
  • Behaviour difference: another team's template answers 403 instead of 404; both end on the detail page's error state.

Verification

  • New unit tests: templates-repository-api-reads.test.ts (detail call and limit=1, name order, list call and description mapping, tag groups call, default templates mapping) and template-specs.test.tsx (disk size shown, and hidden at 0; the second fails without the fix). templates-repository-assign-tag.test.ts drops the unused dashboard-api client.
  • bun run test:unit: 31 files, 317 tests pass. tsc --noEmit (after next typegen), biome ci lint, bun run format and knip:ci are clean.
  • Ran the dashboard locally against a local api with the new routes: the template list, search ("base" narrows to one row), overview (latest build and specs) and tags tab render, and every template read went to api.

Rollout

  • Needs an api that serves these routes (any api build from 2026-10-22 on). Against an older api, the template pages would fail.
  • Self-hosted bundles that pin dashboard and api together should take this dashboard release together with such an api. Older dashboards keep working until dashboard-api's template routes are removed.

Copied from e2b-dev/infra main, as the daily sync workflow does, and
regenerated infra-api.types.ts. Brings in the template search, default
templates, template tag and template detail routes the templates module
moves to next.
The template list, detail, tag reads and default templates now call api
routes: GET /unstable/templates/search, GET /templates/{templateID}?limit=1,
GET /templates/{templateID}/tags/* and GET /default-templates. The tag
writes, deletes and visibility updates already used api, so the templates
module no longer depends on the dashboard-api client.

- The detail sorts names and aliases, since api returns them unordered and
  the list orders them by alias; the title matches the list row.
- The specs line hides a disk size of 0, which api reports for a build that
  recorded none (dashboard-api returned null).
- Default templates map api's Template items directly; descriptions come
  from description.
@cla-bot cla-bot Bot added the cla-signed label Oct 23, 2026

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant