WIP: Fix drag-and-drop on Windows#1074
Draft
rly wants to merge 3 commits into
Draft
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Change
requestedExecutionLevelfrom"requireAdministrator"to"asInvoker"so the app runs at the same privilege level as Explorer, allowing drag-and-drop to work.Replace direct
os.symlinkcalls with acreate_linkhelper that gracefully handles the loss of guaranteed admin privileges. The app uses symlinks in two places:convert_to_nwb)_aggregate_symlinks_in_new_directory)On Windows, symlinks require either Administrator privileges or Developer Mode. Since we no longer guarantee admin,
create_linkuses the following fallback chain:os.symlink— works if the user has Developer Mode enabled or is running as admin_winapi.CreateJunction) for directories — these never require adminos.link) for files — these don't require admin but require source and destination to be on the same driveOn non-Windows platforms, behavior is unchanged (always uses
os.symlink).Test plan
🤖 Generated with Claude Code