From af3cdfd05ccab3d79b822d7bf8807690ed620772 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sat, 3 Oct 2026 03:41:15 -0400 Subject: [PATCH] document.inspect reports video layers (frames, fps, source) for agents Video layers previously looked like plain rasters to inspecting agents; now each reports its frame count, fps, show-altered flag and footage source (blank or file), alongside the existing timeline block. 1 test. Co-Authored-By: Claude Opus 4.8 --- crates/engine/src/inspect.rs | 8 ++++++++ crates/engine/src/video_cmds/tests.rs | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/crates/engine/src/inspect.rs b/crates/engine/src/inspect.rs index 2dd093c089..79fdf3b310 100644 --- a/crates/engine/src/inspect.rs +++ b/crates/engine/src/inspect.rs @@ -112,5 +112,13 @@ fn layer_sel(l: &Layer, selected: &[photocraft_doc::LayerId]) -> Value { "items": l.effects.items.iter().map(|e| json!({"kind": e.label(), "enabled": e.enabled()})).collect::>(), }); } + // Video layer (Layer › Video Layers): the frame stack behind the displayed content. + if let Some(vid) = &l.video { + let source = match &vid.source { + photocraft_doc::VideoSource::Blank => Value::String("blank".into()), + photocraft_doc::VideoSource::File { path } => json!({ "file": path }), + }; + v["video"] = json!({"frames": vid.frames.len(), "fps": vid.fps, "showAltered": vid.show_altered, "source": source}); + } v } diff --git a/crates/engine/src/video_cmds/tests.rs b/crates/engine/src/video_cmds/tests.rs index ccab39201f..f2f8bb13cf 100644 --- a/crates/engine/src/video_cmds/tests.rs +++ b/crates/engine/src/video_cmds/tests.rs @@ -115,3 +115,24 @@ fn render_video_to_animated_gif() { assert_eq!(&gif[..6], b"GIF89a"); assert_eq!(gif.iter().filter(|&&b| b == 0x2C).count(), 3); // 3 frames } + +#[test] +fn inspect_reports_video_layer() { + let dir = tmpdir("vinsp"); + write_png(&format!("{dir}/a.png"), 6, 4, "#ff0000"); + write_png(&format!("{dir}/b.png"), 6, 4, "#00ff00"); + let mut s = session(); + s.execute("layer.videoLayers.newVideoLayerFromFile", json!({"path": dir})).unwrap(); + let r = s.execute("document.inspect", json!({})).unwrap(); + // Find any layer node carrying a "video" block. + fn find_video(v: &serde_json::Value) -> Option { + if let Some(vid) = v.get("video") { + return Some(vid.clone()); + } + v.get("children").and_then(|c| c.as_array()).and_then(|a| a.iter().find_map(find_video)) + } + let layers = r["layers"].as_array().expect("layers array"); + let vid = layers.iter().find_map(find_video).expect("a video layer is reported"); + assert_eq!(vid["frames"], 2); + assert_eq!(vid["source"]["file"].as_str(), Some(dir.as_str())); +}