Skip to content

Fix per-user preview pane not working by detecting actual installation scope#23

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-22
Draft

Fix per-user preview pane not working by detecting actual installation scope#23
Copilot wants to merge 2 commits intomainfrom
copilot/fix-22

Conversation

Copy link

Copilot AI commented Jun 27, 2025

Problem

The preview pane modules were hardcoded to always register as per-user installations (installPerUser = true), regardless of whether PowerToys was actually installed per-machine or per-user. This caused preview handlers to be registered in the wrong registry scope, making them non-functional when PowerToys was installed per-machine.

Root Cause

Two key locations used hardcoded per-user values:

  • powerpreview.cpp:27 - PowerPreviewModule constructor
  • modulesRegistry.h:273,288 - getAllOnByDefaultModulesChangeSets() and getAllModulesChangeSets()

Solution

Replaced hardcoded true values with dynamic detection using the existing registry::install_scope::get_current_install_scope() function:

// Before:
const bool installPerUser = true;

// After:  
const bool installPerUser = (registry::install_scope::get_current_install_scope() == registry::install_scope::InstallScope::PerUser);

Changes Made

  1. powerpreview.cpp: Added #include <common/utils/registry.h> and replaced hardcoded installation scope detection
  2. modulesRegistry.h: Updated both registry ChangeSet functions to use dynamic scope detection

Expected Behavior

  • Per-Machine Installation: Preview handlers registered in HKEY_LOCAL_MACHINE
  • Per-User Installation: Preview handlers registered in HKEY_CURRENT_USER
  • Result: Preview pane functionality works correctly for both installation types

Impact

  • ✅ Fixes preview pane functionality for per-machine PowerToys installations
  • ✅ Maintains compatibility with per-user installations
  • ✅ Affects both runtime module behavior and MSI installer registry setup
  • ✅ No breaking changes to existing functionality

Fixes #22.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: lei9444 <39758135+lei9444@users.noreply.github.com>
Copilot AI changed the title [WIP] per user version preview pane not working Fix per-user preview pane not working by detecting actual installation scope Jun 27, 2025
Copilot AI requested a review from lei9444 June 27, 2025 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

per user version preview pane not working

2 participants