MCPcopy Index your code
hub / github.com/anomalyco/opencode / toggleFavorite

Function toggleFavorite

packages/tui/src/context/local.tsx:339–361  ·  view source on GitHub ↗
(model: { providerID: string; modelID: string })

Source from the content-addressed store, hash-verified

337 })
338 },
339 toggleFavorite(model: { providerID: string; modelID: string }) {
340 batch(() => {
341 if (!isModelValid(model)) {
342 toast.show({
343 message: `Model ${model.providerID}/${model.modelID} is not valid`,
344 variant: "warning",
345 duration: 3000,
346 })
347 return
348 }
349 const exists = modelStore.favorite.some(
350 (x) => x.providerID === model.providerID && x.modelID === model.modelID,
351 )
352 const next = exists
353 ? modelStore.favorite.filter((x) => x.providerID !== model.providerID || x.modelID !== model.modelID)
354 : [model, ...modelStore.favorite]
355 setModelStore(
356 "favorite",
357 next.map((x) => ({ providerID: x.providerID, modelID: x.modelID })),
358 )
359 save()
360 })
361 },
362 variant: {
363 selected() {
364 const m = currentModel()

Callers

nothing calls this directly

Calls 3

batchFunction · 0.85
isModelValidFunction · 0.85
saveFunction · 0.70

Tested by

no test coverage detected