Linux port: first run, packaging, single instance, privacy and wiring
CI / test (push) Has been cancelled

First run and backend
- The companion opens without Ollama or a model (OFFLINE / SETUP REQUIRED),
  opens Settings > Language model and picks the model up once downloaded.
- Model, provider and GPU changes apply without restarting (Ollama is
  restarted when launch settings change); no silent fallback from API mode.
- Fatal startup errors are shown in a window; the fallback avatar loads
  again; the shipped Capri artwork is used when nothing was imported.

Packaging and tooling
- packaging/arch/PKGBUILD, capri.desktop (KWin ScreenShot2 key), icons,
  artwork under /usr/share/capri/assets, Gitea Actions CI.
- xtask: `icons` and `release-check` (no private data or credentials).

Runtime
- One instance per data folder (flock + control socket): second launch
  shows the window; capri stop / restart / toggle / status (JSON, starts
  nothing) / doctor / setup / diagnostics export / purge.
- A foreign program on the Ollama port is refused; an Ollama left behind
  by Capri is replaced.

Privacy and security
- No raw Ollama log on disk; API keys are never saved in plaintext (old
  ones move to the keyring); refused credential notes are stored as
  [Credentials omitted]; launched apps get an allow-listed environment.

Fixes
- Stop/Escape silence the voice; saved voice effects apply to replies;
  settings_control glitch settings apply; distinct KWin cursor scripts;
  KDE window capture authorized for source builds; Linux wording.
- Voice pack references zipped with Windows separators are found.

Wired features
- Initiatives, request router, resource monitor, "clip that", questions
  about a snapshot, sleep mode, tap reactions, stopwatch, attachments,
  Internet mode button, voice-synced subtitles, wake visuals, dictation
  draft, tray switches, Spotify seek/shuffle/repeat; computer-control
  planner and classifier follow model switches and API mode.
- Approval cards: one shown, 8 queued, deduplicated, cancelled on stop,
  failure, lock or pause; one Application access switch.

Desktop
- Compositor detection (no black overlay on i3 without picom), i3lock
  detection, unsupported desktops reported at startup, screenshot-only
  control without AT-SPI, fontconfig fallbacks, translatable feature
  pages with French translations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nocodeandClaude Opus 5.5 committed 2026-11-12 20:21:40 +01:00
1 parent a2abf01280
commit 49349d6ecd
73 files changed
+4834 -517

No files matched your search

+2 -1
View File
@@ -7,7 +7,8 @@ license.workspace = true
[dependencies]
anyhow.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_json = { workspace = true, features = ["raw_value"] }
parking_lot.workspace = true
directories.workspace = true
uuid.workspace = true
libc.workspace = true
+7
View File
@@ -249,7 +249,12 @@ impl Catalog {
self.frames.iter().find(|f| f.id == id)
}
/// File of a frame. The bundled fallback has no folder: its frame path is empty, which the
/// renderer reads as [`DEFAULT_AVATAR_PNG`] (a relative `avatar.png` would depend on the cwd).
pub fn frame_path(&self, frame: &Frame) -> PathBuf {
if self.dir.as_os_str().is_empty() {
return PathBuf::new();
}
self.dir.join(&frame.file)
}
@@ -271,6 +276,8 @@ mod tests {
let c = Catalog::fallback();
assert_eq!(c.default_id, "neutral");
assert_eq!(c.model_sprites.len(), 1);
// Empty path = the embedded PNG, whatever the working directory.
assert_eq!(c.frame_path(c.frame("neutral").unwrap()), PathBuf::new());
}
#[test]
+130
View File
@@ -0,0 +1,130 @@
//! Interface translations: English source strings are the keys of
//! `assets/i18n/interface-locales.json`; a missing locale or key falls back to English.
use std::collections::HashMap;
use std::sync::{Arc, OnceLock};
use parking_lot::RwLock;
use serde::Deserialize;
use serde_json::value::RawValue;
static BUNDLE_JSON: &[u8] = include_bytes!("../../../assets/i18n/interface-locales.json");
/// Bundle order; the JSON object order is lost by the map below.
pub const LOCALES: [&str; 50] = [
"en", "ru", "de", "fr", "es", "it", "pt", "nl", "pl", "uk", "cs", "sk", "bg", "hr", "sr", "sl", "ro", "hu", "el", "da", "no",
"sv", "fi", "et", "lv", "lt", "is", "ca", "ar", "he", "fa", "ur", "hi", "bn", "ta", "te", "mr", "gu", "pa", "zh", "ja", "ko",
"vi", "th", "id", "ms", "tl", "tr", "sw", "af",
];
#[derive(Deserialize)]
struct Bundle {
locales: HashMap<String, Locale>,
#[serde(rename = "languageNames")]
language_names: HashMap<String, Box<RawValue>>,
}
#[derive(Deserialize)]
struct Locale {
#[serde(rename = "nativeName")]
native_name: String,
direction: String,
messages: Box<RawValue>,
}
fn bundle() -> &'static Bundle {
static BUNDLE: OnceLock<Bundle> = OnceLock::new();
BUNDLE.get_or_init(|| serde_json::from_slice(BUNDLE_JSON).expect("bundled interface locales"))
}
struct Active {
id: String,
rtl: bool,
messages: HashMap<String, String>,
names: HashMap<String, String>,
}
static ACTIVE: RwLock<Option<Arc<Active>>> = RwLock::new(None);
fn load(id: &str) -> Active {
let bundle = bundle();
let id = if bundle.locales.contains_key(id) { id } else { "en" };
let locale = &bundle.locales[id];
let names = bundle.language_names.get(id).and_then(|raw| serde_json::from_str(raw.get()).ok()).unwrap_or_default();
Active {
id: id.to_string(),
rtl: locale.direction == "rtl",
messages: serde_json::from_str(locale.messages.get()).unwrap_or_default(),
names,
}
}
fn active() -> Arc<Active> {
if let Some(a) = ACTIVE.read().clone() {
return a;
}
let a = Arc::new(load("en"));
*ACTIVE.write() = Some(a.clone());
a
}
/// Switches the interface language; unknown ids mean English.
pub fn set_locale(id: &str) {
if ACTIVE.read().as_ref().is_some_and(|a| a.id == id) {
return;
}
*ACTIVE.write() = Some(Arc::new(load(id)));
}
pub fn locale() -> String {
active().id.clone()
}
/// Arabic, Hebrew, Persian and Urdu. egui has no bidi shaping: text is right-aligned only.
pub fn rtl() -> bool {
active().rtl
}
/// Translation of an English UI key; unknown keys (owner data) pass through unchanged.
pub fn t(key: &str) -> String {
active().messages.get(key).cloned().unwrap_or_else(|| key.to_string())
}
/// `t` with `{name}` placeholders replaced.
pub fn tf(key: &str, values: &[(&str, &str)]) -> String {
values.iter().fold(t(key), |text, (name, value)| text.replace(&format!("{{{name}}}"), value))
}
/// Native name of an interface locale, for the language picker.
pub fn native_name(id: &str) -> String {
bundle().locales.get(id).map(|l| l.native_name.clone()).unwrap_or_else(|| id.to_string())
}
/// Conversation language name in the interface language.
pub fn language_name(id: &str) -> String {
if let Some(name) = active().names.get(id) {
return name.clone();
}
crate::persona::languages().iter().find(|l| l.id == id).map(|l| l.label.clone()).unwrap_or_else(|| id.to_string())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn lookup_and_fallback() {
// One test: the active locale is process-global.
set_locale("fr");
assert_ne!(t("Settings"), "Settings");
assert_eq!(t("zz untranslated key"), "zz untranslated key");
assert!(!rtl());
assert_eq!(language_name("de"), "allemand");
set_locale("he");
assert!(rtl());
set_locale("xx");
assert_eq!(locale(), "en");
assert_eq!(t("VOICE PENDING"), "PREPARING VOICE");
assert_eq!(tf("{seconds} s", &[("seconds", "3")]), "3 s");
assert_eq!(native_name("ru"), "Русский");
}
}
+2
View File
@@ -1,8 +1,10 @@
//! Shared foundations for Capri: XDG paths, settings, safe file I/O and the persona texts.
pub mod avatar;
pub mod fsutil;
pub mod i18n;
pub mod paths;
pub mod persona;
pub mod process;
pub mod settings;
pub mod store;
+14
View File
@@ -46,6 +46,20 @@ impl Paths {
self.data.join("logs")
}
/// Runtime folder of this instance (lock, control socket, process markers):
/// `$XDG_RUNTIME_DIR/capri/<id>` on tmpfs, where `<id>` is the first 16 hex characters of
/// SHA-256 of the canonical data path, so `CAPRI_HOME` instances never collide.
/// Falls back to `<data>/run` when `XDG_RUNTIME_DIR` is unset. Not created here.
pub fn run(&self) -> PathBuf {
use sha2::{Digest, Sha256};
let data = std::fs::canonicalize(&self.data).unwrap_or_else(|_| self.data.clone());
let id = hex::encode(&Sha256::digest(data.as_os_str().as_encoded_bytes())[..8]);
match std::env::var_os("XDG_RUNTIME_DIR").map(PathBuf::from).filter(|d| d.is_absolute() && d.is_dir()) {
Some(runtime) => runtime.join("capri").join(id),
None => self.data.join("run"),
}
}
/// Creates the private directories (mode 0700).
pub fn ensure(&self) -> Result<()> {
use std::os::unix::fs::DirBuilderExt;
+47
View File
@@ -0,0 +1,47 @@
//! Environment of the applications Capri starts (spec 08 §8.5): an allow-list, so tokens, API
//! keys and Capri/Ollama settings never reach launched programs.
use std::ffi::OsString;
/// Fixed search path for launched programs.
pub const LAUNCH_PATH: &str = "/usr/local/bin:/usr/bin:/bin";
const NAMES: [&str; 18] = [
"HOME", "USER", "LOGNAME", "LANG", "LC_ALL", "LC_MESSAGES", "DISPLAY", "WAYLAND_DISPLAY", "XAUTHORITY", "XDG_RUNTIME_DIR",
"DBUS_SESSION_BUS_ADDRESS", "XDG_SESSION_TYPE", "XDG_CURRENT_DESKTOP", "DESKTOP_SESSION", "XDG_DATA_DIRS", "XDG_DATA_HOME",
"XDG_CONFIG_HOME", "I3SOCK",
];
/// Toolkit look and input-method settings: no credentials, but apps look wrong without them.
const DISPLAY_PREFIXES: [&str; 6] = ["QT_", "GTK_", "GDK_", "KDE_", "XCURSOR_", "XMODIFIERS"];
fn secret_like(name: &str) -> bool {
let upper = name.to_ascii_uppercase();
["TOKEN", "KEY", "SECRET", "PASSWORD", "PASSWD", "CREDENTIAL", "AUTH", "CAPRI", "OLLAMA"].iter().any(|s| upper.contains(s))
}
fn allowed(name: &str) -> bool {
!secret_like(name) && (NAMES.contains(&name) || DISPLAY_PREFIXES.iter().any(|p| name.starts_with(p)))
}
/// `PATH` plus the allowed variables of the current environment; apply after `env_clear()`.
pub fn launch_environment() -> Vec<(OsString, OsString)> {
let mut env = vec![(OsString::from("PATH"), OsString::from(LAUNCH_PATH))];
env.extend(std::env::vars_os().filter(|(k, _)| k.to_str().is_some_and(allowed)));
env
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn only_allowed_variables_pass() {
for name in ["HOME", "DISPLAY", "QT_QPA_PLATFORMTHEME", "GTK_THEME", "I3SOCK"] {
assert!(allowed(name), "{name}");
}
for name in ["OPENAI_API_KEY", "GITHUB_TOKEN", "CAPRI_HOME", "OLLAMA_HOST", "AWS_SECRET_ACCESS_KEY", "SSH_AUTH_SOCK", "QT_AUTH_TOKEN", "LD_PRELOAD", "PATH"] {
assert!(!allowed(name), "{name}");
}
assert_eq!(launch_environment()[0], (OsString::from("PATH"), OsString::from(LAUNCH_PATH)));
}
}