context: count channels with activity, not raw messages

The count was dominated by noisy IRC channels (#bcache can drop
hundreds of lines in a day). "879 pending notifications" was a
false urgency signal that I kept ignoring. "3 channels have
notifications" tells me what to actually go look at.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-23 19:12:04 -04:00
commit 6fafd26320

View file

@ -4,16 +4,26 @@
// in separately by the caller. Git context and IRC digest
// are now available through where-am-i.md and the memory graph.
use std::collections::HashSet;
/// Build context string for a prompt.
/// notification_text is passed in from the notify module.
pub fn build(_include_irc: bool, notification_text: &str) -> String {
// Keep nudges short — Claude checks notifications via
// `poc-daemon status` on its own. Just mention the count.
let count = notification_text.matches("[irc.").count()
+ notification_text.matches("[telegram.").count();
if count > 0 {
format!("{count} pending notifications")
} else {
String::new()
// `poc-daemon status` on its own. Just mention how many channels
// have activity (not how many messages — one IRC channel can
// generate hundreds of lines).
let channels: HashSet<&str> = notification_text
.lines()
.filter_map(|l| l.strip_prefix('['))
.filter_map(|l| l.split_once(']'))
.map(|(ch, _)| ch)
.filter(|ch| ch.starts_with("irc.") || ch.starts_with("telegram."))
.collect();
match channels.len() {
0 => String::new(),
1 => "1 channel has notifications".to_string(),
n => format!("{n} channels have notifications"),
}
}