opencode icon indicating copy to clipboard operation
opencode copied to clipboard

appendPrompt doesn't trigger textarea resize

Open joshuadavidthomas opened this issue 3 weeks ago • 2 comments

Description

When calling appendPrompt() from a plugin, text is inserted but the textarea doesn't resize to fit the content. It stays at minimum height.

Root cause: appendPrompt uses input.insertText() which bypasses onContentChange where resize logic runs.

Workaround:

await ctx.client.tui.appendPrompt({ body: { text: fullPrompt } })
await ctx.client.tui.executeCommand({ body: { command: "session_new" } })
await new Promise(r => setTimeout(r, 200))
await ctx.client.tui.appendPrompt({ body: { text: fullPrompt } })

Suggested fix: Add a setPrompt API that uses the Prompt component's set method, which properly triggers resize.

OpenCode version

1.0.164

Steps to reproduce

  1. Create a plugin that calls appendPrompt after session_new
  2. Run the plugin:
await ctx.client.tui.executeCommand({ body: { command: "session_new" } })
await new Promise(r => setTimeout(r, 500))
await ctx.client.tui.appendPrompt({ body: { text: "Multi-line\ntext\nthat\nshould\nexpand" } })
  1. Text appears but textarea stays 1 line tall

Screenshot and/or share link

No response

Operating System

Arch Linux

Terminal

Ghostty

joshuadavidthomas avatar Dec 17 '25 02:12 joshuadavidthomas

Oops! I was working on this for opencode-handoff and running into this issue. I asked Opus to capture what was happening and it apparently decided that meant I wanted to capture it as an issue, not as a Markdown doc in the current directory. I'll provide some follow-up screenshots here shortly.

joshuadavidthomas avatar Dec 17 '25 02:12 joshuadavidthomas

yeah I've seen this, it doesn't trigger a resize on paste as well when you have a smaller prompt than 2 lines it will just show one line it's mainly due to the update not being tracked properly I saw this when I was implementing the voice feature in one of my own sub-branches

nalin-singh avatar Dec 17 '25 02:12 nalin-singh