use rho_protocol::{MessageOrigin, RhoNotice};
use rho_sdk::model::{ContentBlock, SemanticMessage};
pub(crate) const RESUME_NOTE: &str =
"The rho daemon restarted and interrupted your previous turn. Continue where you left off. \
A tool call the restart interrupted may have partly run; check its effects before \
repeating it.";
pub(crate) const RESUME_NOTICE: &str =
"rho daemon restarted mid-turn; continuing the interrupted turn";
pub(super) fn replayed_origin(
message: &SemanticMessage<'_>,
saved: Option<&MessageOrigin>,
) -> Option<MessageOrigin> {
if let Some(saved) = saved {
return Some(saved.clone());
}
match message {
SemanticMessage::BoundaryInput(_) => Some(MessageOrigin::rho(RhoNotice::Notification)),
SemanticMessage::User([ContentBlock::Text(text)]) if text == RESUME_NOTE => {
Some(MessageOrigin::rho(RhoNotice::Restart))
}
_ => None,
}
}