Skip to content

Conversation

@dobrac
Copy link
Contributor

@dobrac dobrac commented Oct 27, 2025

Summary

Adds the ability to list all builds for a template via the GET /templates/{templateID} endpoint.

Changes

  • Response schema:
    • Template fields (templateID, public, aliases, timestamps, etc.)
    • builds array containing complete build history
  • Each build contains build metadata:
    • buildID - unique identifier for the build
    • status - current build status
    • createdAt, updatedAt, finishedAt - timestamps
    • cpuCount, memoryMB, diskSizeMB - resource configuration
    • envdVersion - version of the envd used

Note

Adds GET /templates/{templateID} to return a template with its paginated build history and introduces shared cursor-based pagination, updating schemas, handlers, DB queries, and clients.

  • API/Spec:
    • New endpoint GET /templates/{templateID} with nextToken/limit to return TemplateWithBuilds (template + paginated builds).
    • Introduce reusable pagination params (paginationNextToken, paginationLimit) and apply to v2/sandboxes.
    • Split build schemas: TemplateBuild (metadata) vs TemplateBuildInfo (status/logs); update build-status endpoint to return TemplateBuildInfo.
  • Handlers:
    • Implement GetTemplatesTemplateID to authorize, fetch template + builds via cursor, and set X-Next-Token.
    • Refactor GetV2Sandboxes to use new pagination utility.
  • DB:
    • Add GetTemplateByIDWithAliases and GetTemplateBuilds (cursor on (created_at, id)), with generated sqlc code.
  • Utils:
    • New generic pagination helper (NewPagination, ProcessResultsWithHeader) and export MaxSandboxID; add CastPtr.
  • Types/Clients:
    • TemplateBuild now includes buildID (uuid), timestamps, resources; logging moved to TemplateBuildInfo.
    • Regenerate API types/clients/tests to reflect new endpoint, params, and schemas.

Written by Cursor Bugbot for commit 6dbcfb8. This will update automatically on new commits. Configure here.

@dobrac dobrac added the feature New feature label Oct 27, 2025
@linear
Copy link

linear bot commented Oct 27, 2025

@dobrac dobrac changed the base branch from main to return-also-templates-that-are-building-for-the-first-time-eng-3222 October 27, 2025 18:51
@dobrac dobrac force-pushed the add-list-of-builds-per-template-eng-3221 branch from 9011e0f to 9c8e858 Compare October 27, 2025 19:00
cursor[bot]

This comment was marked as outdated.

@dobrac dobrac force-pushed the add-list-of-builds-per-template-eng-3221 branch from 9c8e858 to 42b8067 Compare October 27, 2025 19:03
cursor[bot]

This comment was marked as outdated.

Base automatically changed from return-also-templates-that-are-building-for-the-first-time-eng-3222 to main October 27, 2025 19:05
@dobrac dobrac force-pushed the add-list-of-builds-per-template-eng-3221 branch from 42b8067 to 28469c3 Compare October 27, 2025 19:07
cursor[bot]

This comment was marked as outdated.

@dobrac dobrac force-pushed the add-list-of-builds-per-template-eng-3221 branch from 28469c3 to 7b3d08d Compare October 27, 2025 19:10
cursor[bot]

This comment was marked as outdated.

@dobrac dobrac force-pushed the add-list-of-builds-per-template-eng-3221 branch from 7b3d08d to b399ec4 Compare October 27, 2025 19:15
@sitole sitole self-requested a review October 29, 2025 12:26
@dobrac dobrac marked this pull request as draft October 30, 2025 17:49
@dobrac dobrac force-pushed the add-list-of-builds-per-template-eng-3221 branch from b399ec4 to 98d653e Compare October 31, 2025 00:41
@dobrac dobrac force-pushed the add-list-of-builds-per-template-eng-3221 branch from 9a22c03 to b04127d Compare October 31, 2025 00:48
@dobrac dobrac marked this pull request as ready for review October 31, 2025 14:22
@dobrac dobrac requested a review from sitole October 31, 2025 14:22
SELECT eb.*
FROM public.env_builds eb
WHERE eb.env_id = sqlc.arg(template_id)
AND (eb.created_at, eb.id::text) < (@cursor_time, @cursor_id::text)
Copy link
Member

Choose a reason for hiding this comment

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

I think use of uuidv7 can can help here a lot

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe, but only if we're generating them all from the database. Otherwise it's not guaranteed that the uuidv7 generated in one place is always preceeding uuid generated in another afaik

Copy link
Member

Choose a reason for hiding this comment

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

Yep, but as it's part of B-tree, I think it will still benefit from only local arrangements (because you insert newer UUID and then older) than reworking the whole tree because of UUIDv4 use.

@dobrac dobrac merged commit 249e984 into main Nov 3, 2025
48 of 49 checks passed
@dobrac dobrac deleted the add-list-of-builds-per-template-eng-3221 branch November 3, 2025 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants