[PR #1352] [CLOSED] fix: handle absolute paths correctly in drag & drop file attachments (#1330) #9908

Closed
opened 2026-02-16 18:14:22 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/1352
Author: @tleo19
Created: 7/27/2025
Status: Closed

Base: devHead: fix/drag-drop-absolute-path-1330


📝 Commits (1)

  • 1686137 fix: handle absolute paths correctly in drag & drop file attachments (#1330)

📊 Changes

1 file changed (+7 additions, -2 deletions)

View changed files

📝 packages/opencode/src/session/index.ts (+7 -2)

📄 Description

Summary

  • Fixes issue where drag & drop of files from outside the working directory results in ENOENT error
  • The server was incorrectly joining absolute paths with the cwd, creating invalid double paths like /cwd/path/Users/username/Desktop/file.txt

Changes

  • Added a check in session/index.ts to detect if the pathname is already absolute
  • If absolute, use the path directly without joining with cwd
  • If relative, continue with the existing logic

Test plan

  • Tested locally by dragging a file from Desktop into opencode
  • Verified the file attachment works correctly without ENOENT errors
  • Existing relative path functionality remains unchanged

Fixes #1330


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/1352 **Author:** [@tleo19](https://github.com/tleo19) **Created:** 7/27/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/drag-drop-absolute-path-1330` --- ### 📝 Commits (1) - [`1686137`](https://github.com/anomalyco/opencode/commit/168613731f3a44a28a397166f6202513a0127cf5) fix: handle absolute paths correctly in drag & drop file attachments (#1330) ### 📊 Changes **1 file changed** (+7 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/opencode/src/session/index.ts` (+7 -2) </details> ### 📄 Description ## Summary - Fixes issue where drag & drop of files from outside the working directory results in ENOENT error - The server was incorrectly joining absolute paths with the cwd, creating invalid double paths like `/cwd/path/Users/username/Desktop/file.txt` ## Changes - Added a check in `session/index.ts` to detect if the pathname is already absolute - If absolute, use the path directly without joining with cwd - If relative, continue with the existing logic ## Test plan - [x] Tested locally by dragging a file from Desktop into opencode - [x] Verified the file attachment works correctly without ENOENT errors - [x] Existing relative path functionality remains unchanged Fixes #1330 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:14:22 -05:00
yindo closed this issue 2026-02-16 18:14:22 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9908