use super::super::InspectorState;
use crate::AppModel;
use crate::cli_outbound::Cli;
use crate::keymap::InspectorTab;
use crate::steps_view::StepsView;
const RAW_LABEL: &str = "Raw (verbatim bytes)";
const RAW_HINT: &str = "Show the files behind this tab exactly as they are on disk, \
unparsed — nothing summarised away. No key of its own: Tab reaches it, Space \
presses it.";
pub(super) fn per_tab_controls(
ui: &mut egui::Ui,
tab: InspectorTab,
model: &mut AppModel,
inspector: &mut InspectorState,
steps: &StepsView,
lernie: &Cli,
bl: &Cli,
) {
match tab {
InspectorTab::Transcript => {
ui.horizontal(|ui| {
ui.checkbox(&mut inspector.raw, RAW_LABEL)
.on_hover_text(RAW_HINT);
let mut responses = model.transcript_auto_expand().responses;
if ui
.checkbox(&mut responses, "auto-expand conversation")
.on_hover_text(
"Open the model's replies to their full text by default. Off, \
each is one line you can still fold open. Remembered between \
launches. No key of its own: Tab reaches it, Space presses it.",
)
.changed()
{
model.set_transcript_expand_responses(responses);
}
let mut others = model.transcript_auto_expand().others;
if ui
.checkbox(&mut others, "auto-expand machinery")
.on_hover_text(
"Same, for everything that is not the conversation itself — \
thinking, tool calls and their results. Remembered between \
launches. No key of its own: Tab reaches it, Space presses it.",
)
.changed()
{
model.set_transcript_expand_others(others);
}
});
}
InspectorTab::Steps => {
ui.checkbox(&mut inspector.raw, RAW_LABEL)
.on_hover_text(RAW_HINT);
step_controls(ui, inspector, steps);
}
InspectorTab::Inbox => {
ui.horizontal(|ui| {
ui.checkbox(&mut inspector.raw, RAW_LABEL)
.on_hover_text(RAW_HINT);
if ui
.button("Scan")
.on_hover_text(
"Run `lernie scan` on this workspace: it writes a died epitaph \
for every driver that crashed without one, and delivers inbox \
deposits still sitting queued. Nothing is started and nothing \
is killed (f).",
)
.clicked()
{
crate::shell::dispatch::scan_focused(model, lernie, bl);
}
});
}
_ => {}
}
}
fn step_controls(ui: &mut egui::Ui, inspector: &mut InspectorState, steps: &StepsView) {
ui.horizontal(|ui| {
ui.weak("step:");
for (i, step) in steps.steps.iter().enumerate() {
if ui
.selectable_label(inspector.step_sel == Some(i), &step.seq)
.on_hover_text(
"Drill into this step — its request, staging, response events and \
per-tool input/output, byte for byte, below. No key of its own: \
Tab reaches it, Space presses it.",
)
.clicked()
{
inspector.step_sel = Some(i);
}
if step.auth_failed.offered() {
ui.colored_label(crate::theme::ICHOR, step.auth_failed.step_mark());
}
}
});
if inspector.step_sel.is_none() {
return;
}
ui.horizontal(|ui| {
for (which, label, hint) in crate::steps_view::RECORDS {
if ui
.selectable_label(inspector.step_tab == which, label)
.on_hover_text(hint)
.clicked()
{
inspector.step_tab = which;
}
}
});
}