Skip to content

Enhance TV connection with Claude API - #113

Draft
drussell23 wants to merge 1 commit into
mainfrom
cursor/enhance-tv-connection-with-claude-api-claude-4.5-sonnet-thinking-1ec4
Draft

Enhance TV connection with Claude API#113
drussell23 wants to merge 1 commit into
mainfrom
cursor/enhance-tv-connection-with-claude-api-claude-4.5-sonnet-thinking-1ec4

Conversation

@drussell23

@drussell23 drussell23 commented Nov 22, 2025

Copy link
Copy Markdown
Owner

Summary

This PR integrates the Claude Computer Use API into JARVIS to replace hardcoded, coordinate-based display connection workflows with a dynamic, vision-based approach. This significantly enhances robustness, adaptability to UI changes, and provides real-time voice transparency during execution.

Changes Made

  • backend/display/computer_use_display_connector.py: New module for vision-based display connections using the Claude Computer Use API.
  • backend/display/hybrid_display_connector.py: New module implementing a hybrid strategy to intelligently choose between the existing UAE (fast, local) and the new Computer Use (robust, AI-driven) connectors.
  • backend/display/jarvis_computer_use_integration.py: New integration layer that bridges JARVIS's voice system with the hybrid connector, providing real-time voice feedback and managing configuration.
  • test_computer_use_integration.py: New comprehensive test script to demonstrate and verify the integration.
  • Documentation: Added COMPUTER_USE_README.md, COMPUTER_USE_QUICK_START.md, COMPUTER_USE_INTEGRATION.md, and COMPUTER_USE_IMPLEMENTATION_SUMMARY.md for complete guidance.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🎨 Style/UI update (no functional changes)
  • ♻️ Code refactoring (no functional changes)
  • ⚡ Performance improvement
  • ✅ Test update
  • 🔧 Configuration change
  • 🔒 Security fix

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • All tests passing

Testing Steps:

  1. Install anthropic dependency: pip install anthropic>=0.8.0
  2. Set your Anthropic API key: export ANTHROPIC_API_KEY="your-anthropic-api-key"
  3. Run the integration test script: python test_computer_use_integration.py "Living Room TV"
  4. (Optional) Force Computer Use API: python test_computer_use_integration.py "Living Room TV" --force-computer-use
  5. Verify JARVIS provides voice updates and successfully connects to the specified display.

Related Issues

Closes #
Relates to #

Screenshots (if applicable)

N/A

Deployment Notes

  • Database migrations required
  • Environment variables added/changed (updated .env.example) - ANTHROPIC_API_KEY
  • Dependencies added/updated - anthropic>=0.8.0
  • Configuration changes required
  • Infrastructure changes required

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published
  • I have updated the .env.example file if I added new environment variables
  • I have checked for security vulnerabilities in my changes
  • I have verified that no sensitive data is exposed

Additional Context

This integration addresses the "coordinate brittleness" problem by allowing JARVIS to visually understand and interact with the macOS UI. The hybrid approach ensures that common, stable connections remain fast and free via the existing UAE system, while complex or new scenarios leverage the robustness and intelligence of the Claude Computer Use API. JARVIS's voice transparency provides a clear, step-by-step narrative of the connection process.


Reviewer Guidelines:

  • Check code quality and adherence to project standards
  • Verify test coverage is adequate
  • Ensure documentation is updated
  • Validate security considerations
  • Confirm no sensitive data is exposed

Open in Cursor Open in Web


Summary by cubic

Integrates the Claude Computer Use API to make TV/display connections vision-driven and resilient, replacing brittle coordinate clicks. Adds a hybrid connector that uses the fast UAE path first and falls back to Computer Use with real-time voice updates.

  • New Features

    • Vision-based display connector using Computer Use API.
    • Hybrid connector that selects UAE or Computer Use based on confidence.
    • JARVIS voice integration for step-by-step narration.
    • Test script with a flag to force Computer Use.
    • Full docs: README, Quick Start, Integration, and Implementation Summary.
  • Migration

    • Install dependency: pip install anthropic>=0.8.0.
    • Set env var: ANTHROPIC_API_KEY.
    • Test: python test_computer_use_integration.py "Living Room TV".

Written for commit 2e88d07. Summary will update automatically on new commits.

Co-authored-by: djamesr23 <djamesr23@gmail.com>
@cursor

cursor Bot commented Nov 22, 2025

Copy link
Copy Markdown

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@github-actions

github-actions Bot commented Nov 22, 2025

Copy link
Copy Markdown

📊 PR Size Analysis

Size: XL
Files Changed: 8
Lines Added: +3994
Lines Deleted: -0
Total Changes: 3994

⚠️ This PR is very large. Consider breaking it into smaller PRs for easier review.

Review Checklist

  • All tests passing
  • Code follows project style guidelines
  • Documentation updated if needed
  • No sensitive data exposed
  • Breaking changes documented

@github-actions

Copy link
Copy Markdown

🚨 CI/CD Failure Detected

The Environment Variable Validation workflow failed for this PR.

Action Required

A tracking PR has been automatically created to help resolve this issue:
🔗 #114

Quick Links

Please review the analysis and implement the suggested fixes.


🤖 Auto-generated by JARVIS CI/CD Manager

@github-actions

Copy link
Copy Markdown

🚨 CI/CD Failure Detected

The Database Connection Validation workflow failed for this PR.

Action Required

A tracking PR has been automatically created to help resolve this issue:
🔗 #115

Quick Links

Please review the analysis and implement the suggested fixes.


🤖 Auto-generated by JARVIS CI/CD Manager

@github-actions

Copy link
Copy Markdown

🚨 CI/CD Failure Detected

The Validate Configuration workflow failed for this PR.

Action Required

A tracking PR has been automatically created to help resolve this issue:
🔗 #116

Quick Links

Please review the analysis and implement the suggested fixes.


🤖 Auto-generated by JARVIS CI/CD Manager

@github-actions

Copy link
Copy Markdown

🚨 CI/CD Failure Detected

The 🎨 Advanced Auto-Diagram Generator workflow failed for this PR.

Action Required

A tracking PR has been automatically created to help resolve this issue:
🔗 #117

Quick Links

Please review the analysis and implement the suggested fixes.


🤖 Auto-generated by JARVIS CI/CD Manager

@github-actions

Copy link
Copy Markdown

🚨 CI/CD Failure Detected

The PR Automation & Validation workflow failed for this PR.

Action Required

A tracking PR has been automatically created to help resolve this issue:
🔗 #118

Quick Links

Please review the analysis and implement the suggested fixes.


🤖 Auto-generated by JARVIS CI/CD Manager

Comment on lines +130 to +135
self._uae_clicker = get_uae_clicker(
vision_analyzer=self.vision_analyzer,
enable_uae=False, # Disable full UAE to avoid overhead
enable_verification=True,
enable_communication=False # We handle voice in this layer
)

Check failure

Code scanning / CodeQL

Wrong name for an argument in a call Error

Keyword argument 'enable_communication' is not a supported parameter name of
function get_uae_clicker
.

Copilot Autofix

AI 9 months ago

General approach:
The fix consists of removing the unsupported keyword argument (enable_communication=False) from the call to get_uae_clicker on line 134. This will prevent the TypeError that would occur at runtime. If the exclusion of this argument is not functionally correct (i.e., if voice functionality needs to be disabled in this layer), further adjustment may be required elsewhere, but with the info given, we should only remove the problematic argument to match the function's signature precisely.

Detailed fix:

  • Edit file backend/display/jarvis_computer_use_integration.py.
  • In the block starting on line 130, modify the call to get_uae_clicker to remove the line:
    enable_communication=False # We handle voice in this layer
  • Leave all other keyword arguments unchanged.
  • No new imports, methods, or definitions are needed.

Suggested changeset 1
backend/display/jarvis_computer_use_integration.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/backend/display/jarvis_computer_use_integration.py b/backend/display/jarvis_computer_use_integration.py
--- a/backend/display/jarvis_computer_use_integration.py
+++ b/backend/display/jarvis_computer_use_integration.py
@@ -130,8 +130,7 @@
             self._uae_clicker = get_uae_clicker(
                 vision_analyzer=self.vision_analyzer,
                 enable_uae=False,  # Disable full UAE to avoid overhead
-                enable_verification=True,
-                enable_communication=False  # We handle voice in this layer
+                enable_verification=True
             )
             logger.info("[JARVIS-COMPUTER-USE] ✅ UAE clicker initialized")
         except Exception as e:
EOF
@@ -130,8 +130,7 @@
self._uae_clicker = get_uae_clicker(
vision_analyzer=self.vision_analyzer,
enable_uae=False, # Disable full UAE to avoid overhead
enable_verification=True,
enable_communication=False # We handle voice in this layer
enable_verification=True
)
logger.info("[JARVIS-COMPUTER-USE] ✅ UAE clicker initialized")
except Exception as e:
Copilot is powered by AI and may make mistakes. Always verify output.
import base64
import json
from typing import Dict, Any, Optional, List, Callable
from datetime import datetime

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'datetime' is not used.

Copilot Autofix

AI 9 months ago

To fix the problem, simply delete the unused import statement from datetime import datetime from line 27 in backend/display/computer_use_display_connector.py. No changes to other import statements or any additional code sections are required since there is no indication of datetime being used anywhere in the snippet.

Suggested changeset 1
backend/display/computer_use_display_connector.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/backend/display/computer_use_display_connector.py b/backend/display/computer_use_display_connector.py
--- a/backend/display/computer_use_display_connector.py
+++ b/backend/display/computer_use_display_connector.py
@@ -24,7 +24,6 @@
 import base64
 import json
 from typing import Dict, Any, Optional, List, Callable
-from datetime import datetime
 from pathlib import Path
 from io import BytesIO
 
EOF
@@ -24,7 +24,6 @@
import base64
import json
from typing import Dict, Any, Optional, List, Callable
from datetime import datetime
from pathlib import Path
from io import BytesIO

Copilot is powered by AI and may make mistakes. Always verify output.
import json
from typing import Dict, Any, Optional, List, Callable
from datetime import datetime
from pathlib import Path

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'Path' is not used.

Copilot Autofix

AI 9 months ago

To fix an unused import, we should remove the import statement for Path, as it's not actually used in the displayed code. This avoids unnecessary dependencies and improves code readability. Specifically, in the file backend/display/computer_use_display_connector.py, line 28, the statement from pathlib import Path should be deleted. No additional code changes or dependencies are required.


Suggested changeset 1
backend/display/computer_use_display_connector.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/backend/display/computer_use_display_connector.py b/backend/display/computer_use_display_connector.py
--- a/backend/display/computer_use_display_connector.py
+++ b/backend/display/computer_use_display_connector.py
@@ -25,7 +25,6 @@
 import json
 from typing import Dict, Any, Optional, List, Callable
 from datetime import datetime
-from pathlib import Path
 from io import BytesIO
 
 import anthropic
EOF
@@ -25,7 +25,6 @@
import json
from typing import Dict, Any, Optional, List, Callable
from datetime import datetime
from pathlib import Path
from io import BytesIO

import anthropic
Copilot is powered by AI and may make mistakes. Always verify output.
import logging
from typing import Dict, Any, Optional, Callable
from dataclasses import dataclass
from datetime import datetime

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'datetime' is not used.

Copilot Autofix

AI 9 months ago

The best solution is to remove the unused import statement:
Delete the line from datetime import datetime (line 22) from the file backend/display/hybrid_display_connector.py.
This change is limited to a single line and will not affect any existing functionality since datetime is not referenced anywhere in this file. No additional methods, imports, or definitions are required.


Suggested changeset 1
backend/display/hybrid_display_connector.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/backend/display/hybrid_display_connector.py b/backend/display/hybrid_display_connector.py
--- a/backend/display/hybrid_display_connector.py
+++ b/backend/display/hybrid_display_connector.py
@@ -19,7 +19,6 @@
 import logging
 from typing import Dict, Any, Optional, Callable
 from dataclasses import dataclass
-from datetime import datetime
 
 logger = logging.getLogger(__name__)
 
EOF
@@ -19,7 +19,6 @@
import logging
from typing import Dict, Any, Optional, Callable
from dataclasses import dataclass
from datetime import datetime

logger = logging.getLogger(__name__)

Copilot is powered by AI and may make mistakes. Always verify output.
if hasattr(self.uae_clicker, 'coordinate_cache'):
return target in self.uae_clicker.coordinate_cache
return False
except:

Check notice

Code scanning / CodeQL

Except block handles 'BaseException' Note

Except block directly handles BaseException.

Copilot Autofix

AI 9 months ago

The best way to fix this problem is to replace the bare except: on line 276 with an explicit except Exception: clause. This ensures that only standard runtime errors (all subclasses of Exception) are caught. This change allows KeyboardInterrupt and SystemExit to propagate as they should, while still handling regular error conditions gracefully. No extra imports or definitions are needed, as Exception is built into Python.

Only the code in backend/display/hybrid_display_connector.py, specifically the _uae_has_cached method (lines 270–278), needs editing. Replace except: with except Exception:.

Suggested changeset 1
backend/display/hybrid_display_connector.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/backend/display/hybrid_display_connector.py b/backend/display/hybrid_display_connector.py
--- a/backend/display/hybrid_display_connector.py
+++ b/backend/display/hybrid_display_connector.py
@@ -273,7 +273,7 @@
             if hasattr(self.uae_clicker, 'coordinate_cache'):
                 return target in self.uae_clicker.coordinate_cache
             return False
-        except:
+        except Exception:
             return False
     
     async def _connect_with_uae(
EOF
@@ -273,7 +273,7 @@
if hasattr(self.uae_clicker, 'coordinate_cache'):
return target in self.uae_clicker.coordinate_cache
return False
except:
except Exception:
return False

async def _connect_with_uae(
Copilot is powered by AI and may make mistakes. Always verify output.
import asyncio
import logging
from typing import Dict, Any, Optional, Callable
from pathlib import Path

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'Path' is not used.

Copilot Autofix

AI 9 months ago

To fix the problem, we simply need to remove the unused import statement from pathlib import Path in file backend/display/jarvis_computer_use_integration.py on line 22. This is the most direct and safest fix, as it does not affect any other code. There are no references to Path elsewhere in the provided snippet, so removing this line does not change the functionality.

Suggested changeset 1
backend/display/jarvis_computer_use_integration.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/backend/display/jarvis_computer_use_integration.py b/backend/display/jarvis_computer_use_integration.py
--- a/backend/display/jarvis_computer_use_integration.py
+++ b/backend/display/jarvis_computer_use_integration.py
@@ -19,7 +19,6 @@
 import asyncio
 import logging
 from typing import Dict, Any, Optional, Callable
-from pathlib import Path
 
 import pyautogui
 
EOF
@@ -19,7 +19,6 @@
import asyncio
import logging
from typing import Dict, Any, Optional, Callable
from pathlib import Path

import pyautogui

Copilot is powered by AI and may make mistakes. Always verify output.
@github-actions

Copy link
Copy Markdown

🤖 CI/CD Pipeline Results

Status: success
Branch: 113/merge
Commit: 29be04f506004f6c66d036bced0ed50b3c47122e

Pipeline Stages

  • Code Quality: ✅
  • Build & Test: ✅
  • Architecture: ✅
  • Security Scan: ✅

View full workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants