Skip to content

Conversation

@0x5bfa
Copy link
Member

@0x5bfa 0x5bfa commented Nov 14, 2025

Vision towards NativeAOT in the Sidebar functionalities

The current Quick Access helper and its watcher is powered by the reflection-based Activator to instantiate the Quick Access's IShellFolder to enumerate Quick Access items instead of Win32 CoCreateInstance due to UWP limitations. This is now blocking us from leveraging NAOT for faster startup and Trimming for a smaller package size.

I have already refactored the codebase of the Home page, which is relatively ready for the next Storage Abstraction concept. However, that of the Sidebar controls is not yet at all, which is overly complicated and requires to a major refactoring for the NAOT/Trimming adoption.

The first example of the complication is the specifically implemented receivers of events that come from Quick Access, Drives, etc.

public async Task UpdateSectionVisibilityAsync(SectionType sectionType, bool show)
{
if (show)
{
var generalSettingsService = UserSettingsService.GeneralSettingsService;
Func<Task> action = sectionType switch
{
SectionType.CloudDrives when generalSettingsService.ShowCloudDrivesSection => CloudDrivesManager.UpdateDrivesAsync,
SectionType.Drives => drivesViewModel.UpdateDrivesAsync,
SectionType.Network when generalSettingsService.ShowNetworkSection => NetworkService.UpdateComputersAsync,
SectionType.WSL when generalSettingsService.ShowWslSection => WSLDistroManager.UpdateDrivesAsync,
SectionType.FileTag when generalSettingsService.ShowFileTagsSection => App.FileTagsManager.UpdateFileTagsAsync,
SectionType.Library => App.LibraryManager.UpdateLibrariesAsync,
SectionType.Pinned => App.QuickAccessManager.Model.AddAllItemsToSidebarAsync,
_ => () => Task.CompletedTask
};
Manager_DataChanged(sectionType, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
await action();
}
else
{
sidebarItems.Remove(sidebarItems.FirstOrDefault(x => x.Section == sectionType));
}
}

Secondly, the decoupled control SidebarView takes a view model for it. We should be passing references to DPs controlled in the MainPageViewModel instead of having a dedicated view model for this control.

<controls:SidebarView
x:Name="SidebarControl"
Grid.Row="2"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
DisplayMode="{x:Bind SidebarAdaptiveViewModel.SidebarDisplayMode, Mode=TwoWay}"
IsPaneOpen="{x:Bind ViewModel.IsSidebarPaneOpen, Mode=TwoWay}"
Loaded="SidebarControl_Loaded"
MenuItemsSource="{x:Bind SidebarAdaptiveViewModel.SidebarItems, Mode=OneWay}"
OpenPaneLength="{x:Bind UserSettingsService.AppearanceSettingsService.SidebarWidth, Mode=TwoWay}"
SelectedItem="{x:Bind SidebarAdaptiveViewModel.SidebarSelectedItem, Mode=TwoWay}"
ViewModel="{x:Bind SidebarAdaptiveViewModel}">

Thirdly, SidebarView is a UserControl instead of a control that derives from Control, so-called being a custom control. As aforementioned, since the control depends on an instance of a dedicated view model, there's a strong bond between this control and the view model. We should make use of events instead and isolate the control from the implementation details of the view model.

public sealed partial class SidebarView : UserControl, INotifyPropertyChanged


With these reasons, we should be going to refactor the sidebar implementations to get rid of the view model reference and to implement better bindings of sidebar items collection. This PR is the first one of the series of improvements, the next one would refactor the sidebar item models and probably replace the view model.

Resolved / Related Issues

Steps used to test these changes

Since this has no functionality change, this PR can be validated by just deploying and running the app.

  1. Open Files app
  • Ejected device
  • Opened properties window
  • Pinned item
  • Unpinned item
  • Hid section
  • Unhid section
  • Opened reorder items dialog
  • Created library
  • Restored libraries
  • Loaded shell extensions in the context menu
  • Resized sidebar
  • Double clicked to collapse sidebar
  • Confirmed sidebar state is saved across sessions
  • Confirmed the sidebar collapses on smaller windows
  • Confirmed the expanded state for sidebar sections is saved

@0x5bfa 0x5bfa force-pushed the 5bfa/CQ-QuickAccess branch from dd8a033 to d5ef98f Compare November 14, 2025 17:19
@yaira2 yaira2 added the ready for review Pull requests that are ready for review label Nov 26, 2025
@yaira2 yaira2 force-pushed the 5bfa/CQ-QuickAccess branch from d5ef98f to d5b5cd3 Compare December 2, 2025 20:23
@yaira2 yaira2 requested a review from marcelwgn December 2, 2025 20:23
@yaira2
Copy link
Member

yaira2 commented Dec 2, 2025

It looks like unhiding the "Pinned" and "Tags" sidebar sections causes the app to crash.

@yaira2 yaira2 added changes requested Changes are needed for this pull request and removed ready for review Pull requests that are ready for review labels Dec 2, 2025
Copy link
Contributor

@marcelwgn marcelwgn left a comment

Choose a reason for hiding this comment

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

Changes on their own look good but I can repro the crash, that needs to be addressed first.

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

Development

Successfully merging this pull request may close these issues.

3 participants