refactor(tui): extract standalone package (#31193)

This commit is contained in:
Dax 2026-06-07 01:24:27 -04:00 committed by GitHub
commit 106f8e94d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
84 changed files with 1147 additions and 1918 deletions

View file

@ -1,22 +1,23 @@
import { TextAttributes } from "@opentui/core"
import { useKeyboard, useTerminalDimensions } from "@opentui/solid"
import { useKeyboard, useRenderer, useTerminalDimensions } from "@opentui/solid"
import { createSignal } from "solid-js"
import { getScrollAcceleration } from "../util/scroll"
import { useTuiPlatform } from "../platform"
import { useClipboard } from "../context/clipboard"
import { InstallationVersion } from "@opencode-ai/core/installation/version"
import { destroyRenderer } from "../util/renderer"
export function ErrorComponent(props: {
error: Error
reset: () => void
exit: () => Promise<void>
version: string
mode?: "dark" | "light"
}) {
const term = useTerminalDimensions()
const platform = useTuiPlatform()
const renderer = useRenderer()
const clipboard = useClipboard()
useKeyboard((evt) => {
if (evt.ctrl && evt.name === "c") {
void props.exit()
destroyRenderer(renderer)
}
})
const [copied, setCopied] = createSignal(false)
@ -43,10 +44,10 @@ export function ErrorComponent(props: {
)
}
issueURL.searchParams.set("opencode-version", props.version)
issueURL.searchParams.set("opencode-version", InstallationVersion)
const copyIssueURL = () => {
void platform.clipboard?.write?.(issueURL.toString()).then(() => {
void clipboard.write?.(issueURL.toString()).then(() => {
setCopied(true)
})
}
@ -69,7 +70,7 @@ export function ErrorComponent(props: {
<box onMouseUp={props.reset} backgroundColor={colors.primary} padding={1}>
<text fg={colors.bg}>Reset TUI</text>
</box>
<box onMouseUp={() => void props.exit()} backgroundColor={colors.primary} padding={1}>
<box onMouseUp={() => destroyRenderer(renderer)} backgroundColor={colors.primary} padding={1}>
<text fg={colors.bg}>Exit</text>
</box>
</box>