feat(ai-sessions): persistent storage for AI design sessions - #21
Merged
Merged
Conversation
The AI sidebar kept its chat in React state only, so a reload lost the transcript and any in-flight run. This adds the storage layer the multi-turn design agent will build on (not wired to the UI yet). - AiSession / AiMessage Prisma models + additive migration; sessions cascade with their project, messages cascade with their session - lib/ai/session-store.ts: 7-day sliding expiry, 10 sessions per user per project, 60 messages per session; reads ignore expired rows - GET/POST /api/projects/[projectId]/ai-sessions and GET/DELETE /api/projects/[projectId]/ai-sessions/[sessionId], private to the session's creator - Daily Vercel Cron cleanup at /api/cron/ai-sessions/cleanup, gated by CRON_SECRET (public in proxy.ts) Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Sep 15, 2026
Suharshit
added this pull request to stack #24
September 15, 2026 18:40
This was referenced Sep 15, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The AI sidebar keeps its chat in React state only (
useDesignAgent), so a reload loses the transcript and any in-flight run, and every prompt reaches the model with no history. This PR is step 1 of the AI sessions plan. It adds only the storage layer. The UI isn't connected yet;useDesignAgentand/api/ai/designare unchanged.What
AiSessionandAiMessageinprisma/models/ai-session.prisma, plus migration20260915163917_add_ai_sessions.lib/ai/session-store.tsexpiresAt).GET/POST /api/projects/[projectId]/ai-sessionsGET/DELETE /api/projects/[projectId]/ai-sessions/[sessionId]GET /api/cron/ai-sessions/cleanup, scheduled daily at 03:00 UTC in the newvercel.json.Authorization: Bearer $CRON_SECRET.proxy.tsbecause Vercel Cron has no Clerk session.types/ai-session.tshas request/response types without Prisma imports, for the client in step 2.Deploy note
Set
CRON_SECRETin the Vercel project's environment variables. Without it the cleanup route returns 401. It isn't in the committed.env.example, because.gitignoreexcludes.env*.Verification
pnpm typecheckandpnpm lintpass. Lint's only 2 warnings are in vendored skill templates.A tsx script against the database checked:
Its test rows were removed afterwards.
On a dev server: signed-out requests to the session routes are blocked by Clerk. The cron route returns 401 with no secret or a wrong one.
Not yet exercised: the session routes with a signed-in user (step 2 uses them from the sidebar), and the cron route with the correct secret.
🤖 Generated with Claude Code