Feature: Manual Model Import & Config-Based Sync
✨ Commit 1: fix – Refactor Official Model Sync
Scope: Backend only (model_sync).
- Refactored the existing upstream model sync into a shared execution context to unify behavior across sync types.
- Addressed an issue where overwrite steps were skipped when
missing = 0. - Ensures consistent behavior for future sync operations.
✨ Commit 2: feat – Add Config-File Sync with Preview
Scope: Backend and Frontend.
- Introduced new endpoints
POST /sync_config/previewandPOST /sync_configto upload amodels.jsonconfiguration file, preview differences (missing or conflicts), and optionally execute synchronization with overwrite. - Added UI elements in
ModelsActions.jsxandSyncWizardModal.jsxto allow users to select a locale and upload a configuration file via a step-by-step wizard and reuse existing conflict resolution logic. - Implemented
previewConfigDiffandsyncConfiginuseModelsData.jsxfor handling file uploads and refreshing vendor/model lists. - Updated
.gitignoreto exclude local debugging artifacts and restoredantddependency to satisfy icon peer requirements. - Verified that preview diff shows correct missing/conflict results, automatic sync works when no conflicts, conflict flow prompts for overwrite, upstream sync remains unaffected, and UI works on desktop and mobile.
⚠️ Notes / Risks
- Ensure the
models.jsonmatches the backend schema before syncing. - Consider file size limits for future releases.
- Recommended to run preview before executing sync in production.
Ready to merge ✅
Summary by CodeRabbit
-
New Features
- Added configuration file synchronization workflow for models alongside existing upstream sync.
- Enabled users to upload a models.json file to preview and apply configuration changes.
- Introduced conflict preview capability for configuration-based synchronization.
- Added file upload UI to the sync wizard modal with validation and conflict detection.
-
Dependencies
- Added Ant Design (antd) UI component library.
✏️ Tip: You can customize this high-level summary in your review settings.
Walkthrough
Adds a file-based model configuration synchronization workflow: backend endpoints and refactored sync logic to preview and apply uploaded model bundles, plus frontend UI, hooks, and package changes to support uploading, previewing diffs, and applying config-based model syncs.
Changes
| Cohort / File(s) | Summary |
|---|---|
Git ignore updates \.gitignore |
Appends entries for local debugging helpers, LLM agent prompts, local env/config artifacts (.env, docker-compose.local.yml, Dockerfile.local), and package-lock.json. |
Router / Endpoints router/api-router.go |
Registers POST /api/models/sync_config/preview → controller.SyncConfigPreview and POST /api/models/sync_config → controller.SyncConfigModels. |
Backend sync logic controller/model_sync.go |
Large refactor introducing upstream/config parsing, upstreamData container, syncContext/syncResult models, helpers for fetching/parsing upstream and uploaded JSON, conflict calculation, vendor/model resolution, preview handler (SyncUpstreamPreview), config preview (SyncConfigPreview), and apply handler (SyncConfigModels) with unified apply flow and JSON error responses. |
Frontend package web/package.json |
Adds antd dependency ^5.29.1. |
Models actions UI web/src/components/table/models/ModelsActions.jsx |
Adds previewConfigDiff and syncConfig props; introduces syncSource and configContext state; implements handleSyncConfig to preview uploaded config, record preview context, and route confirmations to config vs upstream sync flows. |
Models page wiring web/src/components/table/models/index.jsx |
Wires previewConfigDiff and syncConfig from modelsData into ModelsActions. |
Sync wizard modal web/src/components/table/models/modals/SyncWizardModal.jsx |
Adds file upload UI and internal file state, resets on open, disables Next when option is config with no file, and passes uploaded file in onConfirm payload. |
Models hooks web/src/hooks/models/useModelsData.jsx |
Adds previewConfigDiff({ file, locale }) and syncConfig({ file, locale, overwrite = [] }) to perform multipart POSTs to /api/models/sync_config/preview and /api/models/sync_config, manage loading state, error handling, and refresh vendors/models on success. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant UI as SyncWizardModal
participant Actions as ModelsActions
participant Hook as useModelsData
participant API as /api/models/sync_config
participant Ctrl as controller/model_sync.go
rect rgb(200,220,255)
note over User,API: Config Sync Preview Flow
User->>UI: Choose "config" and upload file
UI->>Actions: onConfirm(option:"config", locale, file)
Actions->>Hook: previewConfigDiff({file, locale})
Hook->>API: POST /sync_config/preview (multipart)
API->>Ctrl: controller parses uploaded file
Ctrl-->>API: returns { conflicts, missing, counts, source }
API-->>Hook: preview response
Hook-->>Actions: preview data
Actions->>User: show conflicts / preview modal
end
rect rgb(220,255,220)
note over User,Ctrl: Config Sync Apply Flow
User->>Actions: confirm overwrite resolution
Actions->>Hook: syncConfig({file, locale, overwrite})
Hook->>API: POST /sync_config (multipart + overwrite)
API->>Ctrl: apply sync (create/update vendors & models)
Ctrl-->>API: results { created, updated, skipped, source }
API-->>Hook: success response
Hook->>Hook: refresh vendors/models
Hook-->>Actions: success notification
Actions->>User: close modal / show results
end
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
- Backend
controller/model_sync.gorequires careful review: parsing, branching between upstream vs uploaded config, conflict calculation, vendor resolution, and apply semantics. - Frontend integration across
ModelsActions,SyncWizardModal, anduseModelsDataneeds validation of prop flows, file handling, and multipart requests. - API contract consistency between preview and apply endpoints and error handling should be checked.
Focus-review items:
- Multipart form construction and content-type handling in
previewConfigDiff/syncConfig. - Conflict detection and overwrite semantics in backend sync context.
- State reset and file lifecycle in
SyncWizardModal. - Response shapes (counts, source metadata) and error payload formats.
Poem
🐰 I found a file to sync today,
I hopped and parsed the JSON way,
Previewed conflicts, then applied,
Vendors, models side by side—yay!
Small paws clap, code danced in play 🥕
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 26.32% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'Feature: Manual Model Import & Config-Based Sync' clearly summarizes the main feature additions: manual model importing and config-based synchronization capabilities, which are the primary changes throughout the PR. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
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.
Comment @coderabbitai help to get the list of available commands and usage tips.