(fix): appcontainer should not poll and footer should use currentModel from ui state (#11923)

This commit is contained in:
Pyush Sinha
2025-10-27 15:33:12 -07:00
committed by GitHub
parent cb0947c501
commit 2dfb813c90
6 changed files with 72 additions and 12 deletions
+8 -10
View File
@@ -261,20 +261,18 @@ export const AppContainer = (props: AppContainerProps) => {
[historyManager.addItem],
);
// Watch for model changes (e.g., from Flash fallback)
// Subscribe to fallback mode changes from core
useEffect(() => {
const checkModelChange = () => {
const handleFallbackModeChanged = () => {
const effectiveModel = getEffectiveModel();
if (effectiveModel !== currentModel) {
setCurrentModel(effectiveModel);
}
setCurrentModel(effectiveModel);
};
checkModelChange();
const interval = setInterval(checkModelChange, 1000); // Check every second
return () => clearInterval(interval);
}, [config, currentModel, getEffectiveModel]);
coreEvents.on(CoreEvent.FallbackModeChanged, handleFallbackModeChanged);
return () => {
coreEvents.off(CoreEvent.FallbackModeChanged, handleFallbackModeChanged);
};
}, [getEffectiveModel]);
const {
consoleMessages,
@@ -256,3 +256,31 @@ describe('<Footer />', () => {
});
});
});
describe('fallback mode display', () => {
it('should display Flash model when in fallback mode, not the configured Pro model', () => {
const { lastFrame } = renderWithProviders(<Footer />, {
width: 120,
uiState: {
sessionStats: mockSessionStats,
currentModel: 'gemini-2.5-flash', // Fallback active, showing Flash
},
});
// Footer should show the effective model (Flash), not the config model (Pro)
expect(lastFrame()).toContain('gemini-2.5-flash');
expect(lastFrame()).not.toContain('gemini-2.5-pro');
});
it('should display Pro model when NOT in fallback mode', () => {
const { lastFrame } = renderWithProviders(<Footer />, {
width: 120,
uiState: {
sessionStats: mockSessionStats,
currentModel: 'gemini-2.5-pro', // Normal mode, showing Pro
},
});
expect(lastFrame()).toContain('gemini-2.5-pro');
});
});
+1 -2
View File
@@ -15,7 +15,6 @@ import { MemoryUsageDisplay } from './MemoryUsageDisplay.js';
import { ContextUsageDisplay } from './ContextUsageDisplay.js';
import { DebugProfiler } from './DebugProfiler.js';
import { isDevelopment } from '../../utils/installationInfo.js';
import { useUIState } from '../contexts/UIStateContext.js';
import { useConfig } from '../contexts/ConfigContext.js';
import { useSettings } from '../contexts/SettingsContext.js';
@@ -41,7 +40,7 @@ export const Footer: React.FC = () => {
isTrustedFolder,
mainAreaWidth,
} = {
model: config.getModel(),
model: uiState.currentModel,
targetDir: config.getTargetDir(),
debugMode: config.getDebugMode(),
branchName: uiState.branchName,