Skip to content

feat(clipboard): accept dropped content - #3211

Merged
bbedward merged 3 commits into
duxlabs-dev:masterfrom
hthienloc:feat/clipboard-drop
Aug 28, 2026
Merged

bbedward merged 3 commits into
duxlabs-dev:masterfrom
hthienloc:feat/clipboard-drop

Conversation

@hthienloc

Copy link
Copy Markdown
Member

Allow users to save dropped text and local files to clipboard history directly from the Clipboard bar widget. Successful drops show a temporary primary-colored check icon instead of a success toast.

Partially addresses #2748.

recording_20260828_221148.mp4

@hthienloc

Copy link
Copy Markdown
Member Author

/claude review

const url = drop.urls[0].toString();
if (url.startsWith("file://")) {
const filePath = decodeURIComponent(url.substring(7));
DMSService.sendRequest("clipboard.copyFile", { "filePath": filePath }, response => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clipboard.copyFile doesn't just add to history — Manager.CopyFile ends with m.takeSelection(offers) (core/internal/server/clipboard/manager.go:1926), so it takes over the Wayland selection and replaces whatever the user currently has copied. The text branch below uses clipboard.store, which only appends to history. Dropping a file therefore silently clobbers the clipboard, which is neither what the PR describes ("save ... to clipboard history") nor consistent with the text path.

If history-only was intended, clipboard.store handles URI lists (StoreData builds a proper preview for text/uri-list):

DMSService.sendRequest("clipboard.store", { "data": url, "mimeType": "text/uri-list" }, ...)

Comment on lines +138 to +141
onDropped: drop => {
draggingOver = false;
root.handleDrop(drop);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The drop event is never accepted. QQuickDropArea::dropEvent only emits dropped; it doesn't accept the underlying QDropEvent, so the drag source is told the drop was refused and shows failure feedback (snap-back animation in most file managers/browsers) even though the item was saved.

Accept explicitly with Qt.CopyAction — accepting the proposed action would let a source that proposed MoveAction delete the original (e.g. text dragged out of an editor):

Suggested change
onDropped: drop => {
draggingOver = false;
root.handleDrop(drop);
}
onDropped: drop => {
draggingOver = false;
drop.accept(Qt.CopyAction);
root.handleDrop(drop);
}

property bool draggingOver: false

DropArea {
anchors.fill: parent

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parent here is the content item, which is only icon.width wide and widgetThickness - horizontalPadding * 2 tall (14px of a 30px pill with the default widgetPadding: 8) — the icon itself overflows it. The drop target is thus much smaller than the visible button, and drops on the pill's padding do nothing. Expanding by the padding makes it match visualWidth/visualHeight:

Suggested change
anchors.fill: parent
anchors.fill: parent
anchors.margins: -root.horizontalPadding

@claude

claude Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Claude review

Nice feature, three things to fix before merge — one behavioral, two around the drop plumbing.

  • Dropping a file uses clipboard.copyFile, which takes over the Wayland selection and overwrites the user's current clipboard, unlike the text path that only writes history — quickshell/Modules/DankBar/Widgets/ClipboardButton.qml:45
  • drop.accept() is never called, so the source app reports the drop as failed — quickshell/Modules/DankBar/Widgets/ClipboardButton.qml:138
  • The DropArea fills the icon-sized content item, not the pill, so most of the button doesn't accept drops — quickshell/Modules/DankBar/Widgets/ClipboardButton.qml:135

Checked: IPC method/param names against core/internal/server/clipboard (both valid), DMSService callback error shape, BasePill content sizing, service/import availability, translation catalogs untouched. Model: claude-opus-5.

@hthienloc

Copy link
Copy Markdown
Member Author

/claude review

Comment on lines +41 to +56
if (drop.hasUrls && drop.urls.length > 0) {
const url = drop.urls[0].toString();
if (url.startsWith("file://")) {
DMSService.sendRequest("clipboard.store", {
"data": url,
"mimeType": "text/uri-list"
}, response => {
if (response.error) {
ToastService.showError(I18n.tr("Failed to save dropped file"));
return;
}
root.showDropConfirmation();
});
return;
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only urls[0] is stored, so a multi-file drag (a normal gesture from any file manager) silently drops everything but the first file — and still flashes the success check, so the user has no way to notice. text/uri-list is a CRLF-separated list and the backend already handles it: uriListPreview returns [[ N files ]] for multi-URI data (core/internal/server/clipboard/manager.go:749).

Collect all file:// entries instead:

if (drop.hasUrls && drop.urls.length > 0) {
    const fileUrls = drop.urls.map(u => u.toString()).filter(u => u.startsWith("file://"));
    if (fileUrls.length > 0) {
        DMSService.sendRequest("clipboard.store", {
            "data": fileUrls.join("\r\n"),
            "mimeType": "text/uri-list"
        }, response => {
            if (response.error) {
                ToastService.showError(I18n.tr("Failed to save dropped file"));
                return;
            }
            root.showDropConfirmation();
        });
        return;
    }
}

@claude

claude Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Claude review

Previous round is addressed — file drops now use clipboard.store, the drop is accepted, and the DropArea covers the pill. One thing left.

  • Multi-file drags only save urls[0], silently discarding the rest while still showing the success check — quickshell/Modules/DankBar/Widgets/ClipboardButton.qml:41

Checked: clipboard.store param names and StoreData/uriListPreview handling of text/uri-list, ClipboardService.clipboardAvailable, ToastService.showError signature, DMSService.sendRequest callback shape, DropArea geometry against BasePill.visualWidth/visualHeight for both bar orientations (including removeWidgetPadding), timer lifetime, translation catalogs untouched. Model: claude-opus-5.

@bbedward

Copy link
Copy Markdown
Member

/claude review

"mimeType": "text/uri-list"
}, response => {
if (response.error) {
ToastService.showError(I18n.tr("Failed to save dropped file"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two new terms (here and line 64) have no translator context. CONTRIBUTING.md requires I18n.tr("...", "<context>") for new user-facing strings, and asks to keep new terms to a minimum — a single term like I18n.tr("Failed to save dropped content", "Error toast when a drag-and-drop onto the clipboard bar widget could not be stored") would cover both branches.

@claude

claude Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Claude review

Previous round of findings looks addressed; one minor i18n issue left.

  • New I18n.tr() terms lack translator context and could be a single reused term, quickshell/Modules/DankBar/Widgets/ClipboardButton.qml:49

Checked: drop handling and uri-list payload against handleStore/StoreData/uriListPreview in core, drop accept action, DropArea geometry vs BasePill (no clipping, no sibling overlap in either orientation), timer lifetime, icon width stability on the check/paste swap, and the earlier review comments (copyFile→store, accept, margins, multi-file) which are all resolved. Model: claude-opus-5.

@bbedward
bbedward merged commit f1bbb97 into duxlabs-dev:master Aug 28, 2026
1 check passed
@hthienloc
hthienloc deleted the feat/clipboard-drop branch November 15, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants