pi session context persistence, fix new session button, add clear all sessions

- handle pi process death by nulling piProcess ref so next message respawns
- replay conversation history on respawn via --session flag
- fix user message JSONL format to array for pi compatibility
- fix container sessions mount to match storage path
- fix ChatPanelWrapper: key on inner component so usePiChat resets on new session
- add bulk delete sessions endpoint and clear all button in chat header

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-27 00:04:14 +00:00
co-authored by Claude Opus 4.6
parent a8d3d1a423
commit c443fe0fe2
9 changed files with 192 additions and 31 deletions
+33
View File
@@ -235,6 +235,39 @@ piRestRouter.delete('/pi/sessions/:sessionId', async (ctx: Context) => {
}
});
/**
* DELETE /api/pi/sessions
* Delete all sessions, optionally filtered by context
*/
piRestRouter.delete('/pi/sessions', async (ctx: Context) => {
const user = ctx.get('user');
if (!user) {
return ctx.json({ error: 'Unauthorized' }, 401);
}
const body = await ctx.req.json().catch(() => ({}));
const contextFilter = body.context ? { context: body.context as string, contextId: body.contextId as string | undefined } : undefined;
const userHome = getHomeDir(user.email);
try {
const sessions = await storage.listUserSessions(userHome, contextFilter);
let deleted = 0;
for (const session of sessions) {
try {
await storage.deleteSession(userHome, session.id, session.groupSlug);
deleted++;
} catch {
// Skip sessions that fail to delete
}
}
logger.info('Bulk deleted sessions', { email: user.email, deleted, total: sessions.length, context: contextFilter?.context });
return ctx.json({ success: true, deleted });
} catch (err) {
logger.error('Failed to bulk delete sessions', { email: user.email, error: String(err) });
return ctx.json({ error: 'Failed to delete sessions' }, 500);
}
});
/**
* GET /api/pi/sessions/search
* Search sessions by query