Skip to content

A personal assistant that lives on your desktop, remembers what matters, and can use your Mac for you.

TypeScript

fix(desktop): say nothing was sent when the recipient changes before typing

Marcelitof015d3c1abcb
diff --git a/apps/desktop/src-tauri/src/computer/mcp.rs b/apps/desktop/src-tauri/src/computer/mcp.rs
index 2b0ba29..7f10937 100644
--- a/apps/desktop/src-tauri/src/computer/mcp.rs
+++ b/apps/desktop/src-tauri/src/computer/mcp.rs
@@ -806,8 +806,10 @@ impl Helper {
let mut posted = 0;
let mut post_typed = |event, characters| -> Result<(), String> {
self.keyboard_target(posted > 0).and_then(|(_, current)| {
- if current != recipient {
+ if current != recipient && posted > 0 {
Err("The app receiving the keys changed while typing, so the rest was not sent.".into())
+ } else if current != recipient {
+ Err("The app receiving the keys changed before typing, so nothing was sent.".into())
} else {
Ok(())
}
@@ -1481,6 +1483,8 @@ mod tests {
if change_front {
// Nothing landed yet, so the screenshot guard can still say so.
assert_eq!(first_text(&result), "Panel is in front now, not the app of the latest screenshot, so nothing was sent. Take a screenshot first. Typing stopped after 0 of 5 characters.");
+ } else {
+ assert_eq!(first_text(&result), "The app receiving the keys changed before typing, so nothing was sent. Typing stopped after 0 of 5 characters.");
}
assert!(rig.desktop.events().is_empty());
}