From 946356161f2676362f6816d0ac57eed897b0ad2a Mon Sep 17 00:00:00 2001 From: Stefan Ernst <24554551+stefan-ernst@users.noreply.github.com> Date: Mon, 2 Nov 2026 15:14:03 +0100 Subject: [PATCH] fix(agents): reconcile the saved model from the submitted connection (WI-1804) saveModel sent the selected connection but its completion handler reread the mutable modelConnectionId. Selecting a different connection while the request was in flight recorded the newer one as saved, so the UI showed it active and disabled Save while the server still used the submitted model. Capture the submitted connection and reconcile the saved state, summary, and indicator from it; a newer selection stays unsaved and keeps Save enabled. Add stable test ids for the model summary and the saved indicator. --- .../lib/features/agents/AgentProfile.svelte | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/frontend/src/lib/features/agents/AgentProfile.svelte b/frontend/src/lib/features/agents/AgentProfile.svelte index c7507dba8..9e36507cb 100644 --- a/frontend/src/lib/features/agents/AgentProfile.svelte +++ b/frontend/src/lib/features/agents/AgentProfile.svelte @@ -451,6 +451,10 @@ async function saveModel() { if (!canAdmin || !adminProfile || !modelChanged || savingModel) return; + // Capture the submitted connection. A selection made while the request is + // in flight must not be recorded as saved when it completes; it stays + // unsaved and modelChanged keeps the Save button enabled. + const submittedConnectionId = Number(modelConnectionId); savingModel = true; modelSaved = false; actionError = ''; @@ -458,22 +462,22 @@ await agentBindings.updateAgentConfig(workspaceId, agentId, { instructions: adminProfile.instructions || '', skill_ids: adminProfile.skill_ids || [], - llm_connection_id: Number(modelConnectionId), + llm_connection_id: submittedConnectionId, }); const nextVersion = markNewDraftVersion(); const connection = llmConnections.find( - (candidate) => Number(candidate.id) === Number(modelConnectionId) + (candidate) => Number(candidate.id) === submittedConnectionId ); adminProfile = { ...adminProfile, - llm_connection_id: Number(modelConnectionId), + llm_connection_id: submittedConnectionId, profile_version: nextVersion, }; agent = { ...agent, model_summary: connection?.model || agent.model_summary, }; - modelSaved = true; + modelSaved = Number(modelConnectionId) === submittedConnectionId; await checkReadiness(); } catch (err) { actionError = err.message || 'The model could not be changed.'; @@ -772,7 +776,7 @@

{label(agent.runtime)} runtime

-

+

{agent.model_summary || 'Model unavailable'}

@@ -1123,11 +1127,12 @@ {#if modelSaved} - +
+ +
{/if} {#if agent.profile_type === 'standard'}