litellm/ui
Yuneng Jiang 770a4feb8d
refactor(ui): extract the MCP server edit payload into a pure module
`handleSave` was 280 lines that parsed stdio JSON, filtered credentials,
resolved half a dozen conditional flags, built the request body, and then made
the network call, all inside one try block reading ten closure variables. None
of it could be tested without rendering the whole modal and pressing Save.

The payload building moves to `editServerPayload.ts` as `buildEditServerPayload`,
mirroring the `createServerPayload.ts` module that already sits beside it: a
pure function taking form values, UI state, and the server being edited, and
returning a tagged union rather than throwing. The six ways it can fail are now
values in that union, and the component maps them to the same toasts it showed
before via an exhaustive switch, so no message text changes.

`AUTH_TYPES_REQUIRING_CREDENTIALS` and the static-header reducer were duplicated
between the create and edit paths; the extracted module imports the create
module's copies instead. The credential filter and stdio parser stay separate,
because the edit versions genuinely differ: edit writes an explicit null to
clear a blanked admin-config key, and stringifies stdio args and env values
where create passes them through

Behaviour is unchanged, and the payload net added earlier is what proves it:
all 20 of its cases still pass against the extracted builder without any
edit to their expectations.

40 unit tests cover the new module in single-digit milliseconds, reaching the
rejection paths and parsing branches that were previously only reachable
through a full render. A ten-mutant battery kills 10/10, each mutant taking
down exactly one test, which is the profile worth having: the tests are
targeted rather than broadly overlapping

One of those mutants is worth noting. Removing the access-group name
normalisation survives the integration net but dies here, because the antd
Select hands the form plain strings and the unit test does not. That mapping is
dead only while that control stays; it is covered now either way
2026-08-18 22:06:44 -07:00
..
litellm-dashboard refactor(ui): extract the MCP server edit payload into a pure module 2026-08-18 22:06:44 -07: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