M13.14: agent-interface audit (every command over MCP, control channel and exec --list; automation ids for every widget)
- command.describe / list_commands {schemas} give each command's params JSON Schema;
MCP describe_command, add_effect, list_effects and get_state (app.capabilities)
- effectcraft-cli exec --list [--schemas]
- headless UI audit: every panel kind's interactive egui widgets are covered by
automation ids (fixed: timeline navigator, label swatch, bar trim edges, group and
property name cells)
- command lookup is indexed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
5cf37921ef
commit
0d5f60c4b7
@@ -839,6 +839,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
p.rect_filled(Rect::from_min_max(pos2(x - 3.0, nav.min.y - 1.0), pos2(x + 3.0, nav.max.y + 1.0)), 3.0, t.accent);
|
||||
}
|
||||
let nresp = ui.interact(nav, egui::Id::new("tl-nav"), Sense::drag());
|
||||
app.auto.add("timeline.navigator", nav, "Time navigator");
|
||||
if nresp.dragged() {
|
||||
let d = nresp.drag_delta().x as f64 / nav.width() as f64 * comp.duration.seconds();
|
||||
app.ui.timeline.start = (app.ui.timeline.start + d).clamp(0.0, comp.duration.seconds());
|
||||
@@ -1159,6 +1160,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let lr = Rect::from_center_size(pos2(cw.label + 10.0, cy), vec2(12.0, 12.0));
|
||||
lp.rect_filled(lr, 2.0, t.label(layer.label));
|
||||
let lresp = ui.interact(lr, egui::Id::new(("label", layer.id.0)), Sense::click());
|
||||
app.auto.add(&format!("timeline.layer.{}.label", layer.id.0), lr, layer.label.name());
|
||||
lresp.context_menu(|ui| {
|
||||
for lab in effectcraft_engine::color::Label::ALL {
|
||||
let name = if lab == effectcraft_engine::color::Label::None { lab.name().to_string() } else { app.session.prefs.label_name(lab) };
|
||||
@@ -1403,10 +1405,12 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
// Interactions: move body, trim edges.
|
||||
let edge_w = 6.0;
|
||||
let body = ui.interact(bar.shrink2(vec2(edge_w, 0.0)), egui::Id::new(("bar", layer.id.0)), Sense::click_and_drag());
|
||||
let lin =
|
||||
ui.interact(Rect::from_min_max(bar.min, pos2(bar.min.x + edge_w, bar.max.y)), egui::Id::new(("bar-in", layer.id.0)), Sense::drag());
|
||||
let lout =
|
||||
ui.interact(Rect::from_min_max(pos2(bar.max.x - edge_w, bar.min.y), bar.max), egui::Id::new(("bar-out", layer.id.0)), Sense::drag());
|
||||
let (in_r, out_r) =
|
||||
(Rect::from_min_max(bar.min, pos2(bar.min.x + edge_w, bar.max.y)), Rect::from_min_max(pos2(bar.max.x - edge_w, bar.min.y), bar.max));
|
||||
let lin = ui.interact(in_r, egui::Id::new(("bar-in", layer.id.0)), Sense::drag());
|
||||
let lout = ui.interact(out_r, egui::Id::new(("bar-out", layer.id.0)), Sense::drag());
|
||||
app.auto.add(&format!("timeline.layer.{}.bar.in", layer.id.0), in_r, "Trim In");
|
||||
app.auto.add(&format!("timeline.layer.{}.bar.out", layer.id.0), out_r, "Trim Out");
|
||||
if lin.hovered() || lout.hovered() || lin.dragged() || lout.dragged() {
|
||||
ctx.set_cursor_icon(egui::CursorIcon::ResizeHorizontal);
|
||||
}
|
||||
@@ -1496,7 +1500,9 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
}
|
||||
lp.text(pos2(ir.max.x + 4.0, cy), Align2::LEFT_CENTER, "Inverted", Tokens::ui(11.0), t.text_dim);
|
||||
}
|
||||
let gr = ui.interact(Rect::from_min_max(pos2(indent + 8.0, r.min.y), pos2(cw.switches, r.max.y)), egui::Id::new(("grow", uid)), Sense::click());
|
||||
let gr_rect = Rect::from_min_max(pos2(indent + 8.0, r.min.y), pos2(cw.switches, r.max.y));
|
||||
let gr = ui.interact(gr_rect, egui::Id::new(("grow", uid)), Sense::click());
|
||||
app.auto.add(&format!("timeline.group.{uid}.name"), gr_rect, name);
|
||||
if gr.clicked() && uid & WAVE_BIT == 0 {
|
||||
actions.push(("prop.select".into(), json!({"layer": layer.id.0, "prop": uid, "selectKeys": false})));
|
||||
}
|
||||
@@ -1710,11 +1716,9 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
Tokens::ui(12.0),
|
||||
if prop.has_expression() { Color32::from_rgb(0xe8, 0x7c, 0x5c) } else { t.text },
|
||||
);
|
||||
let name_resp = ui.interact(
|
||||
Rect::from_min_max(pos2(name_x, r.min.y), pos2(cw.switches - 2.0, r.max.y)),
|
||||
egui::Id::new(("pname", uid)),
|
||||
Sense::click_and_drag(),
|
||||
);
|
||||
let name_rect = Rect::from_min_max(pos2(name_x, r.min.y), pos2(cw.switches - 2.0, r.max.y));
|
||||
let name_resp = ui.interact(name_rect, egui::Id::new(("pname", uid)), Sense::click_and_drag());
|
||||
app.auto.add(&format!("timeline.prop.{uid}.name"), name_rect, &prop.name);
|
||||
if name_resp.drag_started() {
|
||||
// Drop on the Essential Graphics panel to expose the property.
|
||||
egui::DragAndDrop::set_payload(&ctx, crate::panels::DragPayload::Property { layer: layer.id.0, prop: *uid });
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
//! The agent-interface audit (UI side, M13.14):
|
||||
//!
|
||||
//! - every registered engine command is reachable over the control channel (`engine.commands`
|
||||
//! lists it; `engine.execute` routes it: an unknown parameter is rejected by that command);
|
||||
//! - every panel kind, opened headless, registers an automation id for every interactive widget
|
||||
//! it draws: egui's interactive widget rects of the frame are matched against the registered
|
||||
//! automation elements, and any widget no element covers is a gap.
|
||||
|
||||
use effectcraft_engine::Session;
|
||||
use effectcraft_ui_egui::EffectcraftApp;
|
||||
use effectcraft_ui_egui::control::{self, ControlRequest, Outcome};
|
||||
use effectcraft_ui_egui::dock::PanelKind;
|
||||
use egui::Rect;
|
||||
use egui_kittest::Harness;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
fn session() -> Session {
|
||||
let mut s = Session::default();
|
||||
s.execute("file.openDemoProject", json!({})).unwrap();
|
||||
s
|
||||
}
|
||||
|
||||
fn harness(s: Session) -> Harness<'static, EffectcraftApp> {
|
||||
let mut h = Harness::builder().with_size(egui::vec2(1680.0, 1020.0)).build_eframe(|_| EffectcraftApp::new(s));
|
||||
h.run_steps(3);
|
||||
h
|
||||
}
|
||||
|
||||
fn send(h: &mut Harness<'_, EffectcraftApp>, method: &str, params: Value) -> Value {
|
||||
let ctx = h.ctx.clone();
|
||||
let (req, _rx) = ControlRequest::new(method, params);
|
||||
match control::handle(h.state_mut(), &ctx, &req) {
|
||||
Outcome::Done(v) => v,
|
||||
_ => panic!("{method}: no immediate reply"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_engine_command_is_reachable_over_the_control_channel() {
|
||||
let mut h = harness(session());
|
||||
let listed = send(&mut h, "engine.commands", json!({}));
|
||||
let ids: std::collections::HashSet<String> = listed["result"].as_array().unwrap().iter().map(|c| c["id"].as_str().unwrap().to_string()).collect();
|
||||
for spec in effectcraft_engine::command_specs() {
|
||||
assert!(ids.contains(spec.id), "engine.commands misses {}", spec.id);
|
||||
let v = send(&mut h, "engine.execute", json!({"command": spec.id, "params": {"__audit": 1}}));
|
||||
let e = v["error"].as_str().unwrap_or_default();
|
||||
assert!(v["ok"] == false && e.contains("unknown parameter") && e.contains(spec.id), "{}: {v}", spec.id);
|
||||
}
|
||||
}
|
||||
|
||||
/// Interactive widgets (click or drag sense, enabled, visible) of the last frame, in screen
|
||||
/// points, with their accessibility label when egui knows one.
|
||||
fn interactive(ctx: &egui::Context) -> Vec<(Rect, String)> {
|
||||
let screen = ctx.content_rect();
|
||||
ctx.viewport(|v| {
|
||||
let w = &v.this_pass.widgets;
|
||||
let mut out = vec![];
|
||||
for (layer, rects) in w.layers() {
|
||||
if layer.order == egui::Order::Tooltip || layer.order == egui::Order::Debug {
|
||||
continue;
|
||||
}
|
||||
for r in rects {
|
||||
let sense = r.sense;
|
||||
if !(sense.senses_click() || sense.senses_drag()) || !r.enabled {
|
||||
continue;
|
||||
}
|
||||
let ir = r.interact_rect.intersect(screen);
|
||||
if ir.width() < 2.0 || ir.height() < 2.0 {
|
||||
continue;
|
||||
}
|
||||
let info = w.info(r.id);
|
||||
// Selectable text (labels sense drags to select their text) is not a control.
|
||||
if info.is_some_and(|i| i.typ == egui::WidgetType::Label) {
|
||||
continue;
|
||||
}
|
||||
out.push((ir, info.and_then(|i| i.label.clone()).unwrap_or_default()));
|
||||
}
|
||||
}
|
||||
out
|
||||
})
|
||||
}
|
||||
|
||||
/// Automation elements that cover a widget: overlapping at least half of the smaller of the two,
|
||||
/// and not a container many times the widget's size (a panel or a whole row).
|
||||
fn covered(w: Rect, elements: &[Rect]) -> bool {
|
||||
elements.iter().any(|e| {
|
||||
let i = e.intersect(w);
|
||||
if i.width() <= 0.0 || i.height() <= 0.0 {
|
||||
return false;
|
||||
}
|
||||
let (aw, ae) = (w.area(), e.area());
|
||||
i.area() >= 0.5 * aw.min(ae) && ae <= 40.0 * aw.max(64.0)
|
||||
})
|
||||
}
|
||||
|
||||
/// (panel, widget rect, label) of every interactive widget no automation element covers, for
|
||||
/// one panel shown maximized.
|
||||
fn gaps_of(h: &mut Harness<'_, EffectcraftApp>, p: PanelKind) -> Vec<String> {
|
||||
h.state_mut().show_panel(p);
|
||||
h.state_mut().ui.maximized = Some(p);
|
||||
h.run_steps(4);
|
||||
let ctx = h.ctx.clone();
|
||||
let widgets = interactive(&ctx);
|
||||
let app = h.state();
|
||||
let elements: Vec<Rect> = app
|
||||
.auto
|
||||
.previous
|
||||
.iter()
|
||||
.chain(app.auto.elements.iter())
|
||||
.map(|e| Rect::from_min_size(egui::pos2(e.rect[0], e.rect[1]), egui::vec2(e.rect[2], e.rect[3])))
|
||||
.collect();
|
||||
let Some(panel) =
|
||||
app.auto.find(&format!("panel.{}", p.id())).map(|e| Rect::from_min_size(egui::pos2(e.rect[0], e.rect[1]), egui::vec2(e.rect[2], e.rect[3])))
|
||||
else {
|
||||
return vec![format!("{}: panel.{} not registered", p.title(), p.id())];
|
||||
};
|
||||
widgets
|
||||
.into_iter()
|
||||
.filter(|(r, _)| panel.contains(r.center()))
|
||||
.filter(|(r, _)| !covered(*r, &elements))
|
||||
.map(|(r, l)| format!("{}: [{:.0},{:.0} {:.0}x{:.0}] {l:?}", p.title(), r.min.x, r.min.y, r.width(), r.height()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_panel_registers_automation_ids_for_its_widgets() {
|
||||
let mut s = session();
|
||||
// Content for the selection-driven panels: the title (text with effects), a Render Queue
|
||||
// item, a comp marker.
|
||||
s.execute("layer.select", json!({"layers": ["EFFECTCRAFT"]})).unwrap();
|
||||
s.execute("renderQueue.add", json!({"format": "png", "output": "/tmp/ec-audit-[#####].png"})).unwrap();
|
||||
s.execute("markers.add", json!({})).ok();
|
||||
let title = s.active_comp().unwrap().layers.iter().find(|l| l.name == "EFFECTCRAFT").map(|l| l.id.0).unwrap();
|
||||
let mut h = harness(s);
|
||||
h.state_mut().ui.layer_panel = Some(title);
|
||||
// egui records widget types (to tell labels from controls) with this debug option.
|
||||
h.ctx.all_styles_mut(|st| st.debug.show_interactive_widgets = true);
|
||||
let mut gaps = vec![];
|
||||
for p in PanelKind::ALL {
|
||||
gaps.extend(gaps_of(&mut h, p));
|
||||
}
|
||||
// The timeline again with the title twirled open (properties, keys) and in the Graph Editor.
|
||||
send(&mut h, "ui.set", json!({"timeline": {"openLayers": [title]}}));
|
||||
gaps.extend(gaps_of(&mut h, PanelKind::Timeline));
|
||||
send(&mut h, "ui.set", json!({"timeline": {"graphEditor": true}}));
|
||||
gaps.extend(gaps_of(&mut h, PanelKind::Timeline));
|
||||
send(&mut h, "ui.set", json!({"timeline": {"graphEditor": false}}));
|
||||
// Outside the panels: the header and the menu bar.
|
||||
h.state_mut().ui.maximized = None;
|
||||
h.run_steps(3);
|
||||
let ctx = h.ctx.clone();
|
||||
let widgets = interactive(&ctx);
|
||||
let app = h.state();
|
||||
let elements: Vec<Rect> =
|
||||
app.auto.previous.iter().map(|e| Rect::from_min_size(egui::pos2(e.rect[0], e.rect[1]), egui::vec2(e.rect[2], e.rect[3]))).collect();
|
||||
let panels: Vec<Rect> = app
|
||||
.auto
|
||||
.previous
|
||||
.iter()
|
||||
.filter(|e| e.id.starts_with("panel.") && e.id.matches('.').count() == 1)
|
||||
.map(|e| Rect::from_min_size(egui::pos2(e.rect[0], e.rect[1]), egui::vec2(e.rect[2], e.rect[3])))
|
||||
.collect();
|
||||
for (r, l) in widgets {
|
||||
if !panels.iter().any(|p| p.contains(r.center())) && !covered(r, &elements) {
|
||||
gaps.push(format!("chrome: [{:.0},{:.0} {:.0}x{:.0}] {l:?}", r.min.x, r.min.y, r.width(), r.height()));
|
||||
}
|
||||
}
|
||||
assert!(gaps.is_empty(), "{} interactive widgets without an automation id:\n{}", gaps.len(), gaps.join("\n"));
|
||||
}
|
||||
Reference in New Issue
Block a user