feat: design system overhaul — sidebar, AI chats, settings, brainstorm, color cleanup
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 12s
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 12s
- Sidebar: dynamic brand-accent colors, brainstorm section restyled - AI chat general: popup panel with expand/collapse, hides when contextual AI open - AI chat contextual: tabs reordered (Actions first), X close button, height fix - Settings: all tabs restyled, 6 new color presets (sage, terracotta, iron, etc.) - Global color cleanup: emerald/orange hardcoded → brand-accent dynamic - Brainstorm page: orange → brand-accent throughout - PageEntry animation component added to key pages - Floating AI button: bg-brand-accent instead of hardcoded black - i18n: all 15 locales updated with new AI/billing keys - Billing: freemium quota tracking, BYOK, stripe subscription scaffolding - Admin: integrated into new design - AGENTS.md + CLAUDE.md project rules added
This commit is contained in:
@@ -2,9 +2,14 @@ import { NextRequest, NextResponse } from 'next/server'
|
||||
import prisma from '@/lib/prisma'
|
||||
import { auth } from '@/auth'
|
||||
import { z } from 'zod'
|
||||
import { getTagsProvider } from '@/lib/ai/factory'
|
||||
import { runLaneWithBillingUser, willUseByokForLane } from '@/lib/ai/provider-for-user'
|
||||
import { getSystemConfig } from '@/lib/config'
|
||||
import { embeddingService } from '@/lib/ai/services/embedding.service'
|
||||
import {
|
||||
checkEntitlementOrThrow,
|
||||
QuotaExceededError,
|
||||
incrementUsageAsync,
|
||||
} from '@/lib/entitlements'
|
||||
import { logActivity, captureSnapshot } from '@/lib/brainstorm-collab'
|
||||
|
||||
const waveSchema = z.object({
|
||||
@@ -64,11 +69,7 @@ async function autoContextSearch(
|
||||
snippet: (n.content || '').slice(0, 300),
|
||||
}))
|
||||
|
||||
try {
|
||||
const config = await getSystemConfig()
|
||||
const provider = getTagsProvider(config)
|
||||
|
||||
const classifyPrompt = `Given the seed idea: "${seedIdea}"
|
||||
const classifyPrompt = `Given the seed idea: "${seedIdea}"
|
||||
|
||||
Classify each note as SUPPORT (confirms/reinforces the seed), TENSION (contradicts/questions the seed), or EXTENSION (extends the seed into an adjacent domain).
|
||||
|
||||
@@ -78,7 +79,14 @@ ${notesForLLM.map(n => `[${n.id}] "${n.title}": ${n.snippet}`).join('\n')}
|
||||
Respond ONLY with a valid JSON array of objects:
|
||||
{ "noteId": string, "category": "SUPPORT" | "TENSION" | "EXTENSION" }`
|
||||
|
||||
const raw = await provider.generateText(classifyPrompt)
|
||||
try {
|
||||
const config = await getSystemConfig()
|
||||
const { result: raw } = await runLaneWithBillingUser(
|
||||
'tags',
|
||||
config,
|
||||
userId,
|
||||
(provider) => provider.generateText(classifyPrompt),
|
||||
)
|
||||
const cleaned = raw.replace(/```json\n?/g, '').replace(/```\n?/g, '').trim()
|
||||
const classifications: { noteId: string; category: 'SUPPORT' | 'TENSION' | 'EXTENSION' }[] = JSON.parse(cleaned)
|
||||
|
||||
@@ -199,13 +207,23 @@ export async function POST(request: NextRequest) {
|
||||
const body = await request.json()
|
||||
const { seedIdea, sourceNoteId, contextNoteIds, locale } = waveSchema.parse(body)
|
||||
|
||||
// Story 3.5: per-provider BYOK bypass
|
||||
const config = await getSystemConfig()
|
||||
const { usedByok: willUseByok } = await willUseByokForLane('tags', config, userId)
|
||||
if (!willUseByok) {
|
||||
await checkEntitlementOrThrow(userId, 'brainstorm_create')
|
||||
}
|
||||
|
||||
const classifiedNotes = await autoContextSearch(userId, seedIdea, contextNoteIds)
|
||||
|
||||
const config = await getSystemConfig()
|
||||
const provider = getTagsProvider(config)
|
||||
|
||||
const prompt = buildPromptV2(seedIdea, classifiedNotes, locale)
|
||||
const llmResponse = await provider.generateText(prompt)
|
||||
const { result: llmResponse, usedByok } = await runLaneWithBillingUser(
|
||||
'tags',
|
||||
config,
|
||||
userId,
|
||||
(provider) => provider.generateText(prompt),
|
||||
)
|
||||
if (!usedByok) incrementUsageAsync(userId, 'brainstorm_create')
|
||||
|
||||
let ideas: any[]
|
||||
try {
|
||||
@@ -312,6 +330,9 @@ export async function POST(request: NextRequest) {
|
||||
},
|
||||
}, { status: 201 })
|
||||
} catch (error: any) {
|
||||
if (error instanceof QuotaExceededError) {
|
||||
return NextResponse.json(error.toJSON(), { status: 402 })
|
||||
}
|
||||
if (error instanceof z.ZodError) {
|
||||
return NextResponse.json({ error: error.issues }, { status: 400 })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user