Repository navigation
Conversation
The system model settings page previously persisted model selections to localStorage as a workaround for when the Go backend hadn't been rebuilt to return TTS/ASR/VLM defaults from the API. Now that the backend API (GET /api/v1/models/default) is the source of truth for all model types, the localStorage persistence layer is redundant. - Remove STORAGE_KEY constant, loadPersistedValues, and savePersistedValues - Initialize persistedValues state from defaultModelDictionary - Sync state with API response via useEffect instead of localStorage - Simplify resolution order: API response -> empty string fallback
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesSystem settings and agent form
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
web/src/pages/user-setting/setting-model/layout/system-setting.tsx (1)
120-126: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winUse nullish coalescing to prevent optimistic UI updates from failing on clear.
The
||operator causes an empty string ('') to evaluate as falsy. If a user clears an optional model field,handleFieldChangesets its local state to''. The||operator then falls back todefaultModelDictionary[field], instantly reverting the UI to the old value until the API call resolves.Using
??ensures that explicitly set empty strings are respected. The proposed fix below also updates the resolution order comment to accurately reflect the presence of the local state.🐛 Proposed fix
- // Resolution order (same for ALL model types including ASR/VLM/TTS): - // 1. API response (from Go backend GET /api/v1/models/default) - // 2. empty string (fallback) + // Resolution order (same for ALL model types including ASR/VLM/TTS): + // 1. Local state (optimistic updates) + // 2. API response (from Go backend GET /api/v1/models/default) + // 3. empty string (fallback) const getValue = useCallback( (field: string) => - persistedValues[field] || defaultModelDictionary[field] || '', + persistedValues[field] ?? defaultModelDictionary[field] ?? '', [persistedValues, defaultModelDictionary], );🤖 Prompt for 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. In `@web/src/pages/user-setting/setting-model/layout/system-setting.tsx` around lines 120 - 126, Update getValue in the system-setting component to use nullish coalescing instead of truthiness-based fallback, so explicitly cleared empty-string values from persistedValues remain visible. Revise the adjacent resolution-order comment to reflect local state taking precedence, followed by the default model dictionary and empty-string fallback.
🧹 Nitpick comments (1)
web/src/pages/user-setting/setting-model/layout/system-setting.tsx (1)
87-95: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRename
persistedValuesto reflect its new purpose.Since the state is no longer persisted to
localStorageand merely mirrors the API response for optimistic updates, the namepersistedValuesis now misleading. Consider renaming it to something likemodelSelectionsorlocalSelections.💡 Proposed rename (requires changes in other functions)
- const [persistedValues, setPersistedValues] = useState< + const [modelSelections, setModelSelections] = useState< Record<string, string> >(defaultModelDictionary); useEffect(() => { - setPersistedValues(defaultModelDictionary); + setModelSelections(defaultModelDictionary); }, [defaultModelDictionary]);You will also need to update the downstream references in
handleFieldChangeandgetValue:// In handleFieldChange: setModelSelections((prev) => ({ ...prev, [field]: value || '' })); // In getValue: modelSelections[field] ?? defaultModelDictionary[field] ?? ''🤖 Prompt for 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. In `@web/src/pages/user-setting/setting-model/layout/system-setting.tsx` around lines 87 - 95, Rename the persistedValues state and setPersistedValues setter to modelSelections and setModelSelections, and update all references including handleFieldChange, getValue, and the defaultModelDictionary synchronization effect. Preserve the existing optimistic update and API-default fallback behavior.
🤖 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.
Outside diff comments:
In `@web/src/pages/user-setting/setting-model/layout/system-setting.tsx`:
- Around line 120-126: Update getValue in the system-setting component to use
nullish coalescing instead of truthiness-based fallback, so explicitly cleared
empty-string values from persistedValues remain visible. Revise the adjacent
resolution-order comment to reflect local state taking precedence, followed by
the default model dictionary and empty-string fallback.
---
Nitpick comments:
In `@web/src/pages/user-setting/setting-model/layout/system-setting.tsx`:
- Around line 87-95: Rename the persistedValues state and setPersistedValues
setter to modelSelections and setModelSelections, and update all references
including handleFieldChange, getValue, and the defaultModelDictionary
synchronization effect. Preserve the existing optimistic update and API-default
fallback behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 55df5d84-cf82-4f4a-a686-aba6fca52176
📒 Files selected for processing (1)
web/src/pages/user-setting/setting-model/layout/system-setting.tsx
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16934 +/- ##
==========================================
- Coverage 94.56% 93.16% -1.40%
==========================================
Files 10 10
Lines 717 717
Branches 118 118
==========================================
- Hits 678 668 -10
- Misses 25 29 +4
- Partials 14 20 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The persistedValues state was a redundant mirror of defaultModelDictionary. Since useSetDefaultModel invalidates the query on success and React Query automatically refetches, the local state layer adds no value. - Remove persistedValues useState/useEffect and getValue wrapper - Read directly from defaultModelDictionary with ?? fallback - Simplify handleFieldChange to a single setDefaultModel call
Replace hardcoded 'Visual Input File' string with t('flow.visualInputFile')
Summary
Remove the localStorage-based persistence layer from the system model settings page. The localStorage workaround was originally added to handle the case where the Go backend hadn't been rebuilt yet and didn't return TTS/ASR/VLM defaults from the API.
Now that the backend API (
GET /api/v1/models/default) is the source of truth for all model types (including ASR/VLM/TTS), the localStorage persistence is redundant and introduces unnecessary complexity. This PR:STORAGE_KEYconstant,loadPersistedValues, andsavePersistedValueshelper functionspersistedValuesstate directly fromdefaultModelDictionaryinstead of localStorageuseEffectinstead of localStorage