use crate::AppModel;
use crate::jsonview::{GLYPH_COLLAPSED, GLYPH_EXPANDED};
use crate::nav::convs::ConvRow;
use crate::theme;
use super::super::ShellState;
pub(super) fn state_cell(ui: &mut egui::Ui, row: &ConvRow) {
let (glyph, color, phrase) = theme::state_badge(row.state);
ui.colored_label(color, glyph).on_hover_text(phrase);
}
pub(super) fn elbow(ui: &mut egui::Ui, depth: usize) {
if depth > 0 {
ui.monospace(format!(
"{}{}",
" ".repeat(depth.saturating_sub(1)),
theme::ELBOW
));
}
}
pub(super) fn subagent_field(
ui: &mut egui::Ui,
model: &mut AppModel,
state: &mut ShellState,
ws: &std::path::Path,
row: &ConvRow,
) {
if !row.has_children() {
return;
}
let open = state.expanded.contains(&row.root_id);
let glyph = if open {
GLYPH_EXPANDED
} else {
GLYPH_COLLAPSED
};
let (direct, total) = (row.direct, row.total());
let hit = ui
.add(
egui::Label::new(
egui::RichText::new(format!("{glyph} {direct}/{total}"))
.monospace()
.weak(),
)
.sense(egui::Sense::click()),
)
.on_hover_text(format!(
"subagents — {direct} dispatched by this agent itself, {total} under it \
altogether at any depth. Click to {} its children as rows in this list; \
→ unfolds the selected row, ← folds it shut, and ← on a child pages the \
selection up to its parent.",
if open { "fold away" } else { "unfold" }
));
if hit.clicked() {
super::super::focus::toggle_row(model, state, ws, &row.root_id);
}
}