use super::Echo;
use crate::git_tree::{Agent, AgentState};
use crate::inboxview::{Deposit, InboxEntry};
const SENDER: &str = "user";
impl Echo {
pub(crate) fn deposit(&self) -> InboxEntry {
deposit_of(&self.text, self.at_unix)
}
pub(crate) fn deposits(&self) -> Vec<InboxEntry> {
std::iter::once(self.deposit())
.chain(
self.held
.iter()
.map(|send| deposit_of(&send.text, send.at_unix)),
)
.collect()
}
pub(crate) fn pending_conversation(&self, id: &str, name: &str) -> Agent {
Agent {
branch_name: format!("agents/{name}"),
agent_id: id.to_owned(),
tip_oid: String::new(),
tip_short_oid: String::new(),
tip_timestamp_unix: self.at_unix,
call_start_unix: None,
last_action_unix: self.at_unix,
messages: 0,
steps: Vec::new(),
preview: Some(self.text.clone()),
stream: crate::git_tree::Stream::default(),
tool_calls: Vec::new(),
state: AgentState::Stopped,
state_uncertain: true,
truncated: false,
pending: self.deposits(),
conflicted_oid: None,
budget_oid: None,
abandoned_oid: None,
notify_oid: None,
held: None,
goal_ball: None,
name: Some(name.to_owned()),
goal_name: None,
}
}
}
fn deposit_of(text: &str, at_unix: i64) -> InboxEntry {
InboxEntry {
name: String::new(),
raw: text.as_bytes().to_vec(),
deposit: Deposit {
sender: Some(SENDER.to_owned()),
deposited_at: Some(crate::ui_state::iso8601_extended(at_unix)),
body: text.to_owned(),
..Deposit::default()
},
}
}