Skip to content

Conversation

Jack251970
Copy link
Member

@Jack251970 Jack251970 commented Sep 17, 2025

Tried to fix issue 1945

@github-actions github-actions bot added this to the 2.1.0 milestone Sep 17, 2025
@Jack251970 Jack251970 added the bug Something isn't working label Sep 17, 2025
@Jack251970 Jack251970 changed the title Enlarge delay time Fix shell plugin focus issue Sep 17, 2025
@Jack251970 Jack251970 requested a review from Copilot September 17, 2025 13:09
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a shell plugin focus issue by implementing a more robust window focus mechanism and increasing delay timing. The changes address Windows' interference with Win+R keyboard shortcuts that were preventing proper focus restoration.

  • Increased Task.Delay from 50ms to 1000ms to better handle Windows' Win+R processing
  • Added a new BringToForegroundEx method that uses multiple Win32 APIs for reliable window focusing
  • Enhanced the focus mechanism to call the new method before setting text box focus

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
Main.cs Increased delay timing for Win+R handling from 50ms to 1000ms
MainViewModel.cs Added call to new BringToForegroundEx method before focusing text box
Win32Helper.cs Implemented comprehensive BringToForegroundEx method using Win32 APIs
NativeMethods.txt Added required Win32 API method declarations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +419 to 420
await Task.Delay(1000);
Context.API.FocusQueryTextBox();
Copy link
Preview

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The delay has been increased from 50ms to 1000ms, which is a 20x increase. This significantly impacts user experience by making the application feel unresponsive. Consider a more moderate increase (e.g., 100-200ms) or implement a retry mechanism with shorter delays.

Suggested change
await Task.Delay(1000);
Context.API.FocusQueryTextBox();
// Try to set focus up to 4 times with 50ms intervals (max 200ms)
for (int i = 0; i < 4; i++)
{
await Task.Delay(50);
Context.API.FocusQueryTextBox();
}

Copilot uses AI. Check for mistakes.

@Jack251970 Jack251970 closed this Sep 17, 2025
@Jack251970 Jack251970 deleted the test_focus branch September 17, 2025 18:16
@Jack251970
Copy link
Member Author

Cannot work

@jjw24 jjw24 removed this from the 2.1.0 milestone Sep 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants