22 Commits

Author SHA1 Message Date
PrimeBuild-pc 7f75d41a36 fix: migrate saved rules off Automatic, not just profiles
1.7.2 moved profiles off Automatic because it applies only Windows CPU Sets,
a soft preference that leaves the affinity mask in Task Manager unchanged. It
did not move the rules already written to persistent_rules.json: a rule stores
the mode it was saved with, so every rule captured before 1.7.1 kept applying
CPU Sets on each process start - invisible to the user, and indistinguishable
from a rule that never runs at all.

ApplyToRules moves those once. Only rules carrying a CpuSelection: with a
legacy mask Automatic already applies a real affinity, and rewriting a working
rule buys nothing. A deliberate CpuSets or IdealProcessor choice is left alone.

The flag is deliberately separate from the profile one. Sharing it would skip
the rules of everyone who already launched 1.7.2, which is most of the people
this fixes. It is persisted only after the rules reach disk, so a failed write
is retried on the next launch instead of being recorded as done.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 23:38:13 +02:00
PrimeBuild-pc 7559b4af5a fix: migrate upgraded profiles off Automatic and say so (1.7.2)
v1.7.1 changed the shipped default CPU assignment mode to AffinityMask because
Automatic applies only Windows CPU Sets, a soft scheduling preference that
leaves the affinity mask in Task Manager unchanged. A new default only reaches a
profile that has no stored value, so every upgrading user kept Automatic and
still saw an affinity feature that appeared to do nothing. Confirmed against the
published 1.7.1 build: a fresh profile started on AffinityMask, an existing one
stayed on Automatic.

CpuAssignmentModeMigrationPolicy moves a stored Automatic to AffinityMask once
per profile and records that it ran. Two flags are needed, not one: without the
"seen" flag a user who closes the app before acknowledging the change would
never learn of it, and without the "migrated" flag a later deliberate return to
Automatic would be undone on the next launch. Both cases are covered by tests.

The change is announced through an overlay modelled on the existing startup
suggestion, so it is the app's own dialog rather than a system message box, and
it is translated into all seven supported languages. It is queued rather than
stacked when the startup suggestion is already up, and takes keyboard focus.

Persistence is deliberately non-fatal: a failed write is retried on the next
launch, where previously it would have fallen into the load handler's catch and
replaced the profile just loaded with defaults, silently swallowing the notice.
An out-of-range stored mode now repairs to the shipped default instead of
Automatic, so corrupt data is not reported back to the user as a choice they
made.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AhS1xyuMPFvxrojERQ4NuY
2026-08-26 18:48:01 +02:00
PrimeBuild-pc 2ee397ac83 fix: apply real CPU affinity when a rule is applied
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
2026-08-26 14:26:11 +02:00
PrimeBuild-pc 7381a68dbd Release ThreadPilot 1.6.0 CPU assignment modes 2026-08-12 14:58:23 +02:00
PrimeBuild-pc 9f7ba5e4af Fix persistent automation monitoring preference 2026-08-03 17:38:45 +02:00
Prime Build 1540aeb7be Polish Windows 11 tweaks and add one-click updates (#40)
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.
2026-08-01 13:50:11 +02:00
Prime Build 7953fc7774 Refactor repo with ponytail cleanup (#31) 2026-06-24 17:52:45 +02:00
Prime Build 024673dcbe Add safe in-app updater (#28)
## 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.
2026-06-07 06:06:53 +02:00
Prime Build 340610dfd3 Add safe localization support
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.
2026-06-06 18:04:12 +02:00
Prime Build 91287c9860 Fix startup binding and prepare v1.2.0 pre-release (#22)
* 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
2026-05-23 14:28:24 +02:00
Prime Build c82f24638d Apply persistent rules when processes start (#21)
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.
2026-05-22 12:29:36 +02:00
PrimeBuild-pc 8e5780cdb3 Polish theme settings and bundled power plans 2026-05-17 00:17:12 +02:00
PrimeBuild-pc 48e80751b3 Enable low-impact background mode by default 2026-05-16 23:16:07 +02:00
PrimeBuild-pc fd20661bb1 Improve low-impact runtime behavior 2026-05-16 19:56:13 +02:00
PrimeBuild-pc f6f9822828 Elevation modal, overlay refactor and perf tweaks
Refactor UI overlays and add an elevation warning modal; improve performance monitoring and refresh behavior.

- UI: Reworked MainWindow XAML to consolidate content into UIContent, replaced AppContentLayer/backdrop animations with style-driven blur, added ElevationWarningOverlay (shell-style elevation prompt), reorganized PerformanceIntro and Loading overlays, and added popup overlay in PerformanceView.
- MainWindow logic: Added ApplyUIContentBlur/ClearUIContentBlur helpers, elevation warning show/dismiss/request handlers (with persisted HasSeenElevationWarning), suspend/resume logic for system-tray and background refreshes when hidden, and concurrency guards for system-tray updates.
- Services/API: IPerformanceMonitoringService now supports a lightweight GetSystemMetricsAsync(bool lightweight) call. PerformanceMonitoringService caches total physical memory, skips expensive metrics for lightweight calls, increases monitoring interval to 2s, and adds re-entrancy guards.
- ViewModels: PerformanceViewModel gains popup state/commands and blur binding; PowerPlanViewModel can pause/resume auto-refresh, increased refresh interval to 10s and added concurrency protection.

These changes reduce startup and background resource usage, prevent timer overlap, and introduce a clear user-facing elevation prompt while preserving existing behavior via settings.
2026-04-15 00:59:49 +02:00
PrimeBuild-pc 1ab85b21bd Release 1.1.1: installer, elevation & onboarding
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.
2026-04-14 03:22:06 +02:00
PrimeBuild-pc 3dcec45c1b chore: final enterprise polish and release preparation for v1.1.0 2026-04-12 17:46:38 +02:00
PrimeBuild-pc acfd8dca7e Switch project license to AGPLv3 and test visibility
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.
2026-04-12 16:57:52 +02:00
PrimeBuild-pc 7be4cef428 Enhance theming, UI behavior, perf & add CI
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.
2026-04-11 17:41:13 +02:00
PrimeBuild-pc 010dee679f Add docs, themes, services and UI updates
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.
2026-04-10 03:58:51 +02:00
Focaccina-Ripiena37 bb3602342a Load bundled power plans by default, improve core mask handling, and update project licensing 2025-12-23 13:52:51 +01:00
Focaccina-Ripiena37 cff7d00067 Initial clean import 2025-12-21 04:19:52 +01:00