Skip to content

Commit e8cbc96

Browse files
committed
Restore full performance optimization implementation
- Restored complete rate limiting logic in send_filtered_event_static - Restored processing delay implementation - Restored event-specific filtering (mouse, keyboard, performance mode) - Restored config check in handle_text_input_transition - Fixed all unused variable warnings (config, last_event_time, events_this_second) All performance optimization features now fully functional.
1 parent d5fdd31 commit e8cbc96

File tree

1 file changed

+69
-6
lines changed
  • terminator-workflow-recorder/src/recorder/windows

1 file changed

+69
-6
lines changed

terminator-workflow-recorder/src/recorder/windows/mod.rs

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,16 +1357,75 @@ impl WindowsRecorder {
13571357
events_this_second: &Arc<Mutex<(u32, Instant)>>,
13581358
event: WorkflowEvent,
13591359
) {
1360-
// No rate limiting or processing delays in simplified version
1360+
// Apply rate limiting first
1361+
if let Some(max_events) = config.effective_max_events_per_second() {
1362+
let mut counter = events_this_second.lock().unwrap();
1363+
let now = Instant::now();
1364+
1365+
// Reset counter if a new second has started
1366+
if now.duration_since(counter.1).as_secs() >= 1 {
1367+
counter.0 = 0;
1368+
counter.1 = now;
1369+
}
1370+
1371+
if counter.0 >= max_events {
1372+
return; // Rate limit exceeded
1373+
}
13611374

1362-
// In simplified version, we don't filter mouse events but we do exclude mouse moves entirely
1375+
counter.0 += 1;
1376+
}
1377+
1378+
// Apply processing delay
1379+
let processing_delay = config.effective_processing_delay_ms();
1380+
if processing_delay > 0 {
1381+
let mut last_time = last_event_time.lock().unwrap();
1382+
let now = Instant::now();
1383+
if now.duration_since(*last_time).as_millis() < processing_delay as u128 {
1384+
return; // Filter out if within delay window
1385+
}
1386+
*last_time = now;
1387+
}
1388+
1389+
// Apply event-specific filtering
13631390
let should_filter = match &event {
1364-
// Filter out mouse move events entirely
13651391
WorkflowEvent::Mouse(mouse_event) => {
1366-
matches!(mouse_event.event_type, MouseEventType::Move)
1392+
if config.should_filter_mouse_noise() {
1393+
matches!(
1394+
mouse_event.event_type,
1395+
MouseEventType::Move | MouseEventType::Wheel
1396+
)
1397+
} else {
1398+
false
1399+
}
13671400
}
1368-
// Don't filter other events
1369-
_ => false,
1401+
WorkflowEvent::Keyboard(keyboard_event) => {
1402+
if config.should_filter_keyboard_noise() {
1403+
// Filter key-down events and non-printable keys
1404+
if keyboard_event.is_key_down {
1405+
// Keep printable characters (32-126) and common editing keys
1406+
!((keyboard_event.key_code >= 32 && keyboard_event.key_code <= 126)
1407+
|| matches!(
1408+
keyboard_event.key_code,
1409+
0x08 | // Backspace
1410+
0x2E | // Delete
1411+
0x20 | // Space
1412+
0x0D | // Enter
1413+
0x09 // Tab
1414+
))
1415+
} else {
1416+
false
1417+
}
1418+
} else {
1419+
false
1420+
}
1421+
}
1422+
// Never filter high-value events
1423+
WorkflowEvent::ApplicationSwitch(_)
1424+
| WorkflowEvent::Click(_)
1425+
| WorkflowEvent::Clipboard(_) => false,
1426+
1427+
// Other events can be filtered in LowEnergy mode
1428+
_ => matches!(config.performance_mode, crate::PerformanceMode::LowEnergy),
13701429
};
13711430

13721431
if !should_filter {
@@ -1564,6 +1623,10 @@ impl WindowsRecorder {
15641623
trigger_reason: &str,
15651624
config: &WorkflowRecorderConfig,
15661625
) {
1626+
if !config.record_text_input_completion {
1627+
return;
1628+
}
1629+
15671630
let mut tracker = match current_text_input.try_lock() {
15681631
Ok(guard) => guard,
15691632
Err(_) => {

0 commit comments

Comments
 (0)