Users on Windows 11 reported that the app window flickers rapidly on launch (#1584)#1590
Users on Windows 11 reported that the app window flickers rapidly on launch (#1584)#1590mrv0for0vandeta wants to merge 4 commits into
Conversation
) Replace minimize/unminimize cycle with direct focus calls to eliminate visible flickering while maintaining keyboard focus functionality. Changes: - Remove minimize/unminimize from Windows focus fix - Add atomic guard to prevent concurrent focus cycles - Increase CEF initialization delay to 500ms - Implement three-attempt focus strategy with exponential backoff - Add OPENHUMAN_DISABLE_FOCUS_FIX environment variable - Remove duplicate WindowEvent::CloseRequested handler - Update documentation with issue context and trade-offs The previous approach used window.minimize() + window.unminimize() to trigger WM_KILLFOCUS + WM_SETFOCUS events for CEF focus initialization. This worked but caused visible flickering that users reported as rapid flashing making the app unusable. The new approach uses direct set_focus() calls without window state changes. This eliminates flickering but may require users to click once in the text field on some systems. This trade-off is acceptable as flickering made the app completely unusable. Fixes tinyhumansai#1584
All test modules that use ENV_LOCK for serializing environment variable mutations now recover gracefully from mutex poisoning. When a test panics while holding the lock, subsequent tests can continue instead of cascading failures. Changes: - Add test_env_lock() helper in config module that recovers from poison - Add env_lock() helpers in local test modules (logging, lib, file_logging) - Replace all .lock().unwrap() calls with poison-recovering helpers - Prevents PoisonError cascades across 38 failing tests This fixes the test suite failures in: - openhuman::config::ops::tests - openhuman::local_ai::schemas::tests - openhuman::subconscious::executor::tests - openhuman::threads::ops::tests - openhuman::update::ops::tests - openhuman::credentials::cli::tests - openhuman::composio::periodic::tests - core::jsonrpc::tests
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR addresses two concerns: Windows app launch focus flickering by replacing a minimize/unminimize focus cycle with deferred direct focus calls guarded by a process-wide atomic, and improves test robustness by introducing a centralized environment-locking helper that recovers from poisoned mutexes to prevent cascading test failures during parallel execution. ChangesWindows CEF Focus Fix and Test Environment Locking
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
OPENHUMAN_DISABLE_FOCUS_FIXenvironment variable for user controlWindowEvent::CloseRequestedhandlerProblem
Users on Windows 11 reported that the app window flickers rapidly on launch (#1584), making the UI completely unusable. The flickering was caused by an aggressive minimize/unminimize cycle in the Windows CEF focus fix (lines 1686-1720 in
app/src-tauri/src/lib.rs). While this cycle successfully initialized keyboard focus, it created a visible flickering effect that users found unacceptable.Solution
Replaced the minimize/unminimize cycle with direct
set_focus()calls that don't change window state. This eliminates flickering while still attempting to initialize keyboard focus. The implementation includes:AtomicBoolOPENHUMAN_DISABLE_FOCUS_FIX=1Trade-off: Keyboard input may require one click on some systems, but this is acceptable as flickering made the app completely unusable.
Submission Checklist
Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy - N/A: This is a Windows-specific focus fix that requires manual testing on Windows 11 hardware. The change is isolated to startup behavior and doesn't affect testable business logic.
Diff coverage ≥ 80% — changed lines (Vitest + cargo-llvm-cov merged via
diff-cover) meet the gate enforced by.github/workflows/coverage.yml. Runpnpm test:coverageandpnpm test:rustlocally; PRs below 80% on changed lines will not merge. - Pending: Awaiting CI resultsCoverage matrix updated — added/removed/renamed feature rows in
docs/TEST-COVERAGE-MATRIX.mdreflect this change (orN/A: behaviour-only change) - N/A: behaviour-only change - no new features added, only modified existing Windows focus fix behaviorAll affected feature IDs from the matrix are listed in the PR description under
## Related- N/A: No feature IDs affected, this is a bug fixNo new external network dependencies introduced (mock backend used per Testing Strategy) - N/A: No network dependencies added
Manual smoke checklist updated if this touches release-cut surfaces (
docs/RELEASE-MANUAL-SMOKE.md) - N/A: Does not touch release-cut surfacesLinked issue closed via
Closes #NNNin the## Relatedsection - Done: See Related section belowpnpm --filter openhuman-app format:check- Pending: Will run locally if neededpnpm typecheck- Pending: Will run locally if neededFocused tests: - N/A: Windows-specific behavior requires manual testing
Rust fmt/check (if changed): - Pending: Awaiting CI results
Tauri fmt/check (if changed): - Pending: Awaiting CI results
Impact
Runtime/platform impact: Windows 11 desktop only. No impact on macOS, Linux, mobile, web, or CLI.
Performance: Slightly longer startup delay (~580ms additional) but eliminates visible flickering. User experience significantly improved.
Security: No security implications. Atomic guard ensures thread safety.
Migration: No migration needed. Users can opt-out via environment variable if needed.
Compatibility: Maintains backward compatibility. The
show_main_windowfunction still uses unminimize for legitimate cases (showing from tray).Related
Closes: #1584
Follow-up PR(s)/TODOs: None. This is a complete fix for the reported issue.
AI Authored PR Metadata
Linear Issue
Commit & Branch
fix/windows-flickering-158434f20b60Validation Run
pnpm --filter openhuman-app format:check: Pending CIpnpm typecheck: Pending CIValidation Blocked
Behavior Changes
Parity Contract
show_main_windowfunction still uses unminimize for showing from trayDuplicate / Superseded PR Handling
Summary by CodeRabbit
Bug Fixes
Tests