use crate::{agent::ADVISOR_AGENT_ID, config::InternalAgentModelConfig};
use super::RuntimeModelView;
#[derive(Clone, Debug, PartialEq, Eq)]
pub(super) enum AdvisorStatus {
Off,
Reviewing {
model: String,
},
MissingModel,
}
impl AdvisorStatus {
pub(super) fn new(advisor_mode: bool, model: Option<&InternalAgentModelConfig>) -> Self {
match (advisor_mode, model) {
(false, _) => Self::Off,
(true, Some(selection)) => Self::Reviewing {
model: rho_providers::provider::model_reference(
&selection.provider,
&selection.model,
),
},
(true, None) => Self::MissingModel,
}
}
pub(super) fn from_runtime(info: &RuntimeModelView) -> Self {
Self::new(
info.advisor_mode,
info.internal_agents.get(ADVISOR_AGENT_ID),
)
}
pub(super) fn statusline_text(&self) -> Option<String> {
match self {
Self::Off => None,
Self::Reviewing { model } => Some(format!("advisor: {model}")),
Self::MissingModel => Some("advisor: no model".into()),
}
}
pub(super) fn badge(&self) -> String {
match self {
Self::Off => "off".into(),
Self::Reviewing { model } => format!("on · {model}"),
Self::MissingModel => "on · no model".into(),
}
}
pub(super) fn detail(&self) -> String {
match self {
Self::Off => "off".into(),
Self::Reviewing { model } => format!("on, {model} reviews the session"),
Self::MissingModel => "on, but no advisor model is selected".into(),
}
}
pub(super) fn needs_model(&self) -> bool {
matches!(self, Self::MissingModel)
}
}
#[cfg(test)]
#[path = "advisor_status_tests.rs"]
mod tests;