YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(semantic): improve Claude desktop context (#6578)
Ezra Ellettedf0c17bae27f
diff --git a/crates/screenpipe-semantic/src/parsers/claude.rs b/crates/screenpipe-semantic/src/parsers/claude.rsindex 8c05b1ad8..384f6defa 100644--- a/crates/screenpipe-semantic/src/parsers/claude.rs+++ b/crates/screenpipe-semantic/src/parsers/claude.rs@@ -42,7 +42,7 @@ impl ClaudeParser {Self {manifest: ParserManifest {id: "app.claude.message_dom".into(),- parser_version: "2".into(),+ parser_version: "4".into(),schema_version: 1,scope: ParserScope::App,platforms: vec![Platform::Macos, Platform::Windows, Platform::Linux],@@ -82,21 +82,36 @@ impl SemanticParser for ClaudeParser {context: &ParseContext<'_>,tree: &SemanticTree,) -> Result<ParseOutcome, ProjectionError> {+ let code_surface = claude_code_surface(tree);+ let design_surface = claude_design_surface(tree);let (messages, surface, key_from_url) = if let Some(messages) = dom_marker_messages(tree) {(messages, "actor_dom_markers", false)- } else if let Some(messages) = accessible_heading_messages(tree) {+ } else if let Some(messages) = accessible_heading_messages(tree, code_surface.is_some()) {(messages, "accessible_heading_markers", false)} else if let Some(messages) = announcement_messages(tree) {(messages, "sr_announcements", true)+ } else if let Some(surface) = code_surface.as_ref() {+ return Ok(ParseOutcome::Handled(code_surface_items(surface)));+ } else if let Some(surface) = design_surface.as_ref() {+ return Ok(match surface.draft.as_ref() {+ Some(_) => ParseOutcome::Handled(design_surface_items(surface)),+ None => ParseOutcome::Empty,+ });+ } else if claude_shell(tree) {+ return Ok(ParseOutcome::Empty);} else {return Ok(ParseOutcome::NotHandled);};- let title = first_root_title_excluding(tree, "WinCaptionButton").unwrap_or("Claude");+ let title = code_surface+ .as_ref()+ .map(|surface| surface.title.clone())+ .or_else(|| conversation_title(tree))+ .unwrap_or_else(|| "Claude".into());let key_seed = if key_from_url {- context.app.browser_url.as_deref().unwrap_or(title)+ context.app.browser_url.as_deref().unwrap_or(&title)} else {- title+ &title};let mut conversation = SemanticItem::new("conversation",@@ -104,11 +119,15 @@ impl SemanticParser for ClaudeParser {format!("claude:conversation:{}", key_component(key_seed)),IdentityQuality::Derived,);- conversation.title = Some(title.to_owned());+ conversation.title = Some(title);conversation.metadata.insert("app".into(), "Claude".into());conversation.metadata.insert("surface".into(), surface.into());+ if let Some(surface) = code_surface.as_ref() {+ conversation.status = Some(if surface.working { "working" } else { "ready" }.into());+ apply_code_metadata(&mut conversation, surface);+ }conversation.source_nodes.push(messages[0].0);let mut items = Vec::with_capacity(messages.len() + 1);@@ -133,9 +152,14 @@ impl SemanticParser for ClaudeParser {/// Persisted macOS/Electron trees omit DOM classes but preserve one accessible/// heading per turn: `You said: ...` or `Claude responded: ...`. The visible/// body follows the heading and ends at the exact message-actions control.+/// Button labels are excluded without trusting reconstructed ancestry because+/// depth-gapped captures can place later response text under a tool button./// Requiring both actor headings keeps partial loading states and unrelated/// headings from being treated as conversations.-fn accessible_heading_messages(tree: &SemanticTree) -> Option<Vec<(NodeId, &'static str, String)>> {+fn accessible_heading_messages(+ tree: &SemanticTree,+ allow_single_actor: bool,+) -> Option<Vec<(NodeId, &'static str, String)>> {let order: Vec<NodeId> = all_nodes(tree).collect();let mut markers: Vec<(usize, NodeId, &'static str, String)> = Vec::new();for (position, &node) in order.iter().enumerate() {@@ -154,7 +178,7 @@ fn accessible_heading_messages(tree: &SemanticTree) -> Option<Vec<(NodeId, &'sta}let has_user = markers.iter().any(|(_, _, actor, _)| *actor == "[user]");let has_assistant = markers.iter().any(|(_, _, actor, _)| *actor == "Claude");- if !has_user || !has_assistant {+ if (!has_user || !has_assistant) && !allow_single_actor {return None;}@@ -164,7 +188,7 @@ fn accessible_heading_messages(tree: &SemanticTree) -> Option<Vec<(NodeId, &'stalet window_end = markers.get(index + 1).map_or(order.len(), |next| next.0);let body = accessible_turn_body(tree,- *node,+ actor,&order[position + 1..window_end],&mut retained_bytes,)@@ -178,29 +202,23 @@ fn accessible_heading_messages(tree: &SemanticTree) -> Option<Vec<(NodeId, &'stafn accessible_turn_body(tree: &SemanticTree,- marker: NodeId,+ actor: &str,window: &[NodeId],retained_bytes: &mut usize,) -> Option<String> {let mut lines = Vec::<String>::new();- let mut skip_under: Option<NodeId> = None;for &node in window {- if is_descendant(tree, node, marker) {- continue;- }- if let Some(anchor) = skip_under {- if is_descendant(tree, node, anchor) {- continue;- }- skip_under = None;+ if is_composer_text_area(tree, node) {+ break;}if is_button_role(tree.role(node)) {- if node_content(tree, node)- .is_some_and(|content| content.eq_ignore_ascii_case("Show message actions"))- {- break;+ if let Some(content) = node_content(tree, node) {+ if content.eq_ignore_ascii_case("Show message actions")+ || (actor == "[user]" && content.eq_ignore_ascii_case("Show more"))+ {+ break;+ }}- skip_under = Some(node);continue;}if !is_message_text_role(tree.role(node)) {@@ -209,6 +227,14 @@ fn accessible_turn_body(let Some(content) = node_content(tree, node) else {continue;};+ if has_button_ancestor_with_same_content(tree, node, content) {+ continue;+ }+ if content.eq_ignore_ascii_case("Chat mode")+ || content.starts_with("Claude is AI and can make mistakes")+ {+ break;+ }for line in content.lines().map(str::trim)@@ -220,6 +246,7 @@ fn accessible_turn_body(.iter().chain(IGNORED_ACTIONS.iter()).any(|chrome| line.eq_ignore_ascii_case(chrome))+ || is_claude_time_label(line)|| lines.last().is_some_and(|previous| previous == line){continue;@@ -243,6 +270,333 @@ fn accessible_turn_body((!lines.is_empty()).then(|| lines.join("\n"))}+fn has_button_ancestor_with_same_content(tree: &SemanticTree, node: NodeId, content: &str) -> bool {+ let mut current = tree.parent(node);+ while let Some(parent) = current {+ if is_button_role(tree.role(parent))+ && node_content(tree, parent).is_some_and(|label| label.eq_ignore_ascii_case(content))+ {+ return true;+ }+ current = tree.parent(parent);+ }+ false+}++fn is_claude_time_label(line: &str) -> bool {+ line.eq_ignore_ascii_case("just now") || (line.len() <= 32 && line.ends_with(" ago"))+}++struct ClaudeCodeSurface {+ title: String,+ title_node: NodeId,+ draft: Option<(NodeId, String)>,+ project: Option<String>,+ environment: Option<String>,+ branch: Option<String>,+ model: Option<String>,+ effort: Option<String>,+ worktree: bool,+ working: bool,+}++fn claude_code_surface(tree: &SemanticTree) -> Option<ClaudeCodeSurface> {+ let mut terminal = false;+ let mut diff = false;+ let mut browser = false;+ let mut session_actions_index = None;+ let mut remote_control_index = None;+ let mut local_index = None;+ let mut project = None;+ let mut branch = None;+ let mut worktree = false;+ let mut model = None;+ let mut effort = None;+ let mut working = false;++ for index in 0..tree.len() {+ let node = NodeId(index as u32);+ let role = tree.role(node).unwrap_or("");+ let Some(content) = node_content(tree, node) else {+ continue;+ };+ terminal |=+ role.eq_ignore_ascii_case("AXCheckBox") && content.eq_ignore_ascii_case("Terminal");+ diff |= role.eq_ignore_ascii_case("AXCheckBox") && content.eq_ignore_ascii_case("Diff");+ browser |=+ role.eq_ignore_ascii_case("AXCheckBox") && content.eq_ignore_ascii_case("Browser");+ if content.starts_with("Session actions") {+ session_actions_index = Some(index);+ }+ if content.eq_ignore_ascii_case("Remote Control") {+ remote_control_index = Some(index);+ }+ if role.eq_ignore_ascii_case("AXPopUpButton") && content.eq_ignore_ascii_case("Local") {+ local_index = Some(index);+ } else if local_index.is_some_and(|local| index == local + 1)+ && role.eq_ignore_ascii_case("AXPopUpButton")+ {+ project = Some(content.to_owned());+ }+ if role.eq_ignore_ascii_case("AXComboBox") {+ branch = Some(content.to_owned());+ }+ worktree |=+ role.eq_ignore_ascii_case("AXCheckBox") && content.eq_ignore_ascii_case("worktree");+ if role.eq_ignore_ascii_case("AXPopUpButton")+ && ["Opus ", "Sonnet ", "Haiku "]+ .iter()+ .any(|prefix| content.starts_with(prefix))+ {+ model = Some(content.to_owned());+ }+ if role.eq_ignore_ascii_case("AXPopUpButton") && content.starts_with("Effort: ") {+ effort = content.strip_prefix("Effort: ").map(str::to_owned);+ }+ working |= content.eq_ignore_ascii_case("Stop")+ || content.eq_ignore_ascii_case("Claude is responding");+ }++ let active_scaffold = terminal && diff && browser && session_actions_index.is_some();+ let new_task_scaffold = local_index.is_some() && branch.is_some() && worktree;+ if !active_scaffold && !new_task_scaffold {+ return None;+ }++ let title_anchor = remote_control_index.or(session_actions_index);+ let title = title_anchor+ .and_then(|anchor| previous_button_label(tree, anchor))+ .unwrap_or_else(|| "New task".into());+ let title_node = title_anchor+ .and_then(|anchor| previous_button_node(tree, anchor))+ .unwrap_or(NodeId(0));+ Some(ClaudeCodeSurface {+ title,+ title_node,+ draft: claude_composer(tree),+ project,+ environment: local_index.map(|_| "Local".into()),+ branch,+ model,+ effort,+ worktree,+ working,+ })+}++fn previous_button_label(tree: &SemanticTree, before: usize) -> Option<String> {+ previous_button_node(tree, before).and_then(|node| node_content(tree, node).map(str::to_owned))+}++fn previous_button_node(tree: &SemanticTree, before: usize) -> Option<NodeId> {+ (0..before).rev().find_map(|index| {+ let node = NodeId(index as u32);+ tree.role(node)+ .is_some_and(|role| role.eq_ignore_ascii_case("AXButton"))+ .then_some(node)+ })+}++fn claude_composer(tree: &SemanticTree) -> Option<(NodeId, String)> {+ for index in 0..tree.len() {+ let node = NodeId(index as u32);+ if !is_composer_text_area(tree, node) {+ continue;+ }+ let Some(body) = node_content(tree, node) else {+ continue;+ };+ let has_send_control = ((index + 1)..tree.len().min(index + 8)).any(|following| {+ let candidate = NodeId(following as u32);+ node_content(tree, candidate).is_some_and(|content| {+ ["Send", "Stop", "Send message"]+ .iter()+ .any(|label| content.eq_ignore_ascii_case(label))+ })+ });+ if has_send_control && !is_composer_placeholder(body) {+ return Some((node, body.to_owned()));+ }+ }+ None+}++fn is_composer_text_area(tree: &SemanticTree, node: NodeId) -> bool {+ tree.role(node)+ .is_some_and(|role| role.eq_ignore_ascii_case("AXTextArea"))+}++fn is_composer_placeholder(value: &str) -> bool {+ [+ "Type / for commands",+ "Write a message…",+ "Write a message...",+ "Describe a task or ask a question",+ "Describe what you want to create...",+ "Attach a file, link your design system, or describe what you want to make",+ ]+ .iter()+ .any(|placeholder| value.eq_ignore_ascii_case(placeholder))+}++fn code_surface_items(surface: &ClaudeCodeSurface) -> Vec<SemanticItem> {+ let mut conversation = SemanticItem::new(+ "conversation",+ SemanticKind::Conversation,+ format!("claude:conversation:{}", key_component(&surface.title)),+ IdentityQuality::Derived,+ );+ conversation.title = Some(surface.title.clone());+ conversation.status = Some(if surface.working { "working" } else { "ready" }.into());+ conversation.metadata.insert("app".into(), "Claude".into());+ conversation+ .metadata+ .insert("surface".into(), "claude_code".into());+ apply_code_metadata(&mut conversation, surface);+ conversation.source_nodes.push(surface.title_node);+ let mut items = vec![conversation];+ if let Some((node, body)) = surface.draft.as_ref() {+ let mut message = SemanticItem::new(+ "message-0",+ SemanticKind::Message,+ "claude:draft",+ IdentityQuality::Ephemeral,+ );+ message.parent_local_id = Some("conversation".into());+ message.actor = Some("[user]".into());+ message.body = Some(body.clone());+ message.status = Some("draft".into());+ message.source_nodes.push(*node);+ items.push(message);+ }+ items+}++fn apply_code_metadata(conversation: &mut SemanticItem, surface: &ClaudeCodeSurface) {+ for (key, value) in [+ ("project", surface.project.as_ref()),+ ("environment", surface.environment.as_ref()),+ ("branch", surface.branch.as_ref()),+ ("model", surface.model.as_ref()),+ ("effort", surface.effort.as_ref()),+ ] {+ if let Some(value) = value {+ conversation.metadata.insert(key.into(), value.clone());+ }+ }+ if surface.worktree {+ conversation+ .metadata+ .insert("worktree".into(), "true".into());+ }+}++struct ClaudeDesignSurface {+ draft: Option<(NodeId, String)>,+}++fn claude_design_surface(tree: &SemanticTree) -> Option<ClaudeDesignSurface> {+ let design = all_nodes(tree).any(|node| {+ node_content(tree, node).is_some_and(|content| {+ content.eq_ignore_ascii_case("Claude Design")+ || content.eq_ignore_ascii_case("Claude Design Beta")+ })+ });+ design.then(|| ClaudeDesignSurface {+ draft: first_meaningful_text_area(tree),+ })+}++fn first_meaningful_text_area(tree: &SemanticTree) -> Option<(NodeId, String)> {+ all_nodes(tree).find_map(|node| {+ is_composer_text_area(tree, node)+ .then(|| node_content(tree, node))+ .flatten()+ .filter(|body| !is_composer_placeholder(body))+ .map(|body| (node, body.to_owned()))+ })+}++fn design_surface_items(surface: &ClaudeDesignSurface) -> Vec<SemanticItem> {+ let mut conversation = SemanticItem::new(+ "conversation",+ SemanticKind::Conversation,+ "claude:conversation:design",+ IdentityQuality::Derived,+ );+ conversation.title = Some("Claude Design".into());+ conversation.metadata.insert("app".into(), "Claude".into());+ conversation+ .metadata+ .insert("surface".into(), "claude_design".into());+ let mut items = vec![conversation];+ if let Some((node, body)) = surface.draft.as_ref() {+ let mut message = SemanticItem::new(+ "message-0",+ SemanticKind::Message,+ "claude:design-draft",+ IdentityQuality::Ephemeral,+ );+ message.parent_local_id = Some("conversation".into());+ message.actor = Some("[user]".into());+ message.body = Some(body.clone());+ message.status = Some("draft".into());+ message.source_nodes.push(*node);+ items.push(message);+ }+ items+}++fn claude_shell(tree: &SemanticTree) -> bool {+ let mut web_area = false;+ for node in all_nodes(tree) {+ let Some(content) = node_content(tree, node) else {+ continue;+ };+ if tree+ .role(node)+ .is_some_and(|role| role.eq_ignore_ascii_case("AXWebArea"))+ {+ web_area |= content.eq_ignore_ascii_case("Claude")+ || content.ends_with(" - Claude")+ || tree.text(node).is_some_and(|text| {+ text.eq_ignore_ascii_case("Claude") || text.ends_with(" - Claude")+ });+ }+ }+ web_area+}++fn conversation_title(tree: &SemanticTree) -> Option<String> {+ for node in all_nodes(tree) {+ if tree+ .role(node)+ .is_some_and(|role| role.eq_ignore_ascii_case("AXWebArea"))+ {+ let title = tree+ .title(node)+ .or_else(|| tree.text(node))+ .or_else(|| tree.value(node))+ .or_else(|| tree.description(node))+ .map(str::trim);+ if let Some(title) = title.filter(|title| {+ !title.eq_ignore_ascii_case("Claude")+ && !title.eq_ignore_ascii_case("standard window")+ && !title.eq_ignore_ascii_case("HTML content")+ && title.len() <= 240+ && !title.contains(['\n', '\r'])+ }) {+ return Some(title.to_owned());+ }+ }+ }+ first_root_title_excluding(tree, "WinCaptionButton")+ .filter(|title| {+ !title.eq_ignore_ascii_case("Claude") && !title.eq_ignore_ascii_case("standard window")+ })+ .map(str::to_owned)+}+/// Web/macOS surface: actor-bearing DOM marker classes. Unchanged behavior.fn dom_marker_messages(tree: &SemanticTree) -> Option<Vec<(NodeId, &'static str, String)>> {let mut messages = Vec::new();diff --git a/crates/screenpipe-semantic/tests/claude_obsidian_parsers.rs b/crates/screenpipe-semantic/tests/claude_obsidian_parsers.rsindex ec73cd09d..378d622bf 100644--- a/crates/screenpipe-semantic/tests/claude_obsidian_parsers.rs+++ b/crates/screenpipe-semantic/tests/claude_obsidian_parsers.rs@@ -163,6 +163,194 @@ fn claude_abstains_on_an_assistant_only_accessible_heading() {);}+#[test]+fn claude_code_extracts_new_task_draft_and_execution_context() {+ let source = r#"{+ "app": {+ "platform": "macos",+ "app_id": "com.anthropic.claudefordesktop",+ "executable": "Claude",+ "display_name": "Claude"+ },+ "nodes": [+ { "role": "AXWindow", "text": "Claude", "depth": 0, "role_description": "standard window" },+ { "role": "AXWebArea", "text": "Claude", "depth": 7, "role_description": "HTML content" },+ { "role": "AXPopUpButton", "text": "Local", "depth": 16 },+ { "role": "AXPopUpButton", "text": "screenpipe", "depth": 16 },+ { "role": "AXComboBox", "text": "main", "depth": 16 },+ { "role": "AXCheckBox", "text": "worktree", "depth": 16 },+ { "role": "AXTextArea", "value": "Investigate the parser regression.", "depth": 18 },+ { "role": "AXStaticText", "text": "Investigate the parser regression.", "depth": 20 },+ { "role": "AXButton", "text": "Send", "depth": 18 },+ { "role": "AXPopUpButton", "text": "Opus 4.6 · Fast", "depth": 16 },+ { "role": "AXPopUpButton", "text": "Effort: High", "depth": 16 }+ ]+ }"#;+ let items = handled(source, "app.claude.message_dom");+ assert_eq!(items.len(), 2);+ assert_eq!(items[0].title.as_deref(), Some("New task"));+ assert_eq!(+ items[0].metadata.get("project").map(String::as_str),+ Some("screenpipe")+ );+ assert_eq!(+ items[0].metadata.get("branch").map(String::as_str),+ Some("main")+ );+ assert_eq!(+ items[0].metadata.get("worktree").map(String::as_str),+ Some("true")+ );+ assert_eq!(+ items[0].metadata.get("model").map(String::as_str),+ Some("Opus 4.6 · Fast")+ );+ assert_eq!(items[1].actor.as_deref(), Some("[user]"));+ assert_eq!(items[1].status.as_deref(), Some("draft"));+ assert_eq!(+ items[1].body.as_deref(),+ Some("Investigate the parser regression.")+ );+}++#[test]+fn claude_code_loading_turn_stops_before_unattributed_assistant_stream() {+ let source = r#"{+ "app": {+ "platform": "macos",+ "app_id": "com.anthropic.claudefordesktop",+ "executable": "Claude",+ "display_name": "Claude"+ },+ "nodes": [+ { "role": "AXWindow", "text": "Claude", "depth": 0, "role_description": "standard window" },+ { "role": "AXWebArea", "text": "Claude", "depth": 7, "role_description": "HTML content" },+ { "role": "AXButton", "text": "Parser regression", "depth": 17 },+ { "role": "AXPopUpButton", "text": "Remote Control", "depth": 17 },+ { "role": "AXCheckBox", "text": "Terminal", "depth": 17 },+ { "role": "AXCheckBox", "text": "Diff", "depth": 17 },+ { "role": "AXCheckBox", "text": "Browser", "depth": 17 },+ { "role": "AXPopUpButton", "text": "Session actions", "depth": 17 },+ { "role": "AXStaticText", "text": "Claude is responding", "depth": 18 },+ { "role": "AXHeading", "text": "You said: Inspect the parser", "depth": 20 },+ { "role": "AXStaticText", "text": "You said: Inspect the parser", "depth": 21 },+ { "role": "AXStaticText", "text": "Inspect the parser and preserve its boundaries.", "depth": 22 },+ { "role": "AXButton", "text": "Show more", "depth": 21 },+ { "role": "AXStaticText", "text": "I am streaming an assistant answer without an actor heading.", "depth": 22 },+ { "role": "AXStaticText", "text": "Chat mode", "depth": 18 },+ { "role": "AXTextArea", "value": "Type / for commands", "depth": 18 },+ { "role": "AXButton", "text": "Stop", "depth": 18 }+ ]+ }"#;+ let items = handled(source, "app.claude.message_dom");+ assert_eq!(items.len(), 2);+ assert_eq!(items[0].title.as_deref(), Some("Parser regression"));+ assert_eq!(items[1].actor.as_deref(), Some("[user]"));+ assert_eq!(+ items[1].body.as_deref(),+ Some("Inspect the parser and preserve its boundaries.")+ );+}++#[test]+fn claude_conversation_uses_page_title_and_stops_at_composer() {+ let source = r#"{+ "app": {+ "platform": "macos",+ "app_id": "com.anthropic.claudefordesktop",+ "executable": "Claude",+ "display_name": "Claude"+ },+ "nodes": [+ { "role": "AXWindow", "text": "Claude", "depth": 0, "role_description": "standard window" },+ { "role": "AXWebArea", "text": "", "depth": 7, "role_description": "HTML content" },+ { "role": "AXWebArea", "text": "Parser repair - Claude", "depth": 8, "role_description": "HTML content" },+ { "role": "AXHeading", "text": "You said: Repair it", "depth": 16 },+ { "role": "AXStaticText", "text": "Repair the exact parser.", "depth": 20 },+ { "role": "AXHeading", "text": "Claude responded: Done", "depth": 16 },+ { "role": "AXStaticText", "text": "The parser is repaired.", "depth": 20 },+ { "role": "AXStaticText", "text": "just now", "depth": 20 },+ { "role": "AXTextArea", "value": "composer draft", "depth": 18 },+ { "role": "AXButton", "text": "Send message", "depth": 18 },+ { "role": "AXHeading", "text": "Settings", "depth": 5 },+ { "role": "AXStaticText", "text": "Plugins", "depth": 6 }+ ]+ }"#;+ let items = handled(source, "app.claude.message_dom");+ assert_eq!(items.len(), 3);+ assert_eq!(items[0].title.as_deref(), Some("Parser repair - Claude"));+ assert_eq!(items[1].body.as_deref(), Some("Repair the exact parser."));+ assert_eq!(items[2].body.as_deref(), Some("The parser is repaired."));+}++#[test]+fn claude_keeps_response_text_reparented_under_a_tool_button() {+ let source = r#"{+ "app": {+ "platform": "macos",+ "app_id": "com.anthropic.claudefordesktop",+ "executable": "Claude",+ "display_name": "Claude"+ },+ "nodes": [+ { "role": "AXWindow", "text": "Claude", "parent": null },+ { "role": "AXWebArea", "text": "Tool result - Claude", "parent": 0 },+ { "role": "AXHeading", "text": "You said: Connect Figma", "parent": 1 },+ { "role": "AXStaticText", "text": "Connect Figma.", "parent": 2 },+ { "role": "AXHeading", "text": "Claude responded: I checked the connection.", "parent": 1 },+ { "role": "AXStaticText", "text": "Claude responded: I checked the connection.", "parent": 4 },+ { "role": "AXButton", "text": "Searched the web, loaded tools", "parent": 4 },+ { "role": "AXStaticText", "text": "Searched the web, loaded tools", "parent": 6 },+ { "role": "AXStaticText", "text": "I checked the connection.", "parent": 7 },+ { "role": "AXStaticText", "text": "Open Connectors and enable Figma.", "parent": 8 },+ { "role": "AXStaticText", "text": "Then I can inspect the complete design.", "parent": 8 },+ { "role": "AXTextArea", "value": "Write a message…", "parent": 1 },+ { "role": "AXButton", "text": "Send message", "parent": 1 }+ ]+ }"#;+ let items = handled(source, "app.claude.message_dom");+ assert_eq!(items.len(), 3);+ assert_eq!(+ items[2].body.as_deref(),+ Some(+ "I checked the connection.\nOpen Connectors and enable Figma.\nThen I can inspect the complete design."+ )+ );+ assert!(!items[2]+ .body+ .as_deref()+ .unwrap()+ .contains("Searched the web"));+}++#[test]+fn claude_design_extracts_a_meaningful_draft() {+ let source = r#"{+ "app": {+ "platform": "macos",+ "app_id": "com.anthropic.claudefordesktop",+ "executable": "Claude",+ "display_name": "Claude"+ },+ "nodes": [+ { "role": "AXWindow", "text": "Design", "depth": 0 },+ { "role": "AXWebArea", "text": "Claude Design", "depth": 7 },+ { "role": "AXLink", "text": "Claude Design Beta", "depth": 3 },+ { "role": "AXHeading", "text": "What should we create?", "depth": 3 },+ { "role": "AXTextArea", "value": "Make the dock controls easier to understand.", "depth": 6 },+ { "role": "AXButton", "text": "Create", "depth": 5 }+ ]+ }"#;+ let items = handled(source, "app.claude.message_dom");+ assert_eq!(items.len(), 2);+ assert_eq!(items[0].title.as_deref(), Some("Claude Design"));+ assert_eq!(items[1].status.as_deref(), Some("draft"));+ assert_eq!(+ items[1].body.as_deref(),+ Some("Make the dock controls easier to understand.")+ );+}+#[test]fn obsidian_extracts_the_active_codemirror_note() {let items = handled(