use crate::paint_probe::{self, frame::Window};
use crate::reply::convs::{AgentState, ConvRow, Tone};
use crate::reply::roles::RoleRow;
use crate::reply::roster::{WorkspaceKind, WsRow};
use crate::reply::transcript::{Entry, EntryKind, Transcript};
use crate::ui::{Aim, Channel, Chunk, Model, Tuning};
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 role(name: &str) -> RoleRow {
RoleRow {
role: name.to_owned(),
provider: "housevendor".to_owned(),
model: "house-model-1".to_owned(),
priority: false,
effort: Some("medium".to_owned()),
}
}
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 tuned() -> Model {
Model {
roles: Some(vec![role("worker"), role("compactor")]),
tuning: Some(Tuning::Rows),
..seated()
}
}
pub(crate) fn step(seq: &str) -> crate::reply::steps::StepRow {
crate::reply::steps::StepRow {
seq: seq.to_owned(),
framing: "complete".to_owned(),
attempts: 1,
tokens: crate::reply::steps::Spend {
input: 11,
output: 22,
cache_read: 33,
cache_write: 44,
total: 99,
},
commit: Some("abcdef1".to_owned()),
started_at: Some("2026-08-30T05:12Z".to_owned()),
ended_at: Some("2026-08-30T05:14Z".to_owned()),
auth_failed: false,
auth_row: None,
wound: crate::reply::steps::NONE.to_owned(),
wound_reason: None,
}
}
pub(crate) fn recorded() -> Model {
let wounded = crate::reply::steps::StepRow {
seq: "002".to_owned(),
framing: "failed".to_owned(),
attempts: 2,
commit: None,
started_at: None,
ended_at: None,
auth_failed: true,
auth_row: Some("housevendor".to_owned()),
wound: "no_response".to_owned(),
wound_reason: Some("no bytes".to_owned()),
..step("002")
};
Model {
records: true,
steps: Some(crate::reply::steps::Steps {
rows: vec![step("001"), wounded],
orphan: "mail".to_owned(),
orphan_reason: Some("driver died".to_owned()),
}),
files: Some(crate::reply::files::Files {
listing: Some(crate::reply::files::Listing {
rows: vec![
crate::reply::files::FileRow {
path: "src".to_owned(),
size: 0,
dir: true,
},
crate::reply::files::FileRow {
path: "src/a.rs".to_owned(),
size: 12,
dir: false,
},
],
truncated: true,
}),
preview: None,
working_dir: Some("/home/u/elsewhere".to_owned()),
}),
..seated()
}
}
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);
}