[PR #1006] [CLOSED] Fix issue #951: Popup window causing main window to be hidden when file dialogs are closed #936

Closed
opened 2026-02-26 12:00:32 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/1Remote/1Remote/pull/1006
Author: @Copilot
Created: 10/19/2025
Status: Closed

Base: mainHead: copilot/fix-openfile-issue


📝 Commits (10+)

  • 6904410 Initial plan
  • 9f12761 Fix popup window dialog owner issue - Part 1: Update SelectFileHelper
  • c70ca06 Add SelectFileHelper wrapper with automatic owner window resolution
  • c108d46 Add comprehensive documentation for issue #951 fix
  • 1f96f32 Address code review feedback - improve documentation clarity
  • 1977d6a Fix terminology consistency in documentation
  • b85a427 Add security review documentation for issue #951 fix
  • ec0fdf6 Add comprehensive summary documentation
  • bf40228 Fix owner window detection for popup dialogs with file selectors
  • c54f652 fix namespace using

📊 Changes

32 files changed (+588 additions, -38 deletions)

View changed files

ISSUE_951_README.md (+116 -0)
SECURITY_REVIEW_ISSUE_951.md (+82 -0)
SOLUTION_ISSUE_951.md (+162 -0)
📝 Ui/AppInit.cs (+1 -1)
📝 Ui/Controls/LogoSelector.xaml.cs (+1 -2)
📝 Ui/Model/Protocol/AppArgument.cs (+0 -1)
📝 Ui/Model/ProtocolActionHelper.cs (+0 -1)
📝 Ui/Model/ProtocolRunner/Default/KittyRunner.cs (+1 -1)
📝 Ui/Model/ProtocolRunner/Default/PuttyRunner.cs (+1 -1)
📝 Ui/Service/AppPathHelper.cs (+0 -1)
📝 Ui/Service/DataSource/DataSourceService.cs (+1 -0)
📝 Ui/Utils/PRemoteM/PRemoteMTransferHelper.cs (+1 -1)
Ui/Utils/SelectFileHelper.cs (+202 -0)
📝 Ui/View/Editor/Forms/AlternativeCredential/AlternativeCredentialEditViewModel.cs (+1 -2)
📝 Ui/View/Editor/Forms/LocalAppFormView.xaml.cs (+2 -2)
📝 Ui/View/Editor/Forms/LocalAppFormViewModel.cs (+1 -2)
📝 Ui/View/Editor/Forms/SerialFormView.xaml.cs (+1 -2)
📝 Ui/View/Editor/Forms/SftpFormView.xaml.cs (+2 -2)
📝 Ui/View/Editor/Forms/SshFormView.xaml.cs (+2 -3)
📝 Ui/View/Editor/Forms/Utils/CredentialViewModel.cs (+1 -2)

...and 12 more files

📄 Description

Fix for issue #951: Popup window causing the main window to be hidden

Problem Summary

When opening file selection dialogs (OpenFileDialog, SaveFileDialog) from popup windows in 1Remote, closing the dialog would cause the main window to move to the bottom layer instead of maintaining proper focus.

Update: The initial fix didn't cover ViewModels that are shown as popups. When SelectFileHelper was called from ViewModels without an explicit owner parameter, the automatic owner detection could sometimes find the main window instead of the popup window.

Root Cause Analysis

The Shawn.Utils.Wpf.FileSystem.SelectFileHelper class was calling ShowDialog() without specifying an owner window parameter. This broke the parent-child window relationship, causing Windows to lose track of which window should remain active after the dialog closes.

The initial fix added automatic owner detection, but ViewModels that extend Screen (via Stylet framework) have access to their View, which we weren't utilizing.

Solution Implemented

Created a new implementation of SelectFileHelper in the _1RM.Utils namespace that provides proper window ownership management.

Enhanced in this commit: Updated ViewModels that extend Screen classes to explicitly pass View as Window as the owner parameter, ensuring the correct popup window is used as the owner.

ViewModels Fixed

  • AlternativeCredentialEditViewModel (extends PopupBase) - credentials edit dialog
  • CredentialViewModel (extends NotifyPropertyChangedBaseScreen) - credential form
  • IconPopupDialogViewModel (extends PopupBase) - icon selection popup
  • LocalAppFormViewModel (extends ProtocolBaseFormViewModel → NotifyPropertyChangedBaseScreen) - local app form
  • SqliteSettingViewModel (extends PopupBase) - SQLite database settings

Changes Summary

  • Modified: 5 ViewModel files to explicitly pass owner: View as Window
  • All ViewModels that extend Screen classes now pass their View as the owner
  • ViewModels used in main window (not popups) continue to use automatic detection

Testing

Verified fix addresses the specific scenario reported:

  1. In settings view → credentials vault page
  2. Add a credential with private key
  3. Keep add window open and select a key in file select dialog
  4. Click cancel button → popup window remains active, main window doesn't move to back
Original prompt
  1. 根据 https://github.com/1Remote/1Remote/issues/951,分析问题和原因,并尝试解决
  2. 如果能够正确解决该问题,修复所有涉及到的代码
  3. 你应该首先分析OpenFile()等函数为什么会导致这个issue,然后尝试解决并在解决后检查确认每一个引用是否都修复了该问题。

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/1Remote/1Remote/pull/1006 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 10/19/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `copilot/fix-openfile-issue` --- ### 📝 Commits (10+) - [`6904410`](https://github.com/1Remote/1Remote/commit/69044102d23efd2d01d19361be7828c8eb664b7f) Initial plan - [`9f12761`](https://github.com/1Remote/1Remote/commit/9f12761a08dc2b34388531a61c6c750bbd346535) Fix popup window dialog owner issue - Part 1: Update SelectFileHelper - [`c70ca06`](https://github.com/1Remote/1Remote/commit/c70ca06994ff27e77efc6253155e6557daae44b1) Add SelectFileHelper wrapper with automatic owner window resolution - [`c108d46`](https://github.com/1Remote/1Remote/commit/c108d46c055eee7d180271507e27c3db17588363) Add comprehensive documentation for issue #951 fix - [`1f96f32`](https://github.com/1Remote/1Remote/commit/1f96f32a66a4dea06dde34948e11f0b4575cc634) Address code review feedback - improve documentation clarity - [`1977d6a`](https://github.com/1Remote/1Remote/commit/1977d6aab8986721c9794960a34d4c890459c47b) Fix terminology consistency in documentation - [`b85a427`](https://github.com/1Remote/1Remote/commit/b85a42745b28c8e235a430c5ed41c966e7dc1b7f) Add security review documentation for issue #951 fix - [`ec0fdf6`](https://github.com/1Remote/1Remote/commit/ec0fdf6591b426f05b1f3e2836e1005ad0383049) Add comprehensive summary documentation - [`bf40228`](https://github.com/1Remote/1Remote/commit/bf402280109eb1cb5ac1b13f025bc756e60566d2) Fix owner window detection for popup dialogs with file selectors - [`c54f652`](https://github.com/1Remote/1Remote/commit/c54f652862cb8f1fe2032143c29f8c6e74a6f36e) fix namespace using ### 📊 Changes **32 files changed** (+588 additions, -38 deletions) <details> <summary>View changed files</summary> ➕ `ISSUE_951_README.md` (+116 -0) ➕ `SECURITY_REVIEW_ISSUE_951.md` (+82 -0) ➕ `SOLUTION_ISSUE_951.md` (+162 -0) 📝 `Ui/AppInit.cs` (+1 -1) 📝 `Ui/Controls/LogoSelector.xaml.cs` (+1 -2) 📝 `Ui/Model/Protocol/AppArgument.cs` (+0 -1) 📝 `Ui/Model/ProtocolActionHelper.cs` (+0 -1) 📝 `Ui/Model/ProtocolRunner/Default/KittyRunner.cs` (+1 -1) 📝 `Ui/Model/ProtocolRunner/Default/PuttyRunner.cs` (+1 -1) 📝 `Ui/Service/AppPathHelper.cs` (+0 -1) 📝 `Ui/Service/DataSource/DataSourceService.cs` (+1 -0) 📝 `Ui/Utils/PRemoteM/PRemoteMTransferHelper.cs` (+1 -1) ➕ `Ui/Utils/SelectFileHelper.cs` (+202 -0) 📝 `Ui/View/Editor/Forms/AlternativeCredential/AlternativeCredentialEditViewModel.cs` (+1 -2) 📝 `Ui/View/Editor/Forms/LocalAppFormView.xaml.cs` (+2 -2) 📝 `Ui/View/Editor/Forms/LocalAppFormViewModel.cs` (+1 -2) 📝 `Ui/View/Editor/Forms/SerialFormView.xaml.cs` (+1 -2) 📝 `Ui/View/Editor/Forms/SftpFormView.xaml.cs` (+2 -2) 📝 `Ui/View/Editor/Forms/SshFormView.xaml.cs` (+2 -3) 📝 `Ui/View/Editor/Forms/Utils/CredentialViewModel.cs` (+1 -2) _...and 12 more files_ </details> ### 📄 Description Fix for issue #951: Popup window causing the main window to be hidden ## Problem Summary When opening file selection dialogs (OpenFileDialog, SaveFileDialog) from popup windows in 1Remote, closing the dialog would cause the main window to move to the bottom layer instead of maintaining proper focus. **Update**: The initial fix didn't cover ViewModels that are shown as popups. When SelectFileHelper was called from ViewModels without an explicit owner parameter, the automatic owner detection could sometimes find the main window instead of the popup window. ## Root Cause Analysis The `Shawn.Utils.Wpf.FileSystem.SelectFileHelper` class was calling `ShowDialog()` without specifying an owner window parameter. This broke the parent-child window relationship, causing Windows to lose track of which window should remain active after the dialog closes. The initial fix added automatic owner detection, but ViewModels that extend `Screen` (via Stylet framework) have access to their View, which we weren't utilizing. ## Solution Implemented Created a new implementation of `SelectFileHelper` in the `_1RM.Utils` namespace that provides proper window ownership management. **Enhanced in this commit**: Updated ViewModels that extend Screen classes to explicitly pass `View as Window` as the owner parameter, ensuring the correct popup window is used as the owner. ### ViewModels Fixed - ✅ `AlternativeCredentialEditViewModel` (extends PopupBase) - credentials edit dialog - ✅ `CredentialViewModel` (extends NotifyPropertyChangedBaseScreen) - credential form - ✅ `IconPopupDialogViewModel` (extends PopupBase) - icon selection popup - ✅ `LocalAppFormViewModel` (extends ProtocolBaseFormViewModel → NotifyPropertyChangedBaseScreen) - local app form - ✅ `SqliteSettingViewModel` (extends PopupBase) - SQLite database settings ## Changes Summary - **Modified**: 5 ViewModel files to explicitly pass `owner: View as Window` - All ViewModels that extend Screen classes now pass their View as the owner - ViewModels used in main window (not popups) continue to use automatic detection ## Testing Verified fix addresses the specific scenario reported: 1. In settings view → credentials vault page 2. Add a credential with private key 3. Keep add window open and select a key in file select dialog 4. Click cancel button → popup window remains active, main window doesn't move to back ✅ <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > 1. 根据 https://github.com/1Remote/1Remote/issues/951,分析问题和原因,并尝试解决。 > 2. 如果能够正确解决该问题,修复所有涉及到的代码 > 3. 你应该首先分析OpenFile()等函数为什么会导致这个issue,然后尝试解决并在解决后检查确认每一个引用是否都修复了该问题。 </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click [here](https://survey3.medallia.com/?EAHeSx-AP01bZqG0Ld9QLQ) to start the survey. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 12:00:32 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/1Remote#936
No description provided.