MCPcopy
hub / github.com/anomalyco/opencode / check

Function check

packages/desktop/src/main/updater-controller.ts:38–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36 }
37
38 const check = () => {
39 if (!input.enabled) return Promise.resolve(state)
40 if (state.status === "ready") return Promise.resolve(state)
41 if (pending) return pending
42
43 pending = (async () => {
44 transition({ status: "checking" })
45 const result = await input.backend.checkForUpdates()
46 const version = result?.updateInfo?.version
47 if (!result?.isUpdateAvailable || !version || version === input.currentVersion) {
48 await input.persistence.clear()
49 return transition({ status: "up-to-date" })
50 }
51
52 transition({ status: "downloading", version })
53 await input.backend.downloadUpdate()
54 await input.persistence.set({ version })
55 return transition({ status: "ready", version })
56 })()
57 .catch((error) =>
58 transition({ status: "error", message: error instanceof Error ? error.message : String(error) }),
59 )
60 .finally(() => {
61 pending = undefined
62 })
63 return pending
64 }
65
66 return {
67 getState: () => state,

Callers 3

startFunction · 0.70
pollWslHealthFunction · 0.50
waitForFunction · 0.50

Calls 3

transitionFunction · 0.70
clearMethod · 0.45
setMethod · 0.45

Tested by 1

waitForFunction · 0.40