From 203ab3c1335bdff5bdfbc647f61652bacbb62db8 Mon Sep 17 00:00:00 2001 From: Alexander Whitestone Date: Mon, 23 Mar 2026 16:04:05 -0400 Subject: [PATCH] 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 --- artifacts/api-server/src/routes/sessions.ts | 28 +++++++++++++++++++++ artifacts/mobile/app/onboarding.tsx | 26 +++++++++---------- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/artifacts/api-server/src/routes/sessions.ts b/artifacts/api-server/src/routes/sessions.ts index 479c8b9..1931df8 100644 --- a/artifacts/api-server/src/routes/sessions.ts +++ b/artifacts/api-server/src/routes/sessions.ts @@ -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; diff --git a/artifacts/mobile/app/onboarding.tsx b/artifacts/mobile/app/onboarding.tsx index 00652ce..5872a8e 100644 --- a/artifacts/mobile/app/onboarding.tsx +++ b/artifacts/mobile/app/onboarding.tsx @@ -21,6 +21,19 @@ import { ONBOARDING_COMPLETED_KEY } from "@/constants/storage-keys"; const C = Colors.dark; const { width: SCREEN_WIDTH } = Dimensions.get("window"); +const slideStyles = StyleSheet.create({ + iconCircle: { + width: 140, + height: 140, + borderRadius: 70, + backgroundColor: C.surfaceElevated, + borderWidth: 1, + borderColor: C.border, + alignItems: "center", + justifyContent: "center", + }, +}); + type Slide = { id: string; icon: React.ReactNode; @@ -158,19 +171,6 @@ export default function OnboardingScreen() { ); } -const slideStyles = StyleSheet.create({ - iconCircle: { - width: 140, - height: 140, - borderRadius: 70, - backgroundColor: C.surfaceElevated, - borderWidth: 1, - borderColor: C.border, - alignItems: "center", - justifyContent: "center", - }, -}); - const styles = StyleSheet.create({ container: { flex: 1,