From 8707f324c6de3b2cee778358f51b7cd41a0b5746 Mon Sep 17 00:00:00 2001 From: Yichen Jiang Date: Thu, 30 Jul 2026 16:41:44 +0800 Subject: [PATCH] refactor(ui-models): render the curated fields from a narrowed adapter family MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The effort field's existence check was unreachable — EFFORT_FIELD is total over the two known families — and a coverage exemption was papering over the branch, which the merged toolchain no longer honored. Taking the narrowed family as a parameter makes the lookup total at the type level, so the check and its exemption both disappear. The rendered output is unchanged: the browser goldens replay byte-identical. --- .../ui-models/src/client/ProviderEditor.tsx | 130 +++++++++--------- 1 file changed, 67 insertions(+), 63 deletions(-) diff --git a/packages/client/ui-models/src/client/ProviderEditor.tsx b/packages/client/ui-models/src/client/ProviderEditor.tsx index 64c946dff2..8ea1fb22fe 100644 --- a/packages/client/ui-models/src/client/ProviderEditor.tsx +++ b/packages/client/ui-models/src/client/ProviderEditor.tsx @@ -199,7 +199,72 @@ export function ProviderEditor(props: ProviderEditorProps): ReactNode { } const keyLocked = keyState?.writable === false - const effortField = layout === 'unknown' ? undefined : EFFORT_FIELD[layout] + + /** + * The curated fields of one known adapter family. Taking the narrowed + * family as a parameter is what makes `EFFORT_FIELD` total here: an + * unknown namespace never reaches this body. + */ + const curatedFields = (family: 'deepseek' | 'pi-ai'): ReactNode => { + const effortField = EFFORT_FIELD[family] + return ( + <> +
+ {t('keyInput')} + { setKeyDraft(event.target.value) }} + /> +
+
+ {t('customized')} +
+
+ {t('baseUrl')} + { + setField('baseURL', event.target.value === '' ? undefined : event.target.value) + }} + /> +
+
+ {t('effort')} + +
+
+
+ + ) + } return (
@@ -215,68 +280,7 @@ export function ProviderEditor(props: ProviderEditorProps): ReactNode { )} {layout === 'unknown' ?

{`${t('advancedHint')} (${namespace.ns})`}

- : ( - <> -
- {t('keyInput')} - { setKeyDraft(event.target.value) }} - /> -
-
- {t('customized')} -
-
- {t('baseUrl')} - { - setField('baseURL', event.target.value === '' ? undefined : event.target.value) - }} - /> -
- {/* v8 ignore next -- EFFORT_FIELD is total over non-unknown layouts; the check only narrows the type */} - {effortField !== undefined - ? ( -
- {t('effort')} - -
- ) - : null} -
-
- - )} + : curatedFields(layout)} {failure !== undefined ?

{failure}

: null}