Skip to content

Commit a84bf3f

Browse files
authored
Merge pull request #2521 from Brisbanehuang/codex/fix-subscription-model-scopes
fix: hide model scopes for non-antigravity plans
2 parents 1f2c5dc + 26ca73a commit a84bf3f

5 files changed

Lines changed: 112 additions & 0 deletions

File tree

frontend/src/components/payment/SubscriptionPlanCard.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ const MODEL_SCOPE_LABELS: Record<string, string> = {
147147
}
148148
149149
const modelScopeLabels = computed(() => {
150+
if (platform.value !== 'antigravity') return []
150151
const scopes = props.plan.supported_model_scopes
151152
if (!scopes || scopes.length === 0) return []
152153
return scopes.map(s => MODEL_SCOPE_LABELS[s] || s)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { mount } from "@vue/test-utils";
2+
import { describe, expect, it } from "vitest";
3+
import { createI18n } from "vue-i18n";
4+
import SubscriptionPlanCard from "../SubscriptionPlanCard.vue";
5+
6+
const i18n = createI18n({
7+
legacy: false,
8+
locale: "en",
9+
fallbackWarn: false,
10+
missingWarn: false,
11+
messages: {
12+
en: {
13+
payment: {
14+
days: "days",
15+
models: "Models",
16+
planCard: {
17+
quota: "Quota",
18+
rate: "Rate",
19+
unlimited: "Unlimited",
20+
},
21+
subscribeNow: "Subscribe now",
22+
},
23+
},
24+
},
25+
});
26+
27+
const mountPlanCard = (groupPlatform: string) =>
28+
mount(SubscriptionPlanCard, {
29+
props: {
30+
plan: {
31+
id: 1,
32+
group_id: 10,
33+
group_platform: groupPlatform,
34+
name: "Pro",
35+
price: 10,
36+
amount: 1000,
37+
features: [],
38+
rate_multiplier: 1,
39+
validity_days: 30,
40+
validity_unit: "day",
41+
supported_model_scopes: ["claude", "gemini_text", "gemini_image"],
42+
is_active: true,
43+
},
44+
},
45+
global: { plugins: [i18n] },
46+
});
47+
48+
describe("SubscriptionPlanCard", () => {
49+
it("does not show Antigravity model scopes for OpenAI plans", () => {
50+
const text = mountPlanCard("openai").text();
51+
52+
expect(text).not.toContain("Claude");
53+
expect(text).not.toContain("Gemini");
54+
expect(text).not.toContain("Imagen");
55+
});
56+
57+
it("shows model scopes for Antigravity plans", () => {
58+
const text = mountPlanCard("antigravity").text();
59+
60+
expect(text).toContain("Claude");
61+
expect(text).toContain("Gemini");
62+
expect(text).toContain("Imagen");
63+
});
64+
});

frontend/src/views/admin/GroupsView.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2862,6 +2862,7 @@ import {
28622862
resetMessagesDispatchFormState,
28632863
type MessagesDispatchMappingRow,
28642864
} from "./groupsMessagesDispatch";
2865+
import { normalizeSupportedModelScopesForPlatform } from "./groupsSupportedModelScopes";
28652866
28662867
const { t } = useI18n();
28672868
const appStore = useAppStore();
@@ -3707,6 +3708,10 @@ const handleCreateGroup = async () => {
37073708
model_routing: convertRoutingRulesToApiFormat(
37083709
createModelRoutingRules.value,
37093710
),
3711+
supported_model_scopes: normalizeSupportedModelScopesForPlatform(
3712+
createForm.platform,
3713+
createForm.supported_model_scopes,
3714+
),
37103715
messages_dispatch_model_config:
37113716
createForm.platform === "openai"
37123717
? messagesDispatchFormStateToConfig({
@@ -3838,6 +3843,10 @@ const handleUpdateGroup = async () => {
38383843
model_routing: convertRoutingRulesToApiFormat(
38393844
editModelRoutingRules.value,
38403845
),
3846+
supported_model_scopes: normalizeSupportedModelScopesForPlatform(
3847+
editForm.platform,
3848+
editForm.supported_model_scopes,
3849+
),
38413850
messages_dispatch_model_config:
38423851
editForm.platform === "openai"
38433852
? messagesDispatchFormStateToConfig({
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { describe, expect, it } from "vitest";
2+
import { normalizeSupportedModelScopesForPlatform } from "../groupsSupportedModelScopes";
3+
4+
describe("normalizeSupportedModelScopesForPlatform", () => {
5+
it("preserves model scopes for Antigravity groups", () => {
6+
expect(
7+
normalizeSupportedModelScopesForPlatform("antigravity", [
8+
"claude",
9+
"gemini_text",
10+
]),
11+
).toEqual(["claude", "gemini_text"]);
12+
});
13+
14+
it("returns an empty array for Antigravity groups without scopes", () => {
15+
expect(normalizeSupportedModelScopesForPlatform("antigravity", undefined)).toEqual([]);
16+
});
17+
18+
it("drops hidden model scopes for OpenAI groups", () => {
19+
expect(
20+
normalizeSupportedModelScopesForPlatform("openai", [
21+
"claude",
22+
"gemini_text",
23+
"gemini_image",
24+
]),
25+
).toEqual([]);
26+
});
27+
28+
it("drops hidden model scopes for other non-Antigravity groups", () => {
29+
expect(normalizeSupportedModelScopesForPlatform("claude", ["claude"])).toEqual([]);
30+
});
31+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const normalizeSupportedModelScopesForPlatform = (
2+
platform: string,
3+
scopes: string[] | undefined,
4+
): string[] => {
5+
if (platform !== "antigravity") return [];
6+
return scopes ?? [];
7+
};

0 commit comments

Comments
 (0)