Merge model selection pending state from master
This commit is contained in:
commit
8cfb9d4a67
321 files changed
+4127
-3994
No files matched your search
@@ -15,7 +15,9 @@
|
||||
* selected effort come from the Host rather than a client-owned vocabulary. A
|
||||
* rejected selection announces through the shared transient Toast anchored to
|
||||
* the composer card; the in-menu strip with Retry remains the catalog-load
|
||||
* surface.
|
||||
* surface. While the directory's pending selection is unsettled, the trigger
|
||||
* shows a spinner in place of its chevron, and each row whose value that
|
||||
* selection carries shows one in place of its check mark.
|
||||
*/
|
||||
import { MenuSurface } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import {
|
||||
@@ -27,7 +29,7 @@ import clsx from 'clsx'
|
||||
import type { ModelReasoningEffort, ModelSelection } from '@deepseek-ai/dsh-api-remotes/client'
|
||||
import {
|
||||
IconCheckOutlineRegular, IconChevronDownOutlineRegular, IconChevronRightOutlineRegular,
|
||||
IconDataOutlineRegular, IconWarningOutlineRegular, Toast,
|
||||
IconDataOutlineRegular, IconWarningOutlineRegular, StateDot, Toast,
|
||||
} from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
||||
import type { ModelSelectInjected } from './slots.ts'
|
||||
@@ -114,7 +116,8 @@ export function ModelSelect(
|
||||
label: effort.name,
|
||||
})),
|
||||
], [reasoning, t])
|
||||
const busy = state.status === 'selecting'
|
||||
const { pending } = state
|
||||
const busy = pending !== null
|
||||
|
||||
const reload = (): void => {
|
||||
lastActionRef.current = 'load'
|
||||
@@ -366,6 +369,7 @@ export function ModelSelect(
|
||||
aria-expanded={open}
|
||||
aria-controls={open ? `${id}-menu` : undefined}
|
||||
title={triggerLabel}
|
||||
aria-busy={busy}
|
||||
disabled={locked}
|
||||
onClick={() => {
|
||||
if (open) {
|
||||
@@ -378,7 +382,9 @@ export function ModelSelect(
|
||||
<IconDataOutlineRegular className={css.triggerIcon} size={16} />
|
||||
<span className={css.triggerLabel}>{modelLabel}</span>
|
||||
{effortLabel !== undefined && <span className={css.triggerEffort}>{effortLabel}</span>}
|
||||
<IconChevronDownOutlineRegular className={clsx(css.chevron, open && css.chevronOpen)} />
|
||||
{busy
|
||||
? <StateDot state="ongoing" />
|
||||
: <IconChevronDownOutlineRegular className={clsx(css.chevron, open && css.chevronOpen)} />}
|
||||
</button>
|
||||
|
||||
{/* Portaled to body (Menu primitive's portal mode) so the sidebar and
|
||||
@@ -452,7 +458,9 @@ export function ModelSelect(
|
||||
<span className={css.modelName}>{model.name}</span>
|
||||
</span>
|
||||
<span className={css.check}>
|
||||
{selected ? <IconCheckOutlineRegular /> : null}
|
||||
{pending?.provider === group.id && pending.model === model.id
|
||||
? <StateDot state="ongoing" />
|
||||
: selected ? <IconCheckOutlineRegular /> : null}
|
||||
</span>
|
||||
</button>
|
||||
)
|
||||
@@ -492,7 +500,10 @@ export function ModelSelect(
|
||||
<span className={css.modelName}>{level.label}</span>
|
||||
</span>
|
||||
<span className={css.check}>
|
||||
{effectiveEffort === level.effort ? <IconCheckOutlineRegular /> : null}
|
||||
{pending !== null && pending.provider === state.current?.provider
|
||||
&& pending.model === state.current.model && pending.reasoningEffort === level.effort
|
||||
? <StateDot state="ongoing" />
|
||||
: effectiveEffort === level.effort ? <IconCheckOutlineRegular /> : null}
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
|
||||
@@ -28,6 +28,8 @@ export interface ModelDirectoryState {
|
||||
failures: readonly ModelCatalogFailure[]
|
||||
/** Lifecycle of the in-flight operation. */
|
||||
status: 'idle' | 'loading' | 'ready' | 'selecting' | 'error'
|
||||
/** Selection submitted by the latest `select` until it settles; null otherwise. */
|
||||
pending: ModelSelection | null
|
||||
/** Whole-request or selection failure text; null when none. */
|
||||
error: string | null
|
||||
}
|
||||
@@ -36,7 +38,7 @@ export interface ModelDirectoryState {
|
||||
export class ModelDirectory {
|
||||
/** The shared snapshot both entries render from (uSES-safe store). */
|
||||
readonly store: SnapshotStore<ModelDirectoryState> = createSnapshotStore<ModelDirectoryState>({
|
||||
current: null, routable: null, groups: [], failures: [], status: 'idle', error: null,
|
||||
current: null, routable: null, groups: [], failures: [], status: 'idle', pending: null, error: null,
|
||||
})
|
||||
|
||||
/** Latest selection operation wins; an older response never overwrites a newer one. */
|
||||
@@ -90,7 +92,7 @@ export class ModelDirectory {
|
||||
const previousEffort = previous?.reasoningEffort ?? (previous === null ? undefined : this.catalog.reasoningFor(previous)?.defaultEffort)
|
||||
const nextEffort = selection.reasoningEffort ?? this.catalog.reasoningFor(selection)?.defaultEffort
|
||||
const generation = ++this.generation
|
||||
this.store.update((s) => { s.status = 'selecting'; s.error = null })
|
||||
this.store.update((s) => { s.status = 'selecting'; s.pending = selection; s.error = null })
|
||||
const result = await this.sessions.selectModel({
|
||||
sessionId: this.sessionId,
|
||||
provider: selection.provider,
|
||||
@@ -105,6 +107,7 @@ export class ModelDirectory {
|
||||
if (!result.ok) {
|
||||
this.store.update((s) => {
|
||||
s.status = 'error'
|
||||
s.pending = null
|
||||
s.error = `${result.error.code}: ${result.error.message}`
|
||||
})
|
||||
return result
|
||||
@@ -117,7 +120,7 @@ export class ModelDirectory {
|
||||
session_id: this.sessionId, model_name: to, switch_from: previousEffort ?? 'default', switch_to: nextEffort ?? 'default',
|
||||
})
|
||||
}
|
||||
this.store.update((s) => { s.status = 'ready'; s.error = null })
|
||||
this.store.update((s) => { s.status = 'ready'; s.pending = null; s.error = null })
|
||||
this.syncInputs()
|
||||
return { ok: true, value: undefined }
|
||||
}
|
||||
@@ -130,6 +133,7 @@ export class ModelDirectory {
|
||||
++this.generation
|
||||
this.store.update((state) => {
|
||||
if (state.status === 'selecting') state.status = 'idle'
|
||||
state.pending = null
|
||||
state.error = null
|
||||
})
|
||||
this.syncInputs()
|
||||
@@ -165,6 +169,7 @@ export class ModelDirectory {
|
||||
groups: catalog.value?.groups ?? [],
|
||||
failures: catalog.value?.failures ?? [],
|
||||
status: catalog.status === 'error' ? 'error' : 'loading',
|
||||
pending: this.store.getSnapshot().pending,
|
||||
error: catalog.error,
|
||||
})
|
||||
return
|
||||
@@ -181,6 +186,7 @@ export class ModelDirectory {
|
||||
status: this.store.getSnapshot().status === 'selecting'
|
||||
? 'selecting'
|
||||
: 'ready',
|
||||
pending: this.store.getSnapshot().pending,
|
||||
error: null,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user