Skip to content

fix: Move HandlePlatformFileDrop to window._wails internal API#4616

Merged
leaanthony merged 3 commits into
v3-alphafrom
v3-alpha-bugfix/4489-invalid-handle-platform-file-drop
Oct 2, 2025
Merged

fix: Move HandlePlatformFileDrop to window._wails internal API#4616
leaanthony merged 3 commits into
v3-alphafrom
v3-alpha-bugfix/4489-invalid-handle-platform-file-drop

Conversation

@leaanthony

@leaanthony leaanthony commented Oct 2, 2025

Copy link
Copy Markdown
Member

Summary

Fixes #4489 - Drag-and-drop broken with npm package @wailsio/runtime

The npm package @wailsio/runtime doesn't work for drag-and-drop because the Go backend calls window.wails.Window.HandlePlatformFileDrop(), but the npm package doesn't populate window.wails (by design for encapsulation).

Root Cause

PR #3295 (March 2024) intentionally removed window.wails assignment from the npm package to improve encapsulation. However, this broke platform handlers that the Go backend relies on.

Solution

Move HandlePlatformFileDrop from public API (window.wails) to internal API (window._wails), following the existing pattern used by other internal methods:

  • window._wails.invoke
  • window._wails.environment
  • window._wails.flags

Changes

  • Register handlePlatformFileDrop in window._wails namespace (index.ts:61)
  • Update Go backend to call window._wails.handlePlatformFileDrop() (webview_window.go:1501)
  • Use camelCase naming for consistency with other internal API methods
  • Rebuild bundled runtime with changes

Benefits

✅ npm package works without window.wails pollution
✅ Maintains encapsulation of public API
✅ Platform handlers clearly separated as internal
✅ Follows existing internal API conventions
✅ Multi-window support preserved via .bind()

Test plan

  • Test drag-and-drop with bundled runtime
  • Test drag-and-drop with npm package @wailsio/runtime
  • Test multi-window applications
  • Verify dropzone functionality works correctly

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of file drag-and-drop on desktop windows, ensuring correct registration and fewer errors across platforms.
  • Refactor
    • Updated runtime bindings and aligned public exports without changing the external API or behavior.
  • Chores
    • Adjusted frontend namespace for file-drop handling to use a more stable internal hook, with no user-facing impact.

Fixes #4489

## Problem
The npm package @wailsio/runtime doesn't work for drag-and-drop because
Go backend calls window.wails.Window.HandlePlatformFileDrop(), but the
npm package doesn't populate window.wails (by design for encapsulation).

## Root Cause
PR #3295 (March 2024) intentionally removed window.wails assignment from
the npm package to improve encapsulation. However, this broke platform
handlers that Go backend relies on.

## Solution
Move HandlePlatformFileDrop from public API (window.wails) to internal
API (window._wails), following the existing pattern:
- window._wails.invoke
- window._wails.environment
- window._wails.flags

## Changes
- Register handlePlatformFileDrop in window._wails namespace
- Update Go backend to call window._wails.handlePlatformFileDrop()
- Use camelCase naming for consistency with other internal API methods
- Rebuild bundled runtime with changes

## Benefits
✅ npm package works without window.wails pollution
✅ Maintains encapsulation of public API
✅ Platform handlers clearly separated as internal
✅ Follows existing internal API conventions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 2, 2025

Copy link
Copy Markdown

Deploying wails with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8ddb029
Status:🚫  Build failed.

View logs

@coderabbitai

coderabbitai Bot commented Oct 2, 2025

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@leaanthony has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 25 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 20660de and 8ddb029.

📒 Files selected for processing (1)
  • v3/UNRELEASED_CHANGELOG.md (1 hunks)

Walkthrough

Updates internal runtime exports, binds a platform file-drop handler to window._wails.handlePlatformFileDrop, and redirects the Go-side invocation to the new global. Adjusts mapped symbols for CancelError, CancellablePromise, and Window in the bundled runtime.

Changes

Cohort / File(s) Summary
Bundled runtime export remaps
v3/internal/assetserver/bundledassets/runtime.js
Remaps public exports: CancelError k→F, CancellablePromise B→H, Window G→S. No API shape changes indicated.
Internal runtime binding
v3/internal/runtime/desktop/@wailsio/runtime/src/index.ts
Binds Window.HandlePlatformFileDrop to window._wails.handlePlatformFileDrop with correct this context; retains System.invoke("wails:runtime:ready") and window._wails.invoke.
Go WebView callsite update
v3/pkg/application/webview_window.go
Switches call from window.wails.Window.HandlePlatformFileDrop(...) to window._wails.handlePlatformFileDrop(...).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant OS as OS/Platform (Drop)
  participant WV as WebView Window (Go)
  participant JS as Frontend JS (window._wails)
  participant RT as Runtime Window Handler

  OS->>WV: File(s) dropped
  WV->>JS: window._wails.handlePlatformFileDrop(files)
  JS->>RT: Invoke bound Window.HandlePlatformFileDrop(files)
  RT-->>WV: Process/dispatch to Go-side handlers
  note over JS,RT: Binding established in runtime src/index.ts
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

Bug, Javascript, Windows, runtime, v3-alpha, size:M

Suggested reviewers

  • Alpa-1

Poem

A file took a hop, a skip, a plop—drop!
I twitched my ears: “Bind the handle at the top!”
From _wails to Window, the path is clear,
No more lost parcels in midair.
Thump-thump—drag ‘n’ drop, my dear! 🐇📦

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description does not follow the repository’s required template headings and lacks sections for type of change, test configuration details, and the checklist items specified in the template. Please update the description to use the template’s "# Description" heading, include the "## Type of change" section with the appropriate checkbox, provide the "How Has This Been Tested?" and test configuration details, and complete the checklist at the end.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title clearly and concisely describes the key change of moving the HandlePlatformFileDrop method to window._wails and uses a standard "fix:" prefix, so it accurately reflects the primary intent of the changeset.
Linked Issues Check ✅ Passed The changes properly move HandlePlatformFileDrop to window._wails and update the Go backend invocation as required by issue #4489, which restores the broken drag-and-drop functionality on Windows based on the linked issue’s objectives.
Out of Scope Changes Check ✅ Passed All modified files—including the rebuilt runtime.js, index.ts, and webview_window.go—are directly related to the intended fix and runtime rebuild, and no unrelated or extraneous changes are present.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Oct 2, 2025

Copy link
Copy Markdown
Contributor

⚠️ Missing Changelog Update

Hi @leaanthony, please update v3/UNRELEASED_CHANGELOG.md with a description of your changes.

This helps us keep track of changes for the next release.

Updates UNRELEASED_CHANGELOG.md with the fix for #4489.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Oct 2, 2025
@leaanthony leaanthony merged commit 6665a3a into v3-alpha Oct 2, 2025
10 of 12 checks passed
@leaanthony leaanthony deleted the v3-alpha-bugfix/4489-invalid-handle-platform-file-drop branch October 2, 2025 02:01
@sonarqubecloud

sonarqubecloud Bot commented Oct 2, 2025

Copy link
Copy Markdown

Grantmartin2002 pushed a commit to Grantmartin2002/wails that referenced this pull request Apr 29, 2026
…app#4616)

* fix: Move HandlePlatformFileDrop to window._wails internal API

Fixes wailsapp#4489

## Problem
The npm package @wailsio/runtime doesn't work for drag-and-drop because
Go backend calls window.wails.Window.HandlePlatformFileDrop(), but the
npm package doesn't populate window.wails (by design for encapsulation).

## Root Cause
PR wailsapp#3295 (March 2024) intentionally removed window.wails assignment from
the npm package to improve encapsulation. However, this broke platform
handlers that Go backend relies on.

## Solution
Move HandlePlatformFileDrop from public API (window.wails) to internal
API (window._wails), following the existing pattern:
- window._wails.invoke
- window._wails.environment
- window._wails.flags

## Changes
- Register handlePlatformFileDrop in window._wails namespace
- Update Go backend to call window._wails.handlePlatformFileDrop()
- Use camelCase naming for consistency with other internal API methods
- Rebuild bundled runtime with changes

## Benefits
✅ npm package works without window.wails pollution
✅ Maintains encapsulation of public API
✅ Platform handlers clearly separated as internal
✅ Follows existing internal API conventions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* chore: Add changelog entry for drag-and-drop fix

Updates UNRELEASED_CHANGELOG.md with the fix for wailsapp#4489.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements or additions to documentation runtime v3-alpha

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant