Repository navigation
Conversation
There was a problem hiding this comment.
I couldn't verify this end to end. The feature only runs on Windows desktop and needs a real mouse drag into another app. The new drag-out.test.ts passes, bun test src/file in packages/gui-plugins passes (195 tests), and tsc -b is clean in packages/app, packages/gui-plugins, packages/plugin and packages/desktop. When you try it on Windows, please also check that the dragged row doesn't stay dimmed afterwards (see the inline comment on pierre-tree.tsx).
Public API: the only addition is dragOut(event, path) on BuiltinDesktop (@opencode/plugin/gui/builtin). That isn't the public SDK, and it's backwards compatible. The desktop FilesStartDrag call and the startFileDrag additions on the platform and renderer APIs are internal.
Concerns:
- Likely bug: the tree library's internal drag never ends after a drag-out, so the dragged row probably stays at half opacity (inline on
pierre-tree.tsx). - Smaller risk: a drop back into the composer becomes a mention only on an exact path match, so a slash or drive-letter difference would turn it into an attachment (inline on
drag-out.ts).
There was a problem hiding this comment.
The new commits fix both earlier points. When the system drag ends, the tree now gets the dragend its cancelled drag never fired. That event reaches the tree library's window dragend listener, which ends its drag session, so the dragged row should no longer stay dimmed. Drops back into the composer now match the path ignoring case and slash direction. The updated drag-out.test.ts passes (2 tests), bun test src/file in packages/gui-plugins passes (195 tests), and tsc -b is clean in packages/app, packages/gui-plugins and packages/desktop.
I still couldn't run a real drag: that needs Windows desktop and a mouse. When you try it on Windows, please check that the dragged row returns to normal after dropping into Explorer, and that a drop back into the composer adds an @ mention.
Public API: unchanged since my last review. The only addition is BuiltinDesktop.dragOut (@opencode/plugin/gui/builtin); its doc now says the event's target gets a dragend when the system drag ends. It's backwards compatible.
Issue for this PR
No linked issue. Ported from the native Rune desktop build (
anomalyco/rune-desktop,features/open-in/src/lib.rsdrag_item, and Rune'scrates/rune/src/drag_out/windows.rs).Type of change
What does this PR do?
On Windows, a file or folder dragged from the file tree now drops into other apps as the file itself: File Explorer copies it, a browser uploads it, a chat app attaches it. Today the drag carries only text, so other apps get nothing or a
file:string.A drop back into the composer still adds an
@mention, as it does today.How it works:
desktop.dragOut(event, path), with the row's absolute path. The tree calls it only for a session on a local server (the same check as Open in).FilesStartDrag). Main checks that the path is absolute and exists, then callswebContents.startDragwith the file's shell icon.text/plainuntil main answers that the drag ended. A drop into the composer whose single file is that path reads as that text, so it becomes the same mention. While the drag is out, the composer shows its mention drop state, not the attachment one.Only Windows changes. The desktop platform defines
startFileDragonly whenos === "windows", and main'sstartDragreturns false unlessprocess.platform === "win32". ElsewheredragOutreturns false and the tree's own drag goes on, so macOS, Linux and the web are unchanged.dragOutis onBuiltinDesktop(@opencode/plugin/gui/builtin), not the public SDK.How did you verify your code works?
src/runtime/platform/drag-out.test.tsinpackages/app(2 pass, new):dragstartis cancelled, and only a drop of that one file reads as the row's text, until the drag ends;src/composer/attachmentsinpackages/app(6 pass),bun test src/fileinpackages/gui-plugins(195 pass).bun typecheckinpackages/plugin,packages/appandpackages/gui-plugins,bun run typecheck:tscinpackages/desktop,bun script/sdk-docs.tsandbun run lint:changed origin/devclean.startDragreturning only after the drop, which is how Electron's Windows implementation reads. If it returned sooner, such a drop would add the file as an attachment instead.Screenshots / recordings
Not captured: needs a visible desktop.
Checklist
Added by the opencode bot (AI-generated).
Public API: adds
dragOut(event, path)toBuiltinDesktopin@opencode/plugin/gui/builtin, not the public SDK (backwards compatible)