Repository navigation
Description
Description
On Windows, a prompt pasted into the TUI can be submitted by itself, without pressing Enter. The pasted content is a single terminal command line that still carries its trailing line break, and after the paste the message is sent immediately: a new session is created and the text is recorded as a normal user message. From the user's side it looks like opencode sends a message on its own when it opens.
The prompt paste handler normalizes line endings but inserts the untrimmed text:
let it = clipboard.replace(/\r\n?/g, "\n"), ot = it.trim();
// ...
n.insertText(it) // inserts the text including the trailing newlineTwo things look wrong: the trailing newline is kept for single-line content, and a newline inserted programmatically appears to reach input.submit instead of the multiline editor. Related newline handling reports in V2: #43222 and #43286 (Shift+Enter submits instead of inserting a newline).
Plugins
None. Only the 14 built-in CLI plugins are loaded (home.footer, prompt.footer, btw, sidebar.context, sidebar.limit, sidebar.mcp, sidebar.todo, sidebar.footer, notifications, plugins, stats, merman, latex, diffs). No plugin directories exist in the project or global config.
OpenCode version
2.2.5 (2.2.6 available)
Steps to reproduce
- Windows 11, TUI started with a plain
opencodefrom the VS Code integrated terminal (PowerShell profile). - Copy a single command line in a way that keeps the line break, e.g. VS Code Ctrl+C with no selection, which copies the whole line including the newline.
- Open opencode and paste into the empty prompt with Ctrl+V. Do not press Enter.
- The prompt is submitted immediately.
Expected behavior: the paste inserts the text and waits for an explicit Enter.
Actual behavior: the message sends itself. A session is created and the text becomes its first user message.
Screenshot
Not available.
Operating System
Windows 11 (10.0.26300.9711)
Terminal
VS Code 1.145.2 integrated terminal. TERM=xterm-256color, TERM_PROGRAM=vscode, COLORTERM=truecolor. In the affected launch the TUI's parent process was a cmd.exe started from VS Code's terminal.
Additional context
Observed timing in the affected session:
- TUI process starts at
08:14:02. - Session is created at
08:14:05.879. - User message is recorded at
08:14:06.082, 203 ms later, with no keyboard interaction.
There is no stashed draft (prompt-stash.jsonl absent), no queued message for that session (session_inbox empty for it), and a plain opencode launch with OPENCODE_LOG_LEVEL=DEBUG created no session and sent no message, so the send needs an input event. The submitted text is a shell command (d:\dev\budget_cumi\.venv\Scripts\activate.bat) that the user did not intend to send, and the same user pastes terminal transcripts into the prompt regularly, which is why this only shows up intermittently.
Activity
opencodejr commentedon Nov 9, 2026
Thanks for the detailed report and timings. I tried this on 2.2.5 on Linux and couldn't reproduce it there.
d:\dev\x\.venv\Scripts\activate.batwith a trailing CRLF is inserted into the prompt and waits for Enter. The latestdev(524afbb) does the same.So on your setup the paste probably reaches opencode as plain keystrokes. That could happen because of how the VS Code terminal,
cmd.exeand ConPTY pass it through, or because the paste lands while the TUI is still starting up. Checking this needs Windows with the VS Code integrated terminal, which this sandbox doesn't have, so a maintainer with that setup will need to look.If you can, these would help:
opencodedirectly from PowerShell in VS Code, withoutcmd.exein between?Related, but different triggers: