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,23 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/host/font"
// Values
pub fn load(UInt32, String) -> Bool
pub fn rasterise(UInt32, UInt32, UInt32) -> Glyph
// Errors
// Types and methods
pub(all) struct Glyph {
width : Int32
height : Int32
xoff : Int32
yoff : Int32
advance : Int32
coverage : FixedArray[Byte]
}
// Type aliases
// Traits
+8
View File
@@ -12,6 +12,9 @@ fn wasmImportLoadImage(p0 : Int, p1 : Int) -> Int = "chandra:host/raster@0.1.0"
///|
fn wasmImportThumbnail(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int = "chandra:host/raster@0.1.0" "thumbnail"
///|
fn wasmImportImagePixels(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int) -> Int = "chandra:host/raster@0.1.0" "image-pixels"
///|
fn wasmImportSubmit(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int, p5 : Int, p6 : Int, p7 : Int, p8 : Int, p9 : Int, p10 : Int, p11 : Int, p12 : Int) = "chandra:host/raster@0.1.0" "submit"
@@ -56,6 +59,11 @@ extern "wasm" fn mbt_ffi_store32(offset : Int, value : Int) =
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
#|(func (param i32) (result i32) local.get 0 i32.load)
///|
#owned(bytes)
extern "wasm" fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int =
#|(func (param i32) (result i32) local.get 0)
///|
extern "wasm" fn mbt_ffi_free(position : Int) =
#|(func (param i32) local.get 0 call $moonbit.decref)
@@ -20,6 +20,16 @@ fn wasmImportThumbnail(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int {
abort("wasm-only host import")
}
///|
fn wasmImportImagePixels(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int) -> Int {
abort("wasm-only host import")
}
///|
fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int {
abort("wasm-only")
}
///|
fn wasmImportSubmit(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int, p5 : Int, p6 : Int, p7 : Int, p8 : Int, p9 : Int, p10 : Int, p11 : Int, p12 : Int) -> Unit {
abort("wasm-only host import")
@@ -0,0 +1,135 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/host/raster"
// Values
pub fn capture(Int32, Int32, Int32, Int32, Int32, Int32) -> UInt32
pub fn export_memfd() -> Int32
pub fn grab_recording_frame(Int32, Int32, Int32, Int32, Bool, Int32, Int32) -> Bool
pub fn image_pixels(Int32, Int32, FixedArray[Byte], UInt32) -> UInt32
pub fn load_image(String) -> UInt32
pub fn read_frame() -> FixedArray[Byte]
pub fn release(UInt32) -> Unit
pub fn send_recording_frame(Int32) -> Int32
pub fn snapshot_frame() -> Bool
pub fn snapshot_pixels(Int32, Int32, Int32, Int32, Int32, Int32) -> FixedArray[Byte]
pub fn snapshot_png(Int32, Int32, Int32, Int32) -> FixedArray[Byte]
pub fn submit(Frame) -> Unit
pub fn thumbnail(UInt32, Int32, Int32, UInt32) -> UInt32
pub fn write_frame_png(String) -> Bool
// Errors
// Types and methods
pub(all) struct Color {
r : Byte
g : Byte
b : Byte
a : Byte
}
pub(all) struct Disc {
cx : Int32
cy : Int32
radius : Int32
color : Color
filled : Bool
}
pub(all) struct Fill {
area : Rect
color : Color
radius : Int32
}
pub(all) struct Frame {
width : Int32
height : Int32
wallpaper : Array[Op]?
background : Array[Op]
windows : Array[Window]
panel : Array[Op]
popups : Array[Popup]
}
pub(all) struct Label {
x : Int32
y : Int32
text : String
size : Int32
color : Color
align : Byte
bold : Bool
mono : Bool
}
pub(all) enum Op {
FillRect(Fill)
StrokeRect(Stroke)
DrawLine(Segment)
DrawCircle(Disc)
DrawText(Label)
PushClip(Rect)
PopClip
DrawImage(Picture)
}
pub(all) struct Picture {
area : Rect
image : UInt32
}
pub(all) struct Popup {
area : Rect
surface : UInt32
}
pub(all) struct Rect {
x : Int32
y : Int32
w : Int32
h : Int32
}
pub(all) struct Segment {
x0 : Int32
y0 : Int32
x1 : Int32
y1 : Int32
color : Color
width : Int32
}
pub(all) struct Stroke {
area : Rect
color : Color
width : Int32
radius : Int32
}
pub(all) struct Window {
geometry : Rect
inset_top : Int32
inset_right : Int32
inset_bottom : Int32
inset_left : Int32
deco : Array[Op]
fullscreen : Bool
surface : UInt32
}
// Type aliases
// Traits
+14
View File
@@ -95,6 +95,20 @@ pub fn thumbnail(surface : UInt, w : Int, h : Int, reuse : UInt) -> UInt {
let ret = (result).reinterpret_as_uint()
return ret
}
///|
/// `w` x `h` RGBA8888 pixels as an image for `draw-image` (the face unlock window's camera
/// picture). `reuse`: an earlier handle from this function or `thumbnail` to overwrite in place,
/// 0 for a new one. 0 when the size is silly or `rgba` is too short.
pub fn image_pixels(w : Int, h : Int, rgba : FixedArray[Byte], reuse : UInt) -> UInt {
let ptr = mbt_ffi_bytes2ptr(rgba)
let result : Int = wasmImportImagePixels(w, h, ptr, rgba.length(), (reuse).reinterpret_as_int());
mbt_ffi_free(ptr)
let ret = (result).reinterpret_as_uint()
return ret
}
///|
/// Draw a frame into the host framebuffer.
@@ -42,7 +42,7 @@ pub fn sleep_ms(Int32) -> Unit
pub fn spawn(String, String) -> Bool
pub fn spawn_socket(String) -> Int
pub fn spawn_socket(String) -> Int32
pub fn take_fd(Int32) -> Int32