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,32 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/default-apps"
// Values
pub fn apps() -> Array[AppChoice]
pub fn categories() -> Array[AppCategory]
pub fn refresh() -> Unit
pub fn set_default(UInt32, UInt32) -> Unit
// Errors
// Types and methods
pub(all) struct AppCategory {
name : String
current : String
missing : String
}
pub(all) struct AppChoice {
category : UInt32
id : String
name : String
icon : UInt32
current : Bool
}
// Type aliases
// Traits
@@ -1,4 +1,5 @@
Face unlock (docs/face-unlock.md): the session user's enrolled faces and whether the password
dialog and sudo try the face first. Every change runs chandra-face through run0 or pkexec, so
polkit asks for an administrator's password before anything happens; the module never sees a
camera picture or any face data, only labels.
dialog and sudo try the face first. Faces are added and removed in the compositor's Face unlock
window, whose Apply runs chandra-face through run0 or pkexec once, so polkit asks for an
administrator's password before anything changes; the module never sees a camera picture or
any face data, only labels.
@@ -47,14 +47,14 @@ pub fn faces() -> Array[Face] {
}
///|
/// Add a face: after the password, the camera looks for about ten seconds.
/// Open the Face unlock window (live camera picture, Snap, saved faces, one Apply).
pub fn enroll() -> Unit {
wasmImportEnroll();
}
///|
/// Forget face `index` of `faces`.
/// Open the Face unlock window with face `index` of `faces` marked for removal.
pub fn remove(index : UInt) -> Unit {
wasmImportRemove((index).reinterpret_as_int());
@@ -0,0 +1,13 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/icons"
// Values
pub fn app_icon(String) -> UInt32
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,15 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/inspector"
// Values
pub fn is_on() -> Bool
pub fn set_on(Bool) -> Unit
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,17 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/layout-control"
// Values
pub fn current_layout() -> UInt32
pub fn layout_modes() -> Array[String]
pub fn set_layout(UInt32) -> Unit
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,35 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/modules"
// Values
pub fn available() -> Array[ModuleInfo]
pub fn browse() -> Unit
pub fn load_module(String) -> Unit
pub fn loaded() -> Array[InstanceInfo]
pub fn move_instance(String, Int32) -> Unit
pub fn unload_instance(String) -> Unit
// Errors
// Types and methods
pub(all) struct InstanceInfo {
slot : String
module_ : String
name : String
}
pub(all) struct ModuleInfo {
id : String
name : String
path : String
loaded : UInt32
}
// Type aliases
// Traits
@@ -0,0 +1,45 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/network"
// Values
pub fn connect(String, String) -> Unit
pub fn disconnect() -> Unit
pub fn forget(String) -> Unit
pub fn scan() -> Unit
pub fn set_airplane_mode(Bool) -> Unit
pub fn set_wifi_enabled(Bool) -> Unit
pub fn status() -> NetStatus
pub fn wifi_networks() -> Array[WifiNetwork]
// Errors
// Types and methods
pub(all) struct NetStatus {
state : UInt32
signal : UInt32
name : String
message : String
wifi_enabled : Bool
airplane : Bool
can_manage : Bool
has_wifi : Bool
}
pub(all) struct WifiNetwork {
ssid : String
signal : UInt32
secured : Bool
active : Bool
saved : Bool
}
// Type aliases
// Traits
@@ -0,0 +1,25 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/power"
// Values
pub fn power_off() -> Unit
pub fn reboot() -> Unit
pub fn screen_off_minutes() -> UInt32
pub fn set_screen_off_minutes(UInt32) -> Unit
pub fn set_suspend_minutes(UInt32) -> Unit
pub fn suspend() -> Unit
pub fn suspend_minutes() -> UInt32
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,23 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/screenshot"
// Values
pub fn is_recording() -> Bool
pub fn records_pointer() -> Bool
pub fn set_records_pointer(Bool) -> Unit
pub fn start_recording(UInt32) -> Unit
pub fn stop_recording() -> Unit
pub fn take(UInt32) -> Unit
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,17 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/session-settings"
// Values
pub fn is_on(UInt32) -> Bool
pub fn set_setting(UInt32, Bool) -> Unit
pub fn settings() -> Array[String]
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,15 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/session"
// Values
pub fn logout() -> Unit
pub fn reload() -> Unit
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,28 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/shortcuts"
// Values
pub fn cancel_capture() -> Unit
pub fn capture(UInt32) -> Unit
pub fn reset(UInt32) -> Unit
pub fn reset_all() -> Unit
pub fn shortcuts() -> Array[Shortcut]
// Errors
// Types and methods
pub(all) struct Shortcut {
name : String
binding : String
default_binding : String
conflict : String
capturing : Bool
}
// Type aliases
// Traits
@@ -0,0 +1,24 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/system"
// Values
pub fn read() -> Snapshot
// Errors
// Types and methods
pub(all) struct Snapshot {
cpu_permille : UInt32
mem_used_kib : UInt64
mem_total_kib : UInt64
battery_percent : Int32
charging : Bool
uptime_secs : UInt64
net_rx_bytes_per_sec : UInt64
net_tx_bytes_per_sec : UInt64
load_centi : UInt32
}
// Type aliases
// Traits
@@ -0,0 +1,23 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/wallpaper"
// Values
pub fn current_desktop() -> UInt32
pub fn current_wallpaper() -> UInt32
pub fn desktops() -> Array[String]
pub fn set_desktop(UInt32) -> Unit
pub fn set_wallpaper(UInt32) -> Unit
pub fn wallpapers() -> Array[String]
// Errors
// Types and methods
// Type aliases
// Traits
@@ -0,0 +1,32 @@
// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/interface/chandra/desktop/windows"
// Values
pub fn all() -> Array[WindowDetail]
pub fn focus(UInt64) -> Unit
pub fn focus_window(UInt32) -> Unit
pub fn list_windows() -> Array[WindowInfo]
// Errors
// Types and methods
pub(all) struct WindowDetail {
id : UInt64
title : String
app_id : String
focused : Bool
}
pub(all) struct WindowInfo {
id : UInt32
title : String
focused : UInt32
minimized : UInt32
}
// Type aliases
// Traits
@@ -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