perf: add event debouncing to InnerLoopTracker

- Add EVENT_DEBOUNCE_MS constant (50ms) for batching rapid updates
- Add debounce timers and pending flags for todo/loop updates
- Add emitTodoUpdateDebounced() and emitLoopUpdateDebounced() methods
- Add flushPendingEvents() for testing/immediate sync needs
- Update reset()/fullReset() to clear debounce timers
- Replace rapid-fire emit calls with debounced versions
- Reduces UI jitter from rapid consecutive updates
- Tests updated to use flushPendingEvents() for synchronous testing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-21 05:41:30 +01:00
co-authored by Claude Opus 4.5
parent df91823800
commit 08b76cdb60
2 changed files with 122 additions and 5 deletions
+3
View File
@@ -205,6 +205,7 @@ describe('InnerLoopTracker', () => {
tracker.on('todoUpdate', todoHandler);
tracker.processTerminalData('- [ ] First task\n');
tracker.flushPendingEvents(); // Flush debounced events
expect(todoHandler).toHaveBeenCalled();
const todos = tracker.todos;
@@ -380,7 +381,9 @@ describe('InnerLoopTracker', () => {
tracker.on('todoUpdate', todoHandler);
tracker.processTerminalData('- [ ] Task 1\n');
tracker.flushPendingEvents(); // Flush debounced events
tracker.processTerminalData('- [ ] Task 2\n');
tracker.flushPendingEvents(); // Flush debounced events
expect(todoHandler).toHaveBeenCalledTimes(2);
});