-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Code Quality: Sync the jump list with Explorer #17564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
71afbb3 to
9eb7ae9
Compare
97999e5 to
806f922
Compare
278a971 to
33efe98
Compare
|
This might help with #14526 |
|
Would this fix #17659 |
|
Yes. This is one of the motivation. (I updated the PR to include this) |
a038857 to
3669604
Compare
9daefd6 to
032a523
Compare
7529df0 to
ec45efa
Compare
edbda5e to
816fcdc
Compare
There was a problem hiding this 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 pull request implements synchronization of jump lists between Files and Windows Explorer, replacing the existing WindowsJumpListService with a new JumpListManager that uses undocumented COM APIs (IAutomaticDestinationList and IInternalCustomDestinationList). The implementation watches for changes in both Explorer's and Files' jump list files and bidirectionally syncs them, providing a more robust jump list experience.
Changes:
- Removed the WinRT-based WindowsJumpListService and replaced it with a new JumpListManager using native COM APIs
- Added comprehensive CsWin32 definitions for undocumented COM interfaces and helper structures
- Implemented bidirectional file watcher-based synchronization between Files and Explorer jump lists
Reviewed changes
Copilot reviewed 29 out of 30 changed files in this pull request and generated 31 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Files.App/ViewModels/ShellViewModel.cs | Updated to call JumpListManager.AddFolderToRecentCategory instead of the removed service |
| src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs | Removed jump list service usage from filesystem operations |
| src/Files.App/Strings/en-US/Resources.resw | Removed unused "JumpListPinnedGroupHeader" resource string |
| src/Files.App/Services/Windows/WindowsJumpListService.cs | Completely removed old WinRT-based jump list service implementation |
| src/Files.App/Helpers/Application/AppLifecycleHelper.cs | Added JumpListManager initialization in STATask with environment-specific configuration |
| src/Files.App/Data/Contracts/IWindowsJumpListService.cs | Removed service interface |
| src/Files.App/App.xaml.cs | Added JumpListManager disposal on window close |
| src/Files.App.Storage/Windows/Managers/JumpListManager.cs | New comprehensive jump list manager with bidirectional sync capabilities |
| src/Files.App.Storage/Windows/Managers/JumpListItemType.cs | Removed unused enum |
| src/Files.App.Storage/Windows/Managers/JumpListItem.cs | Removed unused class |
| src/Files.App.Storage/Windows/Managers/JumpListDestinationType.cs | Removed unused enum |
| src/Files.App.Storage/Windows/Helpers/WindowsStorageHelpers.System.cs | Added system helper methods for environment variables and indirect strings |
| src/Files.App.Storage/Windows/Helpers/WindowsStorableHelpers.Storage.cs | Added GetRecentFolderPath helper |
| src/Files.App.CsWin32/NativeMethods.txt | Added numerous native methods and constants for jump list operations |
| src/Files.App.CsWin32/ManualPInvokes.cs | Reorganized and added manual P/Invoke definitions |
| src/Files.App.CsWin32/ManualMacros.cs | Added SUCCEEDED/FAILED macros for HRESULT checking |
| src/Files.App.CsWin32/ManualGuids.cs | Added GUIDs for jump list COM interfaces and classes |
| src/Files.App.CsWin32/ManualDelegates.cs | Split delegate definitions into separate file |
| src/Files.App.CsWin32/ManualConstants.cs | Split constants into separate file |
| src/Files.App.CsWin32/IInternalCustomDestinationList.cs | New undocumented COM interface definition |
| src/Files.App.CsWin32/IDCompositionTarget.cs | Split into separate file |
| src/Files.App.CsWin32/IAutomaticDestinationList.cs | New undocumented COM interface definition |
| src/Files.App.CsWin32/HeapPtr`1.cs | New heap pointer management structure |
| src/Files.App.CsWin32/HRESULT.cs | Added E_NOT_SET constant |
| src/Files.App.CsWin32/Extras.cs | Removed (split into separate files) |
| src/Files.App.CsWin32/ComPtr`1.cs | Added CopyTo and InternalAddRef methods |
| src/Files.App.CsWin32/ComHeapPtr`1.cs | Enhanced with Attach, Detach, Allocate, and Reallocate methods |
| src/Files.App.BackgroundTasks/UpdateTask.cs | Updated to delete jump list binary files on update |
| src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj | Added reference to Files.App.Storage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6986e15 to
954b1fc
Compare
|
Copilot review is so spammy :( Anyway, all done. PTAL. |
|
The list of pinned items in the sidebar no longers updates when I make a change from File Explorer. |
|
After the most recent commit, any changes to the jumplist causes the app to freeze. |
77c2c7a to
e236a0d
Compare
ad2854f to
2326930
Compare
| public WindowsStorable() | ||
| { | ||
| void* globalInterfaceTable; | ||
| PInvoke.CoCreateInstance(CLSID.CLSID_StdGlobalInterfaceTable, null, CLSCTX.CLSCTX_INPROC_SERVER, IID.IID_IGlobalInterfaceTable, &globalInterfaceTable); | ||
| _globalInterfaceTable = (IGlobalInterfaceTable*)globalInterfaceTable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The CoCreateInstance call in the WindowsStorable constructor does not check the returned HRESULT, which can lead to a null pointer dereference if the call fails.
Severity: HIGH
Suggested Fix
Check the HRESULT returned by PInvoke.CoCreateInstance. If it indicates failure, throw an exception to prevent the object from being created in an invalid state. This aligns with the error handling pattern used for similar COM object creations elsewhere in the repository, such as using .ThrowIfFailedOnDebug().
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/Files.App.Storage/Windows/WindowsStorable.cs#L66-L70
Potential issue: The constructor for `WindowsStorable` calls `PInvoke.CoCreateInstance`
to create a `GlobalInterfaceTable` but does not check the returned HRESULT for failure.
If this call fails, for instance due to low system resources or COM initialization
issues, the `_globalInterfaceTable` field will be an invalid or null pointer. Subsequent
access to properties like `ThisPtr` or `ContextMenu` will attempt to dereference this
pointer without a null check, leading to a null pointer dereference and an application
crash. This is inconsistent with other parts of the codebase where `CoCreateInstance`
results are always checked.
Resolved / Related Issues
TODOs
Steps used to test these changes