fix: lint
This commit is contained in:
@@ -75,16 +75,16 @@ export function ModelSelect({ locked, directory, load, select }: ModelSelectInje
|
|||||||
const effortChoices = useMemo<readonly EffortChoice[]>(() => reasoning === undefined
|
const effortChoices = useMemo<readonly EffortChoice[]>(() => reasoning === undefined
|
||||||
? []
|
? []
|
||||||
: [
|
: [
|
||||||
...reasoning.defaultEffort === undefined
|
...reasoning.defaultEffort === undefined
|
||||||
? [{ key: 'provider-default', effort: undefined, label: 'Provider default' }]
|
? [{ key: 'provider-default', effort: undefined, label: 'Provider default' }]
|
||||||
: [],
|
: [],
|
||||||
...reasoning.efforts.map((effort: ModelReasoningEffort) => ({
|
...reasoning.efforts.map((effort: ModelReasoningEffort) => ({
|
||||||
key: `effort:${effort.id}`,
|
key: `effort:${effort.id}`,
|
||||||
effort: effort.id,
|
effort: effort.id,
|
||||||
label: effort.name,
|
label: effort.name,
|
||||||
...effort.description === undefined ? {} : { description: effort.description },
|
...effort.description === undefined ? {} : { description: effort.description },
|
||||||
})),
|
})),
|
||||||
], [reasoning])
|
], [reasoning])
|
||||||
const busy = state.status === 'selecting'
|
const busy = state.status === 'selecting'
|
||||||
|
|
||||||
// Mount-time load resolves the trigger label; every open refreshes.
|
// Mount-time load resolves the trigger label; every open refreshes.
|
||||||
@@ -186,7 +186,13 @@ export function ModelSelect({ locked, directory, load, select }: ModelSelectInje
|
|||||||
aria-controls={open ? `${id}-menu` : undefined}
|
aria-controls={open ? `${id}-menu` : undefined}
|
||||||
title={triggerLabel}
|
title={triggerLabel}
|
||||||
disabled={locked}
|
disabled={locked}
|
||||||
onClick={() => { open ? close() : show() }}
|
onClick={() => {
|
||||||
|
if (open) {
|
||||||
|
close()
|
||||||
|
} else {
|
||||||
|
show()
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<span className={css.triggerLabel}>{modelLabel}</span>
|
<span className={css.triggerLabel}>{modelLabel}</span>
|
||||||
{effortLabel !== undefined && <span className={css.triggerEffort}>{effortLabel}</span>}
|
{effortLabel !== undefined && <span className={css.triggerEffort}>{effortLabel}</span>}
|
||||||
@@ -203,13 +209,13 @@ export function ModelSelect({ locked, directory, load, select }: ModelSelectInje
|
|||||||
>
|
>
|
||||||
{pane === 'root' && (
|
{pane === 'root' && (
|
||||||
<>
|
<>
|
||||||
<button ref={itemRef()} type="button" role="menuitem" className={css.cell} onClick={() => setPane('model')}>
|
<button ref={itemRef()} type="button" role="menuitem" className={css.cell} onClick={() => { setPane('model') }}>
|
||||||
<span className={css.cellLabel}>Model</span>
|
<span className={css.cellLabel}>Model</span>
|
||||||
<span className={css.cellValue}>{modelLabel}</span>
|
<span className={css.cellValue}>{modelLabel}</span>
|
||||||
<IconChevronRightOutline14 className={css.cellChevron} />
|
<IconChevronRightOutline14 className={css.cellChevron} />
|
||||||
</button>
|
</button>
|
||||||
{reasoning !== undefined && (
|
{reasoning !== undefined && (
|
||||||
<button ref={itemRef()} type="button" role="menuitem" className={css.cell} onClick={() => setPane('effort')}>
|
<button ref={itemRef()} type="button" role="menuitem" className={css.cell} onClick={() => { setPane('effort') }}>
|
||||||
<span className={css.cellLabel}>Effort</span>
|
<span className={css.cellLabel}>Effort</span>
|
||||||
<span className={css.cellValue}>{effortLabel}</span>
|
<span className={css.cellValue}>{effortLabel}</span>
|
||||||
<IconChevronRightOutline14 className={css.cellChevron} />
|
<IconChevronRightOutline14 className={css.cellChevron} />
|
||||||
@@ -291,27 +297,27 @@ export function ModelSelect({ locked, directory, load, select }: ModelSelectInje
|
|||||||
{effortChoices.length === 0
|
{effortChoices.length === 0
|
||||||
? <div className={css.empty}>当前模型未提供推理等级。</div>
|
? <div className={css.empty}>当前模型未提供推理等级。</div>
|
||||||
: effortChoices.map(level => (
|
: effortChoices.map(level => (
|
||||||
<button
|
<button
|
||||||
ref={itemRef()}
|
ref={itemRef()}
|
||||||
type="button"
|
type="button"
|
||||||
role="menuitemradio"
|
role="menuitemradio"
|
||||||
aria-checked={effectiveEffort === level.effort}
|
aria-checked={effectiveEffort === level.effort}
|
||||||
className={clsx(css.option, effectiveEffort === level.effort && css.selected)}
|
className={clsx(css.option, effectiveEffort === level.effort && css.selected)}
|
||||||
key={level.key}
|
key={level.key}
|
||||||
disabled={busy}
|
disabled={busy}
|
||||||
onClick={() => { chooseEffort(level.effort) }}
|
onClick={() => { chooseEffort(level.effort) }}
|
||||||
>
|
>
|
||||||
<span className={css.optionCopy}>
|
<span className={css.optionCopy}>
|
||||||
<span className={css.modelName}>{level.label}</span>
|
<span className={css.modelName}>{level.label}</span>
|
||||||
{level.description !== undefined && (
|
{level.description !== undefined && (
|
||||||
<span className={css.description}>{level.description}</span>
|
<span className={css.description}>{level.description}</span>
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
<span className={css.check}>
|
<span className={css.check}>
|
||||||
{effectiveEffort === level.effort ? <IconCheckOutline16 /> : null}
|
{effectiveEffort === level.effort ? <IconCheckOutline16 /> : null}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ export interface ModelSelectInjected {
|
|||||||
/** The session's shared directory store (same instance the /model popup reads). */
|
/** The session's shared directory store (same instance the /model popup reads). */
|
||||||
directory: SnapshotStore<ModelDirectoryState>
|
directory: SnapshotStore<ModelDirectoryState>
|
||||||
/** Refresh the advisory directory (fire-and-forget; errors land on the store). */
|
/** Refresh the advisory directory (fire-and-forget; errors land on the store). */
|
||||||
load(): void
|
load: () => void
|
||||||
/**
|
/**
|
||||||
* Select a complete provider/model/reasoning target through the shared route.
|
* Select a complete provider/model/reasoning target through the shared route.
|
||||||
* @param target - model target and optional adapter-owned effort.
|
* @param target - model target and optional adapter-owned effort.
|
||||||
* @returns whether the host accepted the selection.
|
* @returns whether the host accepted the selection.
|
||||||
*/
|
*/
|
||||||
select(target: ModelTarget): Promise<boolean>
|
select: (target: ModelTarget) => Promise<boolean>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user