Skip to content

Commit 41fb8f1

Browse files
committed
fix(tui): avoid custom spinner element crash
1 parent bbdc1e6 commit 41fb8f1

4 files changed

Lines changed: 6 additions & 45 deletions

File tree

‎packages/opencode/src/cli/cmd/run/footer.subagent.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/** @jsxImportSource @opentui/solid */
22
import type { ScrollBoxRenderable } from "@opentui/core"
33
import { useKeyboard } from "@opentui/solid"
4-
import "opentui-spinner/solid"
54
import { Show, createMemo, indexArray } from "solid-js"
6-
import { SPINNER_FRAMES } from "@opencode-ai/tui/component/spinner"
75
import { RunEntryContent, separatorRows } from "./scrollback.writer"
86
import type { FooterSubagentDetail, FooterSubagentTab, RunDiffStyle } from "./types"
97
import type { RunFooterTheme, RunTheme } from "./theme"
@@ -126,7 +124,7 @@ export function RunFooterSubagentBody(props: {
126124
<box width="100%" flexDirection="row" gap={1} paddingBottom={1} flexShrink={0}>
127125
{current().status === "running" ? (
128126
<box flexShrink={0}>
129-
<spinner frames={SPINNER_FRAMES} interval={80} color={statusColor(footer(), current().status)} />
127+
<text fg={statusColor(footer(), current().status)}>...</text>
130128
</box>
131129
) : (
132130
<text fg={statusColor(footer(), current().status)} wrapMode="none" truncate flexShrink={0}>

‎packages/opencode/src/cli/cmd/run/footer.view.tsx‎

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
/** @jsxImportSource @opentui/solid */
1111
import { useTerminalDimensions } from "@opentui/solid"
1212
import { For, Match, Show, Switch, createEffect, createMemo, createSignal, onCleanup } from "solid-js"
13-
import "opentui-spinner/solid"
14-
import { createColors, createFrames } from "@opencode-ai/tui/ui/spinner"
1513
import {
1614
RUN_SUBAGENT_PANEL_ROWS,
1715
RunCommandMenuBody,
@@ -252,22 +250,6 @@ export function RunFooterView(props: RunFooterViewProps) {
252250
const runTheme = createMemo(() => props.theme())
253251
const theme = createMemo(() => runTheme().footer)
254252
const block = createMemo(() => runTheme().block)
255-
const spin = createMemo(() => {
256-
return {
257-
frames: createFrames({
258-
color: theme().highlight,
259-
style: "blocks",
260-
inactiveFactor: 0.6,
261-
minAlpha: 0.3,
262-
}),
263-
color: createColors({
264-
color: theme().highlight,
265-
style: "blocks",
266-
inactiveFactor: 0.6,
267-
minAlpha: 0.3,
268-
}),
269-
}
270-
})
271253
const permission = createMemo<Extract<FooterView, { type: "permission" }> | undefined>(() => {
272254
const view = active()
273255
return view.type === "permission" ? view : undefined
@@ -843,7 +825,7 @@ export function RunFooterView(props: RunFooterViewProps) {
843825
>
844826
<Show when={busy() && !exiting()}>
845827
<box flexShrink={0}>
846-
<spinner color={spin().color} frames={spin().frames} interval={40} />
828+
<text fg={theme().highlight}>...</text>
847829
</box>
848830
</Show>
849831

‎packages/tui/src/component/prompt/index.tsx‎

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
} from "@opentui/core"
1111
import type { CommandContext } from "@opentui/keymap"
1212
import { createEffect, createMemo, onMount, createSignal, onCleanup, on, Show, Switch, Match } from "solid-js"
13-
import "opentui-spinner/solid"
1413
import path from "path"
1514
import { fileURLToPath } from "url"
1615
import { useLocal } from "../../context/local"
@@ -42,7 +41,6 @@ import type { AssistantMessage, FilePart, UserMessage, Goal } from "@opencode-ai
4241
import { Locale } from "../../util/locale"
4342
import { errorMessage } from "../../util/error"
4443
import { formatDuration } from "../../util/format"
45-
import { createColors, createFrames } from "../../ui/spinner"
4644
import { useDialog } from "../../ui/dialog"
4745
import { DialogProvider as DialogProviderConnect } from "../dialog-provider"
4846
import { DialogAlert } from "../../ui/dialog-alert"
@@ -1395,28 +1393,12 @@ export function Prompt(props: PromptProps) {
13951393
return `Ask anything... "${list()[store.placeholder % list().length]}"`
13961394
})
13971395

1398-
const spinnerDef = createMemo(() => {
1396+
const spinnerColor = createMemo(() => {
13991397
const agent =
14001398
status().type !== "idle"
14011399
? (local.agent.list().find((a) => a.name === lastUserMessage()?.agent) ?? local.agent.current())
14021400
: local.agent.current()
1403-
const color = agent ? local.agent.color(agent.name) : theme.border
1404-
return {
1405-
frames: createFrames({
1406-
color,
1407-
style: "blocks",
1408-
inactiveFactor: 0.6,
1409-
// enableFading: false,
1410-
minAlpha: 0.3,
1411-
}),
1412-
color: createColors({
1413-
color,
1414-
style: "blocks",
1415-
inactiveFactor: 0.6,
1416-
// enableFading: false,
1417-
minAlpha: 0.3,
1418-
}),
1419-
}
1401+
return agent ? local.agent.color(agent.name) : theme.border
14201402
})
14211403
const maxHeight = createMemo(() => tuiConfig.prompt?.max_height ?? Math.max(6, Math.floor(dimensions().height / 3)))
14221404
const moveLabelWidth = createMemo(() => Math.max(12, Math.min(44, dimensions().width - 48)))
@@ -1593,7 +1575,7 @@ export function Prompt(props: PromptProps) {
15931575
<box flexShrink={0} flexDirection="row" gap={1}>
15941576
<box marginLeft={1}>
15951577
<Show when={kv.get("animations_enabled", true)} fallback={<text fg={theme.textMuted}>[⋯]</text>}>
1596-
<spinner color={spinnerDef().color} frames={spinnerDef().frames} interval={40} />
1578+
<text fg={spinnerColor()}>...</text>
15971579
</Show>
15981580
</box>
15991581
<box flexDirection="row" gap={1} flexShrink={0}>

‎packages/tui/src/component/spinner.tsx‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { useTheme } from "../context/theme"
33
import { useKV } from "../context/kv"
44
import type { JSX } from "@opentui/solid"
55
import type { RGBA } from "@opentui/core"
6-
import "opentui-spinner/solid"
76

87
export const SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]
98

@@ -14,7 +13,7 @@ export function Spinner(props: { children?: JSX.Element; color?: RGBA }) {
1413
return (
1514
<Show when={kv.get("animations_enabled", true)} fallback={<text fg={color()}>⋯ {props.children}</text>}>
1615
<box flexDirection="row" gap={1}>
17-
<spinner frames={SPINNER_FRAMES} interval={80} color={color()} />
16+
<text fg={color()}>...</text>
1817
<Show when={props.children}>
1918
<text fg={color()}>{props.children}</text>
2019
</Show>

0 commit comments

Comments
 (0)