aboutsummaryrefslogtreecommitdiff
path: root/crates/dinggerd/src/watcher.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/dinggerd/src/watcher.rs')
-rw-r--r--crates/dinggerd/src/watcher.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/dinggerd/src/watcher.rs b/crates/dinggerd/src/watcher.rs
index b0acc1d..1aec88e 100644
--- a/crates/dinggerd/src/watcher.rs
+++ b/crates/dinggerd/src/watcher.rs
@@ -27,6 +27,7 @@
//! - `@dingger_extension`, `@dingger_control` the version of pi's extension
//! and its control socket, for reloading agents on an old one
//! - `@dingger_draft` the draft in the agent's input box, as one line
+//! - `@dingger_cost` what the agent's session spent today (see `cost`)
use std::collections::HashMap;
@@ -509,6 +510,17 @@ impl Watcher {
change("@dingger_control", &pane.written_control, String::new());
}
}
+ // What its session spent today; the cost thread reads every session
+ // file in pi's directory, and these wherever they are.
+ let session = hooks::session(&pane.pane_id).unwrap_or_else(|| pane.written_session.clone());
+ let cost = match pane.agent {
+ Some(_) if !session.is_empty() => {
+ crate::cost::note_session(&session);
+ crate::cost::option_value(crate::cost::session_today(&session))
+ }
+ _ => String::new(),
+ };
+ change("@dingger_cost", &pane.written_cost, cost);
// The draft goes with the agent too.
match (pane.agent, hooks::draft(&pane.pane_id)) {
(Some(_), Some(draft)) => change("@dingger_draft", &pane.written_draft, draft),