Skip to content

feat(site): add AI provider API client and query layer#25580

Merged
jakehwll merged 1 commit into
mainfrom
jakehwll/DEVEX-355/02-api
May 26, 2026
Merged

feat(site): add AI provider API client and query layer#25580
jakehwll merged 1 commit into
mainfrom
jakehwll/DEVEX-355/02-api

Conversation

@jakehwll

@jakehwll jakehwll commented May 21, 2026

Copy link
Copy Markdown
Contributor

🤖 This PR was written by Coder Agents on behalf of Jake Howell.

Linear: DEVEX-355

Second PR in a 5-PR stack splitting #25328. 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.

The aiProviders query module and the per-provider mocks are temporarily added to the knip ignore list / annotated with @lintignore; the next PRs in the stack consume them and remove the exclusions.

Stack
  1. feat(site): add UI primitives for the AI settings stack #25579 jakehwll/DEVEX-355/01-primitives, primitives
  2. jakehwll/DEVEX-355/02-api, API client and query layer (this PR)
  3. jakehwll/DEVEX-355/03-components, provider form components
  4. jakehwll/DEVEX-355/04-pages, pages and routes
  5. jakehwll/DEVEX-355/05-section, section reshuffle

Replaces #25328 once the stack lands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.go document that AIProviderBedrockSettings is "Only meaningful for AIProviderTypeAnthropic", and the AIProviderTypeBedrock constant is reserved for future native gateway support.
  • coderd/ai_providers.go:324 rejects Bedrock settings on any provider whose type is not database.AiProviderTypeAnthropic.
  • isBedrockProvider (and every other helper that branches on it) requires provider.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.

jakehwll commented May 21, 2026

Copy link
Copy Markdown
Contributor Author

@jakehwll jakehwll changed the title feat(site/src/api): AI provider API client and query layer feat(site): add AI provider API client and query layer May 21, 2026
@jakehwll jakehwll force-pushed the jakehwll/DEVEX-355/01-primitives branch from 66f0b25 to e0448f5 Compare May 21, 2026 16:52
@jakehwll jakehwll force-pushed the jakehwll/DEVEX-355/02-api branch from ccdcc22 to 30cfb56 Compare May 21, 2026 16:52
@jakehwll jakehwll requested review from aslilac and jeremyruppel May 21, 2026 17:02
@jakehwll jakehwll force-pushed the jakehwll/DEVEX-355/01-primitives branch from e0448f5 to faeb9d9 Compare May 22, 2026 08:15
@jakehwll jakehwll force-pushed the jakehwll/DEVEX-355/02-api branch from 30cfb56 to e6b423e Compare May 22, 2026 08:15
@jakehwll jakehwll force-pushed the jakehwll/DEVEX-355/01-primitives branch from 3146544 to faa9eb3 Compare May 26, 2026 15:22
Base automatically changed from jakehwll/DEVEX-355/01-primitives to main May 26, 2026 16:01
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.
@jakehwll jakehwll force-pushed the jakehwll/DEVEX-355/02-api branch from e6b423e to e2c7056 Compare May 26, 2026 16:05
@jakehwll jakehwll enabled auto-merge (squash) May 26, 2026 16:05
@coder-tasks

coder-tasks Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

✅ Documentation check complete.

No documentation updates needed. This PR adds frontend API client methods and React Query hooks for existing endpoints already documented in docs/reference/api/aiproviders.md. These are internal implementation details consumed by later PRs in the stack.


Automated review via Coder Agents

@jakehwll jakehwll merged commit 5d39c83 into main May 26, 2026
27 of 28 checks passed
@jakehwll jakehwll deleted the jakehwll/DEVEX-355/02-api branch May 26, 2026 16:13
@github-actions github-actions Bot locked and limited conversation to collaborators May 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants