diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-16 02:26:14 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-16 02:26:14 +0300 |
| commit | 72770305d388fd5ec247493e05a89b686c6d0026 (patch) | |
| tree | 44d95c9c69042ab07e27ace37853e190b6f00ba0 /src/pane | |
| parent | 58c379f1f07adb4113e5f9ee673768b2e4b5be07 (diff) | |
feat: add hook-owned custom agent status labels
Diffstat (limited to 'src/pane')
| -rw-r--r-- | src/pane/state.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/pane/state.rs b/src/pane/state.rs index f9b7a149..2a2f789e 100644 --- a/src/pane/state.rs +++ b/src/pane/state.rs @@ -10,6 +10,7 @@ pub struct HookAuthority { pub agent_label: String, pub state: AgentState, pub message: Option<String>, + pub custom_status: Option<String>, } #[derive(Debug, Clone, PartialEq, Eq)] @@ -71,6 +72,7 @@ impl PaneState { self.recompute_effective_state(previous_agent_label, previous_known_agent, previous_state) } + #[cfg(test)] pub fn set_hook_authority( &mut self, source: String, @@ -79,6 +81,18 @@ impl PaneState { message: Option<String>, seq: Option<u64>, ) -> Option<EffectiveStateChange> { + self.set_hook_authority_with_custom_status(source, agent_label, state, message, None, seq) + } + + pub fn set_hook_authority_with_custom_status( + &mut self, + source: String, + agent_label: String, + state: AgentState, + message: Option<String>, + custom_status: Option<String>, + seq: Option<u64>, + ) -> Option<EffectiveStateChange> { if !self.accept_hook_report(&source, seq) { return None; } @@ -91,6 +105,7 @@ impl PaneState { agent_label, state, message, + custom_status, }); self.recompute_effective_state(previous_agent_label, previous_known_agent, previous_state) } @@ -186,6 +201,12 @@ impl PaneState { self.detected_agent } + pub fn effective_custom_status(&self) -> Option<&str> { + self.hook_authority + .as_ref() + .and_then(|authority| authority.custom_status.as_deref()) + } + pub fn set_manual_label(&mut self, label: String) { let label = label.trim().to_string(); self.manual_label = (!label.is_empty()).then_some(label); @@ -459,6 +480,27 @@ mod tests { } #[test] + fn custom_status_is_hook_authority_metadata() { + let mut pane = PaneState::new(); + pane.set_detected_state(Some(Agent::Claude), AgentState::Idle); + pane.set_hook_authority_with_custom_status( + "herdr:claude".into(), + "claude".into(), + AgentState::Idle, + None, + Some("scheduled".into()), + None, + ); + + assert_eq!(pane.state, AgentState::Idle); + assert_eq!(pane.effective_custom_status(), Some("scheduled")); + + pane.clear_hook_authority(Some("herdr:claude"), None); + + assert_eq!(pane.effective_custom_status(), None); + } + + #[test] fn stale_hook_report_sequence_is_ignored_for_same_source() { let mut pane = PaneState::new(); pane.set_hook_authority( |
