diff --git a/ui/desktop/src/App.test.tsx b/ui/desktop/src/App.test.tsx index 2da21b72b4..c5b72dd9a3 100644 --- a/ui/desktop/src/App.test.tsx +++ b/ui/desktop/src/App.test.tsx @@ -34,6 +34,11 @@ vi.mock('./utils/costDatabase', () => ({ initializeCostDatabase: vi.fn().mockResolvedValue(undefined), })); +vi.mock('./acp/sessions', () => ({ + acpListSessions: vi.fn().mockResolvedValue({ sessions: [], nextCursor: null }), + acpDeleteSession: vi.fn().mockResolvedValue(undefined), +})); + vi.mock('./sessions', () => ({ fetchSessionDetails: vi .fn() diff --git a/ui/desktop/src/App.tsx b/ui/desktop/src/App.tsx index e067c3302a..509f43c1e2 100644 --- a/ui/desktop/src/App.tsx +++ b/ui/desktop/src/App.tsx @@ -18,6 +18,7 @@ import AnnouncementModal from './components/AnnouncementModal'; import TelemetryConsentPrompt from './components/TelemetryConsentPrompt'; import OnboardingGuard from './components/onboarding/OnboardingGuard'; import { createSession } from './sessions'; +import { acpListSessions, acpDeleteSession } from './acp/sessions'; import { ChatType } from './types/chat'; import Hub from './components/Hub'; @@ -396,7 +397,20 @@ export function AppInner() { }, []); useEffect(() => { - const handleOpenSessionShare = async (_event: IpcRendererEvent, ...args: unknown[]) => { + acpListSessions() + .then(({ sessions }) => { + const phantom = sessions.filter( + (s) => s.messageCount === 0 && !s.userSetName && !s.hasRecipe + ); + for (const s of phantom) { + acpDeleteSession(s.id).catch(() => {}); + } + }) + .catch(() => {}); + }, []); + + useEffect(() => { + const handleOpenSharedSession = async (_event: IpcRendererEvent, ...args: unknown[]) => { const link = args[0] as string; window.electron.logInfo('Opening session share link'); @@ -430,9 +444,9 @@ export function AppInner() { } } }; - window.electron.on('open-shared-session', handleOpenSessionShare); + window.electron.on('open-shared-session', handleOpenSharedSession); return () => { - window.electron.off('open-shared-session', handleOpenSessionShare); + window.electron.off('open-shared-session', handleOpenSharedSession); }; }, [navigate]);