feat(ui): display user tier in about command (#17400)

This commit is contained in:
Sehoon Shon
2026-01-23 16:03:53 -05:00
committed by GitHub
parent 2c0cc7b9a5
commit 5c649d8db1
18 changed files with 108 additions and 10 deletions
@@ -64,6 +64,7 @@ describe('codeAssist', () => {
httpOptions,
'session-123',
'free-tier',
undefined,
);
expect(generator).toBeInstanceOf(MockedCodeAssistServer);
});
@@ -89,6 +90,7 @@ describe('codeAssist', () => {
httpOptions,
undefined, // No session ID
'free-tier',
undefined,
);
expect(generator).toBeInstanceOf(MockedCodeAssistServer);
});
@@ -31,6 +31,7 @@ export async function createCodeAssistContentGenerator(
httpOptions,
sessionId,
userData.userTier,
userData.userTierName,
);
}
+1
View File
@@ -69,6 +69,7 @@ export class CodeAssistServer implements ContentGenerator {
readonly httpOptions: HttpOptions = {},
readonly sessionId?: string,
readonly userTier?: UserTierId,
readonly userTierName?: string,
) {}
async generateContentStream(
@@ -67,6 +67,7 @@ describe('setupUser for existing user', () => {
{},
'',
undefined,
undefined,
);
});
@@ -83,10 +84,12 @@ describe('setupUser for existing user', () => {
{},
'',
undefined,
undefined,
);
expect(projectId).toEqual({
projectId: 'server-project',
userTier: 'standard-tier',
userTierName: 'paid',
});
});
@@ -148,6 +151,7 @@ describe('setupUser for new user', () => {
{},
'',
undefined,
undefined,
);
expect(mockLoad).toHaveBeenCalled();
expect(mockOnboardUser).toHaveBeenCalledWith({
@@ -163,6 +167,7 @@ describe('setupUser for new user', () => {
expect(userData).toEqual({
projectId: 'server-project',
userTier: 'standard-tier',
userTierName: 'paid',
});
});
@@ -178,6 +183,7 @@ describe('setupUser for new user', () => {
{},
'',
undefined,
undefined,
);
expect(mockLoad).toHaveBeenCalled();
expect(mockOnboardUser).toHaveBeenCalledWith({
@@ -192,6 +198,7 @@ describe('setupUser for new user', () => {
expect(userData).toEqual({
projectId: 'server-project',
userTier: 'free-tier',
userTierName: 'free',
});
});
@@ -210,6 +217,7 @@ describe('setupUser for new user', () => {
expect(userData).toEqual({
projectId: 'test-project',
userTier: 'standard-tier',
userTierName: 'paid',
});
});
@@ -268,6 +276,7 @@ describe('setupUser for new user', () => {
expect(userData).toEqual({
projectId: 'server-project',
userTier: 'standard-tier',
userTierName: 'paid',
});
});
@@ -294,6 +303,7 @@ describe('setupUser for new user', () => {
expect(userData).toEqual({
projectId: 'server-project',
userTier: 'standard-tier',
userTierName: 'paid',
});
});
});
+13 -1
View File
@@ -25,6 +25,7 @@ export class ProjectIdRequiredError extends Error {
export interface UserData {
projectId: string;
userTier: UserTierId;
userTierName?: string;
}
/**
@@ -37,7 +38,14 @@ export async function setupUser(client: AuthClient): Promise<UserData> {
process.env['GOOGLE_CLOUD_PROJECT'] ||
process.env['GOOGLE_CLOUD_PROJECT_ID'] ||
undefined;
const caServer = new CodeAssistServer(client, projectId, {}, '', undefined);
const caServer = new CodeAssistServer(
client,
projectId,
{},
'',
undefined,
undefined,
);
const coreClientMetadata: ClientMetadata = {
ideType: 'IDE_UNSPECIFIED',
platform: 'PLATFORM_UNSPECIFIED',
@@ -58,6 +66,7 @@ export async function setupUser(client: AuthClient): Promise<UserData> {
return {
projectId,
userTier: loadRes.currentTier.id,
userTierName: loadRes.currentTier.name,
};
}
throw new ProjectIdRequiredError();
@@ -65,6 +74,7 @@ export async function setupUser(client: AuthClient): Promise<UserData> {
return {
projectId: loadRes.cloudaicompanionProject,
userTier: loadRes.currentTier.id,
userTierName: loadRes.currentTier.name,
};
}
@@ -103,6 +113,7 @@ export async function setupUser(client: AuthClient): Promise<UserData> {
return {
projectId,
userTier: tier.id,
userTierName: tier.name,
};
}
throw new ProjectIdRequiredError();
@@ -111,6 +122,7 @@ export async function setupUser(client: AuthClient): Promise<UserData> {
return {
projectId: lroRes.response.cloudaicompanionProject.id,
userTier: tier.id,
userTierName: tier.name,
};
}
+4
View File
@@ -963,6 +963,10 @@ export class Config {
return this.contentGenerator?.userTier;
}
getUserTierName(): string | undefined {
return this.contentGenerator?.userTierName;
}
/**
* Provides access to the BaseLlmClient for stateless LLM operations.
*/
@@ -44,6 +44,8 @@ export interface ContentGenerator {
embedContent(request: EmbedContentParameters): Promise<EmbedContentResponse>;
userTier?: UserTierId;
userTierName?: string;
}
export enum AuthType {
@@ -42,6 +42,7 @@ export type FakeResponse =
export class FakeContentGenerator implements ContentGenerator {
private callCounter = 0;
userTier?: UserTierId;
userTierName?: string;
constructor(private readonly responses: FakeResponse[]) {}
@@ -31,6 +31,7 @@ import type { ContentGenerator } from './contentGenerator.js';
import { LoggingContentGenerator } from './loggingContentGenerator.js';
import type { Config } from '../config/config.js';
import { ApiRequestEvent } from '../telemetry/types.js';
import { UserTierId } from '../code_assist/types.js';
describe('LoggingContentGenerator', () => {
let wrapped: ContentGenerator;
@@ -302,4 +303,16 @@ describe('LoggingContentGenerator', () => {
expect(result).toBe(response);
});
});
describe('delegation', () => {
it('should delegate userTier to wrapped', () => {
wrapped.userTier = UserTierId.STANDARD;
expect(loggingContentGenerator.userTier).toBe(UserTierId.STANDARD);
});
it('should delegate userTierName to wrapped', () => {
wrapped.userTierName = 'Standard Tier';
expect(loggingContentGenerator.userTierName).toBe('Standard Tier');
});
});
});
@@ -23,6 +23,7 @@ import {
ApiErrorEvent,
} from '../telemetry/types.js';
import type { Config } from '../config/config.js';
import type { UserTierId } from '../code_assist/types.js';
import {
logApiError,
logApiRequest,
@@ -51,6 +52,14 @@ export class LoggingContentGenerator implements ContentGenerator {
return this.wrapped;
}
get userTier(): UserTierId | undefined {
return this.wrapped.userTier;
}
get userTierName(): string | undefined {
return this.wrapped.userTierName;
}
private logApiRequest(
contents: Content[],
model: string,
@@ -25,13 +25,19 @@ import { safeJsonStringify } from '../utils/safeJsonStringify.js';
//
// Note that only the "interesting" bits of the responses are actually kept.
export class RecordingContentGenerator implements ContentGenerator {
userTier?: UserTierId;
constructor(
private readonly realGenerator: ContentGenerator,
private readonly filePath: string,
) {}
get userTier(): UserTierId | undefined {
return this.realGenerator.userTier;
}
get userTierName(): string | undefined {
return this.realGenerator.userTierName;
}
async generateContent(
request: GenerateContentParameters,
userPromptId: string,