Face unlock window: live camera preview, Snap, thumbnails, one password on Apply
CI / test (push) Failing after 12m30s

Settings > Session "Add or remove faces…" (and "Remove…" on a face) opens a
compositor-drawn Face unlock window instead of running root steps one by one:

- chandra-face camera runs as the user (no password): it streams a small live
  picture with the face box and a cropped thumbnail per snap; the snaps'
  embeddings stay in that process, nothing is written to disk.
- Click a snap to drop it; mark saved faces Remove/Keep.
- Apply saves the snaps as one face and removes the marked ones in one root
  `chandra-face apply` (JSON on stdin, validated) through run0/pkexec: one
  password prompt.
- New raster host function image-pixels (host-wasm, wasmhost, native) for the
  window's pictures.

Tests: camera session and apply in face/test_face.py; the window end to end
against a fake tool in compositor/host/face_test.mbt. Docs explain why the
change itself still needs root.

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 02:36:29 +00:00
1 parent 0a9787ae36
commit 9f7489cfea
74 files changed
+2617 -89

No files matched your search

@@ -0,0 +1,44 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/components/session-settings/gen/interface/chandra/desktop/plasmoid"
import {
"chandra/desktop/interface/chandra/desktop/types",
}
// Values
pub fn info() -> PlasmoidInfo
pub fn on_event(Surface, @types.InputEvent) -> Bool
pub fn popup() -> PopupSurface?
pub fn render(@types.Size) -> Array[@types.DrawOp]
// Errors
// Types and methods
pub(all) struct PlasmoidInfo {
id : String
name : String
preferred : @types.Size
min_width : UInt32
stretch : Bool
}
pub(all) struct PopupSurface {
size : @types.Size
ops : Array[@types.DrawOp]
}
type Row
pub(all) enum Surface {
WIDGET
POPUP
}
pub fn Surface::from(Int32) -> Self
pub fn Surface::ordinal(Self) -> Int32
// Type aliases
// Traits
@@ -96,9 +96,9 @@ enum Row {
AppOption(Int, Int, @default_apps.AppChoice)
/// Face unlock's switch: the password dialog and sudo try the face first.
FaceUse
/// An enrolled face: its index, label and when it was added (a second click removes it).
/// An enrolled face: its index, label and when it was added ("Remove…" opens the window).
FaceRow(Int, String, String)
/// "Add a face..."
/// "Add or remove faces..." (the Face unlock window)
FaceAdd
}
@@ -305,7 +305,8 @@ fn rows() -> Array[Row] {
}
///| Face unlock's rows on the Session tab (docs/face-unlock.md): the switch, the enrolled faces,
/// "Add a face..." and what the last change said. Changes ask for the password first.
/// "Add or remove faces..." and what the last change said. Changes ask for the password first
/// (the window's Apply asks once for everything).
fn face_rows(rs : Array[Row]) -> Unit {
let st = @face_unlock.status()
rs.push(Heading("Face unlock"))
@@ -329,11 +330,6 @@ fn face_rows(rs : Array[Row]) -> Unit {
}
}
///| `armed` value for "click again to remove" on face `i`.
fn face_armed(i : Int) -> Int {
100 + i
}
///| Whether row `i` of `rs` can be highlighted and acted on (headings can't).
fn active(rs : Array[Row], i : Int) -> Bool {
i >= 0 && i < rs.length() && !(rs[i] is (Heading(_) | Info(_) | Category(_) | NothingToAdd))
@@ -517,12 +513,8 @@ fn act(rs : Array[Row], i : Int, btn~ : Int = -1, x~ : Int = 0) -> Unit {
if !@face_unlock.status().busy {
@face_unlock.set_in_use(!@face_unlock.status().in_use)
}
FaceRow(k, _, _) =>
if was_armed == face_armed(k) {
@face_unlock.remove(k.reinterpret_as_uint())
} else {
armed.val = face_armed(k)
}
// Both open the Face unlock window (nothing changes until its Apply).
FaceRow(k, _, _) => if !@face_unlock.status().busy { @face_unlock.remove(k.reinterpret_as_uint()) }
FaceAdd => if !@face_unlock.status().busy { @face_unlock.enroll() }
Shortcut(k, sc) =>
if sc.capturing {
@@ -691,7 +683,8 @@ pub fn popup() -> PopupSurface? {
switch_ops(w, mid, st.in_use, p, ops)
}
FaceRow(k, label, added) => {
// A face glyph, the label and date; "Remove" at the right (a second click removes).
// A face glyph, the label and date; "Remove…" at the right (opens the Face unlock window
// with this face marked).
let gx = margin + 18
ops.push(@ui.circle(gx, mid, 7, list_fg, filled=false))
ops.push(@ui.circle(gx - 3, mid - 2, 1, list_fg))
@@ -700,13 +693,12 @@ pub fn popup() -> PopupSurface? {
ops.push(@ui.text(margin + 32, mid, label, fs - 1, list_fg))
let lw = @ui.text_width(label, fs - 1)
ops.push(@ui.text(margin + 40 + lw, mid, "added " + added, fs - 3, if hot { list_fg } else { p.foreground_muted }))
let armed_here = armed.val == face_armed(k)
let rlabel = if armed_here { "Click again to remove" } else { "Remove" }
ops.push(@ui.text(w - margin - 10, mid, rlabel, fs - 2, if hot { list_fg } else { p.accent }, align=RIGHT, bold=armed_here))
ignore(k)
ops.push(@ui.text(w - margin - 10, mid, "Remove…", fs - 2, if hot { list_fg } else { p.accent }, align=RIGHT))
}
FaceAdd => {
let busy = @face_unlock.status().busy
ops.push(@ui.text(margin + 10, mid, if busy { "Working…" } else { "Add a face…" }, fs - 1, if busy && !hot { p.foreground_muted } else { list_fg }, bold=true))
ops.push(@ui.text(margin + 10, mid, if busy { "Working…" } else { "Add or remove faces…" }, fs - 1, if busy && !hot { p.foreground_muted } else { list_fg }, bold=true))
}
DesktopChoice(k, name) => {
if k == cur_desk {
@@ -0,0 +1,13 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/components/session-settings/gen"
// Values
pub fn mbt_ffi_cabi_realloc(Int32, Int32, Int32, Int32) -> Int32
// Errors
// Types and methods
// Type aliases
// Traits