Skip to content

Conversation

@0x5bfa
Copy link
Member

@0x5bfa 0x5bfa commented Sep 7, 2025

Resolved / Related Issues

TODOs

  • Completely deletes the binaries for the Files' jump list on startup and on every update
  • Watches the changes to the Explorer's jump list
  • Watches the changes to the Files' jump list
  • Replicates the Explorer's jump list to the Files' jump list
  • Replicates the Files' jump list to the Explorer's jump list

Steps used to test these changes

  • Build the app
  • Cold-launch the app
  • See its jump list being the same as the Explorer's jump list
  • Pin/unpin an item from the Explorer's jump list
  • See that of Files also gets updated
  • Do the way around of above
image image

@0x5bfa 0x5bfa force-pushed the 5bfa/CQ-JumpListManager branch from 71afbb3 to 9eb7ae9 Compare September 7, 2025 17:00
@0x5bfa 0x5bfa changed the title Code Quality: Sync the jump list with Explorer Code Quality: Sync the jump list with Explorer at the startup Sep 7, 2025
@yaira2 yaira2 added the ready for review Pull requests that are ready for review label Sep 7, 2025
@0x5bfa 0x5bfa marked this pull request as draft September 9, 2025 19:04
@yaira2 yaira2 force-pushed the main branch 2 times, most recently from 97999e5 to 806f922 Compare September 9, 2025 21:12
@0x5bfa 0x5bfa force-pushed the 5bfa/CQ-JumpListManager branch 3 times, most recently from 278a971 to 33efe98 Compare September 11, 2025 09:45
@0x5bfa 0x5bfa marked this pull request as ready for review September 11, 2025 09:45
@0x5bfa 0x5bfa changed the title Code Quality: Sync the jump list with Explorer at the startup Code Quality: Sync the jump list with Explorer Sep 14, 2025
@yaira2
Copy link
Member

yaira2 commented Sep 14, 2025

This might help with #14526

@Josh65-2201
Copy link
Member

Would this fix #17659

@yaira2
Copy link
Member

yaira2 commented Sep 19, 2025

Would this fix #17659

I think so. @0x5bfa can you confirm?

@0x5bfa
Copy link
Member Author

0x5bfa commented Sep 19, 2025

Yes. This is one of the motivation. (I updated the PR to include this)

@0x5bfa 0x5bfa force-pushed the 5bfa/CQ-JumpListManager branch from a038857 to 3669604 Compare September 29, 2025 14:53
@yaira2 yaira2 removed the ready for review Pull requests that are ready for review label Sep 29, 2025
@yaira2 yaira2 marked this pull request as draft September 29, 2025 22:14
@0x5bfa 0x5bfa force-pushed the 5bfa/CQ-JumpListManager branch from 9daefd6 to 032a523 Compare September 30, 2025 13:04
@yaira2 yaira2 force-pushed the 5bfa/CQ-JumpListManager branch from 7529df0 to ec45efa Compare November 15, 2025 23:46
@0x5bfa 0x5bfa force-pushed the 5bfa/CQ-JumpListManager branch 2 times, most recently from edbda5e to 816fcdc Compare November 16, 2025 15:31
Copy link
Contributor

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 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.

@0x5bfa 0x5bfa force-pushed the 5bfa/CQ-JumpListManager branch from 6986e15 to 954b1fc Compare January 29, 2026 10:13
@0x5bfa
Copy link
Member Author

0x5bfa commented Jan 29, 2026

Copilot review is so spammy :(

Anyway, all done. PTAL.

@yaira2
Copy link
Member

yaira2 commented Jan 29, 2026

The list of pinned items in the sidebar no longers updates when I make a change from File Explorer.

@yaira2
Copy link
Member

yaira2 commented Feb 1, 2026

After the most recent commit, any changes to the jumplist causes the app to freeze.

@0x5bfa 0x5bfa force-pushed the 5bfa/CQ-JumpListManager branch from 77c2c7a to e236a0d Compare February 2, 2026 10:20
This reverts commit e236a0d.
if (!fRes) return null;

fixed (char* pSource = source)
hr = PInvoke.SHLoadIndirectString(pSource, pszBuffer.Get(), 1024U, null);

This comment was marked as outdated.

@0x5bfa 0x5bfa force-pushed the 5bfa/CQ-JumpListManager branch from ad2854f to 2326930 Compare February 2, 2026 20:58
Comment on lines +56 to +60
public bool Allocate(nuint cch)
{
_ptr = (T*)NativeMemory.Alloc(cch); // malloc()
return _ptr is not null;
}

This comment was marked as outdated.

Comment on lines +66 to +70
public WindowsStorable()
{
void* globalInterfaceTable;
PInvoke.CoCreateInstance(CLSID.CLSID_StdGlobalInterfaceTable, null, CLSCTX.CLSCTX_INPROC_SERVER, IID.IID_IGlobalInterfaceTable, &globalInterfaceTable);
_globalInterfaceTable = (IGlobalInterfaceTable*)globalInterfaceTable;
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changes requested Changes are needed for this pull request

Projects

None yet

3 participants