feat(proto): SurfaceState + SetState command + State event + SurfaceView.state

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-09 22:10:54 +07:00
parent c2f8ef4214
commit 4bd4aa4a36
4 changed files with 67 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
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);
}
}
}