Skip to content
This repository was archived by the owner on Sep 22, 2026. It is now read-only.

fix(frontend): derive the admin types from the OpenAPI spec - #1553

Merged
njbrake merged 1 commit into
mainfrom
simplify/10-frontend-generated-types
Sep 21, 2026
Merged

njbrake merged 1 commit into
mainfrom
simplify/10-frontend-generated-types

Conversation

@njbrake

@njbrake njbrake commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fourth of six stacked PRs. Targets #1552.

admin-api.ts hand-declared 80 interfaces under a comment claiming they "match backend schemas exactly". Twenty-one had an exact counterpart in src/generated/api.d.ts and are now aliases to it, matching what src/types.ts already does.

The generated types are stricter: tool_calls and args come out optional. That is a spec artifact, not an API behavior. A Pydantic default_factory emits no default key, and openapi-typescript marks a property required only when it is in required or carries a default. FastAPI serializes with exclude_unset=False, so those fields are always on the wire. The nullish guards added at the 14 call sites satisfy the type checker and change nothing at runtime.

Aliasing did surface a real inconsistency: LLMEndpointItem typed cache_control, reasoning, and pricing as plain strings while LLMEndpointUpsert typed the same three as Literals, so a value read from a GET could not be handed back to a PUT. The three sets now live in enums.py and are used by the ORM column, both schemas, and the service writer.

openapi.json and api.d.ts regenerated and committed.

Type

  • Refactor

Checklist

  • Tests pass (uv run pytest -v): 4268 passed, 6 skipped; frontend 425 passed, tsc and knip clean
  • Lint passes (ruff check backend/ && ruff format --check backend/)
  • New tests added for new functionality
  • Bug fixes include regression tests

AI Usage

  • AI-assisted: written by Claude Opus 5 via back-and-forth with @njbrake.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 30 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: mozilla-ai/clawbolt/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 7f45b67a-5afa-468b-b7d5-7e1537aa7598

📥 Commits

Reviewing files that changed from the base of the PR and between d08f76a and c71a8aa.

⛔ Files ignored due to path filters (1)
  • frontend/src/generated/api.d.ts is excluded by !**/generated/**
📒 Files selected for processing (7)
  • backend/app/enums.py
  • backend/app/models/llm.py
  • backend/app/schemas/llm.py
  • backend/app/services/llm_endpoints.py
  • frontend/openapi.json
  • frontend/src/extensions/admin/admin-api.ts
  • frontend/src/extensions/admin/tabs/shared.tsx

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@njbrake
njbrake force-pushed the simplify/10-frontend-generated-types branch from 1e430a6 to 864da2c Compare September 21, 2026 15:12
@njbrake
njbrake force-pushed the simplify/10-frontend-generated-types branch from 864da2c to 1cfcd65 Compare September 21, 2026 18:47
@njbrake
njbrake force-pushed the simplify/10-frontend-generated-types branch from 1cfcd65 to 2e3f2d3 Compare September 21, 2026 18:49
@njbrake
njbrake force-pushed the simplify/10-frontend-generated-types branch from 2e3f2d3 to 245bcea Compare September 21, 2026 19:00
@njbrake
njbrake force-pushed the simplify/10-frontend-generated-types branch from 245bcea to 063ef19 Compare September 21, 2026 19:10
Base automatically changed from simplify/09-dedupe to main September 21, 2026 19:18
admin-api.ts hand-declared 80 interfaces under a comment claiming they
"match backend schemas exactly". Twenty-one had an exact counterpart in
src/generated/api.d.ts and are now aliases to it, matching what
src/types.ts already does.

The generated types are stricter: tool_calls and args come out optional,
because a Pydantic default_factory emits no `default` key and
openapi-typescript marks a property required only when it is in
`required` or carries a default. That is a spec artifact, not an API
behavior. FastAPI serializes with exclude_unset=False, so those fields
are always present on the wire; a route returning SharedDataTurn with
only turn_index set still emits "tool_calls": []. The nullish guards
added at the 14 call sites satisfy the type checker and change nothing at
runtime.

Aliasing also surfaced a real inconsistency: LLMEndpointItem typed
cache_control, reasoning, and pricing as plain strings while
LLMEndpointUpsert typed the same three as Literals, so a value read from
a GET could not be handed back to a PUT. The three sets now live in
enums.py and are used by the ORM column, both schemas, and the service
writer.

openapi.json and api.d.ts regenerated. 4268 passed; frontend typecheck,
knip, and 425 vitest tests pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@njbrake
njbrake force-pushed the simplify/10-frontend-generated-types branch from 063ef19 to c71a8aa Compare September 21, 2026 19:18
@njbrake
njbrake merged commit 4e3f1d0 into main Sep 21, 2026
10 checks passed
@njbrake
njbrake deleted the simplify/10-frontend-generated-types branch September 21, 2026 19:29
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.

1 participant