Skip to content

Free, open-source Windows optimization tool for performance, privacy, and simplicity.

fix: resolve virtualization, process cleanup, and partial-success edge cases

fatDuck46963904ab87
diff --git a/.codegraph/.gitignore b/.codegraph/.gitignore
new file mode 100644
index 0000000..9de0f16
--- /dev/null
+++ b/.codegraph/.gitignore
@@ -0,0 +1,16 @@
+# CodeGraph data files
+# These are local to each machine and should not be committed
+
+# Database
+*.db
+*.db-wal
+*.db-shm
+
+# Cache
+cache/
+
+# Logs
+*.log
+
+# Hook markers
+.dirty
diff --git a/.codegraph/config.json b/.codegraph/config.json
new file mode 100644
index 0000000..7af60ad
--- /dev/null
+++ b/.codegraph/config.json
@@ -0,0 +1,143 @@
+{
+ "version": 1,
+ "include": [
+ "**/*.ts",
+ "**/*.tsx",
+ "**/*.js",
+ "**/*.jsx",
+ "**/*.py",
+ "**/*.go",
+ "**/*.rs",
+ "**/*.java",
+ "**/*.c",
+ "**/*.h",
+ "**/*.cpp",
+ "**/*.hpp",
+ "**/*.cc",
+ "**/*.cxx",
+ "**/*.cs",
+ "**/*.php",
+ "**/*.rb",
+ "**/*.swift",
+ "**/*.kt",
+ "**/*.kts",
+ "**/*.dart",
+ "**/*.svelte",
+ "**/*.vue",
+ "**/*.liquid",
+ "**/*.pas",
+ "**/*.dpr",
+ "**/*.dpk",
+ "**/*.lpr",
+ "**/*.dfm",
+ "**/*.fmx",
+ "**/*.scala",
+ "**/*.sc"
+ ],
+ "exclude": [
+ "**/.git/**",
+ "**/node_modules/**",
+ "**/vendor/**",
+ "**/Pods/**",
+ "**/dist/**",
+ "**/build/**",
+ "**/out/**",
+ "**/bin/**",
+ "**/obj/**",
+ "**/target/**",
+ "**/*.min.js",
+ "**/*.bundle.js",
+ "**/.next/**",
+ "**/.nuxt/**",
+ "**/.svelte-kit/**",
+ "**/.output/**",
+ "**/.turbo/**",
+ "**/.cache/**",
+ "**/.parcel-cache/**",
+ "**/.vite/**",
+ "**/.astro/**",
+ "**/.docusaurus/**",
+ "**/.gatsby/**",
+ "**/.webpack/**",
+ "**/.nx/**",
+ "**/.yarn/cache/**",
+ "**/.pnpm-store/**",
+ "**/storybook-static/**",
+ "**/.expo/**",
+ "**/web-build/**",
+ "**/ios/Pods/**",
+ "**/ios/build/**",
+ "**/android/build/**",
+ "**/android/.gradle/**",
+ "**/__pycache__/**",
+ "**/.venv/**",
+ "**/venv/**",
+ "**/site-packages/**",
+ "**/dist-packages/**",
+ "**/.pytest_cache/**",
+ "**/.mypy_cache/**",
+ "**/.ruff_cache/**",
+ "**/.tox/**",
+ "**/.nox/**",
+ "**/*.egg-info/**",
+ "**/.eggs/**",
+ "**/go/pkg/mod/**",
+ "**/target/debug/**",
+ "**/target/release/**",
+ "**/.gradle/**",
+ "**/.m2/**",
+ "**/generated-sources/**",
+ "**/.kotlin/**",
+ "**/.dart_tool/**",
+ "**/.vs/**",
+ "**/.nuget/**",
+ "**/artifacts/**",
+ "**/publish/**",
+ "**/cmake-build-*/**",
+ "**/CMakeFiles/**",
+ "**/bazel-*/**",
+ "**/vcpkg_installed/**",
+ "**/.conan/**",
+ "**/Debug/**",
+ "**/Release/**",
+ "**/x64/**",
+ "**/.pio/**",
+ "**/release/**",
+ "**/*.app/**",
+ "**/*.asar",
+ "**/DerivedData/**",
+ "**/.build/**",
+ "**/.swiftpm/**",
+ "**/xcuserdata/**",
+ "**/Carthage/Build/**",
+ "**/SourcePackages/**",
+ "**/__history/**",
+ "**/__recovery/**",
+ "**/*.dcu",
+ "**/.composer/**",
+ "**/storage/framework/**",
+ "**/bootstrap/cache/**",
+ "**/.bundle/**",
+ "**/tmp/cache/**",
+ "**/public/assets/**",
+ "**/public/packs/**",
+ "**/.yardoc/**",
+ "**/coverage/**",
+ "**/htmlcov/**",
+ "**/.nyc_output/**",
+ "**/test-results/**",
+ "**/.coverage/**",
+ "**/.idea/**",
+ "**/logs/**",
+ "**/tmp/**",
+ "**/temp/**",
+ "**/_build/**",
+ "**/docs/_build/**",
+ "**/site/**"
+ ],
+ "languages": [],
+ "frameworks": [],
+ "maxFileSize": 1048576,
+ "extractDocstrings": true,
+ "trackCallSites": true
+}
\ No newline at end of file
diff --git a/.rtk/filters.toml b/.rtk/filters.toml
new file mode 100644
index 0000000..d9bd43f
--- /dev/null
+++ b/.rtk/filters.toml
@@ -0,0 +1,13 @@
+# Project-local RTK filters — commit this file with your repo.
+# Filters here override user-global and built-in filters.
+# Docs: https://github.com/rtk-ai/rtk#custom-filters
+schema_version = 1
+
+# Example: suppress build noise from a custom tool
+# [filters.my-tool]
+# description = "Compact my-tool output"
+# match_command = "^my-tool\\s+build"
+# strip_ansi = true
+# strip_lines_matching = ["^\\s*$", "^Downloading", "^Installing"]
+# max_lines = 30
+# on_empty = "my-tool: ok"
diff --git a/AGENTS.md b/AGENTS.md
index 6d1459d..1569cfd 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -56,3 +56,176 @@
- Branch from `master`: `feature/<name>` or `fix/<issue-id>`.
- PRs: clear description, linked issue (`Closes #123`), passing `dotnet build` + `dotnet test`, screenshot for UI changes.
- Never commit secrets or machine-specific paths.
+
+<!-- rtk-instructions v2 -->
+# RTK (Rust Token Killer) - Token-Optimized Commands
+
+## Golden Rule
+
+**Always prefix commands with `rtk`**. If RTK has a dedicated filter, it uses it. If not, it passes through unchanged. This means RTK is always safe to use.
+
+**Important**: Even in command chains with `&&`, use `rtk`:
+```bash
+# ❌ Wrong
+git add . && git commit -m "msg" && git push
+
+# ✅ Correct
+rtk git add . && rtk git commit -m "msg" && rtk git push
+```
+
+## RTK Commands by Workflow
+
+### Build & Compile (80-90% savings)
+```bash
+rtk cargo build # Cargo build output
+rtk cargo check # Cargo check output
+rtk cargo clippy # Clippy warnings grouped by file (80%)
+rtk tsc # TypeScript errors grouped by file/code (83%)
+rtk lint # ESLint/Biome violations grouped (84%)
+rtk prettier --check # Files needing format only (70%)
+rtk next build # Next.js build with route metrics (87%)
+```
+
+### Test (60-99% savings)
+```bash
+rtk cargo test # Cargo test failures only (90%)
+rtk go test # Go test failures only (90%)
+rtk jest # Jest failures only (99.5%)
+rtk vitest # Vitest failures only (99.5%)
+rtk playwright test # Playwright failures only (94%)
+rtk pytest # Python test failures only (90%)
+rtk rake test # Ruby test failures only (90%)
+rtk rspec # RSpec test failures only (60%)
+rtk test <cmd> # Generic test wrapper - failures only
+```
+
+### Git (59-80% savings)
+```bash
+rtk git status # Compact status
+rtk git log # Compact log (works with all git flags)
+rtk git diff # Compact diff (80%)
+rtk git show # Compact show (80%)
+rtk git add # Ultra-compact confirmations (59%)
+rtk git commit # Ultra-compact confirmations (59%)
+rtk git push # Ultra-compact confirmations
+rtk git pull # Ultra-compact confirmations
+rtk git branch # Compact branch list
+rtk git fetch # Compact fetch
+rtk git stash # Compact stash
+rtk git worktree # Compact worktree
+```
+
+Note: Git passthrough works for ALL subcommands, even those not explicitly listed.
+
+### GitHub (26-87% savings)
+```bash
+rtk gh pr view <num> # Compact PR view (87%)
+rtk gh pr checks # Compact PR checks (79%)
+rtk gh run list # Compact workflow runs (82%)
+rtk gh issue list # Compact issue list (80%)
+rtk gh api # Compact API responses (26%)
+```
+
+### JavaScript/TypeScript Tooling (70-90% savings)
+```bash
+rtk pnpm list # Compact dependency tree (70%)
+rtk pnpm outdated # Compact outdated packages (80%)
+rtk pnpm install # Compact install output (90%)
+rtk npm run <script> # Compact npm script output
+rtk npx <cmd> # Compact npx command output
+rtk prisma # Prisma without ASCII art (88%)
+```
+
+### Files & Search (60-75% savings)
+```bash
+rtk ls <path> # Tree format, compact (65%)
+rtk read <file> # Code reading with filtering (60%)
+rtk grep <pattern> # Search grouped by file (75%)
+rtk find <pattern> # Find grouped by directory (70%)
+```
+
+### Analysis & Debug (70-90% savings)
+```bash
+rtk err <cmd> # Filter errors only from any command
+rtk log <file> # Deduplicated logs with counts
+rtk json <file> # JSON structure without values
+rtk deps # Dependency overview
+rtk env # Environment variables compact
+rtk summary <cmd> # Smart summary of command output
+rtk diff # Ultra-compact diffs
+```
+
+### Infrastructure (85% savings)
+```bash
+rtk docker ps # Compact container list
+rtk docker images # Compact image list
+rtk docker logs <c> # Deduplicated logs
+rtk kubectl get # Compact resource list
+rtk kubectl logs # Deduplicated pod logs
+```
+
+### Network (65-70% savings)
+```bash
+rtk curl <url> # Compact HTTP responses (70%)
+rtk wget <url> # Compact download output (65%)
+```
+
+### Meta Commands
+```bash
+rtk gain # View token savings statistics
+rtk gain --history # View command history with savings
+rtk discover # Analyze Claude Code sessions for missed RTK usage
+rtk proxy <cmd> # Run command without filtering (for debugging)
+rtk init # Add RTK instructions to CLAUDE.md
+rtk init --global # Add RTK to ~/.claude/CLAUDE.md
+```
+
+## Token Savings Overview
+
+| Category | Commands | Typical Savings |
+|----------|----------|-----------------|
+| Tests | vitest, playwright, cargo test | 90-99% |
+| Build | next, tsc, lint, prettier | 70-87% |
+| Git | status, log, diff, add, commit | 59-80% |
+| GitHub | gh pr, gh run, gh issue | 26-87% |
+| Package Managers | pnpm, npm, npx | 70-90% |
+| Files | ls, read, grep, find | 60-75% |
+| Infrastructure | docker, kubectl | 85% |
+| Network | curl, wget | 65-70% |
+
+Overall average: **60-90% token reduction** on common development operations.
+<!-- /rtk-instructions -->
+
+<!-- CODEGRAPH_START -->
+## CodeGraph
+
+This project has a CodeGraph MCP server (`codegraph_*` tools) configured. CodeGraph is a tree-sitter-parsed knowledge graph of every symbol, edge, and file. Reads are sub-millisecond and return structural information grep cannot.
+
+### When to prefer codegraph over native search
+
+Use codegraph for **structural** questions — what calls what, what would break, where is X defined, what is X's signature. Use native grep/read only for **literal text** queries (string contents, comments, log messages) or after you already have a specific file open.
+
+| Question | Tool |
+|---|---|
+| "Where is X defined?" / "Find symbol named X" | `codegraph_search` |
+| "What calls function Y?" | `codegraph_callers` |
+| "What does Y call?" | `codegraph_callees` |
+| "What would break if I changed Z?" | `codegraph_impact` |
+| "Show me Y's signature / source / docstring" | `codegraph_node` |
+| "Give me focused context for a task/area" | `codegraph_context` |
+| "Survey an unfamiliar module/topic" | `codegraph_explore` |
+| "What files exist under path/" | `codegraph_files` |
+| "Is the index healthy?" | `codegraph_status` |
+
+### Rules of thumb
+
+- **Trust codegraph results.** They come from a full AST parse. Do NOT re-verify them with grep — that's slower, less accurate, and wastes context.
+- **Don't grep first** when looking up a symbol by name. `codegraph_search` is faster and returns kind + location + signature in one call.
+- **Don't chain `codegraph_search` + `codegraph_node`** when you just want context — `codegraph_context` is one call.
+- **`codegraph_explore` is the heavy hitter** for unfamiliar areas — it returns full source from all relevant files in one call, but is token-heavy. If your harness supports parallel subagents (e.g., Claude Code's Task tool), spawn one for explore-class questions to keep main session context clean.
+- **Index lag**: the file watcher debounces ~500ms behind writes; don't re-query immediately after editing a file in the same turn.
+
+### If `.codegraph/` doesn't exist
+
+The MCP server returns "not initialized." Ask the user: *"I notice this project doesn't have CodeGraph initialized. Want me to run `codegraph init -i` to build the index?"*
+<!-- CODEGRAPH_END -->
diff --git a/opencode.jsonc b/opencode.jsonc
new file mode 100644
index 0000000..2c2509a
--- /dev/null
+++ b/opencode.jsonc
@@ -0,0 +1,14 @@
+{
+ "$schema": "https://opencode.ai/config.json",
+ "mcp": {
+ "codegraph": {
+ "type": "local",
+ "command": [
+ "codegraph",
+ "serve",
+ "--mcp"
+ ],
+ "enabled": true
+ }
+ }
+}
diff --git a/optimizerDuck/Domain/Configuration/AppSettings.cs b/optimizerDuck/Domain/Configuration/AppSettings.cs
index d9b2fa2..8ccc5d5 100644
--- a/optimizerDuck/Domain/Configuration/AppSettings.cs
+++ b/optimizerDuck/Domain/Configuration/AppSettings.cs
@@ -1,4 +1,4 @@
-using Wpf.Ui.Appearance;
+using Wpf.Ui.Appearance;
namespace optimizerDuck.Domain.Configuration;
@@ -61,7 +61,7 @@ public sealed class AppSettings
/// <summary>
/// Whether smooth scrolling is enabled globally.
/// </summary>
- public bool SmoothScrolling { get; set; } = true;
+ public bool SmoothScrolling { get; set; } = false;
}
/// <summary>
diff --git a/optimizerDuck/Domain/Execution/ExecutionScope.cs b/optimizerDuck/Domain/Execution/ExecutionScope.cs
index 554b83d..5712a1b 100644
--- a/optimizerDuck/Domain/Execution/ExecutionScope.cs
+++ b/optimizerDuck/Domain/Execution/ExecutionScope.cs
@@ -306,12 +306,13 @@ public sealed class ExecutionScope : IDisposable
return _executedSteps.Select(ToOperationStepResult).ToList();
}
- /// <summary>Maps the execution scope to a result for optimization apply handlers.</summary>
- /// <returns>An <see cref="ApplyResult"/> with <see cref="ApplyResult.Success"/> set to <see langword="true"/> if every step succeeded; otherwise, <see langword="false"/> with a failure message.</returns>
+ /// <summary>Maps the execution scope to an <see cref="ApplyResult"/> from the recorded steps.</summary>
+ /// <returns><see cref="ApplyResult.True"/> if every step succeeded or some succeeded (partial success); <see cref="ApplyResult.False"/> with a message if all steps failed.</returns>
public ApplyResult ToApplyResult()
{
var result = ToResult();
- return result.Status == OptimizationSuccessResult.Success
+ return result.Status is OptimizationSuccessResult.Success
+ or OptimizationSuccessResult.PartialSuccess
? ApplyResult.True()
: ApplyResult.False(result.Message);
}
@@ -347,7 +348,10 @@ public sealed class ExecutionScope : IDisposable
OptimizationName,
failedSteps.Count
),
- _ => $"Unknown result for {OptimizationName}",
+ _ => string.Format(
+ Translations.Optimization_Apply_Error_Unknown,
+ OptimizationName
+ ),
},
FailedSteps = failedSteps,
};
diff --git a/optimizerDuck/Domain/Revert/Steps/UsbPowerRevertStep.cs b/optimizerDuck/Domain/Revert/Steps/UsbPowerRevertStep.cs
index 136c743..bc199be 100644
--- a/optimizerDuck/Domain/Revert/Steps/UsbPowerRevertStep.cs
+++ b/optimizerDuck/Domain/Revert/Steps/UsbPowerRevertStep.cs
@@ -76,10 +76,7 @@ public class UsbPowerRevertStep : IRevertStep
/// </summary>
public static UsbPowerRevertStep FromData(JObject data)
{
- var states =
- data[nameof(States)]?.ToObject<List<DeviceState>>()
- ?? data.ToObject<List<DeviceState>>()
- ?? [];
+ var states = data[nameof(States)]?.ToObject<List<DeviceState>>() ?? [];
return new UsbPowerRevertStep { States = states };
}
diff --git a/optimizerDuck/Resources/Languages/Translations.Designer.cs b/optimizerDuck/Resources/Languages/Translations.Designer.cs
index 2964f44..b490e6d 100644
--- a/optimizerDuck/Resources/Languages/Translations.Designer.cs
+++ b/optimizerDuck/Resources/Languages/Translations.Designer.cs
@@ -2257,6 +2257,15 @@ namespace optimizerDuck.Resources.Languages {
}
}
+ /// <summary>
+ /// Looks up a localized string similar to Unknown result for {0}..
+ /// </summary>
+ internal static string Optimization_Apply_Error_Unknown {
+ get {
+ return ResourceManager.GetString("Optimization.Apply.Error.Unknown", resourceCulture);
+ }
+ }
+
/// <summary>
/// Looks up a localized string similar to Applied {0} with {1} failed step(s)..
/// </summary>
diff --git a/optimizerDuck/Resources/Languages/Translations.resx b/optimizerDuck/Resources/Languages/Translations.resx
index 5ab11da..77a0c8e 100644
--- a/optimizerDuck/Resources/Languages/Translations.resx
+++ b/optimizerDuck/Resources/Languages/Translations.resx
@@ -406,6 +406,9 @@
<data name="Optimization.Apply.Error.Failed" xml:space="preserve">
<value>Failed to apply {0}.</value>
</data>
+ <data name="Optimization.Apply.Error.Unknown" xml:space="preserve">
+ <value>Unknown result for {0}.</value>
+ </data>
<data name="Service.Common.Error.AccessDenied" xml:space="preserve">
<value>Access denied</value>
</data>
diff --git a/optimizerDuck/Services/Optimization/OptimizationService.cs b/optimizerDuck/Services/Optimization/OptimizationService.cs
index 88fe6c9..63a5c4e 100644
--- a/optimizerDuck/Services/Optimization/OptimizationService.cs
+++ b/optimizerDuck/Services/Optimization/OptimizationService.cs
@@ -169,15 +169,13 @@ public class OptimizationService(
if (scope.HasSuccessfulSteps)
await TrySaveRevertDataAsync(scope, optimization);
- var status = scope.HasSuccessfulSteps
- ? OptimizationSuccessResult.PartialSuccess
- : OptimizationSuccessResult.Failed;
-
return new OptimizationResult
{
- Status = status,
+ Status = scope.HasSuccessfulSteps
+ ? OptimizationSuccessResult.PartialSuccess
+ : OptimizationSuccessResult.Failed,
Message = applyResult.ErrorMessage,
- FailedSteps = scope.GetStepResults().Where(step => !step.Success).ToList(),
+ FailedSteps = [.. scope.GetStepResults().Where(step => !step.Success)],
};
}
diff --git a/optimizerDuck/Services/Optimization/Providers/ShellService.cs b/optimizerDuck/Services/Optimization/Providers/ShellService.cs
index aa51399..ff9358c 100644
--- a/optimizerDuck/Services/Optimization/Providers/ShellService.cs
+++ b/optimizerDuck/Services/Optimization/Providers/ShellService.cs
@@ -167,7 +167,7 @@ public static class ShellService
{
try
{
- process.Kill(entireProcessTree: false);
+ process.Kill(entireProcessTree: true);
}
catch (Exception ex)
{
@@ -188,7 +188,7 @@ public static class ShellService
{
try
{
- process.Kill(entireProcessTree: false);
+ process.Kill(entireProcessTree: true);
if (!process.HasExited)
{
process.WaitForExit(5000); // Wait up to 5 seconds for force kill
diff --git a/optimizerDuck/UI/Behaviors/SmoothScrollBehavior.cs b/optimizerDuck/UI/Behaviors/SmoothScrollBehavior.cs
index 08224e1..d518c73 100644
--- a/optimizerDuck/UI/Behaviors/SmoothScrollBehavior.cs
+++ b/optimizerDuck/UI/Behaviors/SmoothScrollBehavior.cs
@@ -11,9 +11,21 @@ public static class SmoothScrollBehavior
{
/// <summary>
/// Global toggle for smooth scrolling. When disabled, all smooth scroll
- /// processing is skipped regardless of per-element IsEnabled.
+ /// processing is skipped regardless of per-element IsEnabled, and all
+ /// attached ScrollViewers have their CanContentScroll restored.
/// </summary>
- public static bool GlobalEnabled { get; set; } = true;
+ private static bool _globalEnabled = true;
+ public static bool GlobalEnabled
+ {
+ get => _globalEnabled;
+ set
+ {
+ if (_globalEnabled == value)
+ return;
+ _globalEnabled = value;
+ UpdateAllCanContentScroll();
+ }
+ }
private sealed class ScrollState
{
@@ -32,6 +44,7 @@ public static class SmoothScrollBehavior
private static readonly ConditionalWeakTable<ScrollViewer, ScrollState> _stateTable = new();
private static readonly List<WeakReference<ScrollViewer>> _activeScrolls = [];
+ private static readonly List<WeakReference<ScrollViewer>> _attachedScrolls = [];
private static bool _renderingSubscribed;
private const double SnapThreshold = 0.5;
@@ -124,6 +137,24 @@ public static class SmoothScrollBehavior
Attach(sv);
}
+ private static void UpdateAllCanContentScroll()
+ {
+ for (var i = _attachedScrolls.Count - 1; i >= 0; i--)
+ {
+ if (_attachedScrolls[i].TryGetTarget(out var sv)
+ && _stateTable.TryGetValue(sv, out var state))
+ {
+ sv.CanContentScroll = _globalEnabled
+ ? false
+ : state.PreviousCanContentScroll;
+ }
+ else
+ {
+ _attachedScrolls.RemoveAt(i);
+ }
+ }
+ }
+
private static void Attach(ScrollViewer sv)
{
var state = _stateTable.GetOrCreateValue(sv);
@@ -132,9 +163,11 @@ public static class SmoothScrollBehavior
state.IsAttached = true;
state.PreviousCanContentScroll = sv.CanContentScroll;
- sv.CanContentScroll = false;
+ if (GlobalEnabled)
+ sv.CanContentScroll = false;
sv.PreviewMouseWheel += OnPreviewMouseWheel;
sv.Unloaded += OnScrollViewerUnloaded;
+ _attachedScrolls.Add(new WeakReference<ScrollViewer>(sv));
}
private static void Detach(ScrollViewer sv)
@@ -148,6 +181,7 @@ public static class SmoothScrollBehavior
sv.PreviewMouseWheel -= OnPreviewMouseWheel;
sv.Unloaded -= OnScrollViewerUnloaded;
RemoveActive(sv);
+ RemoveAttached(sv);
_stateTable.Remove(sv);
}
@@ -333,6 +367,18 @@ public static class SmoothScrollBehavior
}
}
+ private static void RemoveAttached(ScrollViewer sv)
+ {
+ for (var i = _attachedScrolls.Count - 1; i >= 0; i--)
+ {
+ if (_attachedScrolls[i].TryGetTarget(out var target) && target == sv)
+ {
+ _attachedScrolls.RemoveAt(i);
+ return;
+ }
+ }
+ }
+
private static bool IsNestedScrollViewer(DependencyObject? element, ScrollViewer parent)
{
try