MCPcopy Create free account
hub / github.com/block/buzz / handleModelChange

Function handleModelChange

desktop/src/features/agents/ui/ModelPicker.tsx:140–170  ·  view source on GitHub ↗
(modelId: string)

Source from the content-addressed store, hash-verified

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">

Callers

nothing calls this directly

Calls 2

updateManagedAgentFunction · 0.90
errorMethod · 0.80

Tested by

no test coverage detected