diff --git a/GramAddict/core/telepathic_engine.py b/GramAddict/core/telepathic_engine.py index e06c41e..a1a8d65 100644 --- a/GramAddict/core/telepathic_engine.py +++ b/GramAddict/core/telepathic_engine.py @@ -184,25 +184,39 @@ class TelepathicEngine: # We must be extremely strict here: It's only unread if it has the "unread" text or indicator dot unread_candidates = [] - # Check for explicitly unread containers + # 1. Find all explicit unread dots in the UI + dot_nodes = [ + d for d in nodes + if "thread_indicator_status_dot" in (d.get("id", "") or d.get("resource_id", "")) + ] + + import re + for n in nodes: is_unread = False res_id = n.get("id", "") or n.get("resource_id", "") - content_desc = (n.get("description", "") or "").lower() - semantic = (n.get("semantic_string", "") or "").lower() - # Check for explicit 'unread' in description - if "unread" in content_desc or "unread" in semantic: - is_unread = True - - # Some versions might use the explicit unread dot - if "thread_indicator_status_dot" in xml_string: - # Let's fallback to any row if we know an unread dot exists in the xml - if "row_inbox_container" in res_id: + if "row_inbox_container" in res_id and (n.get("x", -1), n.get("y", -1)) not in skip_positions: + content_desc = (n.get("description", "") or "").lower() + semantic = (n.get("semantic_string", "") or "").lower() + + # 1. Check for explicit 'unread' in description + if "unread" in content_desc or "unread" in semantic: is_unread = True + + # 2. Check if an unread dot falls inside this container's bounds + if not is_unread and dot_nodes: + bounds_str = n.get("bounds", "") + m = re.match(r"\[\d+,(\d+)\]\[\d+,(\d+)\]", bounds_str) + if m: + y1, y2 = int(m.group(1)), int(m.group(2)) + for dot in dot_nodes: + dot_y = dot.get("y", -1) + if y1 <= dot_y <= y2: + is_unread = True + break - if is_unread and "row_inbox_container" in res_id and (n.get("x", -1), n.get("y", -1)) not in skip_positions: - if n.get("y", 0) > 200: + if is_unread and n.get("y", 0) > 200: unread_candidates.append(n) if unread_candidates: diff --git a/test_config.yml b/test_config.yml index e87b005..54d051f 100644 --- a/test_config.yml +++ b/test_config.yml @@ -101,7 +101,7 @@ blank_start: true # ── AI Model Endpoints (Ollama / OpenRouter) ── ai-model: qwen3.5:latest ai-model-url: http://localhost:11434/api/generate -ai-telepathic-model: llama3.2-vision +ai-telepathic-model: llava:latest ai-telepathic-url: http://localhost:11434/api/generate ai-embedding-model: nomic-embed-text ai-embedding-url: http://localhost:11434/api/embeddings