This commit is contained in:
Fabian Kukuck 2025-12-23 15:42:22 +08:00 committed by GitHub
commit 7d06e6b09e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 45 additions and 1 deletions

View file

@ -125,6 +125,11 @@ export function Prompt(props: PromptProps) {
const wide = createMemo(() => dimensions().width > 120)
const { theme, syntax } = useTheme()
const cursorStyle = createMemo(() => ({
style: "block" as const,
blinking: sync.data.config.tui?.cursor_blinking ?? true,
}))
function promptModelWarning() {
toast.show({
variant: "warning",
@ -323,6 +328,7 @@ export function Prompt(props: PromptProps) {
createEffect(() => {
if (props.disabled) input.cursorColor = theme.backgroundElement
if (!props.disabled) input.cursorColor = theme.text
input.cursorStyle = cursorStyle()
})
const [store, setStore] = createStore<{
@ -877,11 +883,13 @@ export function Prompt(props: PromptProps) {
input = r
setTimeout(() => {
input.cursorColor = theme.text
input.cursorStyle = cursorStyle()
}, 0)
}}
onMouseDown={(r: MouseEvent) => r.target?.focus()}
focusedBackgroundColor={theme.backgroundElement}
cursorColor={theme.text}
cursorStyle={cursorStyle()}
syntaxStyle={syntax()}
/>
<Show when={tall()}>

View file

@ -1,7 +1,8 @@
import { TextareaRenderable, TextAttributes } from "@opentui/core"
import { useTheme } from "../context/theme"
import { useDialog, type DialogContext } from "./dialog"
import { onMount, type JSX } from "solid-js"
import { useSync } from "../context/sync"
import { createMemo, onMount, type JSX } from "solid-js"
import { useKeyboard } from "@opentui/solid"
export type DialogPromptProps = {
@ -16,8 +17,14 @@ export type DialogPromptProps = {
export function DialogPrompt(props: DialogPromptProps) {
const dialog = useDialog()
const { theme } = useTheme()
const sync = useSync()
let textarea: TextareaRenderable
const cursorStyle = createMemo(() => ({
style: "block" as const,
blinking: sync.data.config.tui?.cursor_blinking ?? true,
}))
useKeyboard((evt) => {
if (evt.name === "return") {
props.onConfirm?.(textarea.plainText)
@ -54,6 +61,7 @@ export function DialogPrompt(props: DialogPromptProps) {
textColor={theme.text}
focusedTextColor={theme.text}
cursorColor={theme.text}
cursorStyle={cursorStyle()}
/>
</box>
<box paddingBottom={1} gap={1} flexDirection="row">

View file

@ -584,6 +584,7 @@ export namespace Config {
.enum(["auto", "stacked"])
.optional()
.describe("Control diff rendering style: 'auto' adapts to terminal width, 'stacked' always shows single column"),
cursor_blinking: z.boolean().optional().describe("Enable or disable cursor blinking in the prompt input box"),
})
export const Layout = z.enum(["auto", "stretch"]).meta({

View file

@ -533,3 +533,26 @@ test("deduplicates duplicate plugins from global and local configs", async () =>
},
})
})
test("handles TUI cursor blinking configuration", async () => {
await using tmp = await tmpdir({
init: async (dir) => {
await Bun.write(
path.join(dir, "opencode.json"),
JSON.stringify({
$schema: "https://opencode.ai/config.json",
tui: {
cursor_blinking: false,
},
}),
)
},
})
await Instance.provide({
directory: tmp.path,
fn: async () => {
const config = await Config.get()
expect(config.tui?.cursor_blinking).toBe(false)
},
})
})

View file

@ -1394,6 +1394,10 @@ export type Config = {
* Control diff rendering style: 'auto' adapts to terminal width, 'stacked' always shows single column
*/
diff_style?: "auto" | "stacked"
/**
* Enable or disable cursor blinking in the prompt input box
*/
cursor_blinking?: boolean
}
/**
* Command configuration, see https://opencode.ai/docs/commands