chore: rename CC compatible feature flag

This commit is contained in:
R.D.
2026-04-01 04:39:29 -04:00
parent 190f02a939
commit 32dc3b36ab
4 changed files with 30 additions and 16 deletions
@@ -21,7 +21,6 @@ import {
isClaudeCodeCompatibleProvider,
isOpenAICompatibleProvider,
} from "@/shared/constants/providers";
import { CC_COMPATIBLE_PROVIDER_ENABLED } from "@/shared/utils/featureFlags";
import Link from "next/link";
import { getErrorCode, getRelativeTime } from "@/shared/utils";
import { useNotificationStore } from "@/store/notificationStore";
@@ -102,6 +101,7 @@ function getConnectionErrorTag(connection) {
export default function ProvidersPage() {
const [connections, setConnections] = useState<any[]>([]);
const [providerNodes, setProviderNodes] = useState<any[]>([]);
const [ccCompatibleProviderEnabled, setCcCompatibleProviderEnabled] = useState(false);
const [expirations, setExpirations] = useState<any>(null);
const [loading, setLoading] = useState(true);
const [showAddCompatibleModal, setShowAddCompatibleModal] = useState(false);
@@ -126,7 +126,10 @@ export default function ProvidersPage() {
const nodesData = await nodesRes.json();
const expirationsData = await expirationsRes.json();
if (connectionsRes.ok) setConnections(connectionsData.connections || []);
if (nodesRes.ok) setProviderNodes(nodesData.nodes || []);
if (nodesRes.ok) {
setProviderNodes(nodesData.nodes || []);
setCcCompatibleProviderEnabled(nodesData.ccCompatibleProviderEnabled === true);
}
if (expirationsRes.ok && expirationsData) setExpirations(expirationsData);
} catch (error) {
console.log("Error fetching data:", error);
@@ -514,7 +517,7 @@ export default function ProvidersPage() {
{testingMode === "compatible" ? t("testing") : t("testAll")}
</button>
)}
{CC_COMPATIBLE_PROVIDER_ENABLED && (
{ccCompatibleProviderEnabled && (
<Button
size="sm"
variant="secondary"
@@ -583,7 +586,7 @@ export default function ProvidersPage() {
setShowAddAnthropicCompatibleModal(false);
}}
/>
{CC_COMPATIBLE_PROVIDER_ENABLED && (
{ccCompatibleProviderEnabled && (
<AddCcCompatibleModal
isOpen={showAddCcCompatibleModal}
onClose={() => setShowAddCcCompatibleModal(false)}
+4 -1
View File
@@ -29,7 +29,10 @@ function sanitizeAnthropicBaseUrl(baseUrl: string) {
export async function GET() {
try {
const nodes = await getProviderNodes();
return NextResponse.json({ nodes });
return NextResponse.json({
nodes,
ccCompatibleProviderEnabled: isCcCompatibleProviderEnabled(),
});
} catch (error) {
console.log("Error fetching provider nodes:", error);
return NextResponse.json({ error: "Failed to fetch provider nodes" }, { status: 500 });
+1 -3
View File
@@ -1,5 +1,3 @@
export function isCcCompatibleProviderEnabled() {
return process.env.NEXT_PUBLIC_ENABLE_CC_COMPATIBLE_PROVIDER === "true";
return process.env.ENABLE_CC_COMPATIBLE_PROVIDER === "true";
}
export const CC_COMPATIBLE_PROVIDER_ENABLED = isCcCompatibleProviderEnabled();
+18 -8
View File
@@ -21,7 +21,7 @@ const providerNodesValidateRoute =
await import("../../src/app/api/provider-nodes/validate/route.ts");
const originalFetch = globalThis.fetch;
const originalFlag = process.env.NEXT_PUBLIC_ENABLE_CC_COMPATIBLE_PROVIDER;
const originalFlag = process.env.ENABLE_CC_COMPATIBLE_PROVIDER;
async function resetStorage() {
core.resetDbInstance();
@@ -32,9 +32,9 @@ async function resetStorage() {
test.afterEach(async () => {
globalThis.fetch = originalFetch;
if (originalFlag === undefined) {
delete process.env.NEXT_PUBLIC_ENABLE_CC_COMPATIBLE_PROVIDER;
delete process.env.ENABLE_CC_COMPATIBLE_PROVIDER;
} else {
process.env.NEXT_PUBLIC_ENABLE_CC_COMPATIBLE_PROVIDER = originalFlag;
process.env.ENABLE_CC_COMPATIBLE_PROVIDER = originalFlag;
}
await resetStorage();
});
@@ -42,9 +42,9 @@ test.afterEach(async () => {
test.after(() => {
globalThis.fetch = originalFetch;
if (originalFlag === undefined) {
delete process.env.NEXT_PUBLIC_ENABLE_CC_COMPATIBLE_PROVIDER;
delete process.env.ENABLE_CC_COMPATIBLE_PROVIDER;
} else {
process.env.NEXT_PUBLIC_ENABLE_CC_COMPATIBLE_PROVIDER = originalFlag;
process.env.ENABLE_CC_COMPATIBLE_PROVIDER = originalFlag;
}
core.resetDbInstance();
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true });
@@ -170,7 +170,7 @@ test("validateProviderApiKey uses CC skeleton request after /models fallback", a
});
test("provider-nodes create route rejects CC mode when feature flag is disabled", async () => {
delete process.env.NEXT_PUBLIC_ENABLE_CC_COMPATIBLE_PROVIDER;
delete process.env.ENABLE_CC_COMPATIBLE_PROVIDER;
const response = await providerNodesRoute.POST(
new Request("http://localhost/api/provider-nodes", {
@@ -190,7 +190,7 @@ test("provider-nodes create route rejects CC mode when feature flag is disabled"
});
test("provider-nodes create route creates CC node with dedicated prefix when enabled", async () => {
process.env.NEXT_PUBLIC_ENABLE_CC_COMPATIBLE_PROVIDER = "true";
process.env.ENABLE_CC_COMPATIBLE_PROVIDER = "true";
const response = await providerNodesRoute.POST(
new Request("http://localhost/api/provider-nodes", {
@@ -217,7 +217,7 @@ test("provider-nodes create route creates CC node with dedicated prefix when ena
});
test("provider-nodes validate route rejects CC mode when feature flag is disabled", async () => {
delete process.env.NEXT_PUBLIC_ENABLE_CC_COMPATIBLE_PROVIDER;
delete process.env.ENABLE_CC_COMPATIBLE_PROVIDER;
const response = await providerNodesValidateRoute.POST(
new Request("http://localhost/api/provider-nodes/validate", {
@@ -234,3 +234,13 @@ test("provider-nodes validate route rejects CC mode when feature flag is disable
assert.equal(response.status, 403);
});
test("provider-nodes list route exposes CC flag state from server env", async () => {
process.env.ENABLE_CC_COMPATIBLE_PROVIDER = "true";
const response = await providerNodesRoute.GET();
assert.equal(response.status, 200);
const data = await response.json();
assert.equal(data.ccCompatibleProviderEnabled, true);
});