From 957a41671bff8b2ed83da36b1e5de8d4468e56d1 Mon Sep 17 00:00:00 2001 From: fkDead Date: Wed, 11 Nov 2026 20:20:49 +0100 Subject: [PATCH] capri-ui: add README --- crates/capri-ui/README.md | 102 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 crates/capri-ui/README.md diff --git a/crates/capri-ui/README.md b/crates/capri-ui/README.md new file mode 100644 index 0000000..b38eba4 --- /dev/null +++ b/crates/capri-ui/README.md @@ -0,0 +1,102 @@ +# capri-ui + +Capri's desktop shell in egui/eframe (glow), forced onto winit's X11 backend: native X11 on i3, +XWayland on KDE Plasma Wayland. Specs: `docs/spec/03-avatar-shell.md` (AV-*), +`docs/spec/04-ui-panels.md` (UI-*). + +| Window | Kind | Notes | +|---|---|---| +| Companion `Capri` 480 x 660 | managed, transparent, undecorated, above, sticky, skip taskbar | X11 input shape = header, composer, reply, cards, sprite box + 12 px: the rest is click-through | +| Settings `Capri Settings` | managed, opaque `#07131c`, undecorated | docked left (or right) of the companion | +| Desktop avatar `Capri Avatar` | override-redirect, transparent, work-area sized | input shape = body box + HUD; raised every 750 ms | +| Mini composer `Capri Composer` 344 x 44 | managed, focusable | shown while detached, within 90 px of the pointer or with a draft | +| Chip `Capri Chip` 52 x 52 | managed, above | shown when hidden to tray (setting) | + +Modules: `avatar` (sprite loader, portrait, mouth plates, intro), `detach` (detach state machine, +overlay, composer, docking), `teleport` (lightning choreography and drag tether, ported from +`avatar-teleport-motion.mjs` / `avatar-drag-tether.mjs`), `dock` (docking geometry, movement +commands), `body` (hit regions, face landmarks), `fx` (glitch, CRT shader, dimming, sleep caption), +`desktop` (KWin scripting over D-Bus, i3 IPC, EWMH fallback, real cursor), `x11` (EWMH states, input +shapes), `settings` (`UiSettings`, theme palette), `settings_window`, `i18n`, `tray`, `chip`, `sound`, +`hooks` (`UiHandle`, approvals). + +## Integration + +### Public API + +```rust +pub fn run( + rt: tokio::runtime::Handle, + engine: Arc, + store: Arc, + pages: Vec, + ui: capri_ui::UiHandle, +) -> anyhow::Result<>; // blocks until Quit + +pub struct SettingsPage { pub section: String, pub title: String, pub draw: Box } +``` + +`run` itself: + +- calls `engine.set_approvals(Arc::new(ui.clone))`: tool confirmations become exact, temporary + approval cards (title translated, detail verbatim, countdown, Confirm/Cancel). Expiry, a dropped + card or anything but Confirm returns `false`. A card reveals a hidden companion (not in focus mode). +- forwards every `SettingsStore` change to `engine.update_settings`. +- starts the tray, the KWin cursor script (KDE) and unloads it on exit. + +Create the `UiHandle` **before** `run` and clone it into the crates that drive the shell: + +| Hook | Caller | Effect | +|---|---|---| +| `set_mouth_level(0..=3)` | voice (RMS -> visemes closed/small/round/wide, ) | mouth plates on standing frames and reviewed poses | +| `set_speaking(bool)` | voice playback | SPEAKING status, speech clip; `false` closes the mouth | +| `set_music(Option)` | music listening (BPM 40..240 with enough confidence) | dance sway, 12 fps held | +| `set_sleeping(bool)` | sleep service | closed eyes, `Zzz.` caption, silent taps | +| `set_wake(Wake::Listening / Heard / Off)` | microphone / wake word | `I'M LISTENING`, `HEARD YOU` (900 ms) | +| `set_stopwatch(Option)` | timers | `HH:MM:SS` in the header | +| `set_attachments(Arc)` | attachments feature | dropped files -> `add`, chips from `names`, `remove` | +| `on_tap(Arc)` | voice / engine | spoken cue and the model reaction at the 10th tap | +| `notice(text)` | anyone | error card in the companion | +| `avatar_command(AvatarCommand)` | voice transcripts | return to frame / perch on a window | +| `show`, `command(Command::…)` | second launch, global shortcut | Show, Hide, ToggleFocus, Settings(section), Teleport, Return, ResetPosition, AlwaysOnTop, Quit | + +`capri_ui::avatar_command(text) -> Option` recognizes the movement commands +(English/Russian, ). The companion's own composer checks it before sending; spoken input must +check it too and call `ui.avatar_command(cmd)` instead of submitting the turn. + +`capri_ui::i18n::{t, tf, set_locale, rtl}`: the interface catalogue +(`assets/i18n/interface-locales.json`, 50 locales, English keys, English fallback). Feature pages +should label their controls with `t("English key")`. + +### Settings sections + +- `sections.ui` = `UiSettings` (`Section::NAME = "ui"`): window (always on top, chip, restore on + wake, start hidden, startup intro, launch at login), presentation (detached style, reply auto-hide), + motion (reduced motion `system|on|off`, float), glitch, CRT, dimming, teleport effects and sound, + drag tether, snap radius, tap gap, interface theme (presets and custom colours). Values are + clamped on read. Read it from other crates with `store.section::`. +- `language.interface` / `language.conversation` / `language.customConversation` (core settings), + personality (`capri_core::persona`), communication style. + +Pages: a known section id (`models`, `api`, `knowledge`, `microphone`, `voice`, `calls`, `music`, +`computer`, `workflows`, `user-tools`, `screen`, `applications`, `files`, `time`, `updates`) takes +that slot in Capri's navigation (`models` shows a placeholder until provided); any other id is +listed under "Capabilities". Page titles are searchable. + +### What the app must wire + +1. One `SettingsStore` shared by every crate and passed to `run`. +2. One `UiHandle` created before `run`, cloned into voice / music / timers / sleep / attachments. +3. Voice transcripts: `capri_ui::avatar_command` before `engine.submit`. +4. i3: a StatusNotifierItem host for the tray (`snixembed --fork` for i3bar's XEmbed tray, or a + bar with SNI support) and a compositor (picom) for transparency. Suggested i3 config: + `for_window [class="^capri$"] floating enable, sticky enable, border none`. + +### Known limits + +- Teleports and docking use the companion's display only; mixed per-output scales assume KWin + logical px = X11 px (true with one global scale). +- Perched windows are followed by an 1800 ms poll (as Capri's Linux bridge), not KWin signals. +- Reviewed-pose limb swing, music notes, portrait pan/zoom, core/collapsed presence, + subtitle paging, credits epithets and the attachment picker button are not implemented. +- egui has no bidi shaping: Arabic/Hebrew/Persian/Urdu text renders unshaped and right-aligned.