4bd4aa4a36
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
40 lines
1.1 KiB
Rust
40 lines
1.1 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
/// Ephemeral agent-activity status of a running surface (orthogonal to the
|
|
/// running/stopped process lifecycle). Defaults to `Idle`.
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum SurfaceState {
|
|
Work,
|
|
Wait,
|
|
Done,
|
|
Error,
|
|
#[default]
|
|
Idle,
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn serializes_snake_case() {
|
|
assert_eq!(serde_json::to_string(&SurfaceState::Work).unwrap(), r#""work""#);
|
|
assert_eq!(serde_json::to_string(&SurfaceState::Idle).unwrap(), r#""idle""#);
|
|
}
|
|
|
|
#[test]
|
|
fn default_is_idle() {
|
|
assert_eq!(SurfaceState::default(), SurfaceState::Idle);
|
|
}
|
|
|
|
#[test]
|
|
fn round_trips() {
|
|
for s in [SurfaceState::Work, SurfaceState::Wait, SurfaceState::Done, SurfaceState::Error, SurfaceState::Idle] {
|
|
let j = serde_json::to_string(&s).unwrap();
|
|
let back: SurfaceState = serde_json::from_str(&j).unwrap();
|
|
assert_eq!(back, s);
|
|
}
|
|
}
|
|
}
|