Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis pull request refactors the model discovery and refresh functionality to return structured error information alongside a richer status payload. The service now classifies discovery failures into typed error codes and provides detailed messages, model previews, and health tracking to both the backend and frontend layers. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant UI as Accounts.tsx
participant API as API Handler
participant Service as refreshModelsForAccount
participant DB as Account & Model Store
participant Discovery as Model Discovery<br/>(per credential)
User->>UI: Click "Check Models"
activate UI
UI->>API: POST /checkModels
activate API
API->>Service: refreshModelsForAccount(accountId)
activate Service
Service->>DB: Load account details
activate DB
DB-->>Service: account data
deactivate DB
alt Account Not Found
Service-->>API: {status: 'failed', errorCode: 'account_not_found'}
else Site Disabled
Service-->>API: {status: 'skipped', errorCode: 'site_disabled'}
else Account Inactive
Service-->>API: {status: 'skipped', errorCode: '...'}
else Valid Account
rect rgba(100, 150, 200, 0.5)
Note over Service,Discovery: Attempt discovery across<br/>account.apiToken, discoveredApiToken,<br/>account.accessToken + enabled tokens
loop Each Credential
Service->>Discovery: Discover models (with timeout)
activate Discovery
Discovery-->>Service: models[] OR error
deactivate Discovery
Service->>Service: Classify error if needed<br/>Aggregate failures
end
end
alt Discovery Success
Service->>DB: Update account health to healthy<br/>Persist model availability
activate DB
DB-->>Service: persisted
deactivate DB
Service-->>API: {status: 'success', errorCode: null,<br/>modelsPreview, modelCount, ...}
else All Discovery Failed
Service->>DB: Update health tracking with failure reason
activate DB
DB-->>Service: updated
deactivate DB
Service-->>API: {status: 'failed', errorCode: classified,<br/>errorMessage, modelsPreview: [], ...}
end
end
deactivate Service
API-->>UI: response
deactivate API
UI->>UI: formatModelSuccess() OR<br/>formatModelFailure()
UI->>UI: Show toast notification
UI->>UI: Update loading state & reload
UI-->>User: Display result
deactivate UI
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
Summary by CodeRabbit
New Features
Tests