Conversation
Move peak KPS and CPS display from standalone card row into a lightning bolt toggle button next to the "今日统计" title. Clicking it opens a floating popup with both values. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CloneDailyStats, RecordCurrentStatsToHistory, NormalizeDailyStats, and MergeDailyStats all omitted PeakKPS/PeakCPS when copying DailyStats, causing the values to be lost on save and always read back as 0. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Previously only mouse move and scroll triggered ScheduleSave(), so key presses and clicks were only persisted on graceful exit via FlushPendingSave(). Crash or power loss could lose all keyboard/click data since last mouse activity. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a unified window backdrop system using DWM interop, featuring a new WindowBackdropHelper and updated theme resources to support transparency. It also refactors the StatsPopupWindow to include a peak statistics popup and ensures these metrics are persisted in StatsManager. Review feedback recommends refactoring the backdrop helper to return a success status, utilizing it in the tray popup logic to avoid duplication, and removing redundant UI thread dispatches and method calls. Additionally, the reviewer noted that hardcoded colors in the window logic should be moved to shared resources to comply with the project's Window Material Rules.
There was a problem hiding this comment.
Pull request overview
This PR updates the Windows UI to use a consistent DWM “system backdrop” (transient window material) across app windows/dialogs and improves peak KPS/CPS display + persistence, including a new compact peak popup in the tray stats UI.
Changes:
- Introduces
WindowBackdropHelperand applies DWM backdrop styling broadly (also switching windows/dialogs away fromAllowsTransparency="True"). - Updates theming resources for translucent window surfaces/cards (
WindowSurfaceBrush, adjustedCardBrush/SubtleFillBrush). - Enhances peak KPS/CPS behavior: new peak popup UI, integer formatting, persistence in history/merge paths, and more frequent save scheduling.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| KeyStats.Windows/KeyStats/Views/StatsPopupWindow.xaml.cs | Applies new backdrop logic for windowed vs tray modes; adds tray popup tint/border behavior and theme refresh handling. |
| KeyStats.Windows/KeyStats/Views/StatsPopupWindow.xaml | Adds peak toggle + popup UI and disables window transparency. |
| KeyStats.Windows/KeyStats/Views/SettingsWindow.xaml.cs | Switches to shared backdrop helper on load/theme change. |
| KeyStats.Windows/KeyStats/Views/SettingsWindow.xaml | Uses WindowSurfaceBrush for top-level window background. |
| KeyStats.Windows/KeyStats/Views/NotificationSettingsWindow.xaml.cs | Switches to shared backdrop helper on load/theme change. |
| KeyStats.Windows/KeyStats/Views/NotificationSettingsWindow.xaml | Uses WindowSurfaceBrush for top-level window background. |
| KeyStats.Windows/KeyStats/Views/MouseCalibrationWindow.xaml.cs | Switches to shared backdrop helper on load/theme change. |
| KeyStats.Windows/KeyStats/Views/MouseCalibrationWindow.xaml | Uses WindowSurfaceBrush for top-level window background. |
| KeyStats.Windows/KeyStats/Views/KeyHistoryWindow.xaml.cs | Switches to shared backdrop helper on load/theme change. |
| KeyStats.Windows/KeyStats/Views/KeyHistoryWindow.xaml | Uses WindowSurfaceBrush for top-level window background. |
| KeyStats.Windows/KeyStats/Views/KeyboardHeatmapWindow.xaml.cs | Switches to shared backdrop helper on load/theme updates. |
| KeyStats.Windows/KeyStats/Views/KeyboardHeatmapWindow.xaml | Uses WindowSurfaceBrush for top-level window background. |
| KeyStats.Windows/KeyStats/Views/ImportModeDialog.xaml.cs | Adds theme-aware backdrop application + lifecycle unsubscribe. |
| KeyStats.Windows/KeyStats/Views/ImportModeDialog.xaml | Disables transparency and uses WindowSurfaceBrush. |
| KeyStats.Windows/KeyStats/Views/ConfirmDialog.xaml.cs | Adds theme-aware backdrop application + lifecycle unsubscribe. |
| KeyStats.Windows/KeyStats/Views/ConfirmDialog.xaml | Disables transparency and uses WindowSurfaceBrush. |
| KeyStats.Windows/KeyStats/Views/AppStatsWindow.xaml.cs | Switches to shared backdrop helper on load/theme change. |
| KeyStats.Windows/KeyStats/Views/AppStatsWindow.xaml | Uses WindowSurfaceBrush for top-level window background. |
| KeyStats.Windows/KeyStats/ViewModels/StatsPopupViewModel.cs | Adds IsPeakPopupOpen; changes peak formatting to rounded integer strings. |
| KeyStats.Windows/KeyStats/Services/StatsManager.cs | Schedules saves on more input events; persists peak fields into history/merge/normalize flows. |
| KeyStats.Windows/KeyStats/Helpers/WindowBackdropHelper.cs | New shared helper to apply DWM backdrop + window chrome tweaks consistently. |
| KeyStats.Windows/KeyStats/Helpers/ThemeManager.cs | Adds WindowSurface* resources and adjusts translucency-related colors/brushes. |
| KeyStats.Windows/KeyStats/Helpers/NativeInterop.cs | Adds DWM backdrop/rounded-corner/border-clear/extend-frame interop helpers. |
| KeyStats.Windows/KeyStats/App.xaml | Adds WindowSurfaceBrush resource and updates default translucency resources. |
| KeyStats.Windows/CLAUDE.md | Adds repository guidance (architecture, build, constraints). |
| KeyStats.Windows/AGENTS.md | Documents “Window Material Rules” and related validation guidance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This pull request introduces a new shared helper for applying modern DWM window backdrops, updates the theme resource structure for better consistency and translucency, and makes improvements to data handling in
StatsManager. It also adds a detailedCLAUDE.mdguide for AI contributors, and documents new window material rules inAGENTS.md. The most important changes are grouped below.Window Backdrop and Theming Improvements:
WindowBackdropHelperto centralize and standardize the application of DWM system backdrops, rounded corners, border clearing, and frame extension for all windows. This ensures visual consistency and reduces per-window code duplication. (KeyStats/Helpers/WindowBackdropHelper.cs)NativeInteropwith new DWM interop methods and types, includingTrySetSystemBackdrop,TrySetRoundedCorners,TryClearWindowBorder, andTryExtendFrameIntoClientArea, as well as theMARGINSstruct andDwmSystemBackdropTypeenum. (KeyStats/Helpers/NativeInterop.cs) [1] [2] [3]App.xamlandThemeManager.csto introduceWindowSurfaceColor/WindowSurfaceBrush, increase translucency of window and card backgrounds, and adjust subtle fill colors for improved backdrop visibility and light/dark theme consistency. (KeyStats/App.xaml,KeyStats/Helpers/ThemeManager.cs) [1] [2] [3] [4] [5] [6]StatsManager Data Handling:
ScheduleSave, reducing the risk of unsaved stats in case of a crash. (KeyStats/Services/StatsManager.cs) [1] [2] [3] [4] [5] [6]PeakKPSandPeakCPSto the data recorded in daily stats history, stats cloning, and normalization, ensuring these metrics are persisted and available for analysis. (KeyStats/Services/StatsManager.cs) [1] [2] [3]Documentation and Contributor Guidance:
CLAUDE.mdto provide a comprehensive project overview, architecture, constraints, and conventions for AI and code contributors. (KeyStats.Windows/CLAUDE.md)AGENTS.mdto ensure consistent use of DWM backdrops, tint layers, and theme resources across all windows. (KeyStats.Windows/AGENTS.md)