litellm/ui
tin-berri ffcb54b06d
feat(ui): reorder Add Auto Router into name + template, with a collapsible detailed config (#35746)
* feat(ui): add template picker to the Add Auto Router flow

Add Auto Router now opens straight into name + an optional Template
dropdown (Anthropic/OpenAI model-family presets or Custom). A preset
prefills the full complexity-router config and collapses the Detailed
Configuration section to a one-line tier summary; choosing Custom (or
nothing yet) leaves it expanded, and a caller can toggle it manually
at any point. A preset option greys out with the specific missing
model(s) named when the caller lacks a model it needs, or while the
model list is loading or failed to load.

Prefill and submit-gating logic live in testable pure functions
(buildPresetPrefill, getReferencedModelsError) rather than inline in
the component, per the dashboard's own testing guidance.

* refactor(ui): memoize presetAvailability

Consistency with the other memoized derived values it closes over
(availableModelSet, presets). Negligible perf impact with two
presets today, but keeps the pattern uniform as more get added.

* refactor(ui): drop pointless useMemo around getAllPresets()

getAllPresets() already returns a stable module-level array
reference; wrapping it in useMemo added React machinery for
something that can't change.

* refactor(ui): hoist presets to module scope

getAllPresets() was still being called from inside the component
body on every render even after dropping the useMemo wrapper.
Resolving it once at module load, alongside PRESETS' own
module-level initialization in autorouter_presets.ts, is the
actually-clean version of the previous fix.

* fix(ui): collapse Detailed Configuration by default

It was defaulting to expanded before any template was chosen, so
the modal still opened onto the full tier/classifier form instead
of just Name + Template. Custom still auto-expands it, and a
preset still collapses it after prefilling.

* fix(ui): list Custom Configuration last in the Template dropdown

Custom is the escape hatch, not the headline choice, so the bundled
presets now come first with Custom listed after them.

Also lets the collapsed Detailed Configuration summary wrap onto
its own line(s) instead of sharing a line with the section label
and truncating mid-model-name.

* feat(ui): match preset models across "-"/"." version separators

Admins spell version numbers inconsistently (claude-sonnet-4-5 vs
claude-sonnet-4.5), so a preset's hardcoded name and a caller's
registered one can refer to the same model while differing only in
that punctuation. getMissingModels (and therefore presetAvailability
and the submit-blocking check) now treats the two as equivalent.

Applying a preset writes the caller's actual registered spelling
into the tiers, not the preset's literal string, since the caller
may only have the dotted (or hyphenated) form and never the other
one - buildPresetPrefill now takes the available-models set for
this rewrite. Two different model names never collide; only the
separator within one version number does.

* fix(ui): re-check referenced models inside submitRecommendedRouter

submitBlockedReason disables the button for a stale/missing model
reference, but Form's onFinish (wired to the same handler) fires on
a real form submission regardless of the button's own disabled
state. The other four blocking checks already re-validate inside
submitRecommendedRouter for this exact reason; this one was missing
it, so a router could still be created referencing a model no
longer in availableModelSet.

Found by Bugbot.

* Update autorouter_presets.json
2026-08-04 23:24:18 +00:00
..
litellm-dashboard feat(ui): reorder Add Auto Router into name + template, with a collapsible detailed config (#35746) 2026-08-04 23:24:18 +00:00
Dockerfile chore(build): move the Admin UI toolchain to Node 24 (#35801) 2026-08-04 12:36:07 -07:00
nginx.conf fix(ui): serve /ui/assets from the nginx image instead of SPA fallback (#34066) 2026-07-21 09:22:02 -07:00