fix(ui): purge empty phantom sessions on startup (#9651)

Signed-off-by: Varun Nuthalapati <nuthalapativarun@gmail.com>
Co-authored-by: Douwe M Osinga <douwe@sidewalklabs.com>
This commit is contained in:
nuthalapativarun 2026-07-03 09:23:23 -07:00 committed by GitHub
parent c82c431c70
commit 6d8c42cfa0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 3 deletions

View file

@ -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()

View file

@ -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]);