From 1d3b1817cec2639ec896743c65fb513c73499782 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Thu, 5 Feb 2026 19:15:32 -0500 Subject: [PATCH] feat(prompt): show mode-specific input placeholders --- .../cli/cmd/tui/component/prompt/index.tsx | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx index 8576dd5763ab..cefef208de4a 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx @@ -1,5 +1,5 @@ import { BoxRenderable, TextareaRenderable, MouseEvent, PasteEvent, t, dim, fg } from "@opentui/core" -import { createEffect, createMemo, type JSX, onMount, createSignal, onCleanup, Show, Switch, Match } from "solid-js" +import { createEffect, createMemo, type JSX, onMount, createSignal, onCleanup, on, Show, Switch, Match } from "solid-js" import "opentui-spinner/solid" import { useLocal } from "@tui/context/local" import { useTheme } from "@tui/context/theme" @@ -54,6 +54,7 @@ export type PromptRef = { } const PLACEHOLDERS = ["Fix a TODO in the codebase", "What is the tech stack of this project?", "Fix broken tests"] +const SHELL_PLACEHOLDERS = ["ls -la", "git status", "pwd"] export function Prompt(props: PromptProps) { let input: TextareaRenderable @@ -134,6 +135,16 @@ export function Prompt(props: PromptProps) { interrupt: 0, }) + createEffect( + on( + () => props.sessionID, + () => { + setStore("placeholder", Math.floor(Math.random() * PLACEHOLDERS.length)) + }, + { defer: true }, + ), + ) + // Initialize agent/model/variant from last user message when session changes let syncedSessionID: string | undefined createEffect(() => { @@ -736,6 +747,15 @@ export function Prompt(props: PromptProps) { return !!current }) + const placeholderText = createMemo(() => { + if (props.sessionID) return undefined + if (store.mode === "shell") { + const example = SHELL_PLACEHOLDERS[store.placeholder % SHELL_PLACEHOLDERS.length] + return `Run a command... "${example}"` + } + return `Ask anything... "${PLACEHOLDERS[store.placeholder % PLACEHOLDERS.length]}"` + }) + const spinnerDef = createMemo(() => { const color = local.agent.color(local.agent.current().name) return { @@ -797,7 +817,7 @@ export function Prompt(props: PromptProps) { flexGrow={1} >