Frontend architecture
Layering, scene runtime invariants, multi-display management, and performance budgets.
1. Layering & responsibilities
The Flutter frontend owns presentation, input, and local interaction state, while the Rust backend owns the PAM/greetd authentication protocol over D-Bus.
GreeterFeature
business state, typed slots, commands, recovery, D-Bus gateway
|
v
GreeterSceneAdapter
maps semantic state to ScenePredicate flags and GreeterHost callbacks
|
v
ThemeDefinition
theme identity, generated SceneDocument, component factory
|
v
ThemeBundle
ThemeTokens, BackgroundRenderer registry, SceneMotionBuilder registry
|
v
SceneRuntime
normalized layout, 2.5D transforms, repaint boundaries, motion lifecycle
Strict separation of concerns:
GreeterFeatureknows nothing about themes, backgrounds, blur, motion, or monitor geometry.- Themes never access
GreeterFeature, D-Bus, or PAM transport objects. - Secrets (passwords, OTP tokens, raw PAM frames) never enter
SceneDocument,ThemeBundle, or logs.
2. Theme packages & scene documents
Each theme is a standalone Dart package compiled into the executable, supported by the shared frontend packages:
| Package | Role |
|---|---|
packages/scene_schema | Flutter-free SceneDocument model, predicate evaluator, component/layout/preset contracts, and JSON codec |
packages/scene | SceneRuntime, ThemeBundle, frame/breakpoint layout, style tokens, portable shader backgrounds, and motion/track playback (re-exports scene_schema) |
packages/scene_codegen | build_runner generator that validates *.scene.json and emits *.scene.g.dart |
packages/theme_sdk | ThemeDefinition, GreeterHost, typed state slots, and wallpaper palette extraction (re-exports scene) |
packages/greeter_components | Optional reusable widget set (StandardGreeterComponents) |
packages/greeter_ui | GreeterFeature business state machine, typed commands, and GreeterSceneAdapter |
packages/theme_project | Pure Dart project validation, primary-scene discovery, and independent theme synthesis |
packages/greeter_harness | Shared preview journeys (face-success, password-fallback) and frame performance aggregation |
Scene node invariants
- Explicit ordering:
z(spatial depth),renderOrder(paint order), andfocusOrder(keyboard traversal) are independent fields and are never inferred from widget tree insertion order. - Declarative visibility (
visibleWhen): Evaluated over a closed enum (ScenePredicate) usingall,any, andnot. Arbitrary scripts or runtime-loaded Dart are not supported. - Compile-time scenes: Production executables use generated
*.scene.g.dartdirectly without parsing JSON at login time.
3. SceneRuntime & rendering performance
SceneRuntime enforces fast, isolated updates across the scene tree:
- Targeted rebuilds & repaints: Each scene node is wrapped in a
RepaintBoundary. Theme widgets subscribe to specificGreeterHostlistenables viaSceneRegion, and visibility changes are handled per node without rebuilding the entire scene tree. - Exit transitions and prewarming: When
visibleWhenbecomesfalse, the node stops accepting pointer/focus input and reverses its exit animation. By default,SceneRuntimeunmounts the hidden subtree after the transition. The greeter’sThemeDefinitionenablesprewarmHiddenNodesto reduce wake latency, keeping hidden components mounted so wake transitions do not pay initial widget creation cost. Theme components should keep hidden state idle and release subscriptions indispose(). - Interactive invariants: Transformed interactive nodes enforce minimum hit target sizes (
minHitTarget), safe-area fallback, and deterministicfocusOrdertraversal.
Layout, backgrounds, motion, and blur
- Frames, primitives, and asset layers: Alongside theme-provided widgets,
SceneRuntimedirectly renders layout frames (absolute,row, andcolumnwithproportional/fill/hugsizing and viewportbreakpoints), portable primitives (text,rectangle,circle), image/SVG asset layers, and shared visualstyleTokens. - Background renderers & shaders: Built-in
image,solid, and portable fragmentshaderrenderers (supporting uniform bindings, texture samplers, and custombackground.parameters), plus compile-timevideoandcustomrenderer extension points. - Motion, keyframe tracks, and state transitions: Supports presence presets (
none,fade,fadeSlide,fadeScale,hoverLift,focusGlow), per-nodemotionTiming(duration, delay, cubic Bezier curve), keyframe propertytracks(opacity,translateX,translateY,scale,rotation), and predicate-triggeredstateEffects/transitions(shake,pulse).SceneMotionBuilderwraps each node using an externally drivenAnimation<double>owned bySceneRuntime—globalAnimatedSwitcheror fullscreen animated overlays are not used. - Blur: Canvas
blurSigmais cached with the background repaint boundary and animated across wake transitions. Bounded glass panels may useBackdropFilterwith a solid fallback in reduced-motion or low-power modes.
4. Multi-display & dormant state behavior
Single-engine multi-monitor views
- The native Linux runner (
apps/greeter/linux/runner/my_application.cc) creates one fullscreenFlViewper connected monitor inside a single Flutter engine. MyApprenders sibling views viaViewAnchorandViewCollection, sharing oneGreeterFeatureand onecredentialController.- Each monitor’s
GreeterSceneAdapterowns its local focus tree and wake animation, while GTK reports the active monitor through theakari/displayschannel so only the focused display processes global keyboard submission. - When a monitor is unplugged, the implicit root view migrates to a remaining output (or stays hidden until an output reconnects) without interrupting the active authentication attempt.
Dormant state (Escape)
Pressing Escape returns the UI to the dormant background (isDormant) and clears local text in credentialController, but does not cancel the active backend authentication attempt. Waking the greeter resumes the same PAM prompt and restores focus, preventing UI hide/wake toggles from counting as failed PAM attempts.
5. Testing & performance budgets
| Test layer | Scope |
|---|---|
| Unit tests | GreeterFeature reducers/commands, attempt isolation, secret handling, scene_schema validation, and codegen contracts |
| Interaction tests | Account/session selection, prompt focus, submit/cancel/retry, power actions, and keyboard traversal |
| Runtime tests | Safe-area fallback, renderOrder / focusOrder, reduced motion, and background fallback |
Performance gate (themes/default) | Runs in Linux/Wayland profile mode (akari verify-perf). Requires >= 3 cycles, < 5 ms first-response UI build/layout/paint time, phase/aggregate p95 within two 16.67 ms frame budgets, < 20% regression vs. baseline, and no extra platform wake-ups when static. |