A personal assistant that lives on your desktop, remembers what matters, and can use your Mac for you.
TypeScript
fix(desktop): name both causes of a pressed modifier
Marcelito764d77e3e322
diff --git a/apps/desktop/src-tauri/src/computer/mcp.rs b/apps/desktop/src-tauri/src/computer/mcp.rsindex 3563b05..bb0de74 100644--- a/apps/desktop/src-tauri/src/computer/mcp.rs+++ b/apps/desktop/src-tauri/src/computer/mcp.rs@@ -1683,7 +1683,7 @@ mod tests {*rig.desktop.held_keys_at.lock().unwrap() = Some((1, vec![0xa2]));let result = rig.call("key", json!({"combo": "return"}));assert!(is_error(&result), "{result}");- assert_eq!(first_text(&result), "Ctrl is held down, so nothing was sent. Release Ctrl and try again.");+ assert_eq!(first_text(&result), "Ctrl is pressed, so nothing was sent. Release Ctrl, or press and release it once if no one is holding it, and try again.");assert!(rig.desktop.events().is_empty());}@@ -1694,7 +1694,7 @@ mod tests {*rig.desktop.held_keys_at.lock().unwrap() = Some((2, vec![0xa1]));let result = rig.call("type", json!({"text": "hello\nworld"}));assert!(is_error(&result), "{result}");- assert_eq!(first_text(&result), "Shift is held down, so the rest was not sent. Release Shift and try again. Typing stopped after 5 of 11 characters.");+ assert_eq!(first_text(&result), "Shift is pressed, so the rest was not sent. Release Shift, or press and release it once if no one is holding it, and try again. Typing stopped after 5 of 11 characters.");assert_eq!(rig.desktop.events(), vec![InputEvent::Text("hello".into())]);}diff --git a/apps/desktop/src-tauri/src/computer/mod.rs b/apps/desktop/src-tauri/src/computer/mod.rsindex d2055f8..98c43e5 100644--- a/apps/desktop/src-tauri/src/computer/mod.rs+++ b/apps/desktop/src-tauri/src/computer/mod.rs@@ -220,8 +220,9 @@ pub enum TypedError {/// The window in front has no keyboard focus, so where the keys would go is not the approved/// recipient's field.NoFocus,- /// Windows observed held modifiers before the post pressed any keys of its own.- HeldModifiers(String),+ /// Windows reported modifiers down before the post pressed any keys of its own: the user's,+ /// or one a failed post could not release.+ HeldModifiers(Vec<&'static str>),/// Posting failed; part of the post may have been sent.Failed(String),}@@ -238,9 +239,17 @@ impl TypedError {(TypedError::NoFocus, false) => "The window in front has no keyboard focus, so nothing was sent.".into(),(TypedError::NoFocus, true) => "The window in front has no keyboard focus, so the rest was not sent.".into(),(TypedError::HeldModifiers(keys), sent) => {- let verb = if keys.contains(" and ") { "are" } else { "is" };let unsent = if sent { "the rest was not sent" } else { "nothing was sent" };- format!("{keys} {verb} held down, so {unsent}. Release {keys} and try again.")+ match keys.as_slice() {+ [key] => format!(+ "{key} is pressed, so {unsent}. Release {key}, or press and release it once if no one is holding it, and try again."+ ),+ [rest @ .., last] => format!(+ "{} and {last} are pressed, so {unsent}. Release them, or press and release each once if no one is holding them, and try again.",+ rest.join(", ")+ ),+ [] => format!("A modifier is pressed, so {unsent}."),+ }}(TypedError::Failed(error), _) => error.clone(),}diff --git a/apps/desktop/src-tauri/src/computer/winput.rs b/apps/desktop/src-tauri/src/computer/winput.rsindex a481c1e..0eb854f 100644--- a/apps/desktop/src-tauri/src/computer/winput.rs+++ b/apps/desktop/src-tauri/src/computer/winput.rs@@ -11,6 +11,8 @@ use super::{InputEvent, MouseButton, TypedError};/// Sample before the post presses its own modifiers, never between a combo's steps./// GetAsyncKeyState's high bit means down; its low (pressed-since-query) bit is irrelevant.+/// A down modifier may be the user's or one a failed post could not release, so the message+/// names both ways out./// Pointer actions do not check held modifiers yet.pub fn without_held_modifiers(mut key_state: impl FnMut(u16) -> i16,@@ -28,7 +30,7 @@ pub fn without_held_modifiers(if held.is_empty() {post()} else {- Err(TypedError::HeldModifiers(held.join(" and ")))+ Err(TypedError::HeldModifiers(held))}}@@ -45,7 +47,7 @@ mod held_modifier_tests {assert_eq!(without_held_modifiers(|key| if key == held { i16::MIN } else { 0 },|| panic!("held modifier must prevent the post")),- Err(TypedError::HeldModifiers(name.into())));+ Err(TypedError::HeldModifiers(vec![name])));}}}@@ -55,7 +57,16 @@ mod held_modifier_tests {let error = without_held_modifiers(|key| if [0xa2, 0xa3, 0xa0].contains(&key) { i16::MIN } else { 0 },|| panic!("must not post")).unwrap_err();- assert_eq!(error.message(false), "Ctrl and Shift are held down, so nothing was sent. Release Ctrl and Shift and try again.");+ assert_eq!(error.message(false), "Ctrl and Shift are pressed, so nothing was sent. Release them, or press and release each once if no one is holding them, and try again.");+ }++ #[test]+ fn three_modifiers_are_joined_with_commas_and_a_final_and() {+ let error = without_held_modifiers(+ |key| if [0xa3, 0xa4, 0xa0].contains(&key) { i16::MIN } else { 0 },+ || panic!("must not post")).unwrap_err();+ assert_eq!(error.message(false), "Ctrl, Alt and Shift are pressed, so nothing was sent. Release them, or press and release each once if no one is holding them, and try again.");+ assert_eq!(error.message(true), "Ctrl, Alt and Shift are pressed, so the rest was not sent. Release them, or press and release each once if no one is holding them, and try again.");}#[test]diff --git a/docs/design.md b/docs/design.mdindex ff92438..5835bd2 100644--- a/docs/design.md+++ b/docs/design.md@@ -173,7 +173,8 @@ The assistant can see the screen and operate apps through a built-in MCP server- S24.2 Tools: `screenshot`, `click`, `move`, `drag`, `scroll`, `type`, `key`, `open_app`, `list_apps`, `wait`, each with an optional `intent`. Screenshots of the display under the pointer are downscaled to a long edge of 1280 px; coordinates are pixels of the latest screenshot; actions return a fresh one; Gentle Dot's own windows are left out.- S24.3 Session grant: the first call without a session shows a native dialog ("Allow Gentle Dot to see and control this Mac for 30 minutes?"). A session ends on timeout, Stop, the tray item, or the panic shortcut ⌥⇧Esc, and queued actions are dropped.- S24.4 Guards: a fixed blocklist (Gentle Dot itself, System Settings, SecurityAgent, loginwindow, Keychain Access, password managers), 10 actions per second, and a native per-action confirmation for risky actions (send, pay, buy, delete, submit, confirm, transfer, and their Spanish equivalents, by Accessibility role and title, by `return` on a default button, or by the declared `intent`). Keyboard actions go only to the app that was steadily in front during the latest screenshot; their recipient is fixed when they are checked and confirmed and rechecked before each chunk of text, each Return, and the key, and a change stops the input with the count of characters already sent. After a confirmation, the app in front before the dialog must be back in front within 500 ms, or nothing is done.- - Windows held-modifier guard (T59): before each keyboard post (text chunk, Return, or key), read both sides of Ctrl, Alt, Shift and Win with `GetAsyncKeyState`. Refuse before pressing the event's own modifiers, so an injected `ctrl+t` does not refuse itself. A held Ctrl reports exactly "Ctrl is held down, so nothing was sent. Release Ctrl and try again." Multiple held keys are named once in Ctrl/Alt/Shift/Win order, e.g. "Ctrl and Shift are held down, so nothing was sent. Release Ctrl and Shift and try again." After earlier text landed, use "the rest was not sent" and append the character count, e.g. "Shift is held down, so the rest was not sent. Release Shift and try again. Typing stopped after 5 of 11 characters." Before any text lands, the suffix is "Typing stopped after 0 of M characters." This is a pre-post snapshot, not a fence against keys pressed during the post. Pointer actions do not check held modifiers yet; macOS/Linux behavior is unchanged.+ - Windows held-modifier guard: before each keyboard post (text chunk, Return, or key), read both sides of Ctrl, Alt, Shift and Win with `GetAsyncKeyState`. Refuse before pressing the event's own modifiers, so an injected `ctrl+t` does not refuse itself. A pressed modifier may be the user's or one a failed post could not release, so the message names both ways out. One key reports exactly "Ctrl is pressed, so nothing was sent. Release Ctrl, or press and release it once if no one is holding it, and try again." Several keys are named once in Ctrl/Alt/Shift/Win order, joined with ", " and a final " and ", e.g. "Ctrl, Alt and Shift are pressed, so nothing was sent. Release them, or press and release each once if no one is holding them, and try again." After earlier text landed, "nothing was sent" becomes "the rest was not sent" and the character count is appended, e.g. "Shift is pressed, so the rest was not sent. Release Shift, or press and release it once if no one is holding it, and try again. Typing stopped after 5 of 11 characters." Before any text lands, the suffix is "Typing stopped after 0 of M characters." This is a pre-post snapshot, not a fence against keys pressed during the post. Pointer actions do not check held modifiers yet; macOS/Linux behavior is unchanged.+ - The guard also refuses when the agent's own combo needs the modifier the user is resting on (a finger on Shift while it sends `shift+tab`); this is conservative and intended.- S24.5 Permissions: the app reports and requests Accessibility and Screen Recording (`computer_permissions`, `computer_request_permission {kind}`). The Connectors screen shows a built-in "Computer" entry with both statuses, Grant buttons, Check again, the note that debug builds lose the grants on every rebuild (macOS ties them to the code signature), and a note when the current model does not accept images (`ConnectorInfo.noImages`, from the model's `input` in the engine's `get_state` and `set_model` answers).- S24.6 Visible state: the app emits `computer://state {active, endsAt?, reason?}` (`computer_status` gives the current one). Between calls, the rose shows the "in control" state (`dot-in_control`, mood `control`: accent rim, steady traveling light) and the panel shows "Controlling your Mac · mm:ss left" with Stop (`computer_stop`). During a screenshot or action call (including an entire batch and its final screenshot), the Dot and panel are temporarily hidden and the top edge of the controlled display glows in the rose's neon with a light traveling along it, without text or logo. The click-through glow must be ready and hiding confirmed before capture or input; failed preparation sends no input. Completion and normal error/Stop paths restore prior visibility without changing saved preferences or taking focus. The tray's "Stop computer control" and the panic shortcut remain independent of the hidden panel; shortcut registration and full-screen tray availability must be verified on the target Mac.- S24.7 Wiring: the app registers its helper itself, over the app channel, right after it spawns the daemon (`computer_register {url, token}`; the daemon accepts only `http://127.0.0.1:<port>/mcp` and a header-safe key). A window cannot register, repoint, or remove it (L61 closed): the panel only calls `computer_endpoint` to know whether a helper exists. The daemon keeps the endpoint in memory, never in `connectors.json`, and renders `computer: {url, headers: {Authorization: "Bearer <key>"}, exposure: "direct"}` into `mcp.json`, then restarts the engine when idle. The guard's policy lists it under `builtin`, so its tools run without in-engine approval cards. It is removed on `computer_unregister` from the app or when the app's channel closes; windows coming and going do not touch it. A daemon without a channel (`pnpm dev`) gets no helper; the app never uses one (§9, Daemon lifecycle). The key is never logged or sent to a window: `connectors` lists only a built-in "Computer" entry (`builtin: true`) that the connector messages cannot change or remove, no saved or imported connector can take the name `computer`, and the import scan never offers the helper.