Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ export function Prompt(props: PromptProps) {
const renderer = useRenderer()
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",
Expand Down Expand Up @@ -271,6 +276,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<{
Expand Down Expand Up @@ -794,11 +800,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()}
/>
<box flexDirection="row" flexShrink={0} paddingTop={1} gap={1}>
Expand Down
10 changes: 9 additions & 1 deletion packages/opencode/src/cli/cmd/tui/ui/dialog-prompt.tsx
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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)
Expand Down Expand Up @@ -52,6 +59,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">
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,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({
Expand Down
23 changes: 23 additions & 0 deletions packages/opencode/test/config/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,3 +501,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)
},
})
})
4 changes: 4 additions & 0 deletions packages/sdk/js/src/v2/gen/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,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
Expand Down
Loading