From fbdae9b6ae8ea1bff77eea2f2705dd22e940862c Mon Sep 17 00:00:00 2001 From: Chris Tate Date: Sat, 14 Mar 2026 13:43:29 -0500 Subject: [PATCH] fix: restore refs dict in --json snapshot output (#787) - Restore the `refs` dictionary in `--json` snapshot output, matching the documented API contract - The `refs` field was silently dropped during the Node.js to Rust rewrite (v0.20), causing consumers parsing `data.refs` for programmatic element interaction to receive no structured ref data Fixes #785 --- cli/src/native/actions.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cli/src/native/actions.rs b/cli/src/native/actions.rs index e64dca9..2d2dc2f 100644 --- a/cli/src/native/actions.rs +++ b/cli/src/native/actions.rs @@ -1377,7 +1377,20 @@ async fn handle_snapshot(cmd: &Value, state: &mut DaemonState) -> Result = state + .ref_map + .entries_sorted() + .into_iter() + .map(|(ref_id, entry)| { + let mut obj = serde_json::Map::new(); + obj.insert("role".into(), Value::String(entry.role)); + obj.insert("name".into(), Value::String(entry.name)); + (ref_id, Value::Object(obj)) + }) + .collect(); + + Ok(json!({ "snapshot": tree, "origin": url, "refs": refs })) } async fn handle_screenshot(cmd: &Value, state: &mut DaemonState) -> Result {