Skip to content

Commit 026e467

Browse files
committed
feat: enable mouse noise filtering in MCP server and debug recorder
- Filter out mouse movements and wheel events to reduce noise - Keep mouse clicks (Down/Up) for proper click detection - Reduces unsupported events from ~24 to ~4 - Fixed HTTP mode in test script - Both MCP server and debug_mcp_recording now use consistent filtering
1 parent d51ed96 commit 026e467

File tree

4 files changed

+368
-374
lines changed

4 files changed

+368
-374
lines changed

examples/record_all_events_5s.py

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Show ALL events that are captured during recording, not just counts.
4+
"""
5+
6+
import subprocess
7+
import time
8+
import os
9+
import json
10+
import re
11+
12+
def show_all_events():
13+
print("=" * 60)
14+
print("SHOWING ALL CAPTURED EVENTS")
15+
print("=" * 60)
16+
print("\nThis will show EVERY event captured during 5 seconds")
17+
print("-" * 60)
18+
19+
# PowerShell command to run recorder
20+
ps_command = """
21+
$process = Start-Process -FilePath "cargo" -ArgumentList @("run", "--example", "debug_mcp_recording", "--release") -WorkingDirectory "../terminator-workflow-recorder" -NoNewWindow -PassThru -RedirectStandardOutput "all_events.txt" -RedirectStandardError "all_events_error.txt"
22+
Start-Sleep 5
23+
if (!$process.HasExited) {
24+
$process.Kill()
25+
}
26+
"""
27+
28+
print("\n🔴 RECORDING - Click once and move mouse a bit\n")
29+
30+
# Run the PowerShell command
31+
result = subprocess.run(
32+
["powershell", "-Command", ps_command],
33+
capture_output=True,
34+
text=True,
35+
cwd="../terminator-workflow-recorder"
36+
)
37+
38+
print("⏹️ Recording stopped\n")
39+
40+
# Read the output file
41+
output_file = "../terminator-workflow-recorder/all_events.txt"
42+
if os.path.exists(output_file):
43+
with open(output_file, 'r', encoding='utf-8', errors='ignore') as f:
44+
lines = f.readlines()
45+
46+
print("=" * 60)
47+
print("📊 ALL EVENTS CAPTURED (Raw Stream)")
48+
print("=" * 60)
49+
50+
# Parse and show each event
51+
event_num = 0
52+
current_event = []
53+
events_list = []
54+
55+
for line in lines:
56+
# Start of new event
57+
if "EVENT #" in line and "─────" in line:
58+
if current_event:
59+
events_list.append(current_event)
60+
current_event = [line.strip()]
61+
event_num += 1
62+
elif event_num > 0 and "└─────" not in line:
63+
current_event.append(line.strip())
64+
elif "└─────" in line and current_event:
65+
current_event.append(line.strip())
66+
events_list.append(current_event)
67+
current_event = []
68+
69+
# Add last event if exists
70+
if current_event:
71+
events_list.append(current_event)
72+
73+
print(f"\n📈 Total Events Captured: {len(events_list)}")
74+
print("\n📝 Event Stream:\n")
75+
76+
# Show each event
77+
for i, event_lines in enumerate(events_list, 1):
78+
print(f"EVENT {i}:")
79+
# Show first few lines of each event
80+
for line in event_lines[:8]: # Show up to 8 lines per event
81+
if line:
82+
print(f" {line}")
83+
if len(event_lines) > 8:
84+
print(f" ... ({len(event_lines) - 8} more lines)")
85+
print()
86+
87+
# Analyze event types
88+
event_types = {
89+
"Click": 0,
90+
"Mouse": 0,
91+
"ApplicationSwitch": 0,
92+
"TextInput": 0,
93+
"Keyboard": 0,
94+
"Other": 0
95+
}
96+
97+
mcp_conversions = 0
98+
unsupported = 0
99+
100+
for event_lines in events_list:
101+
event_text = "\n".join(event_lines)
102+
103+
# Count event types
104+
if "CLICK EVENT" in event_text or "Click event" in event_text:
105+
event_types["Click"] += 1
106+
elif "MOUSE EVENT" in event_text:
107+
event_types["Mouse"] += 1
108+
elif "APPLICATION SWITCH" in event_text:
109+
event_types["ApplicationSwitch"] += 1
110+
elif "TEXT INPUT" in event_text:
111+
event_types["TextInput"] += 1
112+
elif "KEYBOARD" in event_text:
113+
event_types["Keyboard"] += 1
114+
else:
115+
event_types["Other"] += 1
116+
117+
# Count MCP conversions
118+
if "MCP CONVERSION" in event_text and "click_element" in event_text:
119+
mcp_conversions += 1
120+
if "unsupported" in event_text.lower() or "not implemented" in event_text:
121+
unsupported += 1
122+
123+
print("\n" + "=" * 60)
124+
print("📊 EVENT TYPE SUMMARY")
125+
print("=" * 60)
126+
print("\nEvent Types Captured:")
127+
for event_type, count in event_types.items():
128+
if count > 0:
129+
print(f" • {event_type}: {count}")
130+
131+
print(f"\nMCP Conversions: {mcp_conversions}")
132+
print(f"Unsupported Events: {unsupported}")
133+
134+
# Clean up
135+
os.remove(output_file)
136+
error_file = "../terminator-workflow-recorder/all_events_error.txt"
137+
if os.path.exists(error_file):
138+
os.remove(error_file)
139+
140+
else:
141+
print("❌ No output file generated")
142+
143+
print("\n" + "=" * 60)
144+
145+
if __name__ == "__main__":
146+
show_all_events()

0 commit comments

Comments
 (0)