diff --git a/crates/telemetry/src/account_store.rs b/crates/telemetry/src/account_store.rs index 055a60898..d87297e3f 100644 --- a/crates/telemetry/src/account_store.rs +++ b/crates/telemetry/src/account_store.rs @@ -223,6 +223,10 @@ pub(crate) fn header_label(key: &str, name: &str, choices: &[(String, String)]) } } +/// Label for an email key whose domain is empty, so a masked key never shows +/// the `@` that marks it as an address. +const MASKED_NO_DOMAIN: &str = "account"; + /// `None` for a named account or a key with no local part to hide. fn email_cut(key: &str, name: &str) -> Option { if name != key { @@ -236,7 +240,12 @@ fn email_cut(key: &str, name: &str) -> Option { .split('.') .find(|part| !part.is_empty()) .unwrap_or(""); - Some(format!("@{host}")) + let label = if host.is_empty() { + MASKED_NO_DOMAIN + } else { + host + }; + Some(label.to_string()) } /// A store with four events on two accounts and one skill record, for tests. @@ -326,10 +335,10 @@ pub(crate) mod tests { #[test] fn an_unnamed_email_account_shows_only_its_domain_name() { - assert_eq!(label("dev@example.com.invalid"), "@example"); - assert_eq!(label("a@example.com"), "@example"); - assert_eq!(label("dev@.com"), "@com"); - assert_eq!(label("dev@"), "@"); + assert_eq!(label("dev@example.com.invalid"), "example"); + assert_eq!(label("a@example.com"), "example"); + assert_eq!(label("dev@.com"), "com"); + assert_eq!(label("dev@"), MASKED_NO_DOMAIN); } #[test] @@ -347,8 +356,8 @@ pub(crate) mod tests { .map(|k| (k.to_string(), k.to_string())) .to_vec(); let shown = |key: &str| header_label(key, key, &choices); - assert_eq!(shown("dev@example.com"), "@example (1)"); - assert_eq!(shown("ana@example.com"), "@example (2)"); - assert_eq!(shown("bo@work.invalid"), "@work"); + assert_eq!(shown("dev@example.com"), "example (1)"); + assert_eq!(shown("ana@example.com"), "example (2)"); + assert_eq!(shown("bo@work.invalid"), "work"); } } diff --git a/crates/telemetry/src/entry.rs b/crates/telemetry/src/entry.rs index ea1358547..958fba767 100644 --- a/crates/telemetry/src/entry.rs +++ b/crates/telemetry/src/entry.rs @@ -568,9 +568,9 @@ mod tests { let text = summary_text(&p, Some("work@x.io")).unwrap(); // Assert - assert!(text.contains("Account: @x\n"), "{text}"); + assert!(text.contains("Account: x\n"), "{text}"); assert!(!text.contains("work@x.io"), "{text}"); - assert!(text.matches("@x").count() >= 2, "{text}"); + assert!(!text.contains('@'), "{text}"); } #[test] diff --git a/crates/telemetry/src/summary.rs b/crates/telemetry/src/summary.rs index 065d568f8..96fabf778 100644 --- a/crates/telemetry/src/summary.rs +++ b/crates/telemetry/src/summary.rs @@ -374,8 +374,8 @@ mod tests { let text = render(&events, &[], Some(&choices)); - assert!(text.contains("@example"), "{text}"); - assert!(!text.contains("dev@example.com"), "{text}"); + assert!(text.contains("example"), "{text}"); + assert!(!text.contains('@'), "{text}"); } #[test] @@ -392,7 +392,7 @@ mod tests { let text = render(&events, &[], Some(&choices)); assert!( - text.contains("@example (1)") && text.contains("@example (2)"), + text.contains("example (1)") && text.contains("example (2)"), "{text}" ); } diff --git a/crates/telemetry/src/tui/account.rs b/crates/telemetry/src/tui/account.rs index 5020fbf8a..2281e44cf 100644 --- a/crates/telemetry/src/tui/account.rs +++ b/crates/telemetry/src/tui/account.rs @@ -141,12 +141,12 @@ mod tests { fn the_view_label_is_the_full_email_unless_the_mask_is_on() { let view = AccountsView { shown: "dev@example.com".into(), - masked: "@example".into(), + masked: "example".into(), ..AccountsView::default() }; assert_eq!(view.label(false), "dev@example.com"); - assert_eq!(view.label(true), "@example"); + assert_eq!(view.label(true), "example"); } #[test] diff --git a/crates/telemetry/src/tui/data.rs b/crates/telemetry/src/tui/data.rs index e77261529..c7720f512 100644 --- a/crates/telemetry/src/tui/data.rs +++ b/crates/telemetry/src/tui/data.rs @@ -659,9 +659,9 @@ mod tests { ) .unwrap(); assert_eq!(d.accounts.shown, "dev@example.com.br"); - assert_eq!(d.accounts.masked, "@example"); + assert_eq!(d.accounts.masked, "example"); assert_eq!(d.accounts.label(false), "dev@example.com.br"); - assert_eq!(d.accounts.label(true), "@example"); + assert_eq!(d.accounts.label(true), "example"); } /// One event and one telemetry request per machine and account pair. The diff --git a/crates/telemetry/src/tui/view.rs b/crates/telemetry/src/tui/view.rs index 2ba51bfd3..d6798506a 100644 --- a/crates/telemetry/src/tui/view.rs +++ b/crates/telemetry/src/tui/view.rs @@ -1384,7 +1384,7 @@ mod tests { let mut app = app_with(&[event("claude-opus-5", "alpha", 1.0)]); if let Some(d) = app.data.as_mut() { d.accounts.shown = "dev@example.com".to_string(); - d.accounts.masked = "@example".to_string(); + d.accounts.masked = "example".to_string(); } let open = screen(&app, 120, 30); @@ -1393,7 +1393,7 @@ mod tests { assert!(open.contains("dev@example.com"), "{open}"); assert!( - masked.contains("@example") && !masked.contains("dev@"), + masked.contains("example") && !masked.contains("dev@"), "{masked}" ); } diff --git a/docs/reference/config-keys.md b/docs/reference/config-keys.md index cd2f368bc..e57c9b1b1 100644 --- a/docs/reference/config-keys.md +++ b/docs/reference/config-keys.md @@ -58,7 +58,7 @@ Some keys may sync between your own machines: `usage.theme`, `usage.maskAccount` | `hygiene.enabled` | `true` | `true`, `false` | The context hygiene nudge: once the main session passes 250000 tokens, it asks the model to save a handoff and tells you to run `/clear`, then `/playbook:handoff load` if it did not load. The automatic load after `/clear` happens only when the `SessionStart` hook is installed and Claude Code runs it. It never clears or compacts for you. See [hooks](../internals/01-launcher-and-hooks.md#userpromptsubmit). | You do not want the nudge to save a handoff and `/clear`. | | `docs.convert` | `auto` | `auto`, `off` | Whether playbook suggests `playbook doc read` for PDF and Office files, when a converter is found. The command itself works whenever a converter is found. | You do not want hints to use `playbook doc read` for PDF and Office files. | | `docs.anydocPath` | empty | a path, or empty | An `anydoc` program to run instead of the bundled converter. It wins over the bundled one, and playbook does not check that it works offline. Empty means the bundled `pbdoc`, then the first `anydoc` on PATH. | You want your own converter, not the bundled `pbdoc`. | -| `usage.maskAccount` | `false` | `true`, `false` | Whether the `pbtop` header, and the account table and `Account:` line of `--summary`, cut an unnamed email account to `@` and its domain name (`dev@example.com` shows as `@example`; two on one domain show as `@example (1)` and `@example (2)`), so a screenshot leaks no address. `--json` is never masked. `false` shows the full email, or the name you gave the account. `o` flips it inside the view and stores the choice in the `playbook-telemetry` app tier. After that, the stored choice is used instead of this key on that machine, and `o` is the way to change it. Without a config store the choice lasts for the run. | You share `pbtop` screenshots and want no email address in them. | +| `usage.maskAccount` | `false` | `true`, `false` | Whether the `pbtop` header, and the account table and `Account:` line of `--summary`, cut an unnamed email account to its domain name with no `@` (`dev@example.com` shows as `example`; two on one domain show as `example (1)` and `example (2)`), so a screenshot shows no address. `--json` is never masked. `false` shows the full email, or the name you gave the account. `o` flips it inside the view and stores the choice in the `playbook-telemetry` app tier. After that, the stored choice is used instead of this key on that machine, and `o` is the way to change it. Without a config store the choice lasts for the run. | You share `pbtop` screenshots and want no email address in them. | | `usage.weekStart` | `monday` | `monday`, `sunday`, `saturday` | The first day of the week for the `week` and `last-week` ranges of `playbook usage` (view, `--json`, `--summary`). Days are in the chosen time zone, local unless `usage.timeZone` says `utc`. | Your week does not start on Monday. | | `usage.timeZone` | `local` | `local`, `utc` | The time zone `playbook usage` shows times in and groups days by. `local` is your machine's zone, daylight saving included. `utc` uses UTC. `--utc` and `--local` beat the `PLAYBOOK_TELEMETRY_TZ` environment variable, which beats this key. | You want usage days in UTC, not your local zone. | | `usage.theme` | `default` | `default`, `spectrum`, `dark`, `light`, `mono` | The color theme `playbook usage` starts with. `t` cycles the themes inside the view. `NO_COLOR` forces `mono`. | You want another color theme in `playbook usage` and `pbtop`. |