Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/common/ordered_terminal_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ pub enum OrderedTerminalEventType {
AgentConversationReplayStarted,
/// Marks the end of historical agent conversation replay.
AgentConversationReplayEnded,
/// Emitted by the sandboxed Oz AgentDriver when the cloud-mode setup phase is complete but no
/// initial LLM turn will follow (e.g. empty-prompt local-to-cloud handoff with
/// `--skip-initial-turn`). The viewer uses this to tear down the Cloud Mode Setup V2
/// "Running setup commands…" chip and clear `BlockList::is_executing_oz_environment_startup_commands`
/// without needing to wait for the first `AppendedExchange`.
///
/// There is no matching `AmbientSetupPhaseStarted` variant: setup-phase start is already
/// implicit in the existing `SetupCommandState` transitions on the viewer (the default
/// `running_group_id` is `Some(initial)` once scrollback arrives), so an explicit start
/// marker would be redundant.
AmbientSetupPhaseEnded,
}

/// Represents the size of a PTY. Mimics the winsize struct that
Expand All @@ -82,6 +93,7 @@ impl std::fmt::Debug for OrderedTerminalEventType {
Self::AgentResponseEvent { .. } => f.write_str("AgentResponseEvent"),
Self::AgentConversationReplayStarted => f.write_str("AgentConversationReplayStarted"),
Self::AgentConversationReplayEnded => f.write_str("AgentConversationReplayEnded"),
Self::AmbientSetupPhaseEnded => f.write_str("AmbientSetupPhaseEnded"),
}
}
}
Expand All @@ -97,6 +109,7 @@ impl OrderedTerminalEventType {
| OrderedTerminalEventType::CommandExecutionFinished { .. }
| OrderedTerminalEventType::AgentConversationReplayStarted
| OrderedTerminalEventType::AgentConversationReplayEnded
| OrderedTerminalEventType::AmbientSetupPhaseEnded
| OrderedTerminalEventType::Resize { .. } => Byte::from_u64(0),
}
}
Expand All @@ -114,3 +127,31 @@ impl OrderedTerminalEvent {
self.event_type.num_bytes()
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn ambient_setup_phase_ended_serializes_as_unit_variant() {
let event_type = OrderedTerminalEventType::AmbientSetupPhaseEnded;
let json = serde_json::to_string(&event_type).expect("serialize");
assert_eq!(json, "\"AmbientSetupPhaseEnded\"");
}

#[test]
fn ambient_setup_phase_ended_round_trips() {
let event = OrderedTerminalEvent {
event_no: 42,
event_type: OrderedTerminalEventType::AmbientSetupPhaseEnded,
};
let json = serde_json::to_string(&event).expect("serialize");
let parsed: OrderedTerminalEvent = serde_json::from_str(&json).expect("deserialize");
assert_eq!(parsed.event_no, 42);
assert!(matches!(
parsed.event_type,
OrderedTerminalEventType::AmbientSetupPhaseEnded
));
assert_eq!(parsed.num_bytes(), Byte::from_u64(0));
}
}