chore: add offset-based pagination support to aibridge list endpoint (#20393)

Necessary for the frontend to be able to paginate easily. Cursor
pagination is good for fetching all events, but doesn't play very well
when a pagination component gets involved.

Adds support for `?offset=x` to the existing endpoint. The cursor-based
pagination (`?after_id=x`) is still supported. The two pagination modes
are mutually exclusive, and are documented as such. If both are
supplied, the request will be rejected.

Also adds a `total` property to the response that contains the full
count of items matching the filter. We already have indices in place so
I don't think this will impact performance (or we can revisit it before
GA).
This commit is contained in:
Dean Sheather
2025-10-21 11:50:00 +00:00
committed by GitHub
parent 01ff28db11
commit ea261a1f7c
17 changed files with 328 additions and 48 deletions
+10 -1
View File
@@ -91,9 +91,15 @@
},
{
"type": "string",
"description": "Cursor pagination after ID",
"description": "Cursor pagination after ID (cannot be used with offset)",
"name": "after_id",
"in": "query"
},
{
"type": "integer",
"description": "Offset pagination (cannot be used with after_id)",
"name": "offset",
"in": "query"
}
],
"responses": {
@@ -10427,6 +10433,9 @@
"items": {
"$ref": "#/definitions/codersdk.AIBridgeInterception"
}
},
"total": {
"type": "integer"
}
}
},