MCPcopy Create free account
hub / github.com/anomalyco/opencode / addServerDistroStatus

Function addServerDistroStatus

packages/app/src/wsl/settings-model.ts:144–179  ·  view source on GitHub ↗
(input: {
  state: WslServersState | undefined
  name: string
  probingAddable: boolean
})

Source from the content-addressed store, hash-verified

142}
143
144function addServerDistroStatus(input: {
145 state: WslServersState | undefined
146 name: string
147 probingAddable: boolean
148}): DistroStatus | undefined {
149 const installed = input.state?.installed.find((item) => item.name === input.name)
150 if (installed?.version === 1) return { label: { key: "wsl.onboarding.distroStatus.unsupported" }, tone: "muted" }
151 const job = input.state?.job
152 const probe = input.state?.distroProbes[input.name]
153 if (!probe) {
154 if (input.probingAddable || (job?.kind === "probe-addable" && job.distros.includes(input.name))) {
155 return checkingStatus()
156 }
157 return
158 }
159 if (!probe.canExecute) {
160 if (!installed) {
161 return { label: { key: "wsl.onboarding.distroNotInstalled", params: { distro: input.name } }, tone: "warning" }
162 }
163 return { label: { key: "wsl.onboarding.openDistroOnce", params: { distro: input.name } }, tone: "warning" }
164 }
165 if (!probe.hasBash || !probe.hasCurl) {
166 return { label: { key: "wsl.onboarding.distroStatus.missingTools" }, tone: "warning" }
167 }
168 const check = input.state?.opencodeChecks[input.name]
169 if (!check) {
170 if (input.probingAddable || (job?.kind === "probe-addable" && job.distros.includes(input.name))) {
171 return checkingStatus()
172 }
173 return
174 }
175 if (check.matchesDesktop === false) return { label: { key: "wsl.onboarding.updateOpencode" }, tone: "warning" }
176 if (!check.resolvedPath) return { label: { key: "wsl.onboarding.distroStatus.opencodeMissing" }, tone: "warning" }
177 if (check.error) return { label: { key: "wsl.onboarding.installOpencode" }, tone: "warning" }
178 return { label: { key: "wsl.onboarding.distroStatus.ready" }, tone: "success" }
179}
180
181function checkingStatus(): DistroStatus {
182 return { label: { key: "wsl.onboarding.distroStatus.checking" }, tone: "muted" }

Callers 1

addServerViewModelFunction · 0.85

Calls 2

checkingStatusFunction · 0.85
findMethod · 0.65

Tested by

no test coverage detected