Skip to content

Added Concurrency for Faster Performance and Improved UX#4

Merged
ehsan18t merged 28 commits into
mainfrom
concurrency
Dec 14, 2025
Merged

Added Concurrency for Faster Performance and Improved UX#4
ehsan18t merged 28 commits into
mainfrom
concurrency

Conversation

@ehsan18t

Copy link
Copy Markdown
Owner

No description provided.

- Add rayon 1.X for parallel iteration
- Parallelize get_all_tweak_statuses using par_iter
- Parallelize detect_tweak_state with concurrent registry/service checks
- Parallelize validate_all_snapshots for faster startup
- Parallelize snapshot capture operations in capture.rs
- Parallelize capture_current_state for rollback preparation

This significantly reduces startup time and status refresh latency
by running registry, service, and scheduler checks concurrently.
- Use thread::scope for parallel WMI queries
- Each thread creates its own WMI connection (COM threading model)
- CPU, GPU, monitors, memory, motherboard, disks, and network
  queries now run concurrently instead of sequentially

This significantly reduces system info loading time on startup.
- Add loading state tracking in tweaksData store (systemInfoLoading, tweaksLoading, etc.)
- Split initialization into initializeQuick + loadRemainingData for faster perceived load
- Add loadingStateStore with canShowApp, isFullyLoaded, systemInfoLoading, tweaksLoading
- Export new loading functions from tweaks barrel
- Update +page.svelte to use progressive loading pattern
- Add skeleton loading cards in CategoryTab for tweaks
- Add skeleton loading states in OverviewTab for system info, hardware, and categories
- Show app shell immediately after categories load, populate data progressively
- Create toast store with success/error/warning/info types
- Create ToastContainer component with slide-in animation
- Update applyTweak to show success/error toasts with tweak name
- Update revertTweak to show success/error toasts with tweak name
- Update applyPendingChanges to show summary toast
- Add ToastContainer to layout for global notifications
- Export toast store from stores barrel
- Revert visible: false to visible: true with backgroundColor #09090b for seamless dark theme loading
- Remove unused show_main_window command from Rust backend and frontend
- Fix skeleton loop lint warnings: replace Array(N) with explicit arrays in OverviewTab, Sidebar, CategoryTab
- Fix par_iter().collect() anti-pattern in backup detection.rs
- Improve initial loader with icon and smooth fade-out animation
- Fix blank window issue by repositioning loader CSS before SvelteKit injected styles
  - Moved loader <style> block before %sveltekit.head% in app.html
  - Prevents CSS blocking, ensuring spinner shows immediately on launch
  - Updated page title to 'MagicX Toolbox'

- Add window visibility watchdog to prevent stuck hidden state
  - Created window_watchdog.rs with 10-second timeout failsafe
  - Auto-shows window if frontend fails to mount or signal readiness
  - Prevents app from running hidden in background on mount failures

- Enhance show_main_window command with better error handling
  - Added visibility state checking before showing
  - Comprehensive logging to track normal vs fallback code paths
  - Prevents redundant show operations

This fixes the issue where users would see a white screen for several
seconds before the loading skeleton appeared, and ensures the window
always becomes visible even if the frontend encounters errors.
Refactored getAllTweaksWithStatus to use a single batch IPC call for fetching all tweak statuses, reducing the number of IPC calls from N+1 to 2. This improves performance and efficiency when retrieving tweaks with their statuses.
Refactors data loading in +layout.svelte to start category loading immediately and overlap it with UI initialization, improving perceived performance. Updates +page.svelte to avoid duplicate network requests by checking if categories are already loaded, only loading remaining data if necessary.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 22 out of 23 changed files in this pull request and generated 9 comments.

Comment thread src-tauri/src/services/system_info_service.rs Outdated
Comment thread src-tauri/src/commands/tweaks/query.rs
Comment thread src/routes/+layout.svelte Outdated
Comment thread src-tauri/src/services/backup/capture.rs
Comment thread src/routes/+layout.svelte
Comment thread src/routes/+page.svelte Outdated
Comment thread src-tauri/src/window_watchdog.rs Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 23 changed files in this pull request and generated 6 comments.

Comment thread src/lib/stores/tweaksData.svelte.ts
Comment thread src/lib/stores/toast.svelte.ts Outdated
Comment thread src/lib/stores/toast.svelte.ts
Comment thread src-tauri/src/window_watchdog.rs Outdated
Comment thread src-tauri/src/window_watchdog.rs Outdated
Comment thread src/routes/+page.svelte Outdated
Bump several dev dependencies including @types/node (to 24.10.4) and cpy-cli (to 6.0.0) in package.json. This also updates related transitive dependencies in bun.lock for improved compatibility and bug fixes.
…ropping failures

- Add error field to TweakStatus struct (Rust + TypeScript)
- Change filter_map to map in get_all_tweak_statuses to always return tweaks
- Frontend now shows 'unknown state' badge for tweaks with detection errors
- Users can still interact with errored tweaks (apply/revert)

Resolves silent error suppression issue where tweaks failing state detection
were dropped from results, leaving users confused about missing tweaks.
- Replace std::thread::sleep with tokio::time::sleep().await
- Remove redundant nested spawn (function already called from spawned context)
- Add tokio dependency with minimal 'time' feature only
- Improve documentation with usage note

This eliminates unnecessary thread blocking in the async runtime.
- Track timeout IDs in Map<string, ReturnType<typeof setTimeout>>
- Clear timeout in dismiss() to prevent orphaned timers
- Clear all timeouts in clear() for complete cleanup

Previously, manually dismissing toasts left setTimeout callbacks running.
- Cache in-flight promises for quickInit() and loadRemainingData()
- Return existing promise if already loading instead of triggering duplicate backend calls
- Cleaner than boolean flag approach (automatic cleanup on resolution)

Fixes concurrent requests from +layout.svelte and +page.svelte mounting simultaneously.
- Replace silent .ok() chains with match statements that log errors
- Use log::debug! (visible in debug builds, silent in release)
- Improves observability for hardware info query failures

WMI failures are non-critical (UI shows 'Unknown' placeholders), so debug level is appropriate.
Minor formatting consistency improvements.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 28 changed files in this pull request and generated 5 comments.

Comment thread src/lib/stores/tweaksData.svelte.ts Outdated
Comment thread src/app.html Outdated
Comment thread src-tauri/src/commands/tweaks/query.rs
Comment thread src/lib/components/ToastContainer.svelte
Comment thread src/lib/components/ToastContainer.svelte Outdated
…zation

BREAKING CHANGE: initializeData() is removed from public API

- Remove initializeData() which bypassed promise caching
- Update +page.svelte fallback to use initializeQuick() + loadRemainingData()
- These functions have proper promise caching to prevent duplicate requests
- Update all barrel exports to remove initializeData
- Remove slide-in-from-right-5 class which was never defined
- Animation already works via custom .animate-in CSS class
Critical fix for revert_tweak command:

- Add SYSTEM elevation support for scheduler task restoration
  Previously restore used admin-level schtasks which fails on protected
  Windows Update tasks with 'Access Denied'

- Add SYSTEM elevation support for service restoration
  Services like WaaSMedicSvc require SYSTEM to modify

- Return RestoreResult with detailed failure information
  Instead of silently continuing, collect all failures

- Only delete snapshot on FULL success
  Previously snapshot was deleted even on partial failure, leaving
  system in inconsistent state with no way to retry

- Preserve snapshot on partial restore for user retry

This ensures users can retry failed reverts and the system state
remains consistent even when some operations fail.
Updated the comment to better explain discarding the result to match the Promise<void> signature in the initializeQuick function.
…king

- Simplify RestoreResult struct (remove unused count fields)
- Fix batch operations to properly track partial successes
- Count partial failures (success=false) separately from errors
- Propagate inner failure details from TweakResult.failures
- Remove unused RestoreResult export from module
- Extract and display detailed failure messages from TweakResult.failures
- Don't update is_applied on partial revert failure (snapshot still exists)
- Use warning toast instead of error for partial success
- Allow user to retry revert when some operations failed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 32 changed files in this pull request and generated 12 comments.

Comment thread src-tauri/src/commands/tweaks/apply.rs
Comment thread src/routes/+page.svelte Outdated
Comment thread src/routes/+page.svelte Outdated
Comment thread src-tauri/src/services/system_info_service.rs Outdated
Comment thread src/lib/stores/toast.svelte.ts
Comment thread src-tauri/src/services/system_info_service.rs Outdated
Comment thread src/routes/+layout.svelte Outdated
Comment thread src-tauri/Cargo.toml
Comment thread package.json
Comment thread src-tauri/src/services/backup/detection.rs Outdated
Refactored +layout.svelte to await initializeQuick directly, guaranteeing categories are loaded before +page.svelte's onMount runs. Updated +page.svelte to defensively check for categories and only load them if necessary, improving reliability and preventing race conditions.
- Change categoriesStore.load() to re-throw errors instead of returning []
- Change tweaksStore.load() to re-throw errors instead of returning []
- Add comments explaining why systemStore.load() still returns null on error
- Remove defensive empty check in +page.svelte (no longer needed)
- Simplify +layout.svelte to use static import for initializeQuick

Categories are compiled at build time and must always load successfully.
If loading fails, it indicates a critical IPC/runtime error that should
surface to the error UI rather than being silently swallowed.
- Remove unused registry.rs module (file needs manual deletion)
- Remove unused store methods from tweaksData, tweaksLoading, tweaksPending, tweaksActions
- Remove unused API functions: getTweakStatuses, getTweaksForCurrentVersion, checkForUpdate
- Remove console.log statements from systemElevation store
- Update copilot-instructions.md to match actual store API
Expanded the eslint disable comment to explain why a plain Map is used for timeout IDs and why Svelte reactivity is not required in this context.
Expanded comments in detection.rs to clarify why scheduler changes are processed sequentially. The update explains the COM threading model and the need for per-thread COM initialization, documenting the rationale for avoiding parallelization in the current implementation.
Refactored get_hardware_info() to use 3 threads with WMI connection
reuse instead of 7 separate threads each with its own connection:

- Thread 1: Fast cimv2 queries (CPU, Memory, Motherboard, Network)
- Thread 2: Slow cimv2 queries (GPU, Monitors) - WinAPI/registry heavy
- Thread 3: Storage namespace (Disks)

This reduces COM initialization overhead while maintaining good
parallelism. Added timing log for performance monitoring.
- Add NaN check in TweakCard handleOptionChange to prevent invalid option index
- Fix Sidebar effect race condition with initialization guard
- Add schema validation for imported settings in SettingsModal
- Show toast message when app exit fails after update install
- Fix non-null assertion in colorScheme store with proper type narrowing

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 41 out of 43 changed files in this pull request and generated 4 comments.

Comment thread src/lib/stores/colorScheme.svelte.ts
Comment thread src-tauri/src/commands/tweaks/apply.rs
Comment thread src-tauri/src/services/system_info_service.rs
Comment thread src-tauri/src/lib.rs

Copilot AI commented Dec 14, 2025

Copy link
Copy Markdown

@ehsan18t I've opened a new pull request, #5, to work on those changes. Once the pull request is ready, I'll request review from you.

@ehsan18t ehsan18t merged commit 571239a into main Dec 14, 2025
6 checks passed
@ehsan18t ehsan18t deleted the concurrency branch December 14, 2025 11:36
@ehsan18t ehsan18t restored the concurrency branch December 14, 2025 11:36
@ehsan18t ehsan18t deleted the concurrency branch December 14, 2025 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants