From 21598974ce7b9881b51ac6ab0fca07aab2989e5e Mon Sep 17 00:00:00 2001 From: YacaloX <172989715+YacaloX@users.noreply.github.com> Date: Sat, 30 May 2026 19:05:06 -0500 Subject: [PATCH 1/2] Update dotnet.yml, using Windows instead of Ubuntu --- .github/workflows/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 7d03f06..db7551e 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -12,7 +12,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: windows-latest steps: - uses: actions/checkout@v4 From 2fabe6b6c228f1a32a0aa10cb3803740ed2fd32b Mon Sep 17 00:00:00 2001 From: YacaloX Date: Sat, 30 May 2026 20:07:46 -0500 Subject: [PATCH 2/2] Added another things --- Core/HistoryTracker.cs | 11 +++- HistoryTrackerTests.cs | 3 +- RELEASE.md | 129 ----------------------------------------- 3 files changed, 10 insertions(+), 133 deletions(-) delete mode 100644 RELEASE.md diff --git a/Core/HistoryTracker.cs b/Core/HistoryTracker.cs index f5de3d0..e052b34 100644 --- a/Core/HistoryTracker.cs +++ b/Core/HistoryTracker.cs @@ -17,10 +17,17 @@ public class HistoryTracker : IHistoryTracker private readonly System.Timers.Timer _saveTimer = new(2000) { AutoReset = false }; private bool _dirty; - public HistoryTracker() + public HistoryTracker() : this(AppPaths.AppFolder, true) { + } + + internal HistoryTracker(string folderPath, bool autoSave = false) + { + _filePath = Path.Combine(folderPath, "history.json"); _saveTimer.Elapsed += (_, _) => FlushSave(); Load(); + if (autoSave && _history.Count == 0) + Save(); } public IReadOnlyDictionary History => _history; @@ -33,7 +40,6 @@ public void Load() if (!File.Exists(_filePath)) { _history = new(); - Save(); return; } @@ -44,7 +50,6 @@ public void Load() { System.Diagnostics.Debug.WriteLine($"HistoryTracker.Load failed: {ex.Message}"); _history = new(); - Save(); } finally { diff --git a/HistoryTrackerTests.cs b/HistoryTrackerTests.cs index 519b588..e154be5 100644 --- a/HistoryTrackerTests.cs +++ b/HistoryTrackerTests.cs @@ -1,12 +1,13 @@ using SmartFocus.Core; using SmartFocus.Core.Interfaces; using SmartFocus.Models; +using System.IO; namespace SmartFocus.Tests; public class HistoryTrackerTests { - private readonly IHistoryTracker _tracker = new HistoryTracker(); + private readonly IHistoryTracker _tracker = new HistoryTracker(Path.GetTempPath()); [Fact] public void RegisterUse_IncrementsFrequency() diff --git a/RELEASE.md b/RELEASE.md deleted file mode 100644 index cc56840..0000000 --- a/RELEASE.md +++ /dev/null @@ -1,129 +0,0 @@ -# SmartFocus v1.0.100 - -[![.NET](https://img.shields.io/badge/.NET-10.0%2B-512BD4?style=flat&logo=dotnet)](https://dotnet.microsoft.com/) -[![Windows](https://img.shields.io/badge/Windows-11-0078D6?style=flat&logo=windows)](https://www.microsoft.com/windows/) -[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) - -> Ultralight window switcher for Windows — Search and focus any open window instantly. - ---- - -## What's New in 1.0.100 - -### Hotkey -- Default hotkey changed to **Win + Y** -- Configurable from Settings window -- Intelligent fallback chain: Win+Y → Ctrl+Alt+F → warning notification - -### Focus System -- Completely rewritten `FocusWindowAsync` with **3-level focus strategy**: - 1. `SwitchToThisWindow` — simulates Alt+Tab behavior (most reliable) - 2. `AttachThreadInput` — thread-attach technique for stubborn windows - 3. Minimize-Restore — last resort that forces window manager attention -- Eliminated `await Task.Delay` between critical Win32 calls (was causing focus loss) -- Added success/failure debug logging per focus attempt - -### Background Themes -- **4 background themes**: Dark, Light, System (follows Windows), Custom (any color) -- All UI colors update in real-time via `DynamicResource` bindings -- Theme persists in `settings.json` - -### Accent Color -- 5 preset colors: Cyan, Green, Red, Yellow, Magenta -- Custom color picker (Windows ColorDialog) -- Accent color updates glow effects, borders, and search text -- Integrated into theme system - -### Settings Window Redesign -- Now matches search window style: no title bar, transparent, dark border -- **Auto-save** on every change — no Save button needed -- **Hide on focus loss** — click away to close, just like the search overlay -- Persistent window reference (reuses same instance) - -### Result Interaction -- **Double-click** on any search result to focus the window -- Keyboard Enter remains supported - -### Architecture -- Tests migrated into main project: `dotnet test SmartFocus.csproj` -- 10 unit tests covering SearchEngine and HistoryTracker -- Global resource dictionaries in App.xaml (no more duplicated per-window resources) - ---- - -## Installation - -### From Source -```bash -git clone https://github.com/YacaloX/SmartFocus.git -cd SmartFocus -dotnet build -dotnet run -``` - -**Requirements:** .NET 10 SDK, Windows 11 - ---- - -## Quick Start - -| Action | Result | -|---|---| -| Press `Win + Y` | Opens search bar | -| Type app name | Fuzzy search shows results | -| Press `Enter` or double-click | Window comes to front | -| Press `Escape` | Closes search bar | -| Right-click tray icon → Configuración | Opens settings overlay | - ---- - -## Configuration - -Stored in `%AppData%/SmartFocus/settings.json`: - -```json -{ - "AccentColor": "#00FFFF", - "HotkeyModifiers": 8, - "HotkeyKey": "Y", - "BackgroundTheme": "Dark", - "CustomBackground": "#0D1117" -} -``` - -Aliases: `%AppData%/SmartFocus/aliases.json` -History: `%AppData%/SmartFocus/history.json` - ---- - -## Project Structure - -``` -SmartFocus/ -├── Core/ -│ ├── WindowManager.cs # Window enumeration + focus -│ ├── SearchEngine.cs # Fuzzy search (Levenshtein) -│ ├── HistoryTracker.cs # Frequency learning -│ ├── AliasManager.cs # Custom aliases -│ ├── HotkeyService.cs # Global hotkey (Win32) -│ ├── SettingsManager.cs # JSON settings persistence -│ └── Interfaces/ # Abstractions -├── UI/ -│ ├── MainWindow.xaml/cs # Search overlay -│ └── SettingsWindow.xaml/cs # Configuration overlay -├── App.xaml/cs # Entry point + tray icon -└── *Tests.cs # xUnit tests (10 tests) -``` - ---- - -## Known Issues - -- Focus stealing on some Chromium-based apps — under investigation -- Performance with 100+ open windows — optimization pending - ---- - -## License - -MIT — see [LICENSE](LICENSE)