aboutsummaryrefslogtreecommitdiff
path: root/crates/dinggerd/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/dinggerd/src')
-rw-r--r--crates/dinggerd/src/hooks.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/dinggerd/src/hooks.rs b/crates/dinggerd/src/hooks.rs
index 8b24659..a649fa0 100644
--- a/crates/dinggerd/src/hooks.rs
+++ b/crates/dinggerd/src/hooks.rs
@@ -18,6 +18,8 @@
//! order, so a turn that starts and finishes between two polls is still a
//! completion, and each report wakes the watcher immediately.
//!
+//! Each line is answered with `{"ok":true}`.
+//!
//! `{"method":"poke"}` only wakes the watcher; `dingger focus` and tmux's
//! focus-change hooks send it so attendance updates without waiting for the
//! next poll. The last reported state stays authoritative for its pane
@@ -123,8 +125,18 @@ struct HookParams {
}
fn handle_stream(stream: UnixStream) {
+ // Each message gets a reply line: an extension waits for one and sends
+ // the message again without it (herdr's protocol), so a report would
+ // arrive twice and take seconds.
+ let mut replies = stream.try_clone().ok();
for line in BufReader::new(stream).lines() {
let Ok(line) = line else { return };
+ if let Some(out) = replies.as_mut() {
+ use std::io::Write;
+ if out.write_all(b"{\"ok\":true}\n").is_err() {
+ replies = None; // the sender does not read replies
+ }
+ }
let Ok(message) = serde_json::from_str::<HookMessage>(&line) else {
warn!(%line, "invalid hook message");
continue;