refactor(client): simplify local service lifecycle
This commit is contained in:
parent
4f1298063b
commit
75bc611ef1
51 changed files with 635 additions and 534 deletions
|
|
@ -1,11 +1,8 @@
|
|||
import type { Service } from "@opencode-ai/client/effect"
|
||||
import { Show } from "solid-js"
|
||||
import { useTheme } from "../context/theme"
|
||||
import { Spinner } from "./spinner"
|
||||
|
||||
export function Reconnecting(props: { status?: Service.Status }) {
|
||||
export function Reconnecting() {
|
||||
const theme = useTheme().theme
|
||||
const copy = () => reconnectingCopy(props.status)
|
||||
|
||||
return (
|
||||
<box
|
||||
|
|
@ -20,46 +17,8 @@ export function Reconnecting(props: { status?: Service.Status }) {
|
|||
justifyContent="center"
|
||||
>
|
||||
<box width={62} maxWidth="90%" flexDirection="column" alignItems="center" gap={1}>
|
||||
<Show when={!copy().loading} fallback={<Spinner color={theme.textMuted}>{copy().message}</Spinner>}>
|
||||
<text fg={theme.error}>{copy().message}</text>
|
||||
<Show when={copy().detail}>
|
||||
{(detail) => (
|
||||
<text fg={theme.textMuted} wrapMode="word">
|
||||
{detail()}
|
||||
</text>
|
||||
)}
|
||||
</Show>
|
||||
<Show when={copy().action}>
|
||||
{(action) => (
|
||||
<text fg={theme.text} wrapMode="word">
|
||||
{action()}
|
||||
</text>
|
||||
)}
|
||||
</Show>
|
||||
</Show>
|
||||
<Spinner color={theme.textMuted}>Waiting for background service...</Spinner>
|
||||
</box>
|
||||
</box>
|
||||
)
|
||||
}
|
||||
|
||||
export function reconnectingCopy(status?: Service.Status) {
|
||||
if (status?.type === "starting")
|
||||
return {
|
||||
loading: true,
|
||||
message: status.version ? `Starting OpenCode ${status.version}...` : "Starting background service...",
|
||||
}
|
||||
if (status?.type === "stopping")
|
||||
return {
|
||||
loading: true,
|
||||
message: status.targetVersion ? `Updating to ${status.targetVersion}...` : "Restarting background service...",
|
||||
}
|
||||
if (status?.type === "failed")
|
||||
return { loading: false, message: "Background service failed", detail: status.message, action: status.action }
|
||||
if (status?.type === "unresponsive")
|
||||
return {
|
||||
loading: false,
|
||||
message: "Background service is not responding",
|
||||
action: "Run `opencode service restart` to recover it.",
|
||||
}
|
||||
return { loading: true, message: "Waiting for background service..." }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue