Skip to content

feat(drag): save browser images, text, and web links - #1547

Merged
l0gicgate merged 2 commits into
mainfrom
feat/1545-browser-content-drops
Nov 1, 2026
Merged

l0gicgate merged 2 commits into
mainfrom
feat/1545-browser-content-drops

Conversation

@JoeJoeflyn

@JoeJoeflyn JoeJoeflyn commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Reworked from a clean main. Drag content from a browser or another app onto a folder row, pane background, breadcrumb, sidebar folder, or tab, in any view, and Strata saves it as a new file in that (local) folder:

  • image data (Firefox) → image.png
  • an image's own file contents (Chromium's application/octet-stream;name="…") → original bytes, extension taken from the actual image format
  • selected text → dropped text.txt
  • an HTTP(S) address → example.com.desktop, a Type=Link entry with no Exec

Per review feedback, dropping an address never contacts it: no probing, no download, even for image URLs. Opening a saved link sends the address to the default browser. Existing names are never replaced (numbered names, dangling symlinks kept), files appear only once complete, and Open folder after dropping files applies. Remote, Trash, and Recent destinations don't accept new content. Strata's own tab and sidebar reorder drags are never saved as text. Web addresses dropped on the sidebar Trash are now refused instead of being handed to GIO.

The QA foreign drag source can now offer raw MIME content; the new content_drops scenarios drag real content from a separate process and count local HTTP requests to show that nothing is fetched.

Visual evidence

N/A. Agent-prepared change; behaviour is described above and covered by QA scenarios.

How to test

  1. Open a local folder. From Firefox, drag an image onto a folder row; from a Chromium-based browser, drag an image onto a folder row.
  2. Select some text on a web page and drag it onto the pane background, a breadcrumb, a sidebar folder, and a tab.
  3. Drag a link (or the address bar's site icon) onto a folder; check no request reaches the site (offline works too). Double-click the saved .desktop file.
  4. Repeat a drop in the same folder, then try a read-only folder.

Expected result: Firefox images save as image.png, Chromium images save with their original name and bytes, and text saves as dropped text.txt. A link saves as <host>.desktop without network access, and opening it launches the default browser. Repeated drops get numbered names. A read-only folder shows "Unable to save dropped content". Dragging files between folders behaves as before.

Related issue

Closes #1545

@JoeJoeflyn

Copy link
Copy Markdown
Collaborator Author

Final scoped validation: ./scripts/test-headless.py content_drop:: selected/passed 7 tests; ./scripts/test-headless.py drop_open_preference_applies_before_settings_and_live_across_views selected/passed 1. The two previously unresolved Rust cases also pass individually: ./scripts/test-headless.py enter_on_a_video_preview_opens_it_where_it_stopped and ./scripts/test-headless.py entering_tenxer_hides_an_open_filter_and_leaving_restores_it (1 selected/passed each). The final pinned fmt/Clippy and staged whitespace checks passed.

Scope: the explicit attachment correction affects the shared Columns/Icons/List, breadcrumb, sidebar and tab drop receivers. Coverage includes binary receiver attachment/routing, original bytes and captured destination, no-clobber publication, plus startup/live drop preferences across two views and view rebuilds. These native checks do not establish actual-browser transport interoperability.

Owner override: no further E2E runs. Earlier full results remain historical, not replaced by the scoped checks: Rust 2527 passed / 6 failed / 9 ignored; E2E 995 passed / 1 failed. The two uncertain Rust cases now pass above. Three other notification/settings failures reproduced on unchanged baseline; the archive-chord failure passed earlier isolated native/pinned reruns. The E2E text-size failure remains unresolved. Two binary-offer cases failed against the removed deserializer implementation and were not rerun against the final async receiver. Required CI and manual browser confirmation remain necessary before merge.

Visual evidence still pending: no final-build before/after recording is attached. Earlier failure captures are retained locally:

  • /home/giogio/Project/strata/target/e2e-artifacts/test_browser_file_contents_take_precedence_over_url-binary-image.jpg-/screenshot.png — unnamed binary image not saved by the removed implementation.
  • /home/giogio/Project/strata/target/e2e-artifacts/test_browser_file_contents_take_precedence_over_url-named-binary-browser-photo.jpg-/screenshot.png — named binary image not saved by the removed implementation.

These are failure evidence, not final-success screenshots. Please capture the final manual browser drop before/after and upload sanitized captures through the GitHub editor, then embed its attachment URLs in Visual evidence. No captures or task reports were committed. Detailed local handoff: target/browser-drops-launch/prepush-validation.md.

@JoeJoeflyn
JoeJoeflyn marked this pull request as ready for review October 9, 2026 19:36
@blacksmith-sh

This comment has been minimized.

@JoeJoeflyn

Copy link
Copy Markdown
Collaborator Author

CI follow-up pushed in abb15e4e.

The failed check was E2E shard 2, test_archive_far_from_viewport_is_scrolled_into_view[icons] (run 37981400513, job 113993478168; 329 passed, 1 failed). Its capture retained the old 005.txt keyboard destination after archive creation.

Grid reveal previously bypassed deferred reveal handling. It now retains the request until the GTK model is ready and the modal has closed, then focuses the selected output without changing the selection. The existing E2E scenario and assertions are unchanged.

Scoped validation on final code:

  • ./scripts/test-headless.py grid_reveal_survives_reload_and_modal_focus_restoration — 1 passed, exercising model reattachment with and without modal focus restoration. The refined regression failed on the original implementation. The modal fixture includes the normal window focus fallback.
  • ./scripts/test-headless.py ui::modal::tests — 6 passed.
  • ./scripts/test-headless.py app::browser::tests::reveal — 8 passed.
  • STRATA_CONTAINER_ENGINE=podman ./scripts/quality.sh fmt — passed.
  • STRATA_CONTAINER_ENGINE=podman ./scripts/quality.sh clippy — passed.
  • git diff --check — passed.

Scope rationale: this changes only the GridView reveal path; existing List/Columns handling, model selection semantics, transfer services, dependencies, runtime images, and harness inputs are unchanged. Tests cover native focus/lifecycle behavior, not layout assertions.

No local E2E runs were performed, as explicitly requested by the owner. Full local Rust suites were omitted for this bounded correction. The exact failing E2E scenario and required GitHub checks still need CI confirmation; no green CI or completed manual verification is claimed. Existing browser interoperability/manual-validation limitations remain in the description.

@wmfeht

wmfeht commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

Worth discussing how dropped URLs are handled. The common approach in file managers (Finder, Dolphin, Nautilus) is to save a bookmark or link file for a dropped URL without fetching it. The browser only provides real file data when the user drags an actual image or file. Here, dropping a link makes an outbound request to check whether it's an image (web_image.rs). That means a stray drop can reach the network with no prompt.

Could URL drops default to just writing the .desktop link, with fetching left out or made an explicit opt-in? Image and text drops where the browser provides the data itself seem fine as they are.

Dropping browser content on a folder row, pane background, breadcrumb,
sidebar folder, or tab saves it as a new file in local folders: image
data as PNG, a browser's image file contents with their original bytes,
selected text as UTF-8 text, and HTTP(S) addresses as freedesktop
Type=Link entries. Dropped addresses are never fetched; opening a saved
link hands its address to the default browser. Names never replace
existing entries, and files appear only once complete.

Web addresses dropped on the sidebar Trash are refused instead of being
handed to GIO. The QA foreign drag source can now offer raw MIME content.

Refs #1545
@wmfeht
wmfeht force-pushed the feat/1545-browser-content-drops branch from 4407511 to 0baa91a Compare October 31, 2026 22:05
@wmfeht

wmfeht commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

Review

Reviewed head 0baa91a8 by reading the code only. Not verified: no build, Rust tests, or QA scenarios were run.

Minor

1. save_new_file needs rename-noreplace or hard links, which also regresses image paste (src/services/dropped_content.rs, save_new_file; also used by ViewState::paste_image in src/ui/browser/clipboard.rs)
The old write_pasted_image created the file directly with create_new(true). The new code writes a temp file and calls persist_noclobber. In tempfile 3.27 that uses renameat2(RENAME_NOREPLACE) and falls back to hard_link + unlink when the call returns EINVAL.

  • When it breaks: a local-path mount that supports neither, such as a FUSE filesystem without rename2 or hard links (rclone mount, some MTP FUSE drivers).
  • Effect: every content drop fails with "Unable to save dropped content". Ctrl+V image paste also stops working, and because that error is only logged with tracing::warn!, it fails silently.
  • Fix: when persist_noclobber fails with an unsupported, permission or invalid-argument error, fall back to writing the file with create_new.

2. Image data takes priority over a real file list (src/ui/browser/content_drop.rs, drop_types() / preloads())
Texture is listed before FileList, and preloading is off whenever a texture is offered. So a foreign drag that offers image data and a real file:// list is saved as a re-encoded image.png instead of copying the original file. Apps that do this include screenshot tools, image viewers, and Firefox dragging a local image open in a tab.

  • Effect: the original file's name and format are lost. Drops of these on remote folders are refused, where they used to copy.
  • Conflict with the docs: docs/content-drops.md says "A file dragged from another file manager is still copied or moved as usual."
  • Fix: prefer the file list when it contains any non-web URI. Use the texture only when there is no file list or it holds only web links.

3. Chromium file-contents drops have no fallback and fail silently (accepts_offer and attach_drop_target in src/ui/browser/content_drop.rs)
Any foreign offer that includes application/octet-stream is refused by the main DropTarget, so only the async target can take it. That target finishes with an empty action and shows nothing when:

  • the bytes are not a recognised image,
  • the contents are over 64 MB, or
  • the read fails.

The drop is not retried as the text/uri-list or text that came with it. This contradicts "A save that fails … shows an error" in the docs. Offers that also carry a real file list are refused outright on remote folders. Current Chromium only does this for images, so the main risk is other apps that add a bare application/octet-stream.

  • Fix: show the save-error dialog for unreadable or oversized contents. Ideally, only route to the async target when there is no file list with non-web URIs.

4. A list mixing web and local addresses still goes through the file transfer (web_links in src/ui/browser/content_drop.rs)
web_links returns None unless every URI is a web link, so ["https://…", "file:///…"] goes through classify_file_drop and the normal GIO copy with an https:// source. With gvfs-http installed, the volume lookup or the copy reaches the network. This happened on main before, but it contradicts the new "Dropping an address never contacts it" guarantee.

  • Fix: refuse mixed lists, or save the web entries as links and transfer only the non-web ones.

5. No hover feedback for Chromium image drags (attach_drop_target)
The DropTargetAsync path only returns COPY on enter and motion. Rows get no drop-destination highlight, folders don't open on hover (spring-load), and the view doesn't auto-scroll. Firefox images and text, which use the main DropTarget, get all of these.

… content

Address review findings on browser content drops:

- Fall back to an exclusive in-place write when the destination can
  neither rename without replacing nor hard link, as on some FUSE mounts,
  so content drops and image paste keep working there. A failed write
  removes the partial file.
- Read a dropped file list before image data. A drag offering real files
  with an image copies the files; image data is read only when the list
  holds web addresses alone or is absent.
- Read images in the asynchronous companion target at drop time, falling
  back to the offered addresses or text, and show the save error when
  nothing can be saved. The main target now gives all hover feedback,
  so image drags highlight rows, spring-load folders, and auto-scroll.
- Refuse URI lists mixing web addresses with files instead of handing
  them to GIO, so a dropped address is never contacted.

Refs #1545
@wmfeht

wmfeht commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

Fixes applied

  • 1. save_new_file fallback: fixed in b7db2396. If the no-replace rename isn't supported, the file is written directly under a new name instead (the same function also covers image paste).
  • 2. Real file list beats image data: fixed in b7db2396. The file list is read while hovering, and the image is used only when there is no file list or it holds only web links.
  • 3. File-contents fallback and error: fixed in b7db2396. If the image can't be used, the web links or text that came with it are saved instead; if nothing is left, the save-error dialog appears. A new string, "The dropped content is too large", is added in all 13 locales.
  • 4. Mixed web/local lists: fixed in b7db2396. Mixed lists, and web addresses that can't become a link, are refused before any file classification or volume lookup.
  • 5. Hover feedback for image drags: fixed in b7db2396. The main target now handles hover for these drags. On a tab, an image drop made while a dialog is open is still saved, but the tab is not switched.

Validation: ./scripts/test-headless.py with the filters content_drop:: (2 tests), dropped_content:: (6), drop_open_preference_applies_before_settings_and_live_across_views (1), sidebar_trash_refuses_dropped_web_addresses (1), i18n:: (12) and drop (70) all passed. ./scripts/qa.sh on the foreign-content-saves-new-files, foreign-content-reaches-every-drop-target, chooser-sidebar-drops-survive-resize and foreign-folder-drags-validate scenarios passed (19 runs), and ./scripts/quality.sh fmt and clippy passed. Not run: the full Rust and QA suites. The new image_file QA variant was not run against the previous commit to show that it fails there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(drag): save browser images, text, and web links on drop

3 participants