fix(ui): keep manual model override after delegated subtask completes

Synthetic subagent-completion nudges were treated as the latest user model
choice and rehydrated the agent default, while setAgent preferred the agent
pin over the session override. Skip synthetic prompts for restore, preserve
manual selection-store overrides, and prefer session agent models in setAgent.

Closes openchamber/openchamber#2404

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-08-04 12:46:48 +00:00
co-authored by Serhii Dziupin
parent f47110c66f
commit 65a1eec782
7 changed files with 579 additions and 68 deletions
+18 -12
View File
@@ -2503,20 +2503,13 @@ export const useConfigStore = create<ConfigStore>()(
return undefined;
};
// Prefer the selected agent's configured model when switching agents.
const agent = agents.find((candidate) => candidate.name === agentName);
const agentModelSelection = agent?.model;
if (agentModelSelection?.providerID && agentModelSelection?.modelID) {
const { providerID, modelID } = agentModelSelection;
const agentProvider = providers.find((provider) => provider.id === providerID);
const agentModel = agentProvider?.models.find((model) => model.id === modelID);
if (agentModel) {
applyResolvedModelSelection(providerID, modelID, resolveVariantForModel(providerID, modelID, agent?.variant));
return;
}
}
// Prefer a session-level manual override for this agent over the
// agent's configured default. Re-applying setAgent after subtask
// completion / rematerialization must not clobber the override
// (issue #2404). Explicit agent-picker switches still force the
// agent default via ModelControls' shouldPreferAgentModel path.
if (currentSessionId) {
const existingAgentModel = useSelectionStore.getState().getAgentModelForSession(currentSessionId, agentName);
if (existingAgentModel && hasProviderModel(providers, existingAgentModel.providerId, existingAgentModel.modelId)) {
@@ -2532,6 +2525,19 @@ export const useConfigStore = create<ConfigStore>()(
}
}
// No session override — use the agent's configured/pinned model.
const agentModelSelection = agent?.model;
if (agentModelSelection?.providerID && agentModelSelection?.modelID) {
const { providerID, modelID } = agentModelSelection;
const agentProvider = providers.find((provider) => provider.id === providerID);
const agentModel = agentProvider?.models.find((model) => model.id === modelID);
if (agentModel) {
applyResolvedModelSelection(providerID, modelID, resolveVariantForModel(providerID, modelID, agent?.variant));
return;
}
}
// If the agent has no preferred model, use settings default.
if (settingsDefaultModel) {
const parsed = parseModelString(settingsDefaultModel);