diff --git a/packages/app/src/components/prompt-input.tsx b/packages/app/src/components/prompt-input.tsx index 84f16d67eed..02beeef4770 100644 --- a/packages/app/src/components/prompt-input.tsx +++ b/packages/app/src/components/prompt-input.tsx @@ -58,6 +58,7 @@ import { createOpencodeClient, type Message, type Part } from "@opencode-ai/sdk/ import { Binary } from "@opencode-ai/util/binary" import { showToast } from "@opencode-ai/ui/toast" import { base64Encode } from "@opencode-ai/util/encode" +import { SINISTER_PLACEHOLDERS as PLACEHOLDERS } from "@opencode-ai/ui/constants/placeholders" const ACCEPTED_IMAGE_TYPES = ["image/png", "image/jpeg", "image/gif", "image/webp"] const ACCEPTED_FILE_TYPES = [...ACCEPTED_IMAGE_TYPES, "application/pdf"] @@ -77,34 +78,6 @@ interface PromptInputProps { onSubmit?: () => void } -const EXAMPLES = [ - "prompt.example.1", - "prompt.example.2", - "prompt.example.3", - "prompt.example.4", - "prompt.example.5", - "prompt.example.6", - "prompt.example.7", - "prompt.example.8", - "prompt.example.9", - "prompt.example.10", - "prompt.example.11", - "prompt.example.12", - "prompt.example.13", - "prompt.example.14", - "prompt.example.15", - "prompt.example.16", - "prompt.example.17", - "prompt.example.18", - "prompt.example.19", - "prompt.example.20", - "prompt.example.21", - "prompt.example.22", - "prompt.example.23", - "prompt.example.24", - "prompt.example.25", -] as const - interface SlashCommand { id: string trigger: string @@ -248,7 +221,7 @@ export const PromptInput: Component = (props) => { popover: null, historyIndex: -1, savedPrompt: null, - placeholder: Math.floor(Math.random() * EXAMPLES.length), + placeholder: Math.floor(Math.random() * PLACEHOLDERS.length), dragging: false, mode: "normal", applyingHistory: false, @@ -321,7 +294,7 @@ export const PromptInput: Component = (props) => { params.id if (params.id) return const interval = setInterval(() => { - setStore("placeholder", (prev) => (prev + 1) % EXAMPLES.length) + setStore("placeholder", (prev) => (prev + 1) % PLACEHOLDERS.length) }, 6500) onCleanup(() => clearInterval(interval)) }) @@ -1862,11 +1835,7 @@ export const PromptInput: Component = (props) => { aria-label={ store.mode === "shell" ? language.t("prompt.placeholder.shell") - : commentCount() > 1 - ? language.t("prompt.placeholder.summarizeComments") - : commentCount() === 1 - ? language.t("prompt.placeholder.summarizeComment") - : language.t("prompt.placeholder.normal", { example: language.t(EXAMPLES[store.placeholder]) }) + : PLACEHOLDERS[store.placeholder] } contenteditable="true" onInput={handleInput} @@ -1886,11 +1855,7 @@ export const PromptInput: Component = (props) => {
{store.mode === "shell" ? language.t("prompt.placeholder.shell") - : commentCount() > 1 - ? language.t("prompt.placeholder.summarizeComments") - : commentCount() === 1 - ? language.t("prompt.placeholder.summarizeComment") - : language.t("prompt.placeholder.normal", { example: language.t(EXAMPLES[store.placeholder]) })} + : `${PLACEHOLDERS[store.placeholder]}`}
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 e19c8b70982..008b2358224 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx @@ -52,7 +52,7 @@ export type PromptRef = { submit(): void } -const PLACEHOLDERS = ["Fix a TODO in the codebase", "What is the tech stack of this project?", "Fix broken tests"] +import { SINISTER_PLACEHOLDERS as PLACEHOLDERS } from "@opencode-ai/ui/constants/placeholders" export function Prompt(props: PromptProps) { let input: TextareaRenderable @@ -106,6 +106,18 @@ export function Prompt(props: PromptProps) { if (!props.disabled) input.cursorColor = theme.text }) + // Resize textarea when placeholder changes (e.g., when switching sessions or when placeholder index changes) + createEffect(() => { + const placeholderText = props.sessionID ? undefined : PLACEHOLDERS[store.placeholder] + // Track both the placeholder text and sessionID changes + if (input) { + setTimeout(() => { + input.getLayoutNode().markDirty() + renderer.requestRender() + }, 0) + } + }) + const lastUserMessage = createMemo(() => { if (!props.sessionID) return undefined const messages = sync.data.message[props.sessionID] @@ -771,7 +783,11 @@ export function Prompt(props: PromptProps) { flexGrow={1} >