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
23 changes: 19 additions & 4 deletions packages/app/src/components/prompt-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,23 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
applyingHistory: false,
})

const placeholderText = createMemo(() => {
const currentAgent = local.agent.current()
if (currentAgent?.name === "build" || !currentAgent?.description) {
// TODO: Padding workaround for rendering bug where ghost characters from previous
// placeholder remain visible when switching to shorter text. Browser doesn't properly
// clear cached text layout with truncate/ellipsis CSS. Proper fix would be to force
// element recreation or use a different rendering approach.
return `Ask anything... "${PLACEHOLDERS[store.placeholder]}"`.padEnd(70, " ")
}
return currentAgent.description.padEnd(70, " ")
})

const shouldRotatePlaceholder = createMemo(() => {
const currentAgent = local.agent.current()
return currentAgent?.name === "build" || !currentAgent?.description
})

const MAX_HISTORY = 100
const [history, setHistory] = persisted(
Persist.global("prompt-history", ["prompt-history.v1"]),
Expand Down Expand Up @@ -256,7 +273,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
createEffect(() => {
params.id
editorRef.focus()
if (params.id) return
if (params.id || !shouldRotatePlaceholder()) return
const interval = setInterval(() => {
setStore("placeholder", (prev) => (prev + 1) % PLACEHOLDERS.length)
}, 6500)
Expand Down Expand Up @@ -1541,9 +1558,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
/>
<Show when={!prompt.dirty()}>
<div class="absolute top-0 inset-x-0 px-5 py-3 pr-12 text-14-regular text-text-weak pointer-events-none whitespace-nowrap truncate">
{store.mode === "shell"
? "Enter shell command..."
: `Ask anything... "${PLACEHOLDERS[store.placeholder]}"`}
{store.mode === "shell" ? "Enter shell command..." : placeholderText()}
</div>
</Show>
</div>
Expand Down
14 changes: 13 additions & 1 deletion packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,18 @@ export function Prompt(props: PromptProps) {
},
}

const placeholderText = createMemo(() => {
const currentAgent = local.agent.current()
if (currentAgent.name === "build" || !currentAgent.description) {
// TODO: Padding workaround for rendering bug where ghost characters from previous
// placeholder remain visible when switching to shorter text. Browser/terminal doesn't
// properly clear cached text layout. Proper fix would be to force element recreation
// or find why OpenTUI textarea doesn't invalidate placeholder rendering.
return `Ask anything... "${PLACEHOLDERS[store.placeholder]}"`.padEnd(70, " ")
}
return currentAgent.description.padEnd(70, " ")
})

createEffect(() => {
if (props.visible !== false) input?.focus()
if (props.visible === false) input?.blur()
Expand Down Expand Up @@ -761,7 +773,7 @@ export function Prompt(props: PromptProps) {
flexGrow={1}
>
<textarea
placeholder={props.sessionID ? undefined : `Ask anything... "${PLACEHOLDERS[store.placeholder]}"`}
placeholder={props.sessionID ? undefined : placeholderText()}
textColor={keybind.leader ? theme.textMuted : theme.text}
focusedTextColor={keybind.leader ? theme.textMuted : theme.text}
minHeight={1}
Expand Down
Loading