From e413e66c8664b98ac359cd918406735daf71fb3a Mon Sep 17 00:00:00 2001 From: Vadym Kotai Date: Wed, 11 Mar 2026 23:14:25 +0400 Subject: [PATCH] fix(opencode): handle shell-escaped parentheses in drag-drop file paths Terminals like Ghostty shell-escape special characters when drag-dropping files. The paste handler only unescaped backslash-space but not other metacharacters like parentheses, causing silent attachment failure for filenames like 'image (1).png'. Use /\\([^a-zA-Z0-9])/g to unescape all shell metacharacters while preserving Windows path separators (backslash + alphanumeric). Fixes #17075 --- packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx | 5 ++--- 1 file changed, 2 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 2d99051fb97..7ded22e04e2 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx @@ -943,9 +943,8 @@ export function Prompt(props: PromptProps) { return } - // trim ' from the beginning and end of the pasted content. just - // ' and nothing else - const filepath = pastedContent.replace(/^'+|'+$/g, "").replace(/\\ /g, " ") + // strip shell quoting/escaping that terminals add when drag-dropping file paths + const filepath = pastedContent.replace(/^'+|'+$/g, "").replace(/\\([^a-zA-Z0-9])/g, "$1") const isUrl = /^(https?):\/\//.test(filepath) if (!isUrl) { try {