diff options
| author | Dax Raad <[email protected]> | 2025-11-02 13:45:44 -0500 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-11-02 13:45:44 -0500 |
| commit | 05489bc843f2f6d79f495ce19b4a568e52c07a9f (patch) | |
| tree | 449c9817f0390962ec9c438f4c3797e22b5a285d | |
| parent | 3f02eecf2215656b36f3cb70d8e017d5ffa16ae6 (diff) | |
| download | opencode-05489bc843f2f6d79f495ce19b4a568e52c07a9f.tar.gz opencode-05489bc843f2f6d79f495ce19b4a568e52c07a9f.zip | |
tui: fix file path handling when pasting images with spaces in filename
- Fixes issue where files with spaces in their names couldn't be pasted as images
- Prevents default paste behavior to avoid conflicts with image insertion
- Improves error handling for file reading operations
| -rw-r--r-- | packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx | 6 |
1 files changed, 4 insertions, 2 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 e45fa677f..7239440cb 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx @@ -616,14 +616,16 @@ export function Prompt(props: PromptProps) { // trim ' from the beginning and end of the pasted content. just // ' and nothing else - const filepath = pastedContent.replace(/^'+|'+$/g, "") + const filepath = pastedContent.replace(/^'+|'+$/g, "").replace(/\\ /g, " ") + console.log(pastedContent, filepath) try { const file = Bun.file(filepath) if (file.type.startsWith("image/")) { + event.preventDefault() const content = await file .arrayBuffer() .then((buffer) => Buffer.from(buffer).toString("base64")) - .catch(() => {}) + .catch(console.error) if (content) { await pasteImage({ filename: file.name, |
