feat(site): add AI provider API client and query layer#25580
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ccdcc22c02
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /** @lintignore Consumed by component stories landing in the next PR of the AI settings stack. */ | ||
| export const MockAIProviderBedrock: TypesGen.AIProvider = { | ||
| id: "9c2e3b41-2e9f-4c97-9a4f-2e1a3d8f9f21", | ||
| type: "anthropic", |
There was a problem hiding this comment.
Use bedrock type in Bedrock mock provider
MockAIProviderBedrock is defined with type: "anthropic", which makes this fixture represent the wrong provider kind. Any stories or tests that branch on provider type (for example, showing Bedrock-only settings fields or validation) will exercise Anthropic behavior instead and can hide real Bedrock regressions.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pushing back on this one. The Bedrock wire representation is type: "anthropic" + settings._type: "bedrock", not type: "bedrock". Sources:
- The SDK constants in
codersdk/aiproviders.godocument thatAIProviderBedrockSettingsis "Only meaningful for AIProviderTypeAnthropic", and theAIProviderTypeBedrockconstant is reserved for future native gateway support. coderd/ai_providers.go:324rejects Bedrock settings on any provider whose type is notdatabase.AiProviderTypeAnthropic.isBedrockProvider(and every other helper that branches on it) requiresprovider.type === "anthropic"before reading the discriminator.
Flipping the mock to "bedrock" would make stories and tests assert against a wire shape the backend cannot emit. I left the mock at type: "anthropic" and added a JSDoc comment on the export explaining the convention so future readers do not get caught by the same trap.
Reply from Coder Agents on behalf of Jake Howell.
66f0b25 to
e0448f5
Compare
ccdcc22 to
30cfb56
Compare
e0448f5 to
faeb9d9
Compare
30cfb56 to
e6b423e
Compare
3146544 to
faa9eb3
Compare
Adds the frontend layer that talks to the existing /api/v2/ai/providers endpoints already shipped on main: - API client: getAIProviders, getAIProvider, createAIProvider, updateAIProvider, deleteAIProvider. - React Query wrappers in queries/aiProviders.ts with a shared key helper and matching cache invalidations. - Mock fixtures for OpenAI, Anthropic, and Bedrock providers in testHelpers/entities.ts for stories and unit tests. - viewAnyAIProvider registered in permissions.json so the existing permissions hook can read it. - viewAnyAIProvider added to canViewDeploymentSettings so admins who can only manage providers still see the deployment dropdown. No UI yet, the components and pages land in subsequent PRs.
e6b423e to
e2c7056
Compare
|
✅ Documentation check complete. No documentation updates needed. This PR adds frontend API client methods and React Query hooks for existing endpoints already documented in Automated review via Coder Agents |

Linear: DEVEX-355
Second PR in a 5-PR stack splitting #25328. Adds the frontend layer that talks to the existing
/api/v2/ai/providersendpoints already shipped onmain:getAIProviders,getAIProvider,createAIProvider,updateAIProvider,deleteAIProvider.queries/aiProviders.tswith a shared key helper and matching cache invalidations.testHelpers/entities.tsfor stories and unit tests.viewAnyAIProviderregistered inpermissions.jsonso the existing permissions hook can read it.viewAnyAIProvideradded tocanViewDeploymentSettingsso admins who can only manage providers still see the deployment dropdown.The
aiProvidersquery module and the per-provider mocks are temporarily added to theknipignore list / annotated with@lintignore; the next PRs in the stack consume them and remove the exclusions.Stack
Replaces #25328 once the stack lands.