diff --git a/frontend/src/composables/__tests__/useOpenAIOAuth.spec.ts b/frontend/src/composables/__tests__/useOpenAIOAuth.spec.ts index cf67aca417..fe635b8548 100644 --- a/frontend/src/composables/__tests__/useOpenAIOAuth.spec.ts +++ b/frontend/src/composables/__tests__/useOpenAIOAuth.spec.ts @@ -59,6 +59,20 @@ describe('useOpenAIOAuth.buildCredentials', () => { expect(creds.access_token).toBe('at') expect(creds.refresh_token).toBe('rt') }) + + it('should keep ChatGPT subscription expiration from token response', () => { + const oauth = useOpenAIOAuth() + const creds = oauth.buildCredentials({ + access_token: 'at', + refresh_token: 'rt', + expires_at: 1700000000, + plan_type: 'team', + subscription_expires_at: '2026-07-20T19:22:48+00:00' + }) + + expect(creds.plan_type).toBe('team') + expect(creds.subscription_expires_at).toBe('2026-07-20T19:22:48+00:00') + }) }) describe('useOpenAIOAuth.exchangeAuthCode', () => { diff --git a/frontend/src/composables/useOpenAIOAuth.ts b/frontend/src/composables/useOpenAIOAuth.ts index 4483e4ad32..fe9d2c4220 100644 --- a/frontend/src/composables/useOpenAIOAuth.ts +++ b/frontend/src/composables/useOpenAIOAuth.ts @@ -16,6 +16,7 @@ export interface OpenAITokenInfo { email?: string name?: string plan_type?: string + subscription_expires_at?: string privacy_mode?: string // OpenAI specific IDs (extracted from ID Token) chatgpt_account_id?: string @@ -197,6 +198,9 @@ export function useOpenAIOAuth() { if (tokenInfo.plan_type) { creds.plan_type = tokenInfo.plan_type } + if (tokenInfo.subscription_expires_at) { + creds.subscription_expires_at = tokenInfo.subscription_expires_at + } if (tokenInfo.client_id) { creds.client_id = tokenInfo.client_id }