mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-08 02:17:46 +08:00
fix(frontend): preserve compact scope and detail badge
This commit is contained in:
@@ -758,7 +758,9 @@ function handleRequestScopeChange(value: string) {
|
||||
}
|
||||
|
||||
function normalizeUnavailableSessionCompactionScope() {
|
||||
if (props.endpoints === undefined) return
|
||||
// An empty list is also used while endpoints are loading or after loading fails,
|
||||
// so it cannot prove that the existing scope is unsupported.
|
||||
if (!props.endpoints || props.endpoints.length === 0) return
|
||||
if (
|
||||
requestScopeValue.value === COMPACT_REQUEST_SCOPE_VALUE
|
||||
&& !sessionCompactionScopeAvailable.value
|
||||
|
||||
@@ -251,6 +251,65 @@ describe('ModelMappingDialog', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('preserves an edited compact scope when endpoint capabilities are unavailable', async () => {
|
||||
const model = {
|
||||
id: 'model-sol',
|
||||
provider_model_name: 'gpt-5.6-sol',
|
||||
global_model_display_name: 'GPT-5.6 Sol',
|
||||
provider_model_mappings: [{
|
||||
name: 'gpt-5.6-luna',
|
||||
priority: 1,
|
||||
endpoint_ids: ['endpoint-responses'],
|
||||
operations: ['compact'],
|
||||
}],
|
||||
} as Model
|
||||
const editingGroup: AliasGroup = {
|
||||
model,
|
||||
apiFormatsKey: '',
|
||||
apiFormats: [],
|
||||
endpointIdsKey: 'endpoint-responses',
|
||||
endpointIds: ['endpoint-responses'],
|
||||
operationsKey: 'compact',
|
||||
operations: ['compact'],
|
||||
aliases: model.provider_model_mappings ?? [],
|
||||
}
|
||||
const open = ref(false)
|
||||
const root = document.createElement('div')
|
||||
document.body.appendChild(root)
|
||||
const app = createApp(defineComponent({
|
||||
setup() {
|
||||
return () => h(ModelMappingDialog, {
|
||||
open: open.value,
|
||||
providerId: 'provider-1',
|
||||
endpoints: [],
|
||||
models: [model],
|
||||
editingGroup,
|
||||
'onUpdate:open': (value: boolean) => { open.value = value },
|
||||
})
|
||||
},
|
||||
}))
|
||||
app.mount(root)
|
||||
mountedApps.push({ app, root })
|
||||
|
||||
open.value = true
|
||||
await nextTick()
|
||||
await nextTick()
|
||||
|
||||
const saveButton = [...root.querySelectorAll('button')]
|
||||
.find(button => button.textContent?.includes('保存映射'))
|
||||
saveButton?.click()
|
||||
await vi.waitFor(() => expect(updateModel).toHaveBeenCalledTimes(1))
|
||||
|
||||
expect(updateModel).toHaveBeenCalledWith('provider-1', 'model-sol', {
|
||||
provider_model_mappings: [{
|
||||
name: 'gpt-5.6-luna',
|
||||
priority: 1,
|
||||
endpoint_ids: ['endpoint-responses'],
|
||||
operations: ['compact'],
|
||||
}],
|
||||
})
|
||||
})
|
||||
|
||||
it('normalizes and replaces an edited compact operation scope', async () => {
|
||||
const endpoint = {
|
||||
id: 'endpoint-responses',
|
||||
|
||||
@@ -1069,6 +1069,7 @@ type HeaderModelTextField =
|
||||
| 'model'
|
||||
| 'target_model'
|
||||
| 'model_version'
|
||||
| 'request_type'
|
||||
| 'requested_reasoning_effort'
|
||||
| 'reasoning_effort'
|
||||
| 'service_tier'
|
||||
@@ -1162,6 +1163,7 @@ watch(
|
||||
props.summaryRecord?.model,
|
||||
props.summaryRecord?.target_model,
|
||||
props.summaryRecord?.model_version,
|
||||
props.summaryRecord?.request_type,
|
||||
props.summaryRecord?.requested_reasoning_effort,
|
||||
props.summaryRecord?.reasoning_effort,
|
||||
props.summaryRecord?.service_tier,
|
||||
@@ -1515,6 +1517,7 @@ const headerModelRecord = computed(() => {
|
||||
model: resolveHeaderModelTextField('model', currentDetail) ?? '-',
|
||||
target_model: resolveHeaderModelTextField('target_model', currentDetail),
|
||||
model_version: resolveHeaderModelTextField('model_version', currentDetail),
|
||||
request_type: resolveHeaderModelTextField('request_type', currentDetail),
|
||||
requested_reasoning_effort: resolveHeaderModelTextField(
|
||||
'requested_reasoning_effort',
|
||||
currentDetail,
|
||||
|
||||
@@ -98,6 +98,40 @@ describe('RequestDetailDrawer settlement pricing', () => {
|
||||
expect(document.body.textContent).not.toContain('输出 $0/M')
|
||||
})
|
||||
|
||||
it('shows the compact request badge in the model header', async () => {
|
||||
apiMocks.getRequestDetail.mockResolvedValue({
|
||||
...buildEmbeddingDetail(),
|
||||
id: 'usage-compact-1',
|
||||
request_id: 'req-compact-1',
|
||||
request_type: 'compact',
|
||||
})
|
||||
|
||||
let isOpen!: Ref<boolean>
|
||||
const Host = defineComponent({
|
||||
setup() {
|
||||
isOpen = ref(false)
|
||||
return () => h(RequestDetailDrawer, {
|
||||
isOpen: isOpen.value,
|
||||
requestId: 'usage-compact-1',
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
const root = document.createElement('div')
|
||||
document.body.appendChild(root)
|
||||
const app = createApp(Host)
|
||||
app.mount(root)
|
||||
mountedApps.push({ app, root })
|
||||
|
||||
isOpen.value = true
|
||||
await nextTick()
|
||||
|
||||
await vi.waitFor(() => {
|
||||
expect(document.body.querySelector('[data-request-detail-model-badge="compact"]')?.textContent?.trim())
|
||||
.toBe('会话压缩')
|
||||
})
|
||||
})
|
||||
|
||||
it('shows mapping, reasoning, Fast, and Cyber together in the model header', async () => {
|
||||
apiMocks.getRequestDetail.mockResolvedValue({
|
||||
...buildEmbeddingDetail(),
|
||||
|
||||
Reference in New Issue
Block a user