feat: preview upstream model catalog refresh#162
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #162 +/- ##
==========================================
- Coverage 80.22% 80.15% -0.07%
==========================================
Files 118 118
Lines 9995 10035 +40
Branches 3501 3515 +14
==========================================
+ Hits 8018 8044 +26
- Misses 1280 1285 +5
- Partials 697 706 +9
*This pull request uses carry forward flags. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a new "preview" catalog refresh flow so the upstream edit dialog can refresh model catalogs against the editor's unsaved base_url, api_key, route capabilities, and discovery settings, persisting the previewed catalog alongside the form save instead of mutating the upstream record immediately. Catalog import is also reworked to populate local form rules first and persist on save.
Changes:
- New
POST /api/admin/upstreams/[id]/catalog/previewendpoint backed by apreviewUpstreamCatalogservice that runs the discovery against editor-supplied values, falling back to the stored API key when none is provided. - New
usePreviewUpstreamCataloghook plus refactoredUpstreamFormDialogthat previews into a workspace upstream, imports models locally intomodel_rules, and writes the previewed catalog fields on save. - Updated copy (
catalogSavedConfigHint) and tests covering the API route, hook, and dialog flows.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/app/api/admin/upstreams/[id]/catalog/preview/route.ts | New admin endpoint validating editor values and returning a preview catalog. |
| src/lib/services/upstream-crud.ts | Adds UpstreamCatalogPreviewInput and previewUpstreamCatalog service (no DB write). |
| src/lib/services/upstream-service.ts | Re-exports the new preview function and input type. |
| src/hooks/use-upstreams.ts | Adds usePreviewUpstreamCatalog mutation. |
| src/types/api.ts | Adds preview request/response API types. |
| src/components/admin/upstream-form-dialog.tsx | Switches refresh to preview, imports catalog into local rules, persists previewed catalog on save, adjusts dirty/blocked logic. |
| src/messages/en.json, src/messages/zh-CN.json | Updates the catalog hint copy to reflect the new behavior. |
| tests/unit/api/admin/upstreams/catalog.test.ts | Adds API route test for the preview endpoint. |
| tests/unit/hooks/use-upstreams.test.ts | Adds hook test for the preview mutation. |
| tests/components/upstream-form-dialog.test.tsx | Replaces refresh/import tests with preview+save and local-import flows. |
Summary
Adds an upstream model catalog preview refresh flow so the edit dialog can refresh models from current form values before saving.
Related Issue
Closes #161
Type of Change
Changes
POST /api/admin/upstreams/[id]/catalog/previewto refresh a model catalog from editor values without updating the upstream record.base_url,api_key, route capabilities, and discovery settings.Test Plan
pnpm test:run)pnpm exec tsc --noEmit)pnpm lint)Commands run:
Checklist
Screenshots
Not captured.
Additional Notes
pnpm lintpasses with existing JSDoc warnings and no errors.