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:15:49 +01:00
1 parent a2abf01280
commit 844435f21f
73 files changed
+4834 -517

No files matched your search

+18 -3
View File
@@ -320,6 +320,9 @@ pub trait Accessibility: Send + Sync {
pub struct Atspi {
conn: zbus::Connection,
pids: Mutex<HashMap<String, u32>>,
/// The accessibility bus answered. Without it every query is empty and computer control
/// works from screenshots only (instead of being switched off).
available: bool,
}
impl Atspi {
@@ -329,9 +332,21 @@ impl Atspi {
let _ = atspi::connection::set_session_accessibility(true).await;
// A plain connection to the accessibility bus (no registry/peer bookkeeping needed).
let session = zbus::Connection::session().await?;
let address: String = session.call_method(Some("org.a11y.Bus"), "/org/a11y/bus", Some("org.a11y.Bus"), "GetAddress", &()).await?.body().deserialize()?;
let conn = zbus::connection::Builder::address(address.as_str())?.build().await?;
Ok(Self { conn, pids: Mutex::default() })
let bus = async {
let address: String = session.call_method(Some("org.a11y.Bus"), "/org/a11y/bus", Some("org.a11y.Bus"), "GetAddress", &()).await?.body().deserialize()?;
anyhow::Ok(zbus::connection::Builder::address(address.as_str())?.build().await?)
};
match bus.await {
Ok(conn) => Ok(Self { conn, pids: Mutex::default(), available: true }),
Err(e) => {
tracing::warn!("accessibility bus unavailable, computer control uses screenshots only: {e:#}");
Ok(Self { conn: session, pids: Mutex::default(), available: false })
}
}
}
pub fn available(&self) -> bool {
self.available
}
async fn pid(&self, bus: &str) -> u32 {
+27 -2
View File
@@ -20,6 +20,9 @@ impl Section for FullComputerAccess {
const NAME: &'static str = "fullComputerAccess";
}
/// Legacy pause switch of older builds (`applicationAccess.enabled`). The single Application
/// access switch is `tools.applicationAccess` ([`paused`]); [`migrate_legacy_pause`] moves an old
/// pause there once.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(default)]
pub struct ApplicationAccess {
@@ -60,10 +63,27 @@ impl Section for ComputerAppearance {
const NAME: &'static str = "computerControl";
}
/// Application access paused (the one switch shared with files, applications and Spotify).
pub fn paused(store: &SettingsStore) -> bool {
!store.section::<capri_tools::ToolsSettings>().application_access
}
/// An older build paused through its own switch: keep the owner's choice in the shared one.
pub fn migrate_legacy_pause(store: &SettingsStore) -> anyhow::Result<()> {
if store.section::<ApplicationAccess>().enabled {
return Ok(());
}
let mut tools: capri_tools::ToolsSettings = store.section();
tools.application_access = false;
store.set_section(&tools)?;
store.set_section(&ApplicationAccess { enabled: true })?;
Ok(())
}
/// Effective permission: full access granted and application access not paused.
pub fn allowed(store: &SettingsStore) -> bool {
let full: FullComputerAccess = store.section();
full.enabled && full.drives == ["/"] && store.section::<ApplicationAccess>().enabled
full.enabled && full.drives == ["/"] && !paused(store)
}
/// File-access scopes provided by full access (consumed by the file tools).
@@ -135,8 +155,13 @@ mod tests {
assert_eq!(r["confirmation"], "Full computer access is enabled.");
assert!(allowed(&store));
assert_eq!(scopes(&store)[0]["root"], "/");
store.set_section(&ApplicationAccess { enabled: false }).unwrap();
store.set_section(&capri_tools::ToolsSettings { application_access: false, ..Default::default() }).unwrap();
assert!(!allowed(&store), "the pause masks the grant");
store.set_section(&capri_tools::ToolsSettings::default()).unwrap();
store.set_section(&ApplicationAccess { enabled: false }).unwrap();
migrate_legacy_pause(&store).unwrap();
assert!(paused(&store) && store.section::<ApplicationAccess>().enabled, "an old pause moves to the shared switch");
store.set_section(&capri_tools::ToolsSettings { application_access: false, ..Default::default() }).unwrap();
let r = configure(&store, &Yes(false), false, true).await;
assert_eq!(r["confirmation"], "Полный доступ к компьютеру выключен.");
}
+4 -8
View File
@@ -194,8 +194,8 @@ pub fn discover(query: &str, all: &[Entry]) -> Vec<Entry> {
.collect()
}
/// Starts the entry detached: no shell, cwd `~`, new process group, stdio null, Capri and
/// Ollama variables removed. The child is reaped on a background thread.
/// Starts the entry detached: no shell, cwd `~`, new process group, stdio null, allow-listed
/// environment (spec 08 §8.5). The child is reaped on a background thread.
pub fn launch(entry: &Entry, url: Option<&str>) -> Result<()> {
let argv = exec_argv(&entry.exec, url, &entry.name, &entry.path, &entry.icon);
let (bin, args) = argv.split_first().ok_or_else(|| anyhow::anyhow!("The application could not be started."))?;
@@ -205,12 +205,8 @@ pub fn launch(entry: &Entry, url: Option<&str>) -> Result<()> {
if let Some(home) = std::env::var_os("HOME") {
cmd.current_dir(home);
}
for (k, _) in std::env::vars_os() {
let k = k.to_string_lossy().to_string();
if k.starts_with("CAPRI") || k.starts_with("OLLAMA") {
cmd.env_remove(k);
}
}
// Tokens and API keys in Capri's environment never reach the launched application.
cmd.env_clear().envs(capri_core::process::launch_environment());
std::os::unix::process::CommandExt::process_group(&mut cmd, 0);
let mut child = cmd.spawn().map_err(|_| anyhow::anyhow!("The application could not be started."))?;
std::thread::spawn(move || child.wait());
+1 -1
View File
@@ -102,7 +102,7 @@ pub fn trash_with_recovery(file: &Path, recovery_dir: &Path, recovery_total: u64
bail!("The file could not be moved to the Trash: {e}");
}
ensure!(!file.exists(), "The file is still present.");
Ok(json!({"ok": true, "confirmation": "Moved the file to Recycle Bin.", "recoveryId": id, "backup": format!("{id}.backup"), "sha": sha, "bytes": meta.len()}))
Ok(json!({"ok": true, "confirmation": "Moved the file to the Trash.", "recoveryId": id, "backup": format!("{id}.backup"), "sha": sha, "bytes": meta.len()}))
}
#[cfg(test)]
+7 -6
View File
@@ -8,7 +8,7 @@ use std::time::{Duration, Instant};
use capri_agent::tools::Approvals;
use capri_core::SettingsStore;
use capri_perception::llm::{self, LocalModel};
use capri_perception::llm;
use parking_lot::Mutex;
use regex::Regex;
use serde_json::{json, Value};
@@ -145,7 +145,7 @@ pub struct Intent {
}
/// The multilingual computer intent classifier (8 s, 64 tokens, temperature 0). `None` on failure.
pub async fn classify(model: &LocalModel, text: &str, previous: Option<&str>, full_access: bool, cancel: &CancellationToken) -> Option<Intent> {
pub async fn classify(model: &dyn crate::planner::PlannerModel, text: &str, previous: Option<&str>, full_access: bool, cancel: &CancellationToken) -> Option<Intent> {
let intents = ["chat", "memory", "feature", "task", "task_with_access", "enable", "disable"];
let body = json!({
"options": {"num_predict": 64, "temperature": 0},
@@ -155,7 +155,7 @@ pub async fn classify(model: &LocalModel, text: &str, previous: Option<&str>, fu
{"role": "user", "content": json!({"latestOwnerMessage": text, "previousOwnerMessage": previous, "fullComputerAccess": full_access}).to_string()},
],
});
let packet = model.chat(body, 8192, Duration::from_secs(8), cancel).await.ok()?;
let packet = model.chat(body, Duration::from_secs(8), cancel).await.ok()?;
parse_intent(&llm::content_json(&packet).ok()?)
}
@@ -175,14 +175,15 @@ pub type PreviousOwner = Arc<dyn Fn() -> Option<(String, i64)> + Send + Sync>;
pub struct ComputerRouter {
pub desktop: Arc<DesktopControl>,
pub store: Arc<SettingsStore>,
pub model: LocalModel,
/// The intent classifier's model (the active local model or API, see `PlannerModel`).
pub model: Arc<dyn crate::planner::PlannerModel>,
pub approvals: Arc<dyn Approvals>,
pub previous_owner: PreviousOwner,
last_task: Mutex<Option<(String, Instant)>>,
}
impl ComputerRouter {
pub fn new(desktop: Arc<DesktopControl>, store: Arc<SettingsStore>, model: LocalModel, approvals: Arc<dyn Approvals>, previous_owner: PreviousOwner) -> Self {
pub fn new(desktop: Arc<DesktopControl>, store: Arc<SettingsStore>, model: Arc<dyn crate::planner::PlannerModel>, approvals: Arc<dyn Approvals>, previous_owner: PreviousOwner) -> Self {
Self { desktop, store, model, approvals, previous_owner, last_task: Mutex::default() }
}
@@ -200,7 +201,7 @@ impl ComputerRouter {
let mut mode = if previous.is_some() { Some((true, true)) } else { computer_mode_request(text, full) };
if mode.is_none() && (full || desktop_words(text) || mentions_computer_mode(text)) {
let recent = (self.previous_owner)().filter(|(_, at)| capri_perception::now_ms() - at <= 600_000).map(|(t, _)| t.chars().take(800).collect::<String>());
let intent = classify(&self.model, text, recent.as_deref(), full, cancel).await;
let intent = classify(self.model.as_ref(), text, recent.as_deref(), full, cancel).await;
tracing::info!("computer intent: {:?}", intent.as_ref().map(|i| i.intent.as_str()));
match intent {
Some(i) if i.intent == "enable" || i.intent == "disable" => {
+5 -5
View File
@@ -140,7 +140,7 @@ impl DesktopControl {
}
fn paused(&self) -> bool {
!self.store.section::<access::ApplicationAccess>().enabled
access::paused(&self.store)
}
pub fn catalog(&self) -> parking_lot::MutexGuard<'_, Catalog> {
@@ -193,7 +193,7 @@ impl DesktopControl {
pub async fn dispatch(&self, mut args: Value, op_id: &str, turn: &str, approvals: Arc<dyn capri_agent::tools::Approvals>, cancel: &CancellationToken) -> Value {
let action = args["action"].as_str().unwrap_or("").to_string();
if self.paused() && !matches!(action.as_str(), "apps" | "control_status") {
return json!({"ok": false, "error": "Application access is paused. Turn it on from Capri’s toolbar.", "code": "APPLICATION_ACCESS_PAUSED"});
return json!({"ok": false, "error": "Application access is paused. Turn it on in Settings › Applications and files.", "code": "APPLICATION_ACCESS_PAUSED"});
}
if self.agent().running() && !turn.is_empty() && action != "control_status" {
return tools::error("Wait for the current computer task or stop it with Escape.");
@@ -463,7 +463,7 @@ impl DesktopControl {
Ok(t) => t,
Err(e) => return tools::error(e.to_string()),
};
if !self.full() && !files.is_installation(scope) && !approvals.confirm(Approval { kind: "file.trash".into(), title: "Move this file to Recycle Bin?".into(), detail: format!("{}\n\nA private recovery copy will also be kept. Folders are not supported.", target.display()), timeout: Duration::from_secs(90) }).await {
if !self.full() && !files.is_installation(scope) && !approvals.confirm(Approval { kind: "file.trash".into(), title: "Move this file to the Trash?".into(), detail: format!("{}\n\nA private recovery copy will also be kept. Folders are not supported.", target.display()), timeout: Duration::from_secs(90) }).await {
return json!({"ok": true, "cancelled": true});
}
let total = self.journal.recovery_bytes().unwrap_or(u64::MAX);
@@ -529,7 +529,7 @@ impl Tool for WorkflowControl {
async fn call(&self, args: Value, _ctx: ToolContext) -> Value {
let d = &self.0;
if d.paused() {
return tools::error("Application access is paused. Turn it on from Capri’s toolbar.");
return tools::error("Application access is paused. Turn it on in Settings › Applications and files.");
}
match args["action"].as_str() {
Some("list") => d.workflows.summary(),
@@ -584,7 +584,7 @@ mod tests {
let r = d.dispatch(json!({"action": "run_task", "goal": "open Kate"}), "op3", "t", deny.clone(), &c).await;
assert_eq!(r["status"], "cancelled", "declined grant never runs the task");
assert_eq!(d.dispatch(json!({"action": "launch", "windowId": "abc", "appId": "x"}), "op4", "t", deny.clone(), &c).await["error"], "Choose an actual windowId from inspect.");
d.store.set_section(&access::ApplicationAccess { enabled: false }).unwrap();
d.store.set_section(&capri_tools::ToolsSettings { application_access: false, ..Default::default() }).unwrap();
assert_eq!(d.dispatch(json!({"action": "journal"}), "op5", "t", deny.clone(), &c).await["code"], "APPLICATION_ACCESS_PAUSED");
assert_eq!(d.dispatch(json!({"action": "apps"}), "op6", "t", deny, &c).await["ok"], true);
}
+24 -22
View File
@@ -2,8 +2,9 @@
//! confirmation, so the toggle returns a [`ComputerRequest`] for the app to run.
use capri_core::SettingsStore;
use crate::access::{self, ApplicationAccess, ComputerAppearance, FullComputerAccess};
use crate::access::{self, ComputerAppearance, FullComputerAccess};
use crate::tool::DesktopControl;
use capri_core::i18n::t;
pub enum ComputerRequest {
/// Ask the owner (3 s delayed danger confirmation), then enable.
@@ -21,8 +22,8 @@ fn save<T: capri_core::Section>(store: &SettingsStore, v: &T) {
pub fn settings_ui(ui: &mut egui::Ui, store: &SettingsStore, desktop: &DesktopControl) -> Vec<ComputerRequest> {
let mut out = vec![];
egui::CollapsingHeader::new("Computer control").default_open(true).show(ui, |ui| out.extend(computer_page(ui, store, desktop)));
egui::CollapsingHeader::new("Workflows").show(ui, |ui| out.extend(workflows_page(ui, desktop)));
egui::CollapsingHeader::new(t("Computer control")).default_open(true).show(ui, |ui| out.extend(computer_page(ui, store, desktop)));
egui::CollapsingHeader::new(t("Workflows")).show(ui, |ui| out.extend(workflows_page(ui, desktop)));
out
}
@@ -30,7 +31,7 @@ pub fn computer_page(ui: &mut egui::Ui, store: &SettingsStore, desktop: &Desktop
let mut out = vec![];
let full: FullComputerAccess = store.section();
let mut enabled = full.enabled;
if ui.checkbox(&mut enabled, "Full computer access").changed() {
if ui.checkbox(&mut enabled, t("Full computer access")).changed() {
if enabled {
out.push(ComputerRequest::EnableFullAccess);
} else {
@@ -38,43 +39,44 @@ pub fn computer_page(ui: &mut egui::Ui, store: &SettingsStore, desktop: &Desktop
desktop.access_changed();
}
}
let mut app_access: ApplicationAccess = store.section();
if ui.checkbox(&mut app_access.enabled, "Application access").changed() {
save(store, &app_access);
// Same switch as Settings › Applications and files (one pause for every action).
let mut tools: capri_tools::ToolsSettings = store.section();
if ui.checkbox(&mut tools.application_access, t("Application access")).on_hover_text(t("When off, computer control, application, Spotify and trash actions are paused. Grants are kept.")).changed() {
save(store, &tools);
}
if desktop.control.active() && ui.button("Stop computer control").clicked() {
if desktop.control.active() && ui.button(t("Stop computer control")).clicked() {
out.push(ComputerRequest::Stop);
}
ui.separator();
let before: ComputerAppearance = store.section();
let mut a = before.clone();
ui.checkbox(&mut a.enabled, "Indicator effects");
ui.add(egui::Slider::new(&mut a.intensity, 0..=100).text("Intensity"));
ui.checkbox(&mut a.enabled, t("Indicator effects"));
ui.add(egui::Slider::new(&mut a.intensity, 0..=100).text(t("Intensity")));
ui.horizontal(|ui| {
ui.selectable_value(&mut a.theme, "capri".into(), "Capri");
ui.selectable_value(&mut a.theme, "blackwall".into(), "Blackwall");
});
ui.checkbox(&mut a.cursor, "Cursor trail");
ui.add(egui::Slider::new(&mut a.pointer_duration, 0..=1000).text("Pointer animation (ms)"));
ui.checkbox(&mut a.cursor, t("Cursor trail"));
ui.add(egui::Slider::new(&mut a.pointer_duration, 0..=1000).text(t("Pointer animation (ms)")));
if a != before {
desktop.control.pointer_duration.store(a.pointer_duration as u64, std::sync::atomic::Ordering::Relaxed);
save(store, &a);
}
ui.separator();
ui.label("Applications");
ui.label(t("Applications"));
let apps = desktop.catalog().saved.clone();
for app in apps {
ui.horizontal(|ui| {
ui.label(&app.name);
let (mut l, mut i, mut t) = (app.launch, app.inspect, app.text);
let changed = ui.checkbox(&mut l, "Launch").changed() | ui.checkbox(&mut i, "Inspect").changed() | ui.add_enabled(i, egui::Checkbox::new(&mut t, "Text")).changed();
let remove = ui.button("Remove").clicked();
let (mut l, mut i, mut text) = (app.launch, app.inspect, app.text);
let changed = ui.checkbox(&mut l, t("Launch")).changed() | ui.checkbox(&mut i, t("Inspect")).changed() | ui.add_enabled(i, egui::Checkbox::new(&mut text, t("Text"))).changed();
let remove = ui.button(t("Remove")).clicked();
if changed || remove {
let _ = desktop.catalog().update(&app.id, Some(l), Some(i), Some(t && i), remove);
let _ = desktop.catalog().update(&app.id, Some(l), Some(i), Some(text && i), remove);
}
});
}
egui::CollapsingHeader::new("Action journal").show(ui, |ui| {
egui::CollapsingHeader::new(t("Action journal")).show(ui, |ui| {
for op in desktop.journal.recent().unwrap_or_default() {
ui.label(format!("{} · {}", op["state"].as_str().unwrap_or(""), op["result"]["confirmation"].as_str().or(op["result"]["error"].as_str()).unwrap_or("")));
}
@@ -87,21 +89,21 @@ pub fn workflows_page(ui: &mut egui::Ui, desktop: &DesktopControl) -> Vec<Comput
let mut out = vec![];
let list = desktop.workflows.list();
if list.is_empty() {
ui.label("No workflows yet.");
ui.label(t("No workflows yet."));
}
for w in list {
ui.horizontal(|ui| {
ui.label(format!("{} ({} steps)", w.name, w.steps.len()));
if ui.add_enabled(!desktop.workflows.playing(), egui::Button::new("Run")).clicked() {
if ui.add_enabled(!desktop.workflows.playing(), egui::Button::new(t("Run"))).clicked() {
out.push(ComputerRequest::RunWorkflow(w.id.clone()));
}
if ui.button("Remove").clicked()
if ui.button(t("Remove")).clicked()
&& let Err(e) = desktop.workflows.remove(&w.id)
{
tracing::warn!("Workflow not removed: {e}");
}
});
}
ui.small("Recording new workflows is not available on Linux yet.");
ui.small(t("Recording new workflows is not available on Linux yet."));
out
}