A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.
Swift ai-agentsanthropicantigravityclaudeclaude-codecodexcursordynamic-islandgemini-cliiosiphonlinuxmacosmacos-appmenubar-appnotchopen-sourceswiftswiftuiwindows
Phone link: the optional recap capability (counts of last week), off by default behind its own switch
Claude55e6b64339b8
diff --git a/windows/src-tauri/src/lib.rs b/windows/src-tauri/src/lib.rsindex e35793fa..c53fe854 100644--- a/windows/src-tauri/src/lib.rs+++ b/windows/src-tauri/src/lib.rs@@ -100,6 +100,7 @@ fn save_settings(app: AppHandle, shared: State<Shared>, settings: Settings) {settings.phone_answers = current.phone_answers;settings.phone_diffs = current.phone_diffs;settings.phone_usage = current.phone_usage;+ settings.phone_recap = current.phone_recap;settings.phone_services = current.phone_services.clone();settings.phone_relay = current.phone_relay;settings.phone_relay_url = current.phone_relay_url.clone();@@ -739,10 +740,13 @@ pub fn run() {phone_link::phone_link_send_diff,phone_link::phone_usage_status,phone_link::phone_usage_set_enabled,+ phone_link::phone_recap_status,+ phone_link::phone_recap_set_enabled,phone_link::phone_relay_status,phone_link::phone_relay_set,phone_link::phone_relay_set_access,phone_link::phone_link_publish_usage,+ phone_link::phone_link_publish_recap,phone_link::phone_services_status,phone_link::phone_services_set,phone_link::phone_link_publish_services,diff --git a/windows/src-tauri/src/phone_link/hub.rs b/windows/src-tauri/src/phone_link/hub.rsindex d97798a2..d5f91a02 100644--- a/windows/src-tauri/src/phone_link/hub.rs+++ b/windows/src-tauri/src/phone_link/hub.rs@@ -297,6 +297,95 @@ pub struct UsageIn {pub codex: Option<PlanIn>,}+/// The last completed week as the island counted it (cap `recap`): numbers, the week's Monday, the busiest agent's name. Counts only; the+/// project is a folder name and goes only to a phone that has `details`. Numbers are taken as f64 so a wrong one is clamped, not refused.+#[derive(Debug, Clone, PartialEq, Deserialize, Default)]+#[serde(rename_all = "camelCase", default)]+pub struct RecapIn {+ /// The Monday that starts the week, `YYYY-MM-DD`.+ pub week: String,+ pub minutes: f64,+ pub sessions: f64,+ pub files: f64,+ pub lines_added: f64,+ pub lines_removed: f64,+ pub commands: f64,+ pub allowed: f64,+ pub denied: f64,+ pub top_agent: Option<String>,+ pub top_project: Option<String>,+}++/// The two forms of a recap line: without the project, and with it (for a phone that has `details`).+#[derive(Debug, Clone, PartialEq)]+struct RecapLines {+ plain: Arc<str>,+ with_project: Arc<str>,+}++impl RecapLines {+ fn for_phone(&self, details: bool) -> &Arc<str> {+ if details {+ &self.with_project+ } else {+ &self.plain+ }+ }+}++/// A whole number in `0..=max`: junk (NaN, infinite, negative) is 0, too large is the maximum.+fn count(v: f64, max: u64) -> u64 {+ if !v.is_finite() || v < 0.0 {+ 0+ } else {+ (v.round() as u64).min(max)+ }+}++/// `YYYY-MM-DD` with a plausible month and day; nothing else gets through.+fn valid_week(s: &str) -> bool {+ let b = s.as_bytes();+ b.len() == 10+ && b[4] == b'-'+ && b[7] == b'-'+ && b.iter().enumerate().all(|(i, c)| i == 4 || i == 7 || c.is_ascii_digit())+ && (1..=12).contains(&s[5..7].parse::<u8>().unwrap_or(0))+ && (1..=31).contains(&s[8..10].parse::<u8>().unwrap_or(0))+}++/// None when the week has nothing to say (no session, or a week that is not a date).+fn recap_lines(r: &RecapIn) -> Option<RecapLines> {+ if !valid_week(&r.week) || count(r.sessions, 100_000) == 0 {+ return None;+ }+ let mut v = json!({+ "type": "recap",+ "week": r.week,+ // A week has 10 080 minutes.+ "minutes": count(r.minutes, 10_080),+ "sessions": count(r.sessions, 100_000),+ "files": count(r.files, 10_000_000),+ "added": count(r.lines_added, 10_000_000),+ "removed": count(r.lines_removed, 10_000_000),+ "commands": count(r.commands, 10_000_000),+ "allowed": count(r.allowed, 10_000_000),+ "denied": count(r.denied, 10_000_000),+ });+ // An agent's name: letters, digits, spaces and a few marks, short.+ if let Some(name) = r.top_agent.as_deref() {+ let clean: String = name.chars().filter(|c| c.is_alphanumeric() || matches!(c, ' ' | '-' | '.' | '_')).take(24).collect();+ if !clean.trim().is_empty() {+ v["topAgent"] = json!(clean.trim());+ }+ }+ let plain: Arc<str> = v.to_string().into();+ // The folder's own name, never a path, as for the session lines.+ if let Some(name) = r.top_project.as_deref().and_then(project_name) {+ v["project"] = json!(name);+ }+ Some(RecapLines { plain, with_project: v.to_string().into() })+}+/// One line of a service card.#[derive(Debug, Clone, PartialEq, Deserialize, Default)]#[serde(default)]@@ -417,6 +506,8 @@ struct Sub {diffs: bool,/// The phone asked for `usage` and the user's switch was on when it connected.usage: bool,+ /// The phone asked for `recap` and the user's switch was on when it connected.+ recap: bool,/// The phone asked for `relay` and the relay switch was on when it connected: it is sent the new access key/// when the user rotates it (docs/RELAY_LINK.md section 6).relay: bool,@@ -434,6 +525,7 @@ pub struct Caps {pub prefs: bool,pub diffs: bool,pub usage: bool,+ pub recap: bool,pub relay: bool,/// The services the user allowed for the phone (empty: the capability is not offered).pub services: Vec<String>,@@ -448,6 +540,8 @@ struct Inner {outfit: Option<&'static str>,/// The last `usage` line (None: the island has nothing to say).usage: Option<Arc<str>>,+ /// The last `recap` (None: the island has no week to show).+ recap: Option<RecapLines>,/// The service cards the island has, cleaned (all of them: each phone gets only the ones its user allowed).services: Vec<ServiceIn>,subs: Vec<Sub>,@@ -557,7 +651,7 @@ impl Hub {/// Like [`subscribe`], for a phone that may also have been offered `answers` and `prefs`.pub fn subscribe_with(&self, tx: mpsc::Sender<Out>, now: u64, caps: Caps) -> (u64, Arc<AtomicBool>) {- let Caps { details, answers, prefs, diffs, usage, relay, services } = caps;+ let Caps { details, answers, prefs, diffs, usage, recap, relay, services } = caps;let mut inner = self.inner.lock().unwrap();expire(&mut inner, now);let id = inner.next_sub;@@ -587,8 +681,13 @@ impl Hub {let _ = tx.try_send(Out::Line(line.clone()));}}+ if recap {+ if let Some(lines) = &inner.recap {+ let _ = tx.try_send(Out::Line(lines.for_phone(details).clone()));+ }+ }let evicted = Arc::new(AtomicBool::new(false));- inner.subs.push(Sub { id, tx, evicted: evicted.clone(), details, answers, prefs, diffs, usage, relay, services, diff_asks: Vec::new() });+ inner.subs.push(Sub { id, tx, evicted: evicted.clone(), details, answers, prefs, diffs, usage, recap, relay, services, diff_asks: Vec::new() });(id, evicted)}@@ -714,6 +813,31 @@ impl Hub {});}+ /// Last week's recap, as counts (cap `recap`). Only phones that have `recap` hear of it, and a new one at once; two identical weeks are sent+ /// once. The project's folder name goes only to a phone that also has `details`.+ pub fn publish_recap(&self, recap: RecapIn) {+ let lines = recap_lines(&recap);+ let mut inner = self.inner.lock().unwrap();+ if inner.recap == lines {+ return;+ }+ inner.recap = lines.clone();+ inner.subs.retain(|s| {+ if !s.recap {+ return true;+ }+ let line = match &lines {+ Some(l) => l.for_phone(s.details).clone(),+ None => json!({ "type": "recap" }).to_string().into(),+ };+ let kept = s.tx.try_send(Out::Line(line)).is_ok();+ if !kept {+ s.evicted.store(true, Ordering::SeqCst);+ }+ kept+ });+ }+/// A phone asked for a file's diff. Passed on to the island only if the phone has `diffs` and is not asking too often.pub fn request_diff(&self, sub_id: u64, pill_id: &str, file_id: u64, now: u64) {{@@ -1913,6 +2037,124 @@ mod tests {let (_, mut after) = sub_with(&hub, Caps { usage: true, ..Caps::default() });assert!(drain(&mut after).iter().all(|l| l["type"] != "usage"), "after a clear a new phone is told nothing");}+ // ── weekly recap (cap `recap`) ──────────────────────────────────────────────────++ fn recap_in() -> RecapIn {+ RecapIn {+ week: "2026-10-05".into(),+ minutes: 340.4,+ sessions: 12.0,+ files: 40.0,+ lines_added: 900.0,+ lines_removed: 210.0,+ commands: 55.0,+ allowed: 20.0,+ denied: 3.0,+ top_agent: Some("Claude Code\n<b>".into()),+ top_project: Some("/home/someone/private/coucou".into()),+ }+ }++ #[test]+ fn a_phone_with_recap_gets_counts_and_no_project() {+ let (hub, _) = hub();+ let (_, mut rx) = sub_with(&hub, Caps { recap: true, ..Caps::default() });+ let (_, mut other) = sub_with(&hub, Caps { details: true, diffs: true, answers: true, prefs: true, usage: true, ..Caps::default() });+ drain(&mut rx);+ drain(&mut other);+ hub.publish_recap(recap_in());+ let r = drain(&mut rx);+ assert_eq!(r.len(), 1);+ assert_eq!(+ r[0],+ serde_json::json!({+ "type": "recap", "week": "2026-10-05", "minutes": 340, "sessions": 12, "files": 40, "added": 900, "removed": 210,+ "commands": 55, "allowed": 20, "denied": 3, "topAgent": "Claude Codeb",+ }),+ "counts and the busiest agent's name, nothing else"+ );+ assert!(drain(&mut other).is_empty(), "a phone without recap never hears of it");+ }++ #[test]+ fn the_project_goes_only_to_a_phone_that_also_has_details_and_only_as_a_folder_name() {+ let (hub, _) = hub();+ let (_, mut plain) = sub_with(&hub, Caps { recap: true, ..Caps::default() });+ let (_, mut detailed) = sub_with(&hub, Caps { recap: true, details: true, ..Caps::default() });+ drain(&mut plain);+ drain(&mut detailed);+ hub.publish_recap(recap_in());+ assert!(drain(&mut plain)[0].get("project").is_none());+ assert_eq!(drain(&mut detailed)[0]["project"], "coucou", "the folder, never the path");+ // A phone arriving later is told the form it may have.+ let (_, mut late) = sub_with(&hub, Caps { recap: true, details: true, ..Caps::default() });+ assert_eq!(drain(&mut late).iter().find(|l| l["type"] == "recap").unwrap()["project"], "coucou");+ let (_, mut late_plain) = sub_with(&hub, Caps { recap: true, ..Caps::default() });+ assert!(drain(&mut late_plain).iter().find(|l| l["type"] == "recap").unwrap().get("project").is_none());+ }++ #[test]+ fn a_new_phone_gets_the_week_and_a_repeat_is_not_sent() {+ let (hub, _) = hub();+ hub.publish_recap(recap_in());+ let (_, mut rx) = sub_with(&hub, Caps { recap: true, ..Caps::default() });+ assert!(drain(&mut rx).iter().any(|l| l["type"] == "recap" && l["sessions"] == 12));+ hub.publish_recap(recap_in());+ assert!(drain(&mut rx).is_empty());+ let mut next = recap_in();+ next.week = "2026-10-12".into();+ hub.publish_recap(next);+ assert_eq!(drain(&mut rx)[0]["week"], "2026-10-12");+ }++ #[test]+ fn numbers_are_clamped_and_a_week_with_nothing_or_no_date_clears_it() {+ let (hub, _) = hub();+ let (_, mut rx) = sub_with(&hub, Caps { recap: true, ..Caps::default() });+ drain(&mut rx);+ let wild = RecapIn { minutes: 1e12, sessions: 1e12, files: f64::NAN, lines_added: -5.0, lines_removed: f64::INFINITY, ..recap_in() };+ hub.publish_recap(wild);+ let r = &drain(&mut rx)[0];+ assert_eq!(r["minutes"], 10_080);+ assert_eq!(r["sessions"], 100_000);+ assert_eq!(r["files"], 0);+ assert_eq!(r["added"], 0);+ assert_eq!(r["removed"], 0);+ // No session this week: the phone is told there is nothing.+ hub.publish_recap(RecapIn { sessions: 0.0, ..recap_in() });+ assert_eq!(drain(&mut rx), vec![serde_json::json!({ "type": "recap" })]);+ // Not a date: nothing is sent, because nothing is still nothing.+ for bad in ["", "2026-13-01", "2026-10-32", "2026/10/05", "2026-10-5", "<script>1", "2026-10-05\n"] {+ hub.publish_recap(RecapIn { week: bad.into(), ..recap_in() });+ assert!(drain(&mut rx).is_empty(), "{bad:?}");+ }+ let (_, mut after) = sub_with(&hub, Caps { recap: true, ..Caps::default() });+ assert!(drain(&mut after).iter().all(|l| l["type"] != "recap"), "after a clear a new phone is told nothing");+ }++ #[test]+ fn the_agent_name_is_short_and_plain_and_may_be_left_out() {+ let (hub, _) = hub();+ let (_, mut rx) = sub_with(&hub, Caps { recap: true, ..Caps::default() });+ drain(&mut rx);+ hub.publish_recap(RecapIn { top_agent: Some("A very long agent name that goes on and on".into()), ..recap_in() });+ assert_eq!(drain(&mut rx)[0]["topAgent"].as_str().unwrap().chars().count(), 24);+ hub.publish_recap(RecapIn { top_agent: Some("\n\t<>".into()), ..recap_in() });+ assert!(drain(&mut rx)[0].get("topAgent").is_none());+ }++ #[test]+ fn nothing_but_counts_names_and_a_date_ever_leaves() {+ let (hub, _) = hub();+ let (_, mut rx) = sub_with(&hub, Caps { recap: true, details: true, ..Caps::default() });+ drain(&mut rx);+ hub.publish_recap(recap_in());+ let line = drain(&mut rx).remove(0);+ let mut keys: Vec<&str> = line.as_object().unwrap().keys().map(String::as_str).collect();+ keys.sort_unstable();+ assert_eq!(keys, ["added", "allowed", "commands", "denied", "files", "minutes", "project", "removed", "sessions", "topAgent", "type", "week"]);+ }+// ── service cards (cap `services`) ──────────────────────────────────────────────fn card(id: &str, headline: &str, items: &[(&str, &str)]) -> ServiceIn {diff --git a/windows/src-tauri/src/phone_link/interop.rs b/windows/src-tauri/src/phone_link/interop.rsindex 9b955c5b..f3b6aad8 100644--- a/windows/src-tauri/src/phone_link/interop.rs+++ b/windows/src-tauri/src/phone_link/interop.rs@@ -22,7 +22,7 @@ use std::sync::Arc;use std::time::Duration;use super::chat::{BoxFuture, ChatBackend, ChatConfig, ChatFail, ChatLink, ModelOption};-use super::hub::{ApprovalIn, DiffIn, FileIn, Host, Hub, PlanIn, ServiceIn, ServiceItemIn, SessionIn, UsageIn, WindowIn};+use super::hub::{ApprovalIn, DiffIn, FileIn, Host, Hub, PlanIn, RecapIn, ServiceIn, ServiceItemIn, SessionIn, UsageIn, WindowIn};use super::server::Features;use super::pairing::{self, tests::MemStore};use super::server;@@ -43,6 +43,7 @@ struct Switches {details: AtomicBool,diffs: AtomicBool,usage: AtomicBool,+ recap: AtomicBool,services: std::sync::Mutex<Vec<String>>,}impl Features for Switches {@@ -55,6 +56,9 @@ impl Features for Switches {fn usage(&self) -> bool {self.usage.load(Ordering::SeqCst)}+ fn recap(&self) -> bool {+ self.recap.load(Ordering::SeqCst)+ }fn services(&self) -> Vec<String> {self.services.lock().unwrap().clone()}@@ -119,7 +123,7 @@ fn interop_server() {let token = std::env::var("COUCOU_INTEROP_TOKEN").unwrap_or_else(|_| "interop-token-0123456789abcdef".into());let hub = Hub::new(Arc::new(Printing));let fake = Arc::new(FakeChat { on: AtomicBool::new(false) });- let switches = Arc::new(Switches { details: AtomicBool::new(false), diffs: AtomicBool::new(false), usage: AtomicBool::new(false), services: std::sync::Mutex::new(Vec::new()) });+ let switches = Arc::new(Switches { details: AtomicBool::new(false), diffs: AtomicBool::new(false), usage: AtomicBool::new(false), recap: AtomicBool::new(false), services: std::sync::Mutex::new(Vec::new()) });let shared = server::Shared::with_features(hub.clone(), token.clone(), "Rust desktop".into(), Some(ChatLink::new(fake.clone())), switches.clone(),);@@ -185,6 +189,22 @@ fn interop_server() {claude: Some(PlanIn { five_hour: Some(WindowIn { used_pct: pct.parse().unwrap_or(0.0), resets_at: 1_900_000_000_000 }), plan_type: Some("max".into()), ..PlanIn::default() }),codex: None,}),+ (Some("recap"), Some(state), _) => switches.recap.store(state == "on", Ordering::SeqCst),+ // `recapweek 2026-10-05` publishes a sample week (12 sessions...) whose project is a full path, to prove only the folder name leaves.+ (Some("recapweek"), Some(week), _) => hub.publish_recap(RecapIn {+ week: week.into(),+ minutes: 340.0,+ sessions: 12.0,+ files: 40.0,+ lines_added: 900.0,+ lines_removed: 210.0,+ commands: 55.0,+ allowed: 20.0,+ denied: 3.0,+ top_agent: Some("Claude Code".into()),+ top_project: Some("/home/someone/private/coucou".into()),+ }),+ (Some("recapnone"), _, _) => hub.publish_recap(RecapIn::default()),(Some("diffs"), Some(state), _) => switches.diffs.store(state == "on", Ordering::SeqCst),(Some("diff"), Some(conn), Some(lines)) => {// `lines` is how many sample lines to send (to try the limits and the parts).diff --git a/windows/src-tauri/src/phone_link/mod.rs b/windows/src-tauri/src/phone_link/mod.rsindex 279bdc8c..f0adf21e 100644--- a/windows/src-tauri/src/phone_link/mod.rs+++ b/windows/src-tauri/src/phone_link/mod.rs@@ -107,6 +107,9 @@ impl server::Features for TauriFeatures {fn usage(&self) -> bool {self.app.state::<Shared>().settings.lock().unwrap().phone_usage}+ fn recap(&self) -> bool {+ self.app.state::<Shared>().settings.lock().unwrap().phone_recap+ }fn relay(&self) -> bool {self.app.state::<Shared>().settings.lock().unwrap().phone_relay}@@ -625,6 +628,44 @@ pub fn phone_usage_set_enabled(Ok(UsageStatus { enabled })}+// ── Weekly recap on the phone: the switch (Settings → Android phone) ──++#[derive(Serialize)]+#[serde(rename_all = "camelCase")]+pub struct RecapStatus {+ pub enabled: bool,+}++#[tauri::command]+pub fn phone_recap_status(shared: State<Shared>) -> RecapStatus {+ RecapStatus { enabled: shared.settings.lock().unwrap().phone_recap }+}++/// "Show my weekly recap on the phone". Off by default. A change disconnects the phones once so they reconnect and are told (or not) about+/// the capability.+#[tauri::command]+pub fn phone_recap_set_enabled(+ app: AppHandle,+ window: WebviewWindow,+ link: State<PhoneLink>,+ shared: State<Shared>,+ enabled: bool,+) -> Result<RecapStatus, String> {+ only_settings(&window)?;+ let updated = {+ let mut current = shared.settings.lock().unwrap();+ current.phone_recap = enabled;+ if let Err(err) = settings::save(¤t) {+ log::line(format!("could not save settings: {err}"));+ }+ current.clone()+ };+ link.hub.kick_all("closed", "recap setting changed");+ log::line(format!("phone link: weekly recap on the phone {}", if enabled { "on" } else { "off" }));+ let _ = app.emit("settings-changed", updated);+ Ok(RecapStatus { enabled })+}+// ── Service cards on the phone: one tick per service (Settings → Android phone) ──#[derive(Serialize)]@@ -688,6 +729,17 @@ pub fn phone_link_publish_usage(window: WebviewWindow, link: State<PhoneLink>, uOk(())}+/// Last week's recap the island counted, for phones that have `recap`. Only the numbers leave the island (see hub::RecapIn).+#[tauri::command]+pub fn phone_link_publish_recap(window: WebviewWindow, link: State<PhoneLink>, recap: hub::RecapIn) -> Result<(), String> {+ only_island(&window)?;+ if link.running.lock().unwrap().is_none() {+ return Ok(());+ }+ link.hub.publish_recap(recap);+ Ok(())+}+/// The island's answer to a phone's request for a file's diff (event "phone-link-getdiff").#[tauri::command]pub fn phone_link_send_diff(window: WebviewWindow, link: State<PhoneLink>, conn: u64, diff: hub::DiffIn) -> Result<(), String> {diff --git a/windows/src-tauri/src/phone_link/server.rs b/windows/src-tauri/src/phone_link/server.rsindex 3c42cbcb..b40479e5 100644--- a/windows/src-tauri/src/phone_link/server.rs+++ b/windows/src-tauri/src/phone_link/server.rs@@ -74,6 +74,10 @@ pub trait Features: Send + Sync {fn usage(&self) -> bool {false}+ /// Last week's recap (counts only: minutes, sessions, files, lines, commands, permissions, the busiest agent).+ fn recap(&self) -> bool {+ false+ }/// The relay is switched on (the phone then follows an access key rotation).fn relay(&self) -> bool {false@@ -281,6 +285,7 @@ wherelet prefs = asked("prefs");let diffs = asked("diffs") && shared.features.diffs();let usage = asked("usage") && shared.features.usage();+ let recap = asked("recap") && shared.features.recap();let relay = asked("relay") && shared.features.relay();let services: Vec<String> = if asked("services") { shared.features.services() } else { Vec::new() };let mut offered: Vec<&str> = Vec::new();@@ -302,6 +307,9 @@ whereif usage {offered.push("usage");}+ if recap {+ offered.push("recap");+ }if relay {offered.push("relay");}@@ -313,7 +321,7 @@ wherewelcome["caps"] = json!(offered);}let _ = say(welcome).await;- let (id, evicted) = shared.hub.subscribe_with(tx.clone(), (shared.clock)(), crate::phone_link::hub::Caps { details, answers, prefs, diffs, usage, relay, services });+ let (id, evicted) = shared.hub.subscribe_with(tx.clone(), (shared.clock)(), crate::phone_link::hub::Caps { details, answers, prefs, diffs, usage, recap, relay, services });// 2. the conversationloop {diff --git a/windows/src-tauri/src/phone_link/tests.rs b/windows/src-tauri/src/phone_link/tests.rsindex 53036aed..266164cf 100644--- a/windows/src-tauri/src/phone_link/tests.rs+++ b/windows/src-tauri/src/phone_link/tests.rs@@ -1572,6 +1572,140 @@ mod usage_tests {}}+mod recap_tests {+ use super::*;+ use crate::phone_link::hub::RecapIn;+ use crate::phone_link::server::Features;+ use std::sync::atomic::{AtomicBool, Ordering};++ struct Switch {+ recap: AtomicBool,+ details: AtomicBool,+ }+ impl Features for Switch {+ fn details(&self) -> bool {+ self.details.load(Ordering::SeqCst)+ }+ fn recap(&self) -> bool {+ self.recap.load(Ordering::SeqCst)+ }+ }++ fn switch(recap: bool, details: bool) -> Arc<Switch> {+ Arc::new(Switch { recap: AtomicBool::new(recap), details: AtomicBool::new(details) })+ }++ async fn phone(rig: &Rig, caps: Option<Value>) -> (Client, Value) {+ let mut c = Client::connect(rig.port, &rig.fingerprint).await.unwrap();+ let mut hello = json!({ "type": "hello", "v": 1, "token": TOKEN, "device": "Test phone" });+ if let Some(caps) = caps {+ hello["caps"] = caps;+ }+ c.send(hello).await;+ let welcome = c.expect("welcome").await;+ (c, welcome)+ }++ fn week() -> RecapIn {+ RecapIn {+ week: "2026-10-05".into(),+ minutes: 340.0,+ sessions: 12.0,+ files: 40.0,+ lines_added: 900.0,+ lines_removed: 210.0,+ commands: 55.0,+ allowed: 20.0,+ denied: 3.0,+ top_agent: Some("Claude Code".into()),+ top_project: Some("/home/someone/private/coucou".into()),+ }+ }++ #[test]+ fn recap_is_offered_only_while_the_switch_is_on_and_the_phone_asked() {+ block_on(async {+ let on = Rig::start_full(None, switch(true, false)).await;+ let (_c, welcome) = phone(&on, Some(json!(["recap"]))).await;+ assert_eq!(welcome["caps"], json!(["recap"]));+ let (_c, welcome) = phone(&on, None).await;+ assert!(welcome.get("caps").is_none(), "a phone that did not ask is offered nothing");+ let off = Rig::start_full(None, switch(false, false)).await;+ let (_c, welcome) = phone(&off, Some(json!(["recap"]))).await;+ assert!(welcome.get("caps").is_none(), "{welcome}");+ });+ }++ #[test]+ fn the_switch_is_read_again_for_every_connection() {+ block_on(async {+ let features = switch(false, false);+ let rig = Rig::start_full(None, features.clone()).await;+ let (_c, welcome) = phone(&rig, Some(json!(["recap"]))).await;+ assert!(welcome.get("caps").is_none());+ features.recap.store(true, Ordering::SeqCst);+ let (_c, welcome) = phone(&rig, Some(json!(["recap"]))).await;+ assert_eq!(welcome["caps"], json!(["recap"]));+ features.recap.store(false, Ordering::SeqCst);+ let (_c, welcome) = phone(&rig, Some(json!(["recap"]))).await;+ assert!(welcome.get("caps").is_none());+ });+ }++ #[test]+ fn the_phone_hears_the_week_with_counts_only_and_a_change() {+ block_on(async {+ let rig = Rig::start_full(None, switch(true, false)).await;+ rig.hub.publish_recap(week());+ let (mut c, _) = phone(&rig, Some(json!(["recap"]))).await;+ c.expect("sessions").await;+ let line = c.expect("recap").await;+ assert_eq!(line["sessions"], 12);+ assert_eq!(line["minutes"], 340);+ assert_eq!(line["topAgent"], "Claude Code");+ assert!(line.get("project").is_none(), "no project without the details switch: {line}");+ let mut next = week();+ next.week = "2026-10-12".into();+ rig.hub.publish_recap(next);+ assert_eq!(c.expect("recap").await["week"], "2026-10-12");+ rig.hub.publish_recap(RecapIn::default());+ assert_eq!(c.expect("recap").await, json!({ "type": "recap" }));+ });+ }++ #[test]+ fn the_project_folder_goes_only_with_details_and_never_as_a_path() {+ block_on(async {+ let rig = Rig::start_full(None, switch(true, true)).await;+ rig.hub.publish_recap(week());+ let (mut c, welcome) = phone(&rig, Some(json!(["recap", "details"]))).await;+ assert_eq!(welcome["caps"], json!(["details", "recap"]));+ c.expect("sessions").await;+ let line = c.expect("recap").await;+ assert_eq!(line["project"], "coucou");+ assert!(!line.to_string().contains("someone"), "{line}");+ });+ }++ #[test]+ fn a_phone_without_the_capability_never_hears_of_a_recap() {+ block_on(async {+ let rig = Rig::start_full(None, switch(true, false)).await;+ let (mut plain, _) = phone(&rig, None).await;+ plain.expect("sessions").await;+ rig.hub.publish_recap(week());+ plain.send(json!({ "type": "ping" })).await;+ loop {+ let line = plain.recv().await.unwrap();+ assert_ne!(line["type"], "recap");+ if line["type"] == "pong" {+ break;+ }+ }+ });+ }+}+mod services_tests {use super::*;use crate::phone_link::hub::{ServiceIn, ServiceItemIn};diff --git a/windows/src-tauri/src/settings.rs b/windows/src-tauri/src/settings.rsindex 400d5ed5..0544352f 100644--- a/windows/src-tauri/src/settings.rs+++ b/windows/src-tauri/src/settings.rs@@ -89,6 +89,8 @@ pub struct Settings {pub phone_diffs: bool,/// Show the Claude and Codex plan usage on the phone (cap `usage`). Off by default; owned by Rust like the other phone switches.pub phone_usage: bool,+ /// Show last week's recap (counts only) on the phone (cap `recap`). Off by default; owned by Rust like the other phone switches.+ pub phone_recap: bool,/// The service pills whose cards the phone may see, by pill id (cap `services`). None by default; owned by Rust like the other phone switches.pub phone_services: Vec<String>,/// Reach the phone through the user's own relay when it is not on this network (phone_link/relay_client.rs).@@ -159,6 +161,7 @@ impl Default for Settings {phone_answers: false,phone_diffs: false,phone_usage: false,+ phone_recap: false,phone_services: Vec::new(),phone_relay: false,phone_relay_url: String::new(),@@ -446,6 +449,7 @@ mod tests {"phoneAnswers": true,"phoneDiffs": true,"phoneUsage": true,+ "phoneRecap": true,"phoneServices": ["integration_stripe"],"phoneRelay": true,"phoneRelayUrl": "wss://relay.example.workers.dev"@@ -617,6 +621,15 @@ mod tests {assert!(!parse(&custom_with("phoneUsage", Some(serde_json::json!("yes")))).unwrap().phone_usage, "a wrong type does not switch it on");}+ #[test]+ fn a_file_from_before_the_weekly_recap_on_the_phone_keeps_it_off() {+ // Sending last week's numbers to the phone is never on by default; an older file is not consent.+ assert!(!Settings::default().phone_recap);+ assert!(!parse(&custom_with("phoneRecap", None)).unwrap().phone_recap);+ assert!(parse(&custom_with("phoneRecap", Some(serde_json::json!(true)))).unwrap().phone_recap);+ assert!(!parse(&custom_with("phoneRecap", Some(serde_json::json!("yes")))).unwrap().phone_recap, "a wrong type does not switch it on");+ }+#[test]fn a_file_from_before_the_relay_keeps_it_off_and_empty() {assert!(!Settings::default().phone_relay);@@ -953,6 +966,7 @@ mod tests {"phoneAnswers","phoneDiffs","phoneUsage",+ "phoneRecap","phoneServices","phoneRelay","phoneRelayUrl",