Repository navigation
fix(platform): show the model ids Save sends after a source switch - #4315
Conversation
A custom provider's form keeps one ModelAllowlistField across its Models choice (Enter model IDs / Discover from the endpoint). The free-entry draft was seeded once from the list and never heard of a change the picker made, so removing a model under discovery and switching back showed the removed id while Save sent, and stored, the shorter list. The field now shows its draft only while the draft still parses to the list it holds, and otherwise the list itself; typing resyncs the draft, so in-progress commas survive. The adapter's list comparison moves next to the field, so one copy remains. Closes #3664
TALE-700 — independent review of PR #4315Verdict: ACCEPT at source level, exact head Reviewer: Codex #7 Findings and evidence
Executed light checksInstalled Node v24.21.0, Vitest 4.1.11, one worker, 2 GiB Node heap where set. Isolated source archives under this task's delivery box; preinstalled dependencies reused; explicit Vite aliases resolve UI/shared exports to each snapshot.
Initial stock-config test attempt was blocked before test import by Vite's filesystem allowlist for symlinked font assets. The review-only config explicitly allows the snapshot and existing dependency directory, maps workspace packages to snapshot exports, and deduplicates React; corrected positive and negative runs above are the relied-upon evidence. Initial human-format lint runs exited 0 with no printed summary; the JSON run explicitly confirms five files and zero diagnostics. No product source was changed to accommodate the harness. Unrun and handoff
Artifacts: reviewed patch, source blob provenance, focused/head/main logs, independent probe, review-only config, reproduction commands, CI snapshot and posting receipts in this exact delivery box. Temporary owned source archives are removed after evidence retention. |
Summary
A custom provider's credential form could show model IDs that Save would not store (#3664). Here is the reproduction:
alpha, beta.alpha.The field still read
alpha, beta, but Save sent, and the server stored,["beta"]only.Cause.
ProviderExtraFieldsrenders the free-entry field and the catalog picker in the same child slot, so React keeps oneModelAllowlistFieldacross the Models radio. The field's free-text draft came fromuseState(value.join(', ')), which is seeded once. When the picker changed the list, the draft never heard of it. The component comment assumed the opposite ("the dialogs unmount this field on close, so the draft can never go stale"). The add flow has the same root: on the custom entry, type IDs, switch to Discover, remove a chip, then switch back.Fix:
model-allowlist-field.tsx. The field shows its raw draft only while the draft still parses to the list it holds; otherwise it shows the list itself. Typing resyncs the draft, so in-progress commas (alpha, beta,) survive as before, and a trip through the picker that changes nothing leaves the draft alone. There is no effect, no state set during render, and nokeyat the call site, so the guarantee lives in the component for every caller. The adapter's privatesameListmoves next to the field, so the list comparison has one copy.Manual layer. The
SET-F43row inreference/automation.mdnow names this behaviour and the new spec.Checklist
bun run checkpasses (format, lint, typecheck, all tests). Not run locally: a whole-workspace run exceeds this 4 GiB sandbox. The scoped equivalents under Test plan pass, and CI runs the full gate.bun run lint:sastpasses (Opengrep). I ran the pinned v1.22.0 viatools/opengrep/run.shon the 4 changed code files: 162 rules, 0 findings. The pre-commit hook passed too.docs/*/platform/admin/providers.mdalready says Enter model IDs lists the exact IDs in Model allowlist. The field now shows that list, and no documented statement changes.Test plan
New
model-allowlist-field.test.tsx(3 tests). It uses a controlled harness that togglesfreeTextthe way the Models radio does.alpha, and back in free entry the field showsbeta. This test includes an axe check.New page test in
providers-settings.test.tsx. It covers the card's exact flow through the realProvidersSettings→CredentialEditDialog→providerCredentialAdapter, with the mutation hooks stubbed at the module boundary. Edit, choose Discover from the endpoint, use Remove alpha, choose Enter model IDs, and the field readsbeta. Save then sendsmodelAllowlist: ["beta"]withcatalogSource: 'none'.Fails on main. On main's component (
9e8f87f68), 3 of the 4 new tests fail ontoHaveValue(receivedalpha, beta). The draft test passes on main: it's a control that guards against an over-eager fix. A probe on main recordedmanual alpha,beta -> discovery removes alpha -> manual textbox displays "alpha, beta"; Save sends ["beta"], the card's observation.Catches an over-eager fix. I made the field always show
value.join(', '). That fails 3 tests: the draft test, the outside-replacement test, and the existingrequires model ids when the endpoint cannot list them(the comma vanishes while typing).Branch.
model-allowlist-field.test.tsx,providers-settings.test.tsxandcredential-edit-dialog.test.tsxpass 39/39 withvitest.ui.config.tson one worker (Node 24).Gates.
oxfmt --checkand type-awareoxlinton the changed files are clean (4 files, 226 rules, 0 diagnostics).tsc --noEmitscoped to the changed files and their importers (both credential dialogs andproviders-settings.tsx) exits 0.bun run lint:manualpasses.error-message-description.guardpasses.single-failure-toast.guardpasses 51/51 when run alone with a longer timeout. Run alongside the other guard on this shared host, its scan hit vitest's 30 s default once.Not run locally:
tsc.CI runs the suite and
tsc.Closes #3664