Compare commits
2 Commits
app-v0.1.4
...
app-v0.1.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3af881935c | ||
|
|
20bd90f65e |
2
app/Cargo.lock
generated
2
app/Cargo.lock
generated
@@ -1520,7 +1520,7 @@ checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jarvis-app"
|
name = "jarvis-app"
|
||||||
version = "0.1.43"
|
version = "0.1.44"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "jarvis-app"
|
name = "jarvis-app"
|
||||||
version = "0.1.43"
|
version = "0.1.44"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.85"
|
rust-version = "1.85"
|
||||||
description = "Jarvis v2 Windows app core: Discord voice, voice worker supervisor, chat channels"
|
description = "Jarvis v2 Windows app core: Discord voice, voice worker supervisor, chat channels"
|
||||||
|
|||||||
4
app/shell/Cargo.lock
generated
4
app/shell/Cargo.lock
generated
@@ -2637,7 +2637,7 @@ checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jarvis-app"
|
name = "jarvis-app"
|
||||||
version = "0.1.43"
|
version = "0.1.44"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
@@ -2666,7 +2666,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jarvis-shell"
|
name = "jarvis-shell"
|
||||||
version = "0.1.43"
|
version = "0.1.44"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jarvis-app",
|
"jarvis-app",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "jarvis-shell"
|
name = "jarvis-shell"
|
||||||
version = "0.1.43"
|
version = "0.1.44"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.85"
|
rust-version = "1.85"
|
||||||
description = "Jarvis v2 management app window (Tauri 2 over the app core's AdminApi)"
|
description = "Jarvis v2 management app window (Tauri 2 over the app core's AdminApi)"
|
||||||
|
|||||||
@@ -254,7 +254,9 @@ agent-desktop and decides who may.
|
|||||||
has none; win-ci VM 2026-11-19), so keys go behind only where there is no doubt where they land.
|
has none; win-ci VM 2026-11-19), so keys go behind only where there is no doubt where they land.
|
||||||
Store and WinUI apps (the new Calculator), Chromium, Electron and Firefox windows have none.
|
Store and WinUI apps (the new Calculator), Chromium, Electron and Firefox windows have none.
|
||||||
- **In front for a moment**: a combination, any other key, and every key for a window that does
|
- **In front for a moment**: a combination, any other key, and every key for a window that does
|
||||||
not take keys behind. The window is brought to the front (`focus-window`, then `press`) and the
|
not take keys behind or is minimised. A minimised window is restored inside the moment
|
||||||
|
(restoring brings it forward, so the window in front is noted before and brought back after;
|
||||||
|
the window itself stays restored). The window is brought to the front (`focus-window`, then `press`) and the
|
||||||
window that was in front before is brought back right after (`focus-window` on it, also when
|
window that was in front before is brought back right after (`focus-window` on it, also when
|
||||||
`press` failed; one that cannot be brought back is left, with a warning in the log). For a
|
`press` failed; one that cannot be brought back is left, with a warning in the log). For a
|
||||||
window whose process agent-desktop cannot find from the window (the new Calculator, a Store
|
window whose process agent-desktop cannot find from the window (the new Calculator, a Store
|
||||||
@@ -315,7 +317,8 @@ agent-desktop and decides who may.
|
|||||||
interactive elements read afresh after the action (at most 200), so the brain says it was done
|
interactive elements read afresh after the action (at most 200), so the brain says it was done
|
||||||
only from what it sees; an action that closes its window (a dialog's button, Enter) answers the
|
only from what it sees; an action that closes its window (a dialog's button, Enter) answers the
|
||||||
window with no elements. agent-desktop's error codes come back as Korean reasons (`STALE_REF`: "화면이
|
window with no elements. agent-desktop's error codes come back as Korean reasons (`STALE_REF`: "화면이
|
||||||
바뀌었습니다. 다시 읽어 주세요"; a minimised window is restored before acting).
|
바뀌었습니다. 다시 읽어 주세요"; a minimised window is restored before acting; for `keys` inside
|
||||||
|
the moment in front, "Keys").
|
||||||
- **Refused before asking**: the stop, the anti-cheat, an administrator window (a process whose
|
- **Refused before asking**: the stop, the anti-cheat, an administrator window (a process whose
|
||||||
elevation cannot be read counts as one) and a password field are refused without asking.
|
elevation cannot be read counts as one) and a password field are refused without asking.
|
||||||
`windows` and `read` at `ask` answer `ask: true` like the rest.
|
`windows` and `read` at `ask` answer `ask: true` like the rest.
|
||||||
|
|||||||
@@ -719,7 +719,8 @@ impl Pc {
|
|||||||
if self.stop.on() {
|
if self.stop.on() {
|
||||||
return Err(refused(STOPPED));
|
return Err(refused(STOPPED));
|
||||||
}
|
}
|
||||||
if w.minimised {
|
// Keys restore in their moment in front (restoring brings the window forward).
|
||||||
|
if w.minimised && a.action != "keys" {
|
||||||
self.cmd(&args(&["restore", "--window-id", &w.id]), None, &a.action)?;
|
self.cmd(&args(&["restore", "--window-id", &w.id]), None, &a.action)?;
|
||||||
}
|
}
|
||||||
match a.action.as_str() {
|
match a.action.as_str() {
|
||||||
@@ -743,15 +744,16 @@ impl Pc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Press `keys` in window `w` one way, chosen first (admin.spec.md, "Keys"): behind it when it is
|
/// Press `keys` in window `w` one way, chosen first (admin.spec.md, "Keys"): behind it when it is
|
||||||
/// one plain key and the window takes it so, else in front for a moment and the window that was
|
/// one plain key and the window takes it so, else in front for a moment (a minimised window
|
||||||
/// in front brought back. Never both ways: a key is never pressed twice.
|
/// restored in it) and the window that was in front brought back. Never both ways: a key is
|
||||||
|
/// never pressed twice.
|
||||||
fn keys(&self, w: &Win, keys: &str) -> Result<(), Fail> {
|
fn keys(&self, w: &Win, keys: &str) -> Result<(), Fail> {
|
||||||
let front = self.desktop.foreground();
|
let front = self.desktop.foreground();
|
||||||
if front.as_deref() == Some(w.id.as_str()) {
|
if front.as_deref() == Some(w.id.as_str()) {
|
||||||
crate::debug_log!("conversation", "pc keys way=front-already");
|
crate::debug_log!("conversation", "pc keys way=front-already");
|
||||||
return self.press(w, keys);
|
return self.press(w, keys);
|
||||||
}
|
}
|
||||||
if behind_key(keys).is_some() && self.desktop.takes_keys_behind(&w.id) {
|
if !w.minimised && behind_key(keys).is_some() && self.desktop.takes_keys_behind(&w.id) {
|
||||||
crate::debug_log!("conversation", "pc keys way=behind");
|
crate::debug_log!("conversation", "pc keys way=behind");
|
||||||
return self.desktop.post_key(&w.id, keys).map_err(|code| failed(&code, "keys"));
|
return self.desktop.post_key(&w.id, keys).map_err(|code| failed(&code, "keys"));
|
||||||
}
|
}
|
||||||
@@ -760,7 +762,9 @@ impl Pc {
|
|||||||
return Err(refused(NOT_IN_FRONT_NOW));
|
return Err(refused(NOT_IN_FRONT_NOW));
|
||||||
}
|
}
|
||||||
crate::debug_log!("conversation", "pc keys way=front");
|
crate::debug_log!("conversation", "pc keys way=front");
|
||||||
let pressed = self.cmd(&args(&["focus-window", "--window-id", &w.id]), None, "keys")
|
let restored = if w.minimised { self.cmd(&args(&["restore", "--window-id", &w.id]), None, "keys").map(|_| ()) } else { Ok(()) };
|
||||||
|
let pressed = restored
|
||||||
|
.and_then(|_| self.cmd(&args(&["focus-window", "--window-id", &w.id]), None, "keys"))
|
||||||
.and_then(|_| self.press(w, keys));
|
.and_then(|_| self.press(w, keys));
|
||||||
if let Some(back) = front {
|
if let Some(back) = front {
|
||||||
if self.desktop.run(&args(&["focus-window", "--window-id", &back]), None, self.stop).is_err() {
|
if self.desktop.run(&args(&["focus-window", "--window-id", &back]), None, self.stop).is_err() {
|
||||||
@@ -1361,7 +1365,8 @@ mod tests {
|
|||||||
}
|
}
|
||||||
"get" => json!({"property": "states", "value": if self.secure { json!(["secure"]) } else { json!([]) }}),
|
"get" => json!({"property": "states", "value": if self.secure { json!(["secure"]) } else { json!([]) }}),
|
||||||
"launch" => self.launched.clone(),
|
"launch" => self.launched.clone(),
|
||||||
"focus-window" => {
|
// restore activates the window (SW_RESTORE), as focus-window does.
|
||||||
|
"focus-window" | "restore" => {
|
||||||
*self.front.lock().unwrap() = Some(args[2].clone());
|
*self.front.lock().unwrap() = Some(args[2].clone());
|
||||||
json!({"disposition": {"delivery": "delivered_unverified"}})
|
json!({"disposition": {"delivery": "delivered_unverified"}})
|
||||||
}
|
}
|
||||||
@@ -1743,6 +1748,26 @@ mod tests {
|
|||||||
assert_eq!(fake.front().as_deref(), Some("w-2"));
|
assert_eq!(fake.front().as_deref(), Some("w-2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn keys_to_a_minimised_window_bring_back_the_window_that_was_in_front_and_wait_for_no_game() {
|
||||||
|
// Restoring brings the window forward, so it is part of the moment in front.
|
||||||
|
let (pc, fake, _) = keys_auto(Fake { behind: true, ..Fake::new() });
|
||||||
|
assert_eq!(pc.act(&action("keys", OWNER, json!({"window": "calc", "keys": "ctrl+a"}))).reply["ok"], true);
|
||||||
|
assert_eq!(fake.calls_from("restore"), [
|
||||||
|
args(&["restore", "--window-id", "w-3"]),
|
||||||
|
args(&["focus-window", "--window-id", "w-3"]),
|
||||||
|
args(&["press", "ctrl+a", "--window-id", "w-3"]),
|
||||||
|
args(&["focus-window", "--window-id", "w-2"]),
|
||||||
|
args(&["snapshot", "--window-id", "w-3", "--compact", "--timeout-ms", SNAPSHOT_MS])]);
|
||||||
|
assert_eq!(fake.front().as_deref(), Some("w-2"), "the window in front is back");
|
||||||
|
// During a game or full screen a minimised window is not even restored.
|
||||||
|
let (pc, fake, _) = keys_auto(Fake { behind: true, fullscreen: true, ..Fake::new() });
|
||||||
|
let o = pc.act(&action("keys", OWNER, json!({"window": "calc", "keys": "a"})));
|
||||||
|
assert_eq!(o.reply, json!({"ok": false, "error": NOT_IN_FRONT_NOW}));
|
||||||
|
assert!(!fake.commands().contains(&"restore".to_owned()), "{:?}", fake.commands());
|
||||||
|
assert_eq!(fake.front().as_deref(), Some("w-2"));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn a_store_app_agent_desktop_cannot_name_gets_its_keys_once_it_is_in_front() {
|
fn a_store_app_agent_desktop_cannot_name_gets_its_keys_once_it_is_in_front() {
|
||||||
// Brought in front, and already in front: the key is pressed once, in that window.
|
// Brought in front, and already in front: the key is pressed once, in that window.
|
||||||
|
|||||||
@@ -52,6 +52,16 @@ impl Drop for Closed {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Minimise window `id` ("w-<handle>") as the person would.
|
||||||
|
#[cfg(windows)]
|
||||||
|
fn minimise(id: &str) {
|
||||||
|
let h: usize = id.trim_start_matches("w-").parse().unwrap();
|
||||||
|
// SAFETY: a plain window call on a handle from list-windows.
|
||||||
|
unsafe { windows_sys::Win32::UI::WindowsAndMessaging::ShowWindow(h as _, windows_sys::Win32::UI::WindowsAndMessaging::SW_MINIMIZE) };
|
||||||
|
}
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
fn minimise(_id: &str) {}
|
||||||
|
|
||||||
fn wait_window(pc: &Pc, f: impl Fn(&Value) -> bool) -> String {
|
fn wait_window(pc: &Pc, f: impl Fn(&Value) -> bool) -> String {
|
||||||
let until = Instant::now() + Duration::from_secs(15);
|
let until = Instant::now() + Duration::from_secs(15);
|
||||||
loop {
|
loop {
|
||||||
@@ -117,7 +127,20 @@ fn keys_go_behind_or_in_front_for_a_moment_and_the_window_in_front_stays() {
|
|||||||
assert_eq!(r["ok"], true, "x: {r}");
|
assert_eq!(r["ok"], true, "x: {r}");
|
||||||
let after = values(&act(&pc, "read", json!({"window": notepad})));
|
let after = values(&act(&pc, "read", json!({"window": notepad})));
|
||||||
println!("notepad after ctrl+a, x: {after:?}");
|
println!("notepad after ctrl+a, x: {after:?}");
|
||||||
assert!(after.contains('x') && !after.contains("hi"), "ctrl+a selected the text and x replaced it");
|
assert!(after.split(" | ").any(|v| v == "x") && !after.contains("hi"), "ctrl+a selected the text and x replaced it");
|
||||||
|
|
||||||
|
// A minimised window: restored in the moment in front, and the window in front is back.
|
||||||
|
minimise(¬epad);
|
||||||
|
std::thread::sleep(Duration::from_millis(500));
|
||||||
|
let _ = probe.run(&["focus-window".into(), "--window-id".into(), front.clone()], None, stop);
|
||||||
|
let r = act(&pc, "keys", json!({"window": notepad, "keys": "ctrl+a"}));
|
||||||
|
assert_eq!(r["ok"], true, "minimised ctrl+a: {r}");
|
||||||
|
assert_eq!(probe.foreground().as_deref(), Some(front.as_str()), "minimised ctrl+a: the window in front is back");
|
||||||
|
let r = act(&pc, "keys", json!({"window": notepad, "keys": "y"}));
|
||||||
|
assert_eq!(r["ok"], true, "y: {r}");
|
||||||
|
let after = values(&act(&pc, "read", json!({"window": notepad})));
|
||||||
|
println!("notepad after minimised, ctrl+a, y: {after:?}");
|
||||||
|
assert!(after.split(" | ").any(|v| v == "y") && !after.split(" | ").any(|v| v == "x"), "ctrl+a reached the restored Notepad");
|
||||||
|
|
||||||
// The Calculator: in front for a moment when it does not take keys behind (the Store app).
|
// The Calculator: in front for a moment when it does not take keys behind (the Store app).
|
||||||
let calc = act(&pc, "run", json!({"program": "calc"}));
|
let calc = act(&pc, "run", json!({"program": "calc"}));
|
||||||
|
|||||||
Reference in New Issue
Block a user