Skip to content

Commit e413e66

Browse files
committed
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 anomalyco#17075
1 parent cf7ca9b commit e413e66

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

  • packages/opencode/src/cli/cmd/tui/component/prompt

‎packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -943,9 +943,8 @@ export function Prompt(props: PromptProps) {
943943
return
944944
}
945945

946-
// trim ' from the beginning and end of the pasted content. just
947-
// ' and nothing else
948-
const filepath = pastedContent.replace(/^'+|'+$/g, "").replace(/\\ /g, " ")
946+
// strip shell quoting/escaping that terminals add when drag-dropping file paths
947+
const filepath = pastedContent.replace(/^'+|'+$/g, "").replace(/\\([^a-zA-Z0-9])/g, "$1")
949948
const isUrl = /^(https?):\/\//.test(filepath)
950949
if (!isUrl) {
951950
try {

0 commit comments

Comments
 (0)