Skip to content

Fix app activation firing multiple times when launching multiple files#4

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-3
Draft

Fix app activation firing multiple times when launching multiple files#4
Copilot wants to merge 3 commits intomainfrom
copilot/fix-3

Conversation

Copy link
Copy Markdown

Copilot AI commented May 22, 2025

Problem

When a user selects multiple files in Windows Explorer (e.g., 5 image files) and opens them all at once with a single click, the application is activated multiple times. Each activation receives the same complete set of files in the FileActivatedEventArgs.Files collection, leading to duplicate processing.

This behavior is different from UWP where the app would only be activated once with all files, as expected.

Root Cause

When multiple files are selected and opened at once, Windows sends multiple activation events to the application. The Windows App SDK framework was forwarding each of these events as separate activations to the application, without detecting that they were duplicates containing the same set of files.

Solution

The fix implements a deduplication system that:

  1. Tracks file activations that have occurred in the last second
  2. Detects when an activation contains the same set of files as a recent activation
  3. Ignores duplicate activations, ensuring the app is only activated once per unique set of files

This change:

  • Maintains compatibility with the existing API surface
  • Requires no changes to application code that uses the Windows App SDK
  • Only applies to file activations, leaving other activation types unaffected
  • Only deduplicates activations that happen within 1 second of each other, which covers the typical multi-file selection scenario while allowing legitimate repeated activations

Test Scenario

To verify this fix, select multiple files of the same type in Windows Explorer and open them all at once. The application should now only be activated a single time, with all files available in the FileActivatedEventArgs.Files collection.

Fixes #3.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits May 22, 2025 06:03
Co-authored-by: MuyuanMS <116717757+MuyuanMS@users.noreply.github.com>
Co-authored-by: MuyuanMS <116717757+MuyuanMS@users.noreply.github.com>
Copilot AI changed the title [WIP] App activation fires multiple times when launching multiple files Fix app activation firing multiple times when launching multiple files May 22, 2025
Copilot AI requested a review from MuyuanMS May 22, 2025 06:05
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.

App activation fires multiple times when launching multiple files

2 participants