Skip to content

WIP: Fix drag-and-drop on Windows#1074

Draft
rly wants to merge 3 commits into
mainfrom
fix/windows-drag-and-drop
Draft

WIP: Fix drag-and-drop on Windows#1074
rly wants to merge 3 commits into
mainfrom
fix/windows-drag-and-drop

Conversation

@rly

@rly rly commented Mar 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #180

Problem

Drag-and-drop from Windows Explorer into NWB GUIDE does not work on Windows. This is caused by "requestedExecutionLevel": "requireAdministrator" in the electron-builder config (package.json), which forces the app to always run as Administrator. Windows enforces User Interface Privilege Isolation (UIPI), which blocks drag-and-drop from lower-privilege processes (like Explorer) into higher-privilege processes (the elevated Electron app). macOS has no equivalent restriction, which is why this only affects Windows.

This was identified as the root cause in electron/electron#12460.

Solution

  1. Change requestedExecutionLevel from "requireAdministrator" to "asInvoker" so the app runs at the same privilege level as Explorer, allowing drag-and-drop to work.

  2. Replace direct os.symlink calls with a create_link helper that gracefully handles the loss of guaranteed admin privileges. The app uses symlinks in two places:

    • Creating a directory symlink from the default conversion output path to a custom output directory (convert_to_nwb)
    • Creating file symlinks to aggregate NWB files into a temp directory for DANDI upload (_aggregate_symlinks_in_new_directory)

    On Windows, symlinks require either Administrator privileges or Developer Mode. Since we no longer guarantee admin, create_link uses the following fallback chain:

    • Try os.symlink — works if the user has Developer Mode enabled or is running as admin
    • Fall back to directory junctions (_winapi.CreateJunction) for directories — these never require admin
    • Fall back to hard links (os.link) for files — these don't require admin but require source and destination to be on the same drive
    • Raise a clear error if all options fail, advising the user to either run NWB GUIDE as Administrator or ensure files are on the same drive

    On non-Windows platforms, behavior is unchanged (always uses os.symlink).

Test plan

  • Test drag-and-drop on Windows without running as Administrator
  • Test conversion with a custom output directory on Windows
  • Test DANDI upload of multiple filesystem objects on Windows
  • Test that click-to-choose file selection still works
  • Verify no regressions on macOS

🤖 Generated with Claude Code

rly and others added 3 commits March 7, 2026 23:07
Change requestedExecutionLevel from requireAdministrator to asInvoker
so that Windows UIPI does not block drag-and-drop from Explorer into
the app. Replace direct symlink calls with a create_link helper that
falls back to directory junctions and hard links when symlinks are
unavailable without admin privileges.

Fixes #180

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address issues in the Windows drag-and-drop fix:

- Fix create_link crash: os.symlink's keyword is target_is_directory,
  not target_is_dir, so every symlink creation raised TypeError,
  including the primary path on macOS/Linux.
- Recognize junctions in the link teardown paths. is_symlink() returns
  False for Windows junctions, so convert_to_nwb previously took the
  rmtree branch on a junction and deleted the user's real output data
  through it. Add _is_link/_remove_link helpers and use them in
  convert_to_nwb and get_conversion_info; _remove_link removes the link
  without touching its target.
- Pass an absolute target to _winapi.CreateJunction (junctions require it).
- Raise the clear, actionable OSError when the directory-junction
  fallback fails, matching the file hard-link fallback.
- Add unit tests covering symlink/junction/hard-link creation, the
  data-loss teardown regression, and the failure error message.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

[Bug] Dragger for drag-and-drop is no longer working

1 participant