Fix: Improve Paste Reliability with Overlay Timing Callback#394
Fix: Improve Paste Reliability with Overlay Timing Callback#394mg-dev25 wants to merge 1 commit intocjpais:mainfrom
Conversation
Add hide_recording_overlay_with_callback() that waits for the overlay fade-out animation to complete and the window manager to restore focus before executing the paste operation. This fixes paste failures on Wayland/Linux where focus changes are asynchronous and the previous application may not have regained focus by the time the paste is attempted. Changes: - Add hide_recording_overlay_with_callback() in overlay.rs with: - 300ms delay for fade-out animation - 150ms delay for window manager focus restoration - Immediate callback execution if no overlay exists - Update actions.rs to use callback-based approach for pasting - Remove run_on_main_thread wrapper (callback runs in spawned thread) Relates to cjpais#390
|
So I've reviewed this briefly and also with the help of some large language models and I'm a bit skeptical to pull this in as is due to cross-platform concerns. Generally needing to review the history of the code, specifically in regards to the change away from running on the main thread. Quite frankly I'm not quite versed enough in the specifics of each platform to know if that was required anyhow, but the LLM's are concerned for what it's worth. Also there is some code duplication between Also, I'm not very happy with the delay that this introduces on MacOS. In testing, I find it quite awkward. It's fine for Linux because it fixes a real issue on many distros of Linux. But I don't think the delay is acceptable to have on Windows and MacOS and should be feature flagged off for just Linux. I believe your fork prevents me from making any changes on this branch. I'm happy to both review and change files as necessary, if you're up to allow that. |
|
@cjpais Because of this issues with github https://github.com/orgs/community/discussions/5634 |
|
Thanks, that worked, I will take a look when I can |
Fix: Improve Paste Reliability with Overlay Timing Callback
This PR fixes paste failures on Linux (especially Wayland) by ensuring the overlay is fully hidden and focus is restored to the target application before attempting to paste.
Problem
On Linux/Wayland, the current implementation attempts to paste text immediately after hiding the overlay. However, Wayland window managers handle focus changes asynchronously, meaning the previous application may not have regained focus by the time the paste operation is executed. This results in:
Solution
Introduces
hide_recording_overlay_with_callback()which:This ensures reliable paste behavior across all Linux desktop environments, particularly on Wayland compositors.
Technical Changes
src-tauri/src/overlay.rs:hide_recording_overlay_with_callback<F>()function with callback supportsrc-tauri/src/actions.rs:TranscribeAction::stop()to use callback-based overlay hidingTesting
Tested on:
Related Issues