use crate::paint_probe::{self, frame::Window};
use crate::reply::convs::{AgentState, ConvRow, Tone};
use crate::reply::roster::{WorkspaceKind, WsRow};
use crate::reply::transcript::{Entry, EntryKind, Transcript};
use crate::ui::{Aim, Channel, Chunk, Model};
pub(crate) fn wall(name: &str) -> WsRow {
WsRow {
workspace: name.to_owned(),
kind: WorkspaceKind::Named,
attention: 0,
agents: 2,
running: false,
pinned: None,
}
}
pub(crate) fn conv(id: &str, display: &str) -> ConvRow {
ConvRow {
root_id: id.to_owned(),
display: display.to_owned(),
name: Some(display.to_owned()),
state: AgentState::Quiescent,
uncertain: false,
preview: String::new(),
age_secs: 42,
attention: 0,
members: 1,
depth: 0,
tone: Tone::Plain,
failure: None,
}
}
pub(crate) fn said(sender: &str, body: &str) -> Entry {
Entry {
name: format!("001-{sender}.md"),
raw: body.to_owned(),
kind: EntryKind::Delivered {
sender: sender.to_owned(),
epitaph: None,
body: body.to_owned(),
},
}
}
pub(crate) fn own() -> Chunk {
Chunk {
channel: Channel {
name: "(this box's own engine)".to_owned(),
named_there: None,
dials: None,
},
held: crate::ui::Held::Heard,
stale: None,
growth: None,
walls: vec![wall("home")],
}
}
pub(crate) fn seated() -> Model {
Model {
roster: vec![own()],
convs: vec![conv("20260830T051200Z-a1b2", "port the paint probe")],
transcript: Transcript {
entries: vec![said("op", "port it")],
},
aim: Some(Aim {
channel: "(this box's own engine)".to_owned(),
address: "home".to_owned(),
}),
conversation: Some("20260830T051200Z-a1b2".to_owned()),
..Model::default()
}
}
pub(crate) fn painted(model: &mut Model) -> String {
Window::new().text(|ctx| crate::ui::render(ctx, model))
}
pub(crate) fn seen(window: &Window, body: impl FnMut(&egui::Context)) -> Vec<paint_probe::Seen> {
paint_probe::seen_of(&window.frame(Vec::new(), body))
}
pub(crate) fn pane(body: impl FnMut(&mut egui::Ui)) -> String {
paint_probe::paint(body)
}
pub(crate) fn click(window: &Window, label: &str, mut body: impl FnMut(&egui::Context)) {
let at = paint_probe::frame::locate_in(window, label, &mut body)
.unwrap_or_else(|| panic!("nothing on the glass reads {label:?}"));
paint_probe::frame::click(window, at, body);
}