mirror of
https://github.com/block/goose.git
synced 2026-07-10 00:20:17 +00:00
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:
parent
c82c431c70
commit
6d8c42cfa0
2 changed files with 22 additions and 3 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue