From 6fafd26320eadb5c686d70655c12c173a4ad7be9 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Thu, 23 Apr 2026 19:12:04 -0400 Subject: [PATCH] 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 --- src/context.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/context.rs b/src/context.rs index 22b716a..e0bb8f1 100644 --- a/src/context.rs +++ b/src/context.rs @@ -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"), } }