(modelId: string)
| 138 | ); |
| 139 | |
| 140 | const handleModelChange = async (modelId: string) => { |
| 141 | setSaving(true); |
| 142 | setError(null); |
| 143 | try { |
| 144 | if (isLiveSwitch) { |
| 145 | const outcome = await sendLiveSwitch(modelId); |
| 146 | if (outcome === "unsupported") { |
| 147 | toast.error("That model isn't available for this agent."); |
| 148 | return; |
| 149 | } |
| 150 | toast.success("Model switched for this session."); |
| 151 | onModelChanged?.(); |
| 152 | return; |
| 153 | } |
| 154 | |
| 155 | // Non-live path (idle, stopped, or non-persona): persist the default. |
| 156 | await updateManagedAgent({ |
| 157 | pubkey: agent.pubkey, |
| 158 | model: modelId === modelsData?.agentDefaultModel ? null : modelId, |
| 159 | }); |
| 160 | void queryClient.invalidateQueries({ queryKey: managedAgentsQueryKey }); |
| 161 | if (isRunning) { |
| 162 | setNeedsRestart(true); |
| 163 | } |
| 164 | onModelChanged?.(); |
| 165 | } catch (err) { |
| 166 | setError(err instanceof Error ? err.message : String(err)); |
| 167 | } finally { |
| 168 | setSaving(false); |
| 169 | } |
| 170 | }; |
| 171 | |
| 172 | return ( |
| 173 | <span className="inline-flex items-center gap-1.5"> |
nothing calls this directly
no test coverage detected