diff --git a/src/main/services/infrastructure/teamWatchScope.ts b/src/main/services/infrastructure/teamWatchScope.ts index e553f737..0137882b 100644 --- a/src/main/services/infrastructure/teamWatchScope.ts +++ b/src/main/services/infrastructure/teamWatchScope.ts @@ -25,6 +25,10 @@ export function setTeamWatchScopeChangeListener(listener: (() => void) | null): scopeChangeListener = listener; } +export function notifyTeamWatchScopeChanged(): void { + scopeChangeListener?.(); +} + function collectAliveTeams(scope: Set): void { if (!aliveTeamsProvider) { return; diff --git a/test/main/services/infrastructure/teamWatchScope.test.ts b/test/main/services/infrastructure/teamWatchScope.test.ts index 70446671..5901c34f 100644 --- a/test/main/services/infrastructure/teamWatchScope.test.ts +++ b/test/main/services/infrastructure/teamWatchScope.test.ts @@ -3,6 +3,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest'; import { computeTeamWatchScope, markTeamEngaged, + notifyTeamWatchScopeChanged, resetTeamWatchScopeForTests, setAliveTeamsProvider, setTeamWatchScopeChangeListener, @@ -53,6 +54,13 @@ describe('teamWatchScope', () => { expect(listener).not.toHaveBeenCalled(); }); + it('can notify after alive team scope changes outside engagement', () => { + const listener = vi.fn(); + setTeamWatchScopeChangeListener(listener); + notifyTeamWatchScopeChanged(); + expect(listener).toHaveBeenCalledTimes(1); + }); + it('survives a throwing alive provider (watcher falls back safely)', () => { setAliveTeamsProvider(() => { throw new Error('boom');