Fix paste-to-app, settings highlight, and titleBarStyle casing
Paste fix: - Switch from std::process::Command to tokio::process::Command to avoid blocking the async runtime (was stalling the paste action) - Use explicit AppleScript that activates the frontmost app before sending Cmd+V keystroke, making paste more reliable - Increase delay to 300ms for macOS app refocus - Add tokio "process" feature Settings highlight fix: - SettingsPanel now uses local useState for immediate optimistic updates when clicking position/history buttons, instead of waiting for the parent prop round-trip - Buttons highlight instantly on click, then sync with backend Config fix: - titleBarStyle must be PascalCase "Overlay" in Tauri 2 config (was lowercase "overlay" which caused a startup error) Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -74,16 +74,33 @@ pub async fn paste_and_refocus(app: tauri::AppHandle) -> Result<(), String> {
|
||||
}
|
||||
|
||||
// macOS needs time to refocus the previous application
|
||||
tokio::time::sleep(std::time::Duration::from_millis(250)).await;
|
||||
tokio::time::sleep(std::time::Duration::from_millis(300)).await;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
// .output() blocks until osascript finishes, ensuring the keystroke lands
|
||||
std::process::Command::new("osascript")
|
||||
// Activate the frontmost app explicitly, then send Cmd+V.
|
||||
// Using tokio::process::Command to avoid blocking the async runtime.
|
||||
let script = r#"
|
||||
tell application "System Events"
|
||||
set frontApp to name of first application process whose frontmost is true
|
||||
end tell
|
||||
tell application frontApp to activate
|
||||
delay 0.1
|
||||
tell application "System Events"
|
||||
keystroke "v" using command down
|
||||
end tell
|
||||
"#;
|
||||
let output = tokio::process::Command::new("osascript")
|
||||
.arg("-e")
|
||||
.arg(r#"tell application "System Events" to keystroke "v" using command down"#)
|
||||
.arg(script)
|
||||
.output()
|
||||
.map_err(|e| format!("osascript failed: {}", e))?;
|
||||
.await
|
||||
.map_err(|e| format!("osascript spawn failed: {}", e))?;
|
||||
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
log::warn!("osascript paste failed: {}", stderr);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user