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 <[email protected]>
This commit is contained in:
Brandon ThomasandClaude Opus 4.8 committed 2026-10-03 03:41:15 -04:00
1 parent 33d51d2fa6
commit af3cdfd05c
2 files changed
+29

No files matched your search

+8
View File
@@ -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::<Vec<_>>(),
});
}
// 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
}
+21
View File
@@ -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<serde_json::Value> {
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()));
}