From 5713820813e29eadcfd102c19b0fe7e4c31ea125 Mon Sep 17 00:00:00 2001 From: benjamin Date: Mon, 18 May 2026 19:01:55 +0800 Subject: [PATCH] feat: add upstream model sync controls Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- .../components/account/EditAccountModal.vue | 52 ++++++++++++++++-- .../account/ModelWhitelistSelector.vue | 54 +++++++++++++++++++ 2 files changed, 103 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/account/EditAccountModal.vue b/frontend/src/components/account/EditAccountModal.vue index 80f0b890..1d80ce45 100644 --- a/frontend/src/components/account/EditAccountModal.vue +++ b/frontend/src/components/account/EditAccountModal.vue @@ -139,7 +139,7 @@
- +

{{ t('admin.accounts.selectedModels', { count: allowedModels.length }) }} {{ @@ -454,7 +454,7 @@

- +

{{ t('admin.accounts.selectedModels', { count: allowedModels.length }) }} {{ @@ -666,7 +666,7 @@

- +

{{ t('admin.accounts.selectedModels', { count: allowedModels.length }) }} {{ @@ -987,6 +987,17 @@

{{ t('admin.accounts.mapRequestModels') }}

+
+ +
+
('whitelist') const antigravityWhitelistModels = ref([]) const antigravityModelMappings = ref([]) +const isSyncingAntigravityUpstream = ref(false) const tempUnschedEnabled = ref(false) const tempUnschedRules = ref([]) const getModelMappingKey = createStableObjectKeyResolver('edit-model-mapping') @@ -2935,6 +2947,40 @@ const addAntigravityPresetMapping = (from: string, to: string) => { antigravityModelMappings.value.push({ from, to }) } +const syncAntigravityUpstreamModels = async () => { + if (!props.account?.id || isSyncingAntigravityUpstream.value) return + + isSyncingAntigravityUpstream.value = true + try { + const result = await adminAPI.accounts.syncUpstreamModels(props.account.id) + const upstreamModels = result.models.map((model) => model.trim()).filter(Boolean) + if (upstreamModels.length === 0) { + appStore.showInfo(t('admin.accounts.syncUpstreamModelsEmpty')) + return + } + + let addedCount = 0 + for (const model of upstreamModels) { + const exists = antigravityModelMappings.value.some((mapping) => mapping.from === model) + if (!exists) { + antigravityModelMappings.value.push({ from: model, to: model }) + addedCount += 1 + } + } + + if (addedCount > 0) { + appStore.showSuccess(t('admin.accounts.syncUpstreamModelsSuccess', { count: addedCount, total: upstreamModels.length })) + } else { + appStore.showInfo(t('admin.accounts.syncUpstreamModelsNoChanges', { count: upstreamModels.length })) + } + } catch (error) { + const message = error instanceof Error ? error.message : t('admin.accounts.syncUpstreamModelsFailed') + appStore.showError(t('admin.accounts.syncUpstreamModelsError', { message })) + } finally { + isSyncingAntigravityUpstream.value = false + } +} + // Error code toggle helper const toggleErrorCode = (code: number) => { const index = selectedErrorCodes.value.indexOf(code) diff --git a/frontend/src/components/account/ModelWhitelistSelector.vue b/frontend/src/components/account/ModelWhitelistSelector.vue index ebce3740..9a0d6af8 100644 --- a/frontend/src/components/account/ModelWhitelistSelector.vue +++ b/frontend/src/components/account/ModelWhitelistSelector.vue @@ -85,6 +85,15 @@ > {{ t('admin.accounts.fillRelatedModels') }} +