The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): keep a failed watch snapshot distinct from an empty directory
Austin Pickett8a0aaf9966f7
diff --git a/apps/desktop/electron/watch-storm-breaker.test.ts b/apps/desktop/electron/watch-storm-breaker.test.tsindex 6bbd1b4d0c1..374abcb3d3c 100644--- a/apps/desktop/electron/watch-storm-breaker.test.ts+++ b/apps/desktop/electron/watch-storm-breaker.test.ts@@ -179,4 +179,24 @@ describe('guardedWatch', () => {expect(onPollChange).toHaveBeenCalledTimes(1)})++ test('an empty directory vanishing is still a change (error is not the empty snapshot)', () => {+ let gone = false++ const { fw, onPollChange } = setup('win32', {+ snapshot: () => {+ if (gone) {+ throw new Error('ENOENT')+ }++ return ''+ }+ })++ fw.emit(WATCH_STORM_MAX_EVENTS + 1)+ gone = true+ vi.advanceTimersByTime(WATCH_STORM_POLL_MS)++ expect(onPollChange).toHaveBeenCalledTimes(1)+ })})diff --git a/apps/desktop/electron/watch-storm-breaker.ts b/apps/desktop/electron/watch-storm-breaker.tsindex 77b5d01eb9c..fed18ee0895 100644--- a/apps/desktop/electron/watch-storm-breaker.ts+++ b/apps/desktop/electron/watch-storm-breaker.ts@@ -55,11 +55,16 @@ export function stormBreakerArmed(platform: string): boolean {return platform === 'win32'}-function safeSnapshot(snapshot: () => string): string {+/**+ * `null` = the snapshot failed (target removed or unreadable). Kept distinct+ * from the empty string, which is the valid snapshot of an empty directory, so+ * an empty directory vanishing still compares as a change.+ */+function safeSnapshot(snapshot: () => string): string | null {try {return snapshot()} catch {- return ''+ return null}}