Change flag name to flag id for existing flags (#13073)

This commit is contained in:
Adib234
2025-11-14 13:34:54 -08:00
committed by GitHub
parent ba15eeb55f
commit ce56b4ee1b
5 changed files with 15 additions and 16 deletions

View File

@@ -42,8 +42,8 @@ describe('experiments', () => {
const { getExperiments } = await import('./experiments.js'); const { getExperiments } = await import('./experiments.js');
const mockApiResponse: ListExperimentsResponse = { const mockApiResponse: ListExperimentsResponse = {
flags: [ flags: [
{ name: 'flag1', boolValue: true }, { flagId: 234, boolValue: true },
{ name: 'flag2', stringValue: 'value' }, { flagId: 345, stringValue: 'value' },
], ],
experimentIds: [123, 456], experimentIds: [123, 456],
}; };
@@ -58,12 +58,12 @@ describe('experiments', () => {
); );
// Verify that the response was parsed correctly // Verify that the response was parsed correctly
expect(experiments.flags['flag1']).toEqual({ expect(experiments.flags[234]).toEqual({
name: 'flag1', flagId: 234,
boolValue: true, boolValue: true,
}); });
expect(experiments.flags['flag2']).toEqual({ expect(experiments.flags[345]).toEqual({
name: 'flag2', flagId: 345,
stringValue: 'value', stringValue: 'value',
}); });
expect(experiments.experimentIds).toEqual([123, 456]); expect(experiments.experimentIds).toEqual([123, 456]);
@@ -85,7 +85,7 @@ describe('experiments', () => {
const mockApiResponse: ListExperimentsResponse = { const mockApiResponse: ListExperimentsResponse = {
flags: [ flags: [
{ boolValue: true } as Flag, // No name { boolValue: true } as Flag, // No name
{ name: 'flag2', stringValue: 'value' }, { flagId: 256, stringValue: 'value' },
], ],
}; };
vi.mocked(mockServer.listExperiments).mockResolvedValue(mockApiResponse); vi.mocked(mockServer.listExperiments).mockResolvedValue(mockApiResponse);
@@ -93,7 +93,7 @@ describe('experiments', () => {
const experiments = await getExperiments(mockServer); const experiments = await getExperiments(mockServer);
expect(Object.keys(experiments.flags)).toHaveLength(1); expect(Object.keys(experiments.flags)).toHaveLength(1);
expect(experiments.flags['flag2']).toBeDefined(); expect(experiments.flags[256]).toBeDefined();
expect(experiments.flags['undefined']).toBeUndefined(); expect(experiments.flags['undefined']).toBeUndefined();
}); });

View File

@@ -38,8 +38,8 @@ export async function getExperiments(
function parseExperiments(response: ListExperimentsResponse): Experiments { function parseExperiments(response: ListExperimentsResponse): Experiments {
const flags: Record<string, Flag> = {}; const flags: Record<string, Flag> = {};
for (const flag of response.flags ?? []) { for (const flag of response.flags ?? []) {
if (flag.name) { if (flag.flagId) {
flags[flag.name] = flag; flags[flag.flagId] = flag;
} }
} }
return { return {

View File

@@ -5,9 +5,8 @@
*/ */
export const ExperimentFlags = { export const ExperimentFlags = {
CONTEXT_COMPRESSION_THRESHOLD: CONTEXT_COMPRESSION_THRESHOLD: 45740197,
'GeminiCLIContextCompression__threshold_fraction', USER_CACHING: 45740198,
USER_CACHING: 'GcliUserCaching__user_caching',
} as const; } as const;
export type ExperimentFlagName = export type ExperimentFlagName =

View File

@@ -19,7 +19,7 @@ export interface ListExperimentsResponse {
} }
export interface Flag { export interface Flag {
name?: string; flagId?: number;
boolValue?: boolean; boolValue?: boolean;
floatValue?: number; floatValue?: number;
intValue?: string; // int64 intValue?: string; // int64

View File

@@ -1425,8 +1425,8 @@ export class Config {
this.experiments = experiments; this.experiments = experiments;
const flagSummaries = Object.entries(experiments.flags ?? {}) const flagSummaries = Object.entries(experiments.flags ?? {})
.sort(([a], [b]) => a.localeCompare(b)) .sort(([a], [b]) => a.localeCompare(b))
.map(([name, flag]) => { .map(([flagId, flag]) => {
const summary: Record<string, unknown> = { name }; const summary: Record<string, unknown> = { flagId };
if (flag.boolValue !== undefined) { if (flag.boolValue !== undefined) {
summary['boolValue'] = flag.boolValue; summary['boolValue'] = flag.boolValue;
} }