mirror of
https://github.com/coder/coder.git
synced 2026-06-04 05:28:20 +00:00
59cec5be65
## Summary The `chattool` `list_templates` tool previously returned all templates in a single response with no popularity signal. On deployments with many templates (e.g. 71 on dogfood), this wastes tokens and makes it hard for the AI to pick the right template for broad user questions. ## Changes Single file: `coderd/chatd/chattool/listtemplates.go` - **`page` parameter** — optional, 1-indexed, 10 results per page - **Popularity sort** — queries `GetWorkspaceUniqueOwnerCountByTemplateIDs` to get active developer counts, then sorts descending (most popular first). The DB query returns templates alphabetically, so this explicit sort is needed. - **`active_developers`** — included on each template item so the agent can see the signal - **Pagination metadata** — `page`, `total_pages`, `total_count` in the response so the agent knows there are more results - **Updated tool description** — tells the agent that results are ordered by popularity and paginated ## Frontend No frontend changes needed. The renderer already reads `rec.templates` and `rec.count` from the response — the new fields (`page`, `total_pages`, `total_count`) are additive and safely ignored.