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:
@@ -1,6 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use crate::ids::{GroupId, SurfaceId, WorkspaceId};
|
||||
use crate::layout::LayoutNode;
|
||||
use crate::status::SurfaceState;
|
||||
use crate::workspace::{Group, WorkspaceView};
|
||||
|
||||
/// Wire envelope. `kind` is the serde tag.
|
||||
@@ -114,6 +115,7 @@ pub enum Cmd {
|
||||
order: Option<u32>,
|
||||
},
|
||||
DeleteGroup { group_id: GroupId },
|
||||
SetState { surface_id: SurfaceId, state: SurfaceState },
|
||||
Status,
|
||||
Shutdown,
|
||||
}
|
||||
@@ -131,6 +133,7 @@ pub enum Evt {
|
||||
WorkspaceClosed { workspace_id: WorkspaceId },
|
||||
GroupsChanged { groups: Vec<Group> },
|
||||
SurfaceRestarted { surface_id: SurfaceId },
|
||||
State { surface_id: SurfaceId, state: SurfaceState },
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -240,4 +243,23 @@ mod tests {
|
||||
let back: Envelope = serde_json::from_str(&serde_json::to_string(&evt).unwrap()).unwrap();
|
||||
assert_eq!(back, evt);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_state_round_trips() {
|
||||
let env = Envelope::Req {
|
||||
id: 1,
|
||||
cmd: Cmd::SetState { surface_id: SurfaceId("s_1".into()), state: crate::status::SurfaceState::Done },
|
||||
};
|
||||
let back: Envelope = serde_json::from_str(&serde_json::to_string(&env).unwrap()).unwrap();
|
||||
assert_eq!(back, env);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn state_event_round_trips() {
|
||||
let evt = Envelope::Evt(Evt::State { surface_id: SurfaceId("s_1".into()), state: crate::status::SurfaceState::Wait });
|
||||
let j = serde_json::to_string(&evt).unwrap();
|
||||
assert!(j.contains(r#""evt":"state""#));
|
||||
let back: Envelope = serde_json::from_str(&j).unwrap();
|
||||
assert_eq!(back, evt);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user