Skip to content

feat(sidebar): pin dragged folders without blocking hover - #1692

Merged
l0gicgate merged 6 commits into
mainfrom
feat/1690-pin-dragged-folders
Oct 16, 2026
Merged

l0gicgate merged 6 commits into
mainfrom
feat/1690-pin-dragged-folders

Conversation

@JoeJoeflyn

@JoeJoeflyn JoeJoeflyn commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Pin folders or reorder existing pins through compact sidebar insertion gaps, without changing folder-row transfers. Preserve selection order, skip duplicate new pins, and persist the resulting bookmarks and labels.

Internal folder and pin drags use provider-matched metadata without filesystem probes. Move-only internal offers are supported; external Move-only offers are rejected to avoid requesting source deletion. External folder validation remains asynchronous and bounded, and pending pin drops never fall through to file transfers. Remote pins and directory symlinks are supported without canonicalizing aliases.

Visual evidence

screenrecording-2026-10-15_21-27-44.mp4

How to test

  1. Drag folders from Columns, List, or Icons into an empty Pinned section, then before, between, and after existing pins. Repeat an internal drag with Shift held and a normal folder drag from another file manager.
  2. Drag an existing local or remote sidebar pin into those same gaps to reorder it. Restart Strata.
  3. Drop an already-pinned folder from the main pane into another gap, try files/mixed selections in a gap, and drop a file onto a pinned folder row.

Expected result: New folders pin in selection order and survive restart. Existing sidebar pins reorder through the insertion gaps without changing their labels or folder contents. Dragging an already-pinned folder from the main pane neither duplicates nor reorders it. Files/mixed selections do not pin or transfer through gaps; folder rows retain their transfer behavior.

Related issue

Closes #1690

JoeJoeflyn and others added 2 commits October 15, 2026 18:39
Accept verified internal Move-only offers without requesting deletion from foreign sources. Route existing pin drags through the insertion gaps using provider-matched locations and current bookmark anchors. Preserve folder-row transfers, labels and persisted order while reducing gap spacing.

Refs #1690
@ogarza

ogarza commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Review findings (checked against 75a74f8)

Thanks for this, the drop protocol handling is careful. Below are the issues worth fixing before merge. Each one was confirmed by tracing the code paths at 75a74f8f; none were reproduced by running Strata. The Checked line under each item says exactly what was traced. The first two sections are bugs and test gaps; the last section lists smaller issues.

Bugs

1. Trashed folders can be pinned by dragging (window.rs#L2990)
pin_locations_at skips only standard places and duplicates. The menu and keyboard paths refuse trash locations (can_pin_entry / pin_action_for in ui/browser/paths.rs, change_keyboard_pin), so dragging is the one way a trash:///… pin gets written.
Checked: the List/Icons and Columns drag sources (browser_modes.rs and columns/rows.rs connect_prepare) have no trash gate, so a trashed folder in the Trash view yields a snapshot with all_directories: true and a trash:/// location. A trashed folder dragged from another file manager also queries as Directory and passes.
Fix: skip is_trash_location in pin_locations_at, which covers internal and external drops.

2. Hovering a web link over a gap makes a network request (pinned_drop.rs#L243, #L140-L147)
connect_accept admits any drop that deserializes to FileList. GTK turns text/uri-list into a FileList without checking schemes, and browsers typically offer text/uri-list for link drags. On drag-enter the validation reads the list, location_for_file keeps https://… as a URI location, and all_directories runs query_info on it.
Checked: the code path above, plus /usr/share/gvfs/mounts/http.mount on an Arch/Omarchy machine has AutoMount=true, so gvfsd-http starts and queries the URL on hover, before any drop.
Fix: reject http(s) and other non-folder schemes before any probe.

3. Drag-pinned folders are labelled with the URI basename (window.rs#L2992)
Menu and keyboard pins store the entry's display_name (context_menu.rs#L1402, browser.rs#L1684); drag pins use location.display_name(). The two differ on GVfs backends whose basenames are IDs (e.g. Google Drive) and for trash items.
Checked: file_drag_content already has each FileEntry (whose display_name comes from standard::display-name), but DragSnapshot keeps only the locations.
Fix: carry names in DragSnapshot, and for external drops add standard::display-name to the existing query_info call (no extra I/O).

4. A gap whose pin was removed elsewhere drops at the end (window.rs#L1844, #L1863)
If the gap's anchor pin isn't in the freshly loaded bookmarks, insertion falls back to places.len(), and a reorder moves the source to the bottom.
Checked: other windows don't watch the bookmarks file (watch_changes in adapters/bookmarks.rs is only notified from deletion_completed). Unpinning in window B therefore leaves window A showing the old gaps until its next pin action. A drop on A's gap above the removed pin then lands at the bottom.
Fix: fall back to the gap's other neighbour, or treat a missing anchor as a no-op for reorders.

Tests

5. an_expired_internal_drag_never_replaces_another_drops_sources can't fail (clipboard/tests.rs#L1106)
prepared.target has no current_drop(), so active_drag_locations returns at its first ? and never reaches the provider comparison. The test passes with the expiry check removed, and it repeats a_cached_internal_drag_never_replaces_another_drops_sources, which has the same gap.
Checked: sources() → active_drag_locations() → target.current_drop()?.
Fix: remove it, or test drag_snapshot_for_content directly as directory_drag_snapshot_uses_entry_metadata_without_touching_paths does.

6. The last drop in the pinning E2E is never awaited (test_sidebar_pinning.py#L66-L69)
The already-pinned pin-a is dropped on the last gap and the app is stopped right after the XTest release. If that drop wrongly reordered pins, the process would usually be gone before saving, so the post-restart assertion still passes.
Checked: drag_to_pin returns after the raw button release, and application.stop() → terminate() sends SIGTERM immediately.
Fix: wait for an observable result before stopping, e.g. follow with another drop whose expected order would differ if pin-a had moved.

Smaller issues

7. A sidebar rebuild while an external drop is pending rejects it (window.rs#L1664, pinned_drop.rs#L112, #L281)
Each rebuild creates a new FolderDragCache. Dropping the old one finishes the pending validation with None, and the drop handler also requires the gap's root(), so the drop is rejected either way. Triggers include mount/volume changes, device release, sidebar preference changes and a folder deletion finishing. This is smaller because it needs one of those during validation, with the button released before validation completes (milliseconds locally, up to 2 s on remote shares).
Checked: rebuild removes the gaps → their controllers and the cache drop → FolderValidation::drop → finish(None) → drop.finish(empty).
Fix: keep the cache on SidebarState across rebuilds, and check the sidebar's root rather than the gap's (anchors already resolve by location).

8. Shortcut/Mountable items pin from Strata but not from other apps (directory_validation.rs#L24)
Strata's listing maps Shortcut and Mountable to EntryKind::Directory (local_files.rs#L374), so an SMB share or network item dragged from Strata pins. The same item dragged from another file manager would query as Mountable, and the whole selection is rejected. This is smaller because it only affects network-browse entries.
Checked: the two type checks above.
Fix: accept Mountable/Shortcut, resolving standard::target-uri as the listing does.

9. Large or slow external selections time out (directory_validation.rs#L16, pinned_drop.rs#L153)
Queries run one at a time under a single 2 s deadline that also covers reading the payload. For example, 100 folders on SFTP at ~25 ms per query exceed it, and the selection is then rejected for the rest of the drag. This is smaller, and docs/architecture.md documents it as intended. A few queries in flight (4–8) would still bound the work without the false rejections.
Checked: the serial await in the loop, with the timeout wrapping the whole future.

10. In rail mode, an empty Pinned section leaves two separators with nothing between them (window.rs#L1657, #L1415)
The empty section is intentional per the docs. In rail mode, though, sync_rail_rows hides only Labels, so the heading disappears but the gap stays. When a Devices section follows, the result is two separators about 20 px apart with nothing between them. This is smaller because it is visual only.
Checked: sync_rail_rows hides headings only, and the gap is a Box.
Fix: drop one of the separators when the section is empty in rail mode.

11. Pinned rows sit 8 px apart while other sections use 2 px (style.css#L2306, sidebar.rs#L92)
Each 4 px gap sits inside the 2 px-spaced box, so consecutive pinned rows are 2 + 4 + 2 px apart. This is smaller and visual; worth a side-by-side screenshot with Places to confirm it's intended.

12. Each gap is an empty accessible group named "PINNED" (pinned_drop.rs#L232-L235)
This adds N+1 identical, empty groups to the accessibility tree, and their only consumer is the E2E pin_gap lookup (test_sidebar_pinning.py#L21). This is smaller because Tab navigation doesn't announce them (they have no focusable children), but they clutter object navigation for screen-reader users.
Fix: leave the gaps without a role and name, and have the test compute gap points from neighbouring row bounds, as it already does for the row-half reorder at L170.

13. No-op drops report success (window.rs#L1885)
update_pinned_places returns true whenever load and save succeed, even when change returned false. Dropping an already-pinned folder, or reordering a pin onto an adjacent gap, therefore finishes with COPY/MOVE. This is a nit: it's harmless today because MOVE is only offered to internal sources, which never delete. Returning whether anything changed would fix it.

14. Hand-rolled timeout (pinned_drop.rs#L65, #L153)
futures_lite::future::race plus timeout_future duplicates glib::future_with_timeout, which is used throughout (portal.rs, local_files.rs). The 2 s literal also duplicates adapters::volume::REMOTE_QUERY_TIMEOUT; use a named constant, or that one if the intent matches. Cleanup only.

Drag pins now use entry display names, refuse trash and http(s) locations
before probing, resolve a gap through either neighbour so a pin unpinned
elsewhere cannot send a drop to the end, and finish no-op drops as rejected.
@l0gicgate

Copy link
Copy Markdown
Contributor

Review follow-up

I merged main (52b9c0d4) and addressed the merge-blocking findings from the review.

Fixed

Not changed (non-blocking): #7 (a rebuild mid-validation rejects a pending external drop, which needs a sidebar rebuild inside a validation window of milliseconds), #8 (Mountable/Shortcut from foreign apps), #9 (serial validation, documented as intended), #10/#11 (rail-mode separators and pinned row spacing are visual polish and are best judged against the owner's screenshots), #12 (gap accessible groups, which the E2E uses to locate targets; worth a follow-up).

Verification: the targeted Rust tests for pinned_drop, directory_validation, the sidebar and clipboard (54 tests), plus new cases for gap fallback, adjacent-gap no-ops, and trash/web rejection. The pinned-container E2E for test_sidebar_pinning.py and test_locations.py passed (37). The full Rust suite, fmt and clippy also passed. These changes are non-visual, so there are no new screenshots.

@l0gicgate
l0gicgate marked this pull request as ready for review October 16, 2026 00:48
@blacksmith-sh

blacksmith-sh Bot commented Oct 16, 2026

Copy link
Copy Markdown

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
test_settings_text_size_keeps_switches_inside_the_page View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

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.

feat(sidebar): pin folders by dragging them into the sidebar

3 participants