From cd73d7975e1f672dafc46525620e974edcc4a01d Mon Sep 17 00:00:00 2001 From: r266-tech Date: Sun, 29 Nov 2026 13:32:29 +0900 Subject: [PATCH] fix(accounts): preserve Antigravity options on refresh token import --- .../components/account/CreateAccountModal.vue | 3 +- .../__tests__/CreateAccountModal.spec.ts | 31 ++++++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/account/CreateAccountModal.vue b/frontend/src/components/account/CreateAccountModal.vue index 026c00df43..b63642fcbe 100644 --- a/frontend/src/components/account/CreateAccountModal.vue +++ b/frontend/src/components/account/CreateAccountModal.vue @@ -7128,14 +7128,13 @@ const handleAntigravityValidateRT = async (refreshTokenInput: string) => { // Generate account name with index for batch const accountName = refreshTokens.length > 1 ? `${form.name} #${i + 1}` : form.name - // Note: Antigravity doesn't have buildExtraInfo, so we pass empty extra or rely on credentials const createPayload = withAntigravityConfirmFlag({ name: accountName, notes: form.notes, platform: 'antigravity', type: 'oauth', credentials, - extra: withUpstreamRequestIdHeader({}), + extra: withUpstreamRequestIdHeader(buildAntigravityExtra()), proxy_id: form.proxy_id, concurrency: form.concurrency, load_factor: form.load_factor ?? undefined, diff --git a/frontend/src/components/account/__tests__/CreateAccountModal.spec.ts b/frontend/src/components/account/__tests__/CreateAccountModal.spec.ts index 0e30886822..0b8f26954e 100644 --- a/frontend/src/components/account/__tests__/CreateAccountModal.spec.ts +++ b/frontend/src/components/account/__tests__/CreateAccountModal.spec.ts @@ -54,6 +54,9 @@ vi.mock('@/api/admin', () => ({ importCodexSession: importCodexSessionMock, createOpenAICodexPAT: createOpenAICodexPATMock, }, + antigravity: { + refreshAntigravityToken: vi.fn().mockResolvedValue({ access_token: 'test-access-token' }), + }, settings: { getWebSearchEmulationConfig: vi.fn().mockResolvedValue({ enabled: false, providers: [] }), getSettings: vi.fn().mockResolvedValue({}), @@ -94,7 +97,7 @@ const OAuthAuthorizationFlowStub = defineComponent({ initialInputMethod: String, }, data: () => ({ inputMethod: 'manual' }), - emits: ['import-codex-session', 'import-codex-pat'], + emits: ['import-codex-session', 'import-codex-pat', 'validate-refresh-token'], template: `
@@ -900,6 +903,32 @@ describe('CreateAccountModal OpenAI long-context billing', () => { expect(createAccountMock.mock.calls[0]?.[0]?.upstream_billing_probe_enabled).toBe(false) }) + it('preserves Antigravity account options for every refresh token imported', async () => { + const wrapper = mountModal() + await selectButtonByText(wrapper, 'Antigravity') + await wrapper.get('[data-tour="account-form-name"]').setValue('Antigravity import') + for (const option of ['mixedScheduling', 'allowOverages']) { + const label = wrapper.findAll('label').find(label => label.text() === `admin.accounts.${option}`) + if (!label) throw new Error(`Missing ${option} checkbox`) + await label.get('input').setValue(true) + } + await wrapper.get('[data-testid="upstream-request-id-header"]').setValue('x-trace-id') + await wrapper.get('#create-account-form').trigger('submit.prevent') + await flushPromises() + wrapper.getComponent(OAuthAuthorizationFlowStub).vm.$emit('validate-refresh-token', 'test-one\ntest-two') + await flushPromises() + + expect(createAccountMock).toHaveBeenCalledTimes(2) + for (const [payload] of createAccountMock.mock.calls) { + expect(payload.extra).toEqual({ + mixed_scheduling: true, + allow_overages: true, + upstream_request_id_header: 'x-trace-id', + }) + } + wrapper.unmount() + }) + it('antigravity upstream 创建默认携带上游倍率探测开关', async () => { // antigravity upstream 走独立创建 helper, // 也必须与其余 API-key 平台一样默认开启探测并传递开关。