From 6c3b28db64e47895553949880f296bae74691f4a Mon Sep 17 00:00:00 2001 From: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Date: Thu, 16 Apr 2026 14:38:39 -0500 Subject: [PATCH] fix: ensure that double pasting doesnt happen after tui perf commit was merged (#22880) --- .../opencode/src/cli/cmd/tui/component/prompt/index.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 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 e64a16eb8a..82c4a7222f 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx @@ -1031,6 +1031,10 @@ export function Prompt(props: PromptProps) { return } + // Once we cross an async boundary below, the terminal may perform its + // default paste unless we suppress it first and handle insertion ourselves. + event.preventDefault() + const filepath = iife(() => { const raw = pastedContent.replace(/^['"]+|['"]+$/g, "") if (raw.startsWith("file://")) { @@ -1048,7 +1052,6 @@ export function Prompt(props: PromptProps) { const filename = path.basename(filepath) // Handle SVG as raw text content, not as base64 image if (mime === "image/svg+xml") { - event.preventDefault() const content = await Filesystem.readText(filepath).catch(() => {}) if (content) { pasteText(content, `[SVG: ${filename ?? "image"}]`) @@ -1056,7 +1059,6 @@ export function Prompt(props: PromptProps) { } } if (mime.startsWith("image/") || mime === "application/pdf") { - event.preventDefault() const content = await Filesystem.readArrayBuffer(filepath) .then((buffer) => Buffer.from(buffer).toString("base64")) .catch(() => {}) @@ -1078,11 +1080,12 @@ export function Prompt(props: PromptProps) { (lineCount >= 3 || pastedContent.length > 150) && !sync.data.config.experimental?.disable_paste_summary ) { - event.preventDefault() pasteText(pastedContent, `[Pasted ~${lineCount} lines]`) return } + input.insertText(normalizedText) + // Force layout update and render for the pasted content setTimeout(() => { // setTimeout is a workaround and needs to be addressed properly