feat: implement Session Mode UI for Fund Once, Ask Many interactions
- Fix slideStyles used-before-declaration error in onboarding.tsx that blocked typecheck (introduced by #79). Moved slideStyles const above the slides array that references it. - Add missing DELETE /sessions/:id/history endpoint to sessions.ts. The frontend session.js calls this endpoint for the "Clear history" button but no matching route existed. Fixes #67
This commit is contained in:
@@ -569,4 +569,32 @@ router.post("/sessions/:id/topup", async (req: Request, res: Response) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ── DELETE /sessions/:id/history ─────────────────────────────────────────────
|
||||
|
||||
router.delete("/sessions/:id/history", async (req: Request, res: Response) => {
|
||||
const id = req.params.id as string;
|
||||
const macaroon = extractMacaroon(req);
|
||||
|
||||
try {
|
||||
const session = await getSessionById(id);
|
||||
if (!session) { res.status(404).json({ error: "Session not found" }); return; }
|
||||
|
||||
if (!macaroon || macaroon !== session.macaroon) {
|
||||
res.status(401).json({ error: "Invalid or missing macaroon" });
|
||||
return;
|
||||
}
|
||||
|
||||
if (session.state !== "active" && session.state !== "paused") {
|
||||
res.status(409).json({ error: `Cannot clear history for a session in state '${session.state}'` });
|
||||
return;
|
||||
}
|
||||
|
||||
await db.delete(sessionMessages).where(eq(sessionMessages.sessionId, id));
|
||||
|
||||
res.json({ ok: true, sessionId: id });
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err instanceof Error ? err.message : "Failed to clear history" });
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user