categories/UserExperience.ps1

# User Experience category: menu show delay, taskbar animations, transparency, Sticky Keys
# prompt. All HKCU (per-user), same precedent as explorer-start in feature 001 - no elevation
# required. research.md -> user-experience category table.
#
# ponytail: taskbar "drag tray" restriction was in scope per 006's original ask, but no
# confidently-documented registry mechanism was found (research.md) - dropped rather than
# shipping a guess.

function Get-OctaUserExperienceCategory {
    [CmdletBinding()]
    param()
    return [pscustomobject]@{
        Id                          = 'user-experience'
        DisplayName                 = 'User Experience'
        Description                 = 'Menu delay, taskbar animations, transparency'
        RequiresElevation           = $false
        ContainsIrreversibleActions = $false
        GetActionsFunction          = 'Get-OctaUserExperienceActions'
        ApplyActionFunction         = 'Set-OctaUserExperienceAction'
    }
}

function Get-OctaUserExperienceActions {
    [CmdletBinding()]
    param()
    $actions = @()

    $desktopKey = 'HKCU:\Control Panel\Desktop'
    $currentDelay = (Get-ItemProperty -Path $desktopKey -Name 'MenuShowDelay' -ErrorAction SilentlyContinue).MenuShowDelay
    if ($null -eq $currentDelay -or $currentDelay -ne '0') {
        $displayCurrent = if ($null -eq $currentDelay) { '(not set)' } else { $currentDelay }
        $actions += New-OctaAction -TargetType Registry -TargetIdentifier "$desktopKey|MenuShowDelay" `
            -CurrentValue $displayCurrent -PlannedValue '0' -Reversible $true -RiskLevel Safe
    }

    $advancedKey = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced'
    $currentAnimations = (Get-ItemProperty -Path $advancedKey -Name 'TaskbarAnimations' -ErrorAction SilentlyContinue).TaskbarAnimations
    if ($null -eq $currentAnimations -or $currentAnimations -ne 0) {
        $displayCurrent = if ($null -eq $currentAnimations) { '(not set)' } else { $currentAnimations }
        $actions += New-OctaAction -TargetType Registry -TargetIdentifier "$advancedKey|TaskbarAnimations" `
            -CurrentValue $displayCurrent -PlannedValue 0 -Reversible $true -RiskLevel Safe
    }

    $personalizeKey = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize'
    $currentTransparency = (Get-ItemProperty -Path $personalizeKey -Name 'EnableTransparency' -ErrorAction SilentlyContinue).EnableTransparency
    if ($null -eq $currentTransparency -or $currentTransparency -ne 0) {
        $displayCurrent = if ($null -eq $currentTransparency) { '(not set)' } else { $currentTransparency }
        $actions += New-OctaAction -TargetType Registry -TargetIdentifier "$personalizeKey|EnableTransparency" `
            -CurrentValue $displayCurrent -PlannedValue 0 -Reversible $true -RiskLevel Safe
    }

    $stickyKeysKey = 'HKCU:\Control Panel\Accessibility\StickyKeys'
    $currentFlags = (Get-ItemProperty -Path $stickyKeysKey -Name 'Flags' -ErrorAction SilentlyContinue).Flags
    if ($currentFlags -ne '506') {
        $displayCurrent = if ($null -eq $currentFlags) { '(not set)' } else { $currentFlags }
        $actions += New-OctaAction -TargetType Registry -TargetIdentifier "$stickyKeysKey|Flags" `
            -CurrentValue $displayCurrent -PlannedValue '506' -Reversible $true -RiskLevel Safe
    }

    return $actions
}

function Set-OctaUserExperienceAction {
    [CmdletBinding()]
    param([Parameter(Mandatory)]$Action)
    $keyPath, $valueName = $Action.TargetIdentifier -split '\|', 2
    if (-not (Test-Path $keyPath)) {
        New-Item -Path $keyPath -Force | Out-Null
    }
    $type = if ($valueName -in @('MenuShowDelay', 'Flags')) { 'String' } else { 'DWord' }
    Set-ItemProperty -Path $keyPath -Name $valueName -Value $Action.PlannedValue -Type $type
}