merge(main): resolve subscription usage policy conflicts

This commit is contained in:
elky
2026-09-05 14:21:16 +08:00
20 changed files with 806 additions and 78 deletions
@@ -70,7 +70,7 @@
class="p-2 hover:bg-muted rounded-md transition-colors shrink-0"
:disabled="fetchingUpstreamModels"
title="刷新上游模型"
@click="fetchUpstreamModels()"
@click="fetchUpstreamModels(true)"
>
<RefreshCw
class="w-4 h-4"
@@ -82,7 +82,7 @@
type="button"
class="p-2 hover:bg-muted rounded-md transition-colors shrink-0"
title="从提供商获取模型"
@click="fetchUpstreamModels()"
@click="fetchUpstreamModels(true)"
>
<Zap class="w-4 h-4" />
</button>
@@ -678,12 +678,12 @@ function toggleGroupCollapse(group: string) {
}
// 从提供商获取模型(使用缓存)
async function fetchUpstreamModels() {
async function fetchUpstreamModels(forceRefresh = false) {
if (!props.providerId) return
try {
loadingModels.value = true
fetchingUpstreamModels.value = true
const result = await fetchCachedModels(props.providerId)
const result = await fetchCachedModels(props.providerId, undefined, forceRefresh)
if (result.models.length > 0) {
upstreamModels.value = result.models
upstreamModelsLoaded.value = true
@@ -153,7 +153,24 @@ describe('ModelMappingDialog', () => {
mountedApps.push({ app, root })
await vi.waitFor(() => expect(upstreamModelMocks.fetchModels).toHaveBeenCalledTimes(1))
expect(upstreamModelMocks.fetchModels).toHaveBeenCalledWith('provider-1')
expect(upstreamModelMocks.fetchModels).toHaveBeenCalledWith('provider-1', undefined, false)
// Both manual fetch and refresh must bypass the backend cache.
upstreamModelMocks.fetchModels.mockResolvedValue({ models: [{ id: 'gpt-old' }] })
await nextTick()
const fetchButton = root.querySelector<HTMLButtonElement>('[title="从提供商获取模型"]')
expect(fetchButton).not.toBeNull()
fetchButton!.click()
await vi.waitFor(() => expect(root.textContent).toContain('gpt-old'))
expect(upstreamModelMocks.fetchModels).toHaveBeenLastCalledWith('provider-1', undefined, true)
upstreamModelMocks.fetchModels.mockResolvedValue({ models: [{ id: 'gpt-6-astra' }] })
const refreshButton = root.querySelector<HTMLButtonElement>('[title="刷新上游模型"]')
expect(refreshButton).not.toBeNull()
refreshButton!.click()
await vi.waitFor(() => expect(root.textContent).toContain('gpt-6-astra'))
expect(root.textContent).not.toContain('gpt-old')
expect(upstreamModelMocks.fetchModels).toHaveBeenLastCalledWith('provider-1', undefined, true)
})
it('offers session compaction only for an explicitly selected Responses endpoint', async () => {