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};
pub(crate) mod panes;
pub(crate) use panes::{
attempt, boarded, clearing, column, commanded, configured, deposit, diff, drilled, figure,
finding, fleeting, helped, hit, lineage, machine, machines, mark, notch, own_row, pinned,
provider, queued, recorded, signing, step, trailed, trailing, tuned, waiting,
};
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 numbered(n: usize) -> String {
use std::fmt::Write;
(1..=n).fold(String::new(), |mut all, at| {
let _ = writeln!(all, "line {at:03}");
all
})
}
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(),
sender_name: None,
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 {
column: crate::ui::Column::Conversation,
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 = aim(window, label, &mut body);
paint_probe::frame::click(window, at, body);
}
pub(crate) fn right_click(window: &Window, label: &str, mut body: impl FnMut(&egui::Context)) {
let at = aim(window, label, &mut body);
paint_probe::frame::secondary(window, at, body);
}
fn aim(window: &Window, label: &str, body: impl FnMut(&egui::Context)) -> egui::Pos2 {
paint_probe::frame::locate_in(window, label, body)
.unwrap_or_else(|| panic!("nothing on the glass reads {label:?}"))
}