A user reported that the CPU affinity feature did nothing when applying a
rule. Two distinct defects were behind it.
ProcessService.SetProcessorAffinity(process, long) silently substituted
SetProcessDefaultCpuSets for the hard affinity write. CPU Sets are only a
soft scheduling hint and leave the mask returned by GetProcessAffinityMask
untouched, so the single caller - AffinityApplyService.ApplyAsync, which
reads the mask back and compares - always reported VerificationMismatch.
The Rules tab path (ProcessMonitorManagerService association core masks)
therefore failed while the affinity never changed. Reproduced on a 16-CPU
machine: requesting 0x3 left the process at 0xFFFF and returned a failure.
The overload now writes the affinity mask it was asked for; soft assignment
keeps its own entry points (CpuAssignmentMode.CpuSets, CpuSelectionAffinityApplier).
The shipped DefaultCpuAssignmentMode was Automatic, which is CPU-Sets-first,
so out of the box "Apply CPU Assignment" produced no change visible in Task
Manager while reporting success. The default is now AffinityMask, and the
CPU Sets result message states that it is a soft preference rather than
claiming "Affinity applied successfully".
Save Current Settings as Rule only captured the core selection while edits
were staged, otherwise falling back to process.ProcessorAffinity - which
soft modes never change - saving a rule pinned to every CPU. It now captures
what the core checkboxes show.
Adds a regression test that spawns a real process and asserts the hard
affinity mask actually changes; it fails on the previous implementation.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AhS1xyuMPFvxrojERQ4NuY
Verify persisted Windows tweak state on startup, modernize selection styling, and make in-app updates check every launch, install automatically after consent, preserve settings, and relaunch ThreadPilot.
## Summary
Adds a safe in-app updater for ThreadPilot. This PR does not bump the app version and does not prepare a release; version and release metadata will be handled separately for v1.4.0.
## Type of Change
- [x] Feature
- [x] Security hardening
- [x] Documentation
- [x] Added/updated tests
## Update flow
- Checks for updates on demand from Settings.
- Performs background startup checks only when enabled and the last check is older than the configured interval.
- Defaults to a 7-day interval.
- Excludes prereleases by default.
- Notifies users when an update is available.
- Requires explicit user action before download/install.
## Security and safety
- Uses release metadata from the official `PrimeBuild-pc/ThreadPilot` repository only.
- Selects safe ThreadPilot installer assets from GitHub HTTPS release assets.
- Downloads into a ThreadPilot-owned temp update directory.
- Verifies SHA256 checksums when `SHA256SUMS.txt` is available.
- Rejects checksum mismatches.
- Performs best-effort Authenticode verification and rejects explicitly invalid signatures.
- Starts the installer elevated without shell command construction.
- Prevents concurrent install attempts.
## User data preservation
- Update flow does not delete AppData, settings, profiles, CPU masks, rules, custom/imported power plans, or logs.
- Only updater temp files are cleaned.
- Full uninstall behavior remains separate.
## Validation
- `dotnet restore ThreadPilot_1.sln`: passed
- `dotnet build ThreadPilot_1.sln`: passed, 0 warnings, 0 errors
- `dotnet test ThreadPilot_1.sln`: passed, 537 tests
## Release note
This PR intentionally leaves `ThreadPilot.csproj` at `1.3.1`. The `1.4.0` version bump, changelog, packaging metadata, and tag should happen in a separate release-prep branch after this PR is merged.
Adds English/Chinese localization infrastructure with en-US as default, zh-CN as optional language, safe fallback behavior, settings integration, localized notifications, and expanded test coverage.
* Fix startup binding and prep v1.2.0
* Polish v1.2.0 validation UX
* Fix final v1.2.0 validation polish
* Make Activity Logs a ThreadPilot audit trail
* Fix high scheduling registry value
* Polish process list and automation settings UX
* Fix process context menu separator styling
* Theme process context menu visuals
* Stabilize process context menu styling
* Remove process menu icon gutter
* Polish startup and idle process refresh
* Finalize PR22 release polish
Apply persistent rules when processes start
Wire persistent process rules into runtime process discovery so existing enabled rules can apply automatically while ThreadPilot is running.
- Add PersistentRuleAutoApplyService for runtime rule auto-apply
- Hook auto-apply into ProcessMonitorManagerService snapshot and process-start paths
- Add ApplyPersistentRulesOnProcessStart app setting enabled by default
- Use existing PersistentRulesEngine for CpuSelection, legacy affinity, CPU priority and memory priority
- Add per-process/rule cooldown to avoid repeated apply spam
- Clear cooldown state when processes exit or disappear from snapshots
- Preserve safe protected-process and access-denied behavior without bypass claims
- Preserve cancellation semantics during shutdown/stop paths
- Add tests for matching rules, disabled/no-match cases, cooldown, retry, PID reuse, failures, feature flag and monitor integration
No Windows Service, registry/IFEO persistence, installer changes, rules editor, version bump or tag changes.
Migrate Process tab manual affinity apply to CpuSelection
Route manual Process tab affinity operations through a topology-aware coordinator so CpuSelection and CPU Sets are preferred over legacy long masks.
- Add ProcessAffinityApplyCoordinator for manual Process tab affinity apply
- Prefer CoreMask.CpuSelection when available
- Migrate legacy BoolMask selections to CpuSelection when topology is available
- Block unsafe legacy fallback for selections above CPU64
- Keep legacy long mask fallback only for safe single-group <=64 selections
- Wire SetAffinity, ApplyCoreMaskToProcessAsync and QuickApplyAffinityAndPowerPlan through the coordinator
- Document CoreMask.ToProcessorAffinity as legacy-only
- Ensure ProcessViewModel fallback coordinator receives topology provider
- Add regression tests for CPU64, multi-group, safe legacy fallback, migration and protected-process messages
No UI redesign, preset generator, memory priority, persistent rules engine, migration logic, version or tag changes.
Add process memory priority foundation
Introduce backend support for process memory priority using Windows GetProcessInformation and SetProcessInformation while keeping the feature testable and safe.
- Add ProcessMemoryPriority model with documented Windows memory priority levels
- Add fakeable native API wrapper for process memory priority
- Add ProcessMemoryPriorityService with safe error handling
- Add ProcessOperationResult for process operation outcomes
- Extend persistent process rules with memory priority support
- Apply memory priority through PersistentRulesEngine when configured
- Preserve anti-cheat/protected-process safety messaging
- Add tests for native get/set, invalid process, access denied, unsupported API, enum mapping, persistent rules and JSON roundtrip
No UI redesign, registry/IFEO persistence, Windows Service, preset generator, migration, version or tag changes.
Add persistent rules engine foundation
Introduce the foundation for Apply at process start without adding a background loop, Windows Service, installer changes, registry affinity or anti-cheat bypass behavior.
- Add PersistentProcessRule and PersistentRuleApplyResult models
- Add process-name and executable-path rule matching
- Add PersistentRulesEngine using existing safe affinity and priority services
- Add JSON-backed persistent rule store
- Add safe Apply at process start user-facing copy
- Validate incomplete rules so missing affinity/priority payloads fail safely
- Add tests for matching, CpuSelection, legacy affinity, priority, Realtime guardrails, access denied, protected processes, process exit, disabled rules and storage roundtrip
No process monitor hook, UI management, Windows Service, registry/IFEO expansion, version bump or tag changes.
Migrate profiles and core masks to CpuSelection
Add a conservative compatibility layer for moving persisted profiles and core masks toward topology-aware CpuSelection while preserving legacy fields.
- Add profile schema version constants and CpuSelection migration metadata
- Add ProcessProfileSnapshot with legacy ProcessorAffinity plus optional CpuSelection
- Extend ProfileModel and CoreMask with CpuSelection fields without removing legacy data
- Add CpuSelectionMigrationService for legacy affinity mask and bool core mask conversion
- Preserve legacy mask build-back only when CpuSelection is safely representable
- Wire profile save/load to read and persist CpuSelection when topology is available
- Wire core mask load/save to attach CpuSelection metadata while keeping BoolMask
- Return failure when CpuSelection profile application fails
- Add tests for CPU64 alias protection, multi-group safety, topology signature review, legacy/v2 JSON compatibility and profile load behavior
No UI, preset generator, registry/IFEO, priority guardrail, X3D detection, version or tag changes.
Add topology-aware CPU preset generator foundation
Introduce a topology-derived preset generator for safe default CPU affinity suggestions without relying on CPU SKU hardcoding.
- Add CpuPreset, ICpuPresetGenerator and CpuPresetGenerationOptions
- Generate deterministic presets for all cores, physical/no-SMT, all except CPU0, P/E cores, L3 group physical cores, best gaming and safe compatibility
- Add SourcePresetId for best-gaming while keeping Reason user-facing
- Use CpuTopologySnapshot metadata such as CoreIndex, EfficiencyClass, L3/cache groups and SMT siblings
- Avoid X3D/3D V-Cache preset generation until reliable detection is available
- Register the generator for future UI/profile phases
- Add tests for SMT, hybrid P/E cores, dual CCD, >64 logical processors, deleted presets and missing CoreIndex
No UI, profile migration, runtime affinity apply, ProcessService, registry/IFEO, version or tag changes.
Add CPU topology provider abstraction
Introduce ICpuTopologyProvider and WindowsCpuTopologyProvider for topology-aware CPU detection using Windows CPU Sets and logical processor relationship APIs.
- Extend CpuTopologySnapshot with core, NUMA, L3/cache, package and SMT sibling metadata
- Add WindowsCpuTopologyNativeLayout for testable Win32 native layout parsing
- Add group-aware fallback processor generation for >64 logical processors
- Add simulated topology tests for multi-group, hybrid efficiency classes, SMT on/off, L3 groups and >64 LP systems
No runtime affinity, ProcessService, ProcessCpuSetHandler, UI, preset or profile migration behavior changes.
* Improve background refresh and process detection
* Harden affinity and power plan automation
* Fix passive process refresh failures
* Improve UX terminology and process layout
* Polish UX layout and empty states
* Expand core service test coverage
Move and centralize MainWindow behavior/logic into a new partial file and tidy related viewmodel/service code.
- Add MainWindow.Behaviors.partial.cs containing initialization, loading overlay, view model loading, service setup, system tray management, monitoring lifecycle, keyboard shortcuts, elevation/performance overlays, graceful shutdown and related helpers (moved out of MainWindow.xaml.cs).
- Remove duplicated behavior code from MainWindow.xaml.cs.
- Add ProcessViewModel.Behaviors.partial.cs and update ViewModels/ProcessViewModel.cs to separate behavior logic from core viewmodel.
- Update Models/ProcessModel.cs and services (GameDetectionService.cs, ProcessMonitorService.cs, ProcessService.cs) to align with the refactor and improve robustness (timeouts, fallbacks, logging and error handling).
Reason: reduce MainWindow.xaml.cs size, improve separation of concerns and maintainability, and introduce more resilient startup/shutdown and tray/update logic.
Add comprehensive CI and release improvements (coverage collection, Codecov upload, SBOM generation), split release workflow into build/smoke-test/release stages with deterministic version resolution, artifact uploads, winget manifest updates and changelog generation. Add a pre-commit hook to block large or unwanted artifacts. Introduce runtime improvements: smoke-test startup mode, improved unhandled/dispatcher/task-exception reporting, ThreadPilotException error codes, single-instance behavior adjustments, and logging enhancements. UI and UX changes include a new Logs tab and LogViewer wiring, DWM title-bar theming helper, navigation serialization/unsaved-changes guard, system-tray update backoff logic, and related viewmodel/service integrations. Also add installer template, helper classes, tests, docs, packaging and build scripts, and minor .gitignore updates.
Bump release to v1.1.1 and add release/build packaging, installer and onboarding enhancements. Key changes:
- Version bump across csproj, README and release assets to 1.1.1.
- CI/workflow: copy bundled Powerplans into single-file output, install Inno Setup, build Inno Setup installer, include installer artifacts in GitHub release, and stage unified package zips with uninstall/license files.
- Installer: update InstallScript (setup.iss) to point to staged artifacts, include Powerplans folder, and output installer to artifacts/release/installer.
- App startup/elevation: requireAdministrator manifest and App.xaml.cs now requests elevation early, terminating non-elevated instance when elevation is requested/declined.
- UX: add Performance first-run onboarding overlay (modal with blurred background), updated loading overlay visuals, and related MainWindow logic to show/hide intro and persist seen state.
- Settings & config: implement export/import configuration bundle (JSON) with Save/Open dialogs, add ReplaceConfigurationAsync and CloneConfiguration in association service, and adjust settings view labels.
- Power plan features: add PowerPlanService.AddCustomPowerPlanFileAsync and UI/command to add .pow files; adjust Import/Apply button labels.
- Performance tweaks: reduce power plan change delay from 1000ms to 250ms in config, models and viewmodels.
- Theme detection: improve ThemeService to resolve registry values and fallback to system theme helper.
- Misc: various logging/status improvements, packaging script fixes (build-release/build-msix), and added package-release-zips script.
These changes prepare the project for a formal 1.1.1 release with installer distribution, improved elevation handling and onboarding, plus enhanced import/export and custom power plan support.
Replaces the project's license from GNU GPL v3 to the GNU Affero General Public License v3: updated LICENSE (full AGPL text) and updated license headers across source files. Adds InternalsVisibleTo("ThreadPilot.Core.Tests") (plus using System.Runtime.CompilerServices) in AssemblyInfo to allow test access to internal types. Also introduces Services/TaskSafety.cs and two new test files under Tests/ThreadPilot.Core.Tests to cover task safety. These changes apply the AGPLv3 terms and enable internal API access for unit tests.
Multiple improvements across theming, UI flow, performance refresh logic, and CI:
- Add CI DevSecOps GH Action workflow: .NET restore/build (Debug/Release), dependency audit, and gitleaks secret scan.
- Theming: preload and apply theme at startup; add HasUserThemePreference to settings model; detect legacy theme flag when loading settings; ThemeService now reads system theme from registry (GetSystemUsesDarkTheme) and exposes system-use check.
- Richer theme resources: major updates to FluentDark.xaml and FluentLight.xaml (expanded color palette, control styles/templates, system brushes) to modernize visuals and controls.
- Startup/UI behavior: improved autostart/minimize-to-tray handling, consistent ShowInTaskbar/Visibility logic, OnSourceInitialized hook to reapply caption theme, and apply DWM immersive dark caption via DwmSetWindowAttribute.
- Robust UI error handling: throttle dispatcher exception dialog to avoid multiple dialogs using an interlocked flag and short time window.
- MainWindow refactor: introduce ShowWindowFromTray helper, unify show/activate flows, apply caption theming, and adjust several shortcut handlers to use the helper.
- Tab switching: add SemaphoreSlim guard and improved selection logic to debounce concurrent tab changes; prompt/save/discard unsaved settings when switching away from Settings; dispose semaphore on shutdown.
- PerformanceViewModel: debounce/gate top-process refreshes with SemaphoreSlim and a pending flag to avoid overlapping refreshes; update TopCpuProcesses on UI dispatcher and refresh selected process impact safely.
- Misc: small XAML cleanups (Settings tab header simplification), add COMPLIANCE_AUDIT.md to .gitignore, and various logging/error message tweaks.
These changes aim to reduce UI flicker on startup, respect user/system theme preferences, harden UI interactions, prevent concurrent refresh race conditions, and add CI/DevSecOps checks.
Large changeset adding documentation, themes, converters and wiring between UI and services. Key changes:
- Rewrote .gitignore to standardize build, IDE, OS and project-specific ignores.
- Added comprehensive documentation: ADVANCED_CPU_FEATURES.md, API_REFERENCE.md, ARCHITECTURE_GUIDE.md, DEVELOPER_GUIDE.md, GAME_BOOST_VALIDATION.md, CLAUDE.md, PROJECT_STRUCTURE.md, UI_STYLE_GUIDE.md, TRADEMARK.md.
- Added theme resources (Themes/FluentLight.xaml, Themes/FluentDark.xaml) and merged FluentLight into App.xaml resource dictionary.
- Added NullToBoolConverter and registered it in App.xaml.
- Enabled a DEBUG-only console test mode in App.xaml.cs (--test flag) and guarded AllocConsole with #if DEBUG.
- Added new service/support files (AtomicFileWriter, StoragePaths, ThemeService) and numerous updates across Services (CpuTopologyService, CoreMaskService, PowerPlanService, ProcessMonitorManagerService, ProcessService, NotificationService, SystemTrayService, SystemTweaksService, EnhancedLoggingService, etc.).
- Updated many ViewModels and Views to support new functionality (CPU topology, power plan and game-boost features) and tests (Tests/TestRunner.cs).
- Added build-release.ps1 and various project metadata updates.
Overall this commit introduces documentation, theming, new converters and test/debug support, plus extensive service and UI wiring for CPU topology, process monitoring, power plans and game boost features.