fix: cherry-pick commits for release (#12549)

This commit is contained in:
Abhi
2025-11-04 14:13:51 -05:00
committed by GitHub
parent a2cb116980
commit 51a415f2b9
8 changed files with 112 additions and 6 deletions

View File

@@ -1137,7 +1137,7 @@ const SETTINGS_SCHEMA = {
label: 'Thinking Budget',
category: 'Experimental',
requiresRestart: true,
default: -1,
default: 8192,
description:
'The thinking budget for the Codebase Investigator agent.',
showInDialog: false,

View File

@@ -47,7 +47,7 @@ import {
UIActionsContext,
type UIActions,
} from './contexts/UIActionsContext.js';
import { useContext } from 'react';
import { useContext, act } from 'react';
// Mock useStdout to capture terminal title writes
let mockStdout: { write: ReturnType<typeof vi.fn> };
@@ -1395,5 +1395,41 @@ describe('AppContainer State Management', () => {
expect.any(Number),
);
});
it('updates currentModel when ModelChanged event is received', async () => {
// Arrange: Mock initial model
vi.spyOn(mockConfig, 'getModel').mockReturnValue('initial-model');
const { unmount } = render(
<AppContainer
config={mockConfig}
settings={mockSettings}
version="1.0.0"
initializationResult={mockInitResult}
/>,
);
// Verify initial model
await act(async () => {
await vi.waitFor(() => {
expect(capturedUIState?.currentModel).toBe('initial-model');
});
});
// Get the registered handler for ModelChanged
const handler = mockCoreEvents.on.mock.calls.find(
(call: unknown[]) => call[0] === CoreEvent.ModelChanged,
)?.[1];
expect(handler).toBeDefined();
// Act: Simulate ModelChanged event
act(() => {
handler({ model: 'new-model' });
});
// Assert: Verify model is updated
expect(capturedUIState.currentModel).toBe('new-model');
unmount();
});
});
});

View File

@@ -47,6 +47,7 @@ import {
debugLogger,
coreEvents,
CoreEvent,
type ModelChangedPayload,
} from '@google/gemini-cli-core';
import { validateAuthMethod } from '../config/auth.js';
import { loadHierarchicalGeminiMemory } from '../config/config.js';
@@ -253,16 +254,22 @@ export const AppContainer = (props: AppContainerProps) => {
[historyManager.addItem],
);
// Subscribe to fallback mode changes from core
// Subscribe to fallback mode and model changes from core
useEffect(() => {
const handleFallbackModeChanged = () => {
const effectiveModel = getEffectiveModel();
setCurrentModel(effectiveModel);
};
const handleModelChanged = (payload: ModelChangedPayload) => {
setCurrentModel(payload.model);
};
coreEvents.on(CoreEvent.FallbackModeChanged, handleFallbackModeChanged);
coreEvents.on(CoreEvent.ModelChanged, handleModelChanged);
return () => {
coreEvents.off(CoreEvent.FallbackModeChanged, handleFallbackModeChanged);
coreEvents.off(CoreEvent.ModelChanged, handleModelChanged);
};
}, [getEffectiveModel]);