fix(ui): reflect persisted "Store Prompts in Spend Logs" toggle on load - #32143
fix(ui): reflect persisted "Store Prompts in Spend Logs" toggle on load#32143devin-ai-integration[bot] wants to merge 2 commits into
Conversation
Co-Authored-By: bot_apk <apk@cognition.ai>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
|
Greptile SummaryThis PR fixes a UI-only bug where the "Store Prompts in Spend Logs" toggle incorrectly showed as OFF on page load even when the backend had it set to
Confidence Score: 5/5Small, focused UI fix with a targeted regression test; no backend or auth changes. The change touches only two files in a React component: it replaces one pattern for syncing async data into an antd form with a more correct one, and adds a test that directly reproduces the bug. The logic is straightforward — form.setFieldsValue inside a useEffect keyed on the server data is the standard antd pattern for this scenario. The initialValues prop on Form is now only used as the mount-time default (its documented scope), and explicit setFieldsValue handles subsequent async updates. No security, auth, or data-path logic is touched. No files require special attention.
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/components/Settings/AdminSettings/LoggingSettings/LoggingSettings.tsx | Replaces fragile key-remount strategy with a useEffect + setFieldsValue pattern so persisted toggle values from the DB are correctly reflected on load; drops the now-unnecessary Form.useWatch. |
| ui/litellm-dashboard/src/components/Settings/AdminSettings/LoggingSettings/LoggingSettings.test.tsx | Adds a regression test that renders in the loading state first and then rerenders with real data, asserting the switch reflects the persisted value — this test would have failed on the old code. |
Reviews (1): Last reviewed commit: "fix(ui): reflect persisted store_prompts..." | Re-trigger Greptile
Co-Authored-By: bot_apk <apk@cognition.ai>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Superseded by #32145 (rebranched to a litellm_ prefix so enterprise CI runs). Same changes. |
Relevant issues
Admin Settings → Logging Settings → "Store Prompts in Spend Logs" toggle appeared to revert to OFF. The value was correctly persisted to the DB (verified via
/config/update+/config/list), but the switch rendered as OFF whenever the config loaded asynchronously (fresh page load / navigating back to the tab).Linear ticket
Pre-Submission checklist
Screenshots / Proof of Fix
Backend was already persisting correctly; the bug was purely in the UI. Reproduced live on a local proxy (
/ui/admin-panel→ Logging Settings) withstore_prompts_in_spend_logs=truein the DB.Before (DB =
true, switch renders OFF on load):After (DB =
true, switch renders ON on load):DB round-trip confirming persistence both directions:
Type
🐛 Bug Fix
Changes
Root cause: the form was reset via
key={JSON.stringify(initialValues)}while reusing the sameuseForminstance. On first renderproxyConfigDataisundefined, so the form mounted withstore_prompts_in_spend_logs: falseand wrote that into the (preserved) form store. When the config arrived and thekeychanged, antd re-mounts the Form element but keeps the persisted store, so the newerinitialValues(true) were not re-applied — theSwitch, driven byForm.useWatch, kept showingfalse.Fix in
LoggingSettings.tsx:form.setFieldsValue(initialValues)in auseEffectkeyed onproxyConfigData(re-applies on initial load and after post-save refetch), instead of the fragilekey-remount.Form.Itemown the switch (name+valuePropName="checked"); drop the manualForm.useWatch+ controlledchecked/onChange.Added a regression test (
LoggingSettings.test.tsx) that renders in the loading state first, then rerenders withfield_value: true, and asserts the switch is checked — this fails on the old code and passes with the fix.Link to Devin session: https://app.devin.ai/sessions/32b64ceba1494e5991cb45a42c68d9d1