Skip to content

Commit 82ebf66

Browse files
committed
non-corpo loading spinner
1 parent 883ed4d commit 82ebf66

File tree

5 files changed

+434
-92
lines changed

5 files changed

+434
-92
lines changed

bun.lock

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/opencode/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"jsonc-parser": "3.3.1",
8383
"minimatch": "10.0.3",
8484
"open": "10.1.2",
85+
"opentui-spinner": "0.0.5",
8586
"partial-json": "0.1.7",
8687
"remeda": "catalog:",
8788
"solid-js": "catalog:",

packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { BoxRenderable, TextareaRenderable, MouseEvent, PasteEvent, t, dim, fg, type KeyBinding } from "@opentui/core"
22
import { createEffect, createMemo, type JSX, onMount, createSignal, onCleanup, Show, Switch, Match } from "solid-js"
3+
import "opentui-spinner/solid";
34
import { useLocal } from "@tui/context/local"
45
import { useTheme } from "@tui/context/theme"
56
import { EmptyBorder } from "@tui/component/border"
@@ -20,7 +21,7 @@ import type { FilePart } from "@opencode-ai/sdk"
2021
import { TuiEvent } from "../../event"
2122
import { iife } from "@/util/iife"
2223
import { Locale } from "@/util/locale"
23-
import { Shimmer } from "../../ui/shimmer"
24+
import { createColors, createFrames } from "../../ui/spinner.ts"
2425

2526
export type PromptProps = {
2627
sessionID?: string
@@ -545,6 +546,22 @@ export function Prompt(props: PromptProps) {
545546
return local.agent.color(local.agent.current().name)
546547
})
547548

549+
const spinnerDef = createMemo(() => {
550+
const color = local.agent.color(local.agent.current().name)
551+
return {
552+
frames: createFrames({
553+
color,
554+
style: "blocks",
555+
inactiveFactor: 0.25,
556+
}),
557+
color: createColors({
558+
color,
559+
style: "blocks",
560+
inactiveFactor: 0.25,
561+
}),
562+
}
563+
})
564+
548565
createEffect(() => {
549566
renderer.setCursorColor(highlight())
550567
})
@@ -813,7 +830,11 @@ export function Prompt(props: PromptProps) {
813830
justifyContent={status().type === "retry" ? "space-between" : "flex-start"}
814831
>
815832
<box flexShrink={0} flexDirection="row" gap={1}>
816-
<Loader />
833+
<spinner
834+
color={spinnerDef().color}
835+
frames={spinnerDef().frames}
836+
interval={40}
837+
/>
817838
<box flexDirection="row" gap={1} flexShrink={0}>
818839
{(() => {
819840
const retry = createMemo(() => {
@@ -884,37 +905,3 @@ export function Prompt(props: PromptProps) {
884905
)
885906
}
886907

887-
function Loader() {
888-
const FRAMES = [
889-
"▱▱▱▱▱▱▱",
890-
"▱▱▱▱▱▱▱",
891-
"▱▱▱▱▱▱▱",
892-
"▱▱▱▱▱▱▱",
893-
"▰▱▱▱▱▱▱",
894-
"▰▰▱▱▱▱▱",
895-
"▰▰▰▱▱▱▱",
896-
"▱▰▰▰▱▱▱",
897-
"▱▱▰▰▰▱▱",
898-
"▱▱▱▰▰▰▱",
899-
"▱▱▱▱▰▰▰",
900-
"▱▱▱▱▱▰▰",
901-
"▱▱▱▱▱▱▰",
902-
"▱▱▱▱▱▱▱",
903-
"▱▱▱▱▱▱▱",
904-
"▱▱▱▱▱▱▱",
905-
"▱▱▱▱▱▱▱",
906-
]
907-
const [frame, setFrame] = createSignal(0)
908-
909-
onMount(() => {
910-
const timer = setInterval(() => {
911-
setFrame((frame() + 1) % FRAMES.length)
912-
}, 100)
913-
onCleanup(() => {
914-
clearInterval(timer)
915-
})
916-
})
917-
918-
const { theme } = useTheme()
919-
return <text fg={theme.diffAdded}>{FRAMES[frame()]}</text>
920-
}

packages/opencode/src/cli/cmd/tui/ui/shimmer.tsx

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)