refactor(ui-models): render the curated fields from a narrowed adapter family
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.
This commit is contained in:
@@ -199,23 +199,15 @@ export function ProviderEditor(props: ProviderEditorProps): ReactNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const keyLocked = keyState?.writable === false
|
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 (
|
return (
|
||||||
<div className={styles['editor']}>
|
|
||||||
{props.hideTitle === true
|
|
||||||
? null
|
|
||||||
: (
|
|
||||||
<div className={styles['editorHeader']}>
|
|
||||||
<span className={styles['editorTitle']}>{props.displayName}</span>
|
|
||||||
{props.provider !== props.displayName
|
|
||||||
? <span className={styles['editorRoute']}>{props.provider}</span>
|
|
||||||
: null}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{layout === 'unknown'
|
|
||||||
? <p className={styles['advancedHint']}>{`${t('advancedHint')} (${namespace.ns})`}</p>
|
|
||||||
: (
|
|
||||||
<>
|
<>
|
||||||
<div className={styles['field']}>
|
<div className={styles['field']}>
|
||||||
<span className={styles['fieldLabel']}>{t('keyInput')}</span>
|
<span className={styles['fieldLabel']}>{t('keyInput')}</span>
|
||||||
@@ -241,7 +233,7 @@ export function ProviderEditor(props: ProviderEditorProps): ReactNode {
|
|||||||
className={styles['input']}
|
className={styles['input']}
|
||||||
type="text"
|
type="text"
|
||||||
value={stringAt(draft, 'baseURL') ?? ''}
|
value={stringAt(draft, 'baseURL') ?? ''}
|
||||||
placeholder={layout === 'deepseek'
|
placeholder={family === 'deepseek'
|
||||||
? DEEPSEEK_PUBLIC_BASE_URL
|
? DEEPSEEK_PUBLIC_BASE_URL
|
||||||
: stringAt(fallback, 'baseURL') ?? t('baseUrlDefault')}
|
: stringAt(fallback, 'baseURL') ?? t('baseUrlDefault')}
|
||||||
aria-label={t('baseUrl')}
|
aria-label={t('baseUrl')}
|
||||||
@@ -251,9 +243,6 @@ export function ProviderEditor(props: ProviderEditorProps): ReactNode {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/* v8 ignore next -- EFFORT_FIELD is total over non-unknown layouts; the check only narrows the type */}
|
|
||||||
{effortField !== undefined
|
|
||||||
? (
|
|
||||||
<div className={styles['field']}>
|
<div className={styles['field']}>
|
||||||
<span className={styles['fieldLabel']}>{t('effort')}</span>
|
<span className={styles['fieldLabel']}>{t('effort')}</span>
|
||||||
<select
|
<select
|
||||||
@@ -266,17 +255,32 @@ export function ProviderEditor(props: ProviderEditorProps): ReactNode {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<option value="">{t('effortInherit')}</option>
|
<option value="">{t('effortInherit')}</option>
|
||||||
{EFFORT_CHOICES[layout].map(choice => (
|
{EFFORT_CHOICES[family].map(choice => (
|
||||||
<option key={choice} value={choice}>{choice}</option>
|
<option key={choice} value={choice}>{choice}</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
)
|
|
||||||
: null}
|
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
</>
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles['editor']}>
|
||||||
|
{props.hideTitle === true
|
||||||
|
? null
|
||||||
|
: (
|
||||||
|
<div className={styles['editorHeader']}>
|
||||||
|
<span className={styles['editorTitle']}>{props.displayName}</span>
|
||||||
|
{props.provider !== props.displayName
|
||||||
|
? <span className={styles['editorRoute']}>{props.provider}</span>
|
||||||
|
: null}
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{layout === 'unknown'
|
||||||
|
? <p className={styles['advancedHint']}>{`${t('advancedHint')} (${namespace.ns})`}</p>
|
||||||
|
: curatedFields(layout)}
|
||||||
{failure !== undefined ? <p className={styles['error']}>{failure}</p> : null}
|
{failure !== undefined ? <p className={styles['error']}>{failure}</p> : null}
|
||||||
<div className={styles['editorActions']}>
|
<div className={styles['editorActions']}>
|
||||||
<button
|
<button
|
||||||
|
|||||||
Reference in New Issue
Block a user