From 9ed1988346e5942c9e7800297a57aaf08e3148ea Mon Sep 17 00:00:00 2001 From: 777genius Date: Sat, 30 May 2026 17:34:05 +0300 Subject: [PATCH] fix: refresh watch scope on provider fallback --- src/main/services/infrastructure/teamWatchScope.ts | 2 +- .../services/infrastructure/teamWatchScope.test.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/services/infrastructure/teamWatchScope.ts b/src/main/services/infrastructure/teamWatchScope.ts index 9e471781..0d3f409f 100644 --- a/src/main/services/infrastructure/teamWatchScope.ts +++ b/src/main/services/infrastructure/teamWatchScope.ts @@ -76,7 +76,7 @@ export function markTeamEngaged(teamName: string, nowMs: number = Date.now()): v return; } const currentScope = computeTeamWatchScope(nowMs); - const wasInScope = currentScope === null || currentScope.has(teamName); + const wasInScope = currentScope?.has(teamName) === true; engagedAtByTeam.set(teamName, nowMs); if (!wasInScope) { scopeChangeListener?.(); diff --git a/test/main/services/infrastructure/teamWatchScope.test.ts b/test/main/services/infrastructure/teamWatchScope.test.ts index fff0f888..9240136d 100644 --- a/test/main/services/infrastructure/teamWatchScope.test.ts +++ b/test/main/services/infrastructure/teamWatchScope.test.ts @@ -69,6 +69,18 @@ describe('teamWatchScope', () => { expect(computeTeamWatchScope(0)).toBeNull(); }); + it('notifies on engagement when alive provider fails so watcher can refresh to fallback', () => { + const listener = vi.fn(); + setAliveTeamsProvider(() => { + throw new Error('boom'); + }); + setTeamWatchScopeChangeListener(listener); + + markTeamEngaged('x', 0); + + expect(listener).toHaveBeenCalledTimes(1); + }); + it('ignores empty team names', () => { const listener = vi.fn(); setTeamWatchScopeChangeListener(listener);