use super::super::{login_pane, start_rows};
use super::fixture::world;
use crate::cli_outbound::Cli;
use crate::config_edit::brazen::ProviderRowView;
use crate::paint_probe::{self, Painted};
use crate::projects::join::JoinState;
use crate::start::{BallSpec, Payload, StartInputs};
const PANEL: f32 = 240.0;
fn in_a_bounded_panel(body: impl FnOnce(&mut egui::Ui)) -> Vec<Painted> {
let ctx = egui::Context::default();
let mut body = Some(body);
let out = ctx.run(paint_probe::screen_sized(600.0, 400.0), |ctx| {
egui::SidePanel::left("bounded")
.exact_width(PANEL)
.show(ctx, |ui| {
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Truncate);
if let Some(body) = body.take() {
body(ui);
}
});
});
paint_probe::painted_of(&out)
}
fn in_a_seat_with_no_wrap_mode(body: impl FnOnce(&mut egui::Ui)) -> Vec<Painted> {
let ctx = egui::Context::default();
let mut body = Some(body);
let out = ctx.run(paint_probe::screen_sized(PANEL, 400.0), |ctx| {
egui::CentralPanel::default().show(ctx, |ui| {
if let Some(body) = body.take() {
body(ui);
}
});
});
paint_probe::painted_of(&out)
}
fn says(painted: &[Painted]) -> String {
let mut out = String::new();
for (text, _) in painted {
out.push_str(text);
out.push('\n');
}
out
}
fn assert_inside_the_panel(painted: &[Painted]) {
for (text, rect) in painted {
assert!(
rect.right() <= PANEL + 1.0,
"`{text}` is laid past the panel's right edge at {}",
rect.right()
);
assert!(
rect.left() >= -1.0,
"`{text}` is laid past the panel's left edge at {} — a row that \
cannot fit grows off the edge it was laid from, and the operator \
gets a hard cut with no ellipsis to warn them",
rect.left()
);
}
}
#[test]
fn the_login_verb_stays_whole_on_the_row_whose_name_would_have_eaten_it() {
let painted = in_a_bounded_panel(|ui| {
login_pane::provider_row(
ui,
&ProviderRowView {
name: "claude-session-direct".to_owned(),
fact: "auth oauth2 · not signed in".to_owned(),
blocked: None,
},
);
});
let said = says(&painted);
assert!(
said.contains("Login"),
"the verb is on screen whole, not a bare `…`:\n{said}"
);
assert!(
!said.contains("auth oauth2 · not signed in"),
"and the row really was over-full — the fact beside it elided:\n{said}"
);
assert!(
said.contains("claude-session-direct"),
"the name, which is the row's identity, survives:\n{said}"
);
assert_inside_the_panel(&painted);
}
#[test]
fn the_assign_verb_stays_whole_behind_a_ball_title_of_any_length() {
let lernie = Cli::new("lernie");
let mut world = world();
let ws = world.ws.clone();
let inputs = StartInputs {
workspace: ws.clone(),
repo: Some(ws.clone()),
payload: Payload::Ball {
project: crate::naming::leaf(&ws),
ball: BallSpec::Existing {
id: "bl-b5ce".to_owned(),
title: "epic: the inspector rework".to_owned(),
body: String::new(),
join: JoinState::ReadyStartable,
},
},
home: ws.clone(),
yog_data_root: world.yog_data.clone(),
balls_state_root: ws,
conversation_names: Vec::new(),
};
let to = world
.model
.focused_ws_name()
.expect("the fixture focuses a workspace");
let painted = in_a_bounded_panel(|ui| {
start_rows::ready_row(ui, &mut world.model, &mut world.state, &lernie, inputs);
});
let said = says(&painted);
assert!(
said.contains(&format!("assign → {to}")),
"the assign verb names its target whole:\n{said}"
);
assert!(
!said.contains("epic: the inspector rework"),
"and the row really was over-full — the ▶ label elided:\n{said}"
);
assert!(
said.contains("▶ bl-b5ce"),
"keeping the verb glyph and the ball id at its head:\n{said}"
);
assert_inside_the_panel(&painted);
}
#[test]
fn the_row_truncates_itself_in_a_seat_that_declares_no_wrap_mode() {
let painted = in_a_seat_with_no_wrap_mode(|ui| {
login_pane::provider_row(
ui,
&ProviderRowView {
name: "openai-chatgpt".to_owned(),
fact: "auth bearer · no credential stored".to_owned(),
blocked: Some("bearer-token provider — set the token in Config".to_owned()),
},
);
});
let said = says(&painted);
assert!(
said.contains("bearer-token provider — set the token in Config"),
"the reason there is no verb stays whole:\n{said}"
);
assert!(
!said.contains("auth bearer · no credential stored"),
"and the fact beside it elided rather than extending:\n{said}"
);
for (i, (a_text, a)) in painted.iter().enumerate() {
for (b_text, b) in painted.iter().skip(i + 1) {
assert!(
!a.intersects(*b),
"`{a_text}` and `{b_text}` share pixels: {a:?} vs {b:?}"
);
}
}
assert_inside_the_panel(&painted);
}
#[test]
fn the_activity_trail_paints_the_tail_that_tells_two_ops_apart() {
const PREFIX: &str = "lernie prompt --name growing \
/home/u/.cache/yog-drive/quality-20260807T214407Z/data/yog/workspaces/";
const HOME: &str = "home 20260807T214551Z-2a1181a3";
const SCRATCH: &str = "scratch 20260807T220107Z-c0ffeeba";
let mut world = crate::shell::acceptance::fixture::world();
for leaf in [HOME, SCRATCH] {
crate::opslog::append(
world.model.state_root(),
&crate::opslog::OpEntry {
ts: "1785630266".into(),
argv: vec![format!("{PREFIX}{leaf}")],
cwd: "/proj".into(),
exit: 0,
stdout: String::new(),
stderr: String::new(),
origin: crate::opslog::Origin::default(),
},
)
.expect("the fixture world takes an ops line");
}
world.model.after_lernie_verb();
world.converge();
world.converge();
let mut open = true;
let painted = super::wire::wired(&mut world, &mut |model, _| {
crate::paint_probe::paint(|ui| {
crate::shell::activity::accessory(ui, model, &mut open);
})
});
let rows: Vec<&str> = painted
.lines()
.filter(|line| line.contains("lernie prompt"))
.collect();
assert_eq!(rows.len(), 2, "both ops paint one row each:\n{painted}");
assert_ne!(rows[0], rows[1], "the two rows must not read alike");
for (row, leaf) in rows.iter().zip([HOME, SCRATCH]) {
assert!(
row.ends_with(leaf),
"the row ends with what names it: {row}"
);
assert!(row.contains('…'), "the cut is marked on screen: {row}");
assert!(
!row.contains("quality-20260807T214407Z"),
"and the invariant run between the ends is what went: {row}"
);
}
}