From 8c889279f839fca6d295d12fb0ec4c5ca069c2da Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 13 Oct 2026 13:12:41 -0700 Subject: [PATCH] Keyboard Shortcuts: importMatches.list answers an unknown parameter key with an error Since #1442 (3acc29f8), a caller outside the app gets an error for a parameter key that the command's params description doesn't name, and every_description_parses requires each top-level entry of the params object to start with a key. The note on query in importMatches.list had a comma at the top level ("text in the name, target or label"), so the description didn't parse: the test failed, and the command took any key. The note is now in parentheses, and the command takes kind and query. A test checks that shortcutSet.read and the three importMatches commands take every key they read and refuse a misspelled one. --- crates/engine/src/cmd/importmatches.rs | 2 +- crates/engine/src/tests_shortcutset.rs | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/importmatches.rs b/crates/engine/src/cmd/importmatches.rs index fcadf8cbb..d227b84ed 100644 --- a/crates/engine/src/cmd/importmatches.rs +++ b/crates/engine/src/cmd/importmatches.rs @@ -45,7 +45,7 @@ pub fn specs() -> Vec { "Import Matches", [], None, - "{kind?: name|key|modifiers, query?: text in the name, target or label (any case)} the matches the user confirmed when importing other apps' files (shortcut sets), kept with the preferences → [{kind, name, target, label?}] (target \"\": no equivalent)", + "{kind?: name|key|modifiers, query?: text (in the name, target or label; any case)} the matches the user confirmed when importing other apps' files (shortcut sets), kept with the preferences → [{kind, name, target, label?}] (target \"\": no equivalent)", always, list ), diff --git a/crates/engine/src/tests_shortcutset.rs b/crates/engine/src/tests_shortcutset.rs index bc14cf864..6b9952c31 100644 --- a/crates/engine/src/tests_shortcutset.rs +++ b/crates/engine/src/tests_shortcutset.rs @@ -224,3 +224,17 @@ fn read_shows_what_earlier_imports_matched() { let mods = json!([{"value": 0, "count": 1, "mods": ""}, {"value": 64, "count": 1, "mods": "Cmd"}, {"value": 80, "count": 1}]); assert_eq!(r["codes"]["modifiers"], mods); } + +#[test] +fn the_commands_take_only_the_keys_they_describe() { + // The control channel, MCP and the CLI check params against the description (#1442). + for (id, every_key) in [ + ("shortcutSet.read", json!({"path": "/x/a.kys", "data": "", "dataBase64": "", "name": "a.kys"})), + ("importMatches.list", json!({"kind": "name", "query": "undo"})), + ("importMatches.set", json!({"matches": []})), + ("importMatches.reset", json!({"kind": "key"})), + ] { + check_params(id, &every_key).unwrap(); + assert!(check_params(id, &json!({"qeury": "undo"})).is_err(), "{id}"); + } +}