feat(cli): Partial threading of AgentLoopContext. (#22978)

This commit is contained in:
joshualitt
2026-03-19 09:02:13 -07:00
committed by GitHub
parent 9053f409f5
commit ed9e47d76e
68 changed files with 608 additions and 421 deletions
@@ -9,6 +9,7 @@ import { authCommand } from './authCommand.js';
import { type CommandContext } from './types.js';
import { createMockCommandContext } from '../../test-utils/mockCommandContext.js';
import { SettingScope } from '../../config/settings.js';
import type { GeminiClient } from '@google/gemini-cli-core';
vi.mock('@google/gemini-cli-core', async () => {
const actual = await vi.importActual('@google/gemini-cli-core');
@@ -24,8 +25,10 @@ describe('authCommand', () => {
beforeEach(() => {
mockContext = createMockCommandContext({
services: {
config: {
getGeminiClient: vi.fn(),
agentContext: {
geminiClient: {
stripThoughtsFromHistory: vi.fn(),
},
},
},
});
@@ -101,17 +104,19 @@ describe('authCommand', () => {
const mockStripThoughts = vi.fn();
const mockClient = {
stripThoughtsFromHistory: mockStripThoughts,
} as unknown as ReturnType<
NonNullable<typeof mockContext.services.config>['getGeminiClient']
>;
if (mockContext.services.config) {
mockContext.services.config.getGeminiClient = vi.fn(() => mockClient);
} as unknown as GeminiClient;
if (mockContext.services.agentContext?.config) {
mockContext.services.agentContext.config.getGeminiClient = vi.fn(
() => mockClient,
);
}
await logoutCommand!.action!(mockContext, '');
expect(mockStripThoughts).toHaveBeenCalled();
expect(
mockContext.services.agentContext?.geminiClient
.stripThoughtsFromHistory,
).toHaveBeenCalled();
});
it('should return logout action to signal explicit state change', async () => {
@@ -123,7 +128,7 @@ describe('authCommand', () => {
it('should handle missing config gracefully', async () => {
const logoutCommand = authCommand.subCommands?.[1];
mockContext.services.config = null;
mockContext.services.agentContext = null;
const result = await logoutCommand!.action!(mockContext, '');