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:
parent
11e2f20820
commit
6fafd26320
1 changed files with 17 additions and 7 deletions
|
|
@ -4,16 +4,26 @@
|
||||||
// in separately by the caller. Git context and IRC digest
|
// in separately by the caller. Git context and IRC digest
|
||||||
// are now available through where-am-i.md and the memory graph.
|
// are now available through where-am-i.md and the memory graph.
|
||||||
|
|
||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
/// Build context string for a prompt.
|
/// Build context string for a prompt.
|
||||||
/// notification_text is passed in from the notify module.
|
/// notification_text is passed in from the notify module.
|
||||||
pub fn build(_include_irc: bool, notification_text: &str) -> String {
|
pub fn build(_include_irc: bool, notification_text: &str) -> String {
|
||||||
// Keep nudges short — Claude checks notifications via
|
// Keep nudges short — Claude checks notifications via
|
||||||
// `poc-daemon status` on its own. Just mention the count.
|
// `poc-daemon status` on its own. Just mention how many channels
|
||||||
let count = notification_text.matches("[irc.").count()
|
// have activity (not how many messages — one IRC channel can
|
||||||
+ notification_text.matches("[telegram.").count();
|
// generate hundreds of lines).
|
||||||
if count > 0 {
|
let channels: HashSet<&str> = notification_text
|
||||||
format!("{count} pending notifications")
|
.lines()
|
||||||
} else {
|
.filter_map(|l| l.strip_prefix('['))
|
||||||
String::new()
|
.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"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue