fix(ui): keep the selected model when switching agent modes (#2690)

fix(ui): keep the selected model when switching agent modes
This commit is contained in:
Bohdan Triapitsyn
2026-08-28 23:41:16 +03:00
committed by GitHub
3 changed files with 36 additions and 37 deletions
@@ -698,6 +698,30 @@ describe('useConfigStore provider persistence', () => {
expect(state.currentModelId).toBe('model-a');
});
test('[issue-2531] setAgent keeps the manual model when switching to an agent without an override', () => {
const sessionId = 'ses_2531_mode_switch';
useSessionUIStore.setState({ currentSessionId: sessionId });
useConfigStore.setState({
activeDirectoryKey: DIRECTORY,
providers: [provider('deepseek', 'deepseek-v4-pro'), provider('kimi', 'kimi-k3')],
agents: [testAgent('build'), testAgent('plan')],
settingsDefaultModel: 'deepseek/deepseek-v4-pro',
currentProviderId: 'kimi',
currentModelId: 'kimi-k3',
currentAgentName: 'build',
selectionSource: 'manual',
currentVariant: undefined,
directoryScoped: {},
});
useConfigStore.getState().setAgent('plan');
const state = useConfigStore.getState();
expect(state.currentAgentName).toBe('plan');
expect(state.currentProviderId).toBe('kimi');
expect(state.currentModelId).toBe('kimi-k3');
});
test('loadAgents does not fetch OpenCode config directly', async () => {
useConfigStore.setState({
activeDirectoryKey: DIRECTORY,