Face unlock window steps aside while Apply asks for the password
CI / test (push) Canceled after 3m23s

After Apply the window kept the keyboard and the pointer and its dimmed card
covered the screen, so a password dialog that isn't Chandra's own (another
polkit agent's window) couldn't be reached. While Apply waits, the window now
shows only a note at the top and takes no input. A refused or cancelled
password brings it back with the snaps and marks kept (chandra-face camera
restarts the camera instead of exiting) and says so.

Test: snaps, Enter, the password dialog gets typing (Space no longer snaps
underneath) and the Authenticate click, then the root step finishes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hhiJfJNAYqWzQiuKMf
This commit is contained in:
Claude committed 2026-11-26 04:05:11 +00:00
1 parent f2b2618104
commit 2c2ce3f913
8 files changed
+150 -8

No files matched your search

+80
View File
@@ -563,3 +563,83 @@ let real_keymap : String =
#|};
#|
#|};
///| `settle`, composing frames too (the Face unlock window and Settings follow their tool there).
fn fsettle(comp : @host.ChandraCompositor, a : MockAuthority, cond : () -> Bool) -> Bool {
for i = 0; i < 300; i = i + 1 {
a.bus.pump()
comp.step()
ignore(comp.compose_frame())
if cond() {
return true
}
@sys.sleep_ms(10)
}
false
}
///|
test "Face unlock window: snaps, Apply, then the password dialog gets the keyboard and the click" {
let bus = match auth_bus("faceapply") {
Some(b) => b
None => return
}
let a = MockAuthority::new(bus)
let hpath = "/tmp/chandra-auth-helper-faceapply-" + @sys.getpid().to_string()
let listen = @sys.unix_listen(hpath)
let comp = auth_comp("faceapply", bus, hpath)
comp.server.set_keymap(@utf8.encode(real_keymap))
assert_true(fsettle(comp, a, fn() { comp.polkit.map(p => p.registered()).unwrap_or(false) }))
let dir = "/tmp/chandra-face-apply-" + @sys.getpid().to_string()
let tool = fake_face_tool(dir)
ignore(@sys.write_file_bytes(dir + "/wait", b""))
comp.shell.set_face_tool(["/bin/sh", tool])
assert_true(comp.shell.open_settings(Session))
assert_true(fsettle(comp, a, fn() { face_texts(comp).contains("Desk") }))
face_click(comp, "Add or remove faces…", 10U)
assert_true(fsettle(comp, a, fn() { comp.shell.face.window.map(w => w.picture != 0U).unwrap_or(false) }))
let w = comp.shell.face.window.unwrap()
face_key(comp, 57U, 20U)
assert_true(fsettle(comp, a, fn() { w.snaps.length() == 1 }))
face_key(comp, 57U, 30U)
assert_true(fsettle(comp, a, fn() { w.snaps.length() == 2 }))
// Enter: Apply; the root step asks polkit, which asks us. Meanwhile the window steps aside:
// no dimming card, no input of its own (another agent's password window must be reachable).
face_key(comp, 28U, 40U)
assert_true(w.applying)
ignore(comp.compose_frame())
comp.handle_input(@nested.InputEvent::Key(57U, true), 1U)
comp.handle_input(@nested.InputEvent::Key(57U, false), 1U)
assert_eq(w.snaps.length(), 2)
a.begin("f1", run0_details)
assert_true(fsettle(comp, a, fn() { comp.auth_dialog() is Some(_) }))
let d = comp.auth_dialog().unwrap()
let (h, _) = helper_accept(listen, comp, a)
helper_say(h, "PAM_PROMPT_ECHO_OFF Password: ")
assert_true(fsettle(comp, a, fn() { d.phase == Prompt }))
auth_shot(comp, "18-face-apply-password")
// Typing goes to the password dialog, not to the window under it (Space would snap).
auth_type(comp, "Secret9")
comp.handle_input(@nested.InputEvent::Key(57U, true), 1U)
comp.handle_input(@nested.InputEvent::Key(57U, false), 1U)
assert_eq(d.typed(), 8)
assert_eq(w.snaps.length(), 2)
// The Authenticate button takes the click.
ignore(comp.compose_frame())
let allow = comp.auth.unwrap().hits.filter(x => x.1 == Allow)[0].0
comp.handle_input(@nested.InputEvent::PointerMove((allow.x + 4).to_double(), (allow.y + 4).to_double()), 1U)
comp.handle_input(@nested.InputEvent::PointerButton(272U, true), 2U)
comp.handle_input(@nested.InputEvent::PointerButton(272U, false), 3U)
assert_true(fsettle(comp, a, fn() { d.phase == Checking }))
assert_eq(helper_lines(h, 1), "Secret9 ")
helper_say(h, "SUCCESS")
assert_true(fsettle(comp, a, fn() { comp.auth_dialog() is None && a.answers.length() == 1 }))
// The root step goes on; the window closes with what it said.
ignore(@sys.write_file_bytes(dir + "/go", b""))
assert_true(fsettle(comp, a, fn() { comp.shell.face.window is None }))
assert_eq(comp.shell.face.message, "Added Face 2 and removed 1 face")
@sys.close_fd(h)
@sys.close_fd(listen)
@sys.unlink(hpath)
comp.close()
}