The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): forward the event that trips the watch storm breaker
Austin Pickett357f51c49106
diff --git a/apps/desktop/electron/watch-storm-breaker.test.ts b/apps/desktop/electron/watch-storm-breaker.test.tsindex 374abcb3d3c..ac794c9209a 100644--- a/apps/desktop/electron/watch-storm-breaker.test.ts+++ b/apps/desktop/electron/watch-storm-breaker.test.ts@@ -103,12 +103,17 @@ describe('guardedWatch', () => {test('a win32 storm closes the watcher, drops further events, and polls', () => {const { fw, guard, onEvent, onPollChange, onTrip, setSnap } = setup('win32')- fw.emit(WATCH_STORM_MAX_EVENTS + 50_000)+ fw.emit(WATCH_STORM_MAX_EVENTS)+ fw.emit(1, 'target.md')+ fw.emit(50_000)expect(fw.close).toHaveBeenCalledTimes(1)expect(guard.mode()).toBe('poll')expect(onTrip).toHaveBeenCalledTimes(1)- expect(onEvent).toHaveBeenCalledTimes(WATCH_STORM_MAX_EVENTS)+ // The event that crosses the threshold is still forwarded; only the+ // events queued behind it are dropped.+ expect(onEvent).toHaveBeenCalledTimes(WATCH_STORM_MAX_EVENTS + 1)+ expect(onEvent).toHaveBeenLastCalledWith('rename', 'target.md')// Unchanged snapshot: no change reported.vi.advanceTimersByTime(WATCH_STORM_POLL_MS * 3)diff --git a/apps/desktop/electron/watch-storm-breaker.ts b/apps/desktop/electron/watch-storm-breaker.tsindex fed18ee0895..44bf9ae7845 100644--- a/apps/desktop/electron/watch-storm-breaker.ts+++ b/apps/desktop/electron/watch-storm-breaker.ts@@ -117,7 +117,12 @@ export function guardedWatch(options: GuardedWatchOptions): GuardedWatch {count += 1if (count > maxEvents) {+ // Trip first so the baseline snapshot is taken before the consumer+ // reacts, then forward this event: it may be the one change the+ // consumer cares about (a target-file write after 1000 sibling+ // events), and the poll baseline already includes it.trip()+ options.onEvent(eventType, filename)return}