MCPcopy Create free account
hub / github.com/arctic-cli/interface / cycleFavorite

Function cycleFavorite

packages/arctic/src/cli/cmd/tui/context/local.tsx:259–288  ·  view source on GitHub ↗
(direction: 1 | -1)

Source from the content-addressed store, hash-verified

257 setModelStore("model", agent.current().name, { ...val })
258 },
259 cycleFavorite(direction: 1 | -1) {
260 const favorites = modelStore.favorite.filter((item) => isModelValid(item))
261 if (!favorites.length) {
262 toast.show({
263 variant: "info",
264 message: "Add a favorite model to use this shortcut",
265 duration: 3000,
266 })
267 return
268 }
269 const current = currentModel()
270 let index = -1
271 if (current) {
272 index = favorites.findIndex((x) => x.providerID === current.providerID && x.modelID === current.modelID)
273 }
274 if (index === -1) {
275 index = direction === 1 ? 0 : favorites.length - 1
276 } else {
277 index += direction
278 if (index < 0) index = favorites.length - 1
279 if (index >= favorites.length) index = 0
280 }
281 const next = favorites[index]
282 if (!next) return
283 setModelStore("model", agent.current().name, { ...next })
284 const uniq = uniqueBy([next, ...modelStore.recent], (x) => x.providerID + x.modelID)
285 if (uniq.length > 10) uniq.pop()
286 setModelStore("recent", uniq)
287 save()
288 },
289 set(model: { providerID: string; modelID: string }, options?: { recent?: boolean }) {
290 batch(() => {
291 if (!isModelValid(model)) {

Callers

nothing calls this directly

Calls 3

isModelValidFunction · 0.85
saveFunction · 0.70
currentMethod · 0.45

Tested by

no test coverage detected