feat(web): drop the account catalog editor from the Models page

This commit is contained in:
Yichen Jiang committed 2026-09-24 13:15:30 +08:00
1 parent e647f079b9
commit 783d98b78e
3 files changed
+27 -47

No files matched your search

@@ -463,21 +463,26 @@ function Loaded({ injected, renderSlot }: { injected: ModelsSectionFace; renderS
: null}
</span>
<span className={styles['rowActions']}>
<button
type="button"
className={styles['secondaryButton']}
aria-label={providerCopy(t('editProvider'), target)}
onClick={() => {
setSavedTarget(undefined)
// One card at a time: the add card closes with whatever
// it held, since closing either card would otherwise
// discard the other's draft.
setAddOpen(false)
setEditing(open ? undefined : target)
}}
>
{t('edit')}
</button>
{/* The account catalog comes from the account listing; its model overrides live in cordis.patch.yml. */}
{row.entry.provider === 'deepseek-account'
? null
: (
<button
type="button"
className={styles['secondaryButton']}
aria-label={providerCopy(t('editProvider'), target)}
onClick={() => {
setSavedTarget(undefined)
// One card at a time: the add card closes with whatever
// it held, since closing either card would otherwise
// discard the other's draft.
setAddOpen(false)
setEditing(open ? undefined : target)
}}
>
{t('edit')}
</button>
)}
{row.removable
? (
<button
@@ -183,7 +183,6 @@ export function ProviderEditor(props: ProviderEditorProps): ReactNode {
const fallback = schema.getPath(namespace.value, settingsPath)
const disabled = props.readOnly || busy
const layout = layoutOf(namespace.ns)
const accountProvider = props.provider === 'deepseek-account'
const keyRef = refFor(schema, namespace, settingsPath, props.provider)
// The same schema read the create card makes, so the choices offered here
// and there cannot drift apart: both come from the adapter's own `Config`.
@@ -195,7 +194,6 @@ export function ProviderEditor(props: ProviderEditorProps): ReactNode {
)
useEffect(() => {
if (accountProvider) return
let stale = false
setKeyState(undefined)
// The key state is a placeholder hint, not a precondition for editing: a
@@ -205,7 +203,7 @@ export function ProviderEditor(props: ProviderEditorProps): ReactNode {
setKeyState(described)
})
return () => { stale = true }
}, [operations, keyRef, accountProvider])
}, [operations, keyRef])
const stringAt = (source: unknown, key: string): string | undefined => {
const value = schema.getPath(source, [key])
@@ -370,9 +368,6 @@ export function ProviderEditor(props: ProviderEditorProps): ReactNode {
},
onReset: () => { setDraft(current => schema.deletePath(current, ['models'])) },
}
if (accountProvider) return <DeepSeekModelsEditor {...catalogProps}
defaultContextWindow={typeof defaultContextWindow === 'number' ? defaultContextWindow : undefined}
defaultMaxTokens={typeof defaultMaxTokens === 'number' ? defaultMaxTokens : undefined} />
return (
<>
<div className={styles['field']}>
@@ -13,7 +13,7 @@ import {
ModelsSection, needsSetup, providerCopy, providerTargetLabel, removeProviderProfile,
} from '../src/client/ModelsSection.tsx'
import type { ModelsSectionInjected, ModelsSectionProps } from '../src/client/ModelsSection.tsx'
import { ProviderEditor, pathOps } from '../src/client/ProviderEditor.tsx'
import { pathOps } from '../src/client/ProviderEditor.tsx'
import {
DeepSeekModelsEditor, formatCapacity, modelDrafts, parseCapacity, validateDeepSeekModels,
} from '../src/client/DeepSeekModelsEditor.tsx'
@@ -23,7 +23,7 @@ import { deriveKeyRef, ModelsSettingsStore } from '../src/client/store.ts'
import { createModelsOperations } from '../src/client/operations.ts'
import type { ModelsOperations } from '../src/client/operations.ts'
import type { ProviderRow } from '../src/client/store.ts'
import { en, zh } from '../src/client/locales.ts'
import { en } from '../src/client/locales.ts'
import { settingsSchema } from './settings-schema.client.ts'
afterEach(cleanup)
@@ -1883,33 +1883,13 @@ describe('apiKeyFailure', () => {
})
})
it.each([en, zh])('edits the account model catalog without credential or endpoint fields', async (copy) => {
it('renders the localized account row without an edit action', async () => {
const scripted = scriptedFace({})
const ops = operationsWith(scripted.face)
const describe = vi.spyOn(ops, 'describeCredential')
render(<ProviderEditor provider="deepseek-account" displayName={copy.deepSeekAccount}
namespace={wireNamespaces()[0]!} settingsPath={[]} schema={settingsSchema}
operations={ops} t={key => copy[key]} readOnly={false} onClose={() => {}} />)
expect(screen.queryByLabelText(copy.keyInput)).toBeNull()
expect(screen.queryByLabelText(copy.baseUrl)).toBeNull()
expect(describe).not.toHaveBeenCalled()
expect(screen.getByDisplayValue('deepseek-v4-flash')).toBeTruthy()
await expect(`${document.body.textContent}\n`)
.toMatchFileSnapshot(`./expected/deepseek-account-${copy === en ? 'en' : 'zh'}.txt`)
})
it('renders the localized account row and supports catalogs without capacity defaults', async () => {
const scripted = scriptedFace({})
const { controller, view } = await mountFace(scripted)
const { controller } = await mountFace(scripted)
const row = controller.store.getSnapshot().rows[0]!
await act(async () => { controller.store.update((state) => {
state.rows = [{ ...row, accountAvailable: true, entry: { ...row.entry, provider: 'deepseek-account' } }]
}) })
expect(screen.getByText(en.deepSeekAccount)).toBeTruthy()
view.unmount()
const namespace = wireNamespaces()[0]!
render(<ProviderEditor provider="deepseek-account" displayName={en.deepSeekAccount}
namespace={{ ...namespace, value: { models: [] }, base: { models: [] } }} settingsPath={[]} schema={settingsSchema}
operations={operationsWith(scripted.face)} t={t} readOnly={false} onClose={() => {}} />)
expect(screen.queryByLabelText(en.keyInput)).toBeNull()
const item = screen.getByText(en.deepSeekAccount).closest('li')!
expect(within(item).queryByText(en.edit)).toBeNull()
})