feat(gui): add custom models from provider workspace - #449
Conversation
Reason: - Provider workspace users could not add a model when live discovery was incomplete. Changes: - Add provider-scoped custom model entry with validation, failure handling, and immediate list updates. - Preserve configured fallback models and cover duplicate, loading, refresh, and network error paths.
📝 WalkthroughWalkthroughChangesThe provider workspace now supports adding provider-scoped custom model IDs, loading existing custom models, merging them into filtered results, and retaining configured fallback models for custom-only catalogs. Validation covers successful, duplicate, server-error, network-error, and unavailable-refresh flows. Provider custom model support
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant ProviderDetails
participant ProviderModels
participant CustomModelsAPI
ProviderDetails->>ProviderModels: Pass apiBase and provider name
ProviderModels->>CustomModelsAPI: GET /api/custom-models
CustomModelsAPI-->>ProviderModels: Return custom model IDs
ProviderModels->>CustomModelsAPI: POST provider and modelId
CustomModelsAPI-->>ProviderModels: Return save result
ProviderModels->>ProviderModels: Update local IDs and invoke onRetryModels
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@gui/src/components/provider-workspace/ProviderModels.tsx`:
- Around line 164-173: Update the custom model input’s onChange handler in
ProviderModels so changing the draft value also clears customSuccess and
customError, while preserving the existing customModelId update and save
behavior.
- Around line 58-81: Extract the custom-model fetch logic from the useEffect
into a reusable loadCustomModels function, preserving its success, validation,
cleanup, and error behavior. Expose that function to the custom-model error
state and render a Retry button alongside customError, following the existing
modelsLoadFailed/onRetryModels pattern; the button must invoke
loadCustomModels() without requiring the component to remount.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 451f57ff-b1da-4b66-9574-1680f23bf31f
📒 Files selected for processing (6)
gui/src/components/provider-workspace/ProviderDetails.tsxgui/src/components/provider-workspace/ProviderModels.tsxgui/src/provider-workspace/report.tsgui/src/styles/provider-workspace-shell.cssgui/tests/provider-model-custom-add.test.tsxtests/provider-workspace-state.test.ts
🔒 Maintainer integration in progress — please hold off on merging@lidge-jun (maintainer) is actively integrating this PR into What is happening This PR is being integrated on the maintainer branch What this means for you
This PR will be closed with a merge receipt (integration commit SHA, verification output, Integration tracker: |
PR #449 (head eeb61e9, author apple-ouyang)를 통합하고 결함 2건을 함께 고친다. provider workspace Models 탭에서 provider 범위 custom 모델을 추가할 수 있다. 빈 ID, 네임스페이스 포함 ID, 중복은 클라이언트와 서버 양쪽에서 거부한다. 결함 1 — live catalog provenance: custom ID 차집합으로 live 여부를 추론하면, 기존 custom ID가 나중에 live discovery에도 나타날 때 live catalog를 custom-only로 오분류해 configured fallback이 잘못 authoritative로 남았다. 이제 discovery 성공 시 실제 반환된 행 수를 기록하고 /api/selected-models가 그 값을 전달한다. count는 configured alias 증강 전에 capture한다. markProviderDiscoveryOk의 count와 GUI의 hasLiveModels를 required로 두어 배선 누락이 typecheck에서 잡히게 했다. 결함 2 — custom-model 조회 실패 후 영구 비활성: GET이 한 번 실패하면 customModelsReady가 false로 남고 effect 재실행 트리거가 없어 remount 전까지 Add가 막혔다. 실패를 별도 상태로 두고 Retry 버튼과 epoch 기반 재조회를 추가했다. 테스트: - overlap된 custom/live ID에서 live catalog가 authoritative로 유지되고, 실제로 discovery가 비었을 때만 fallback이 돌아옴 - discovery 3시나리오(non-empty, 성공한 empty, 실패 후 stale 보존)를 실제 discovery 경로로 통과시켜 count를 관찰. 직접 marker 호출로는 production branch의 누락을 잡지 못한다 - 같은 mount에서 GET 실패 -> Retry -> 성공 -> Add 활성화 -> POST 정확히 1회 Co-authored-by: apple-ouyang <apple-ouyang@users.noreply.github.com>
✅ Integrated into
|
|
Closing: integrated into |
Summary
Fixes #448
Testing
Local full-suite note
bun run test completed 4,074 tests successfully and reported 25 environment-specific failures. In this local network, the affected test hostnames resolve to Clash-style 198.18.0.x fake IPs, so the destination-policy guard blocks mocked provider discovery before the tests reach their fetch stubs. The changed focused suites pass; CI remains the authoritative clean-environment full-suite result.
Summary by CodeRabbit
New Features
Bug Fixes