feat: improve AI Chat UX, add notebook summary, and fix shared/reminders routing
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 1m50s

This commit is contained in:
Antigravity
2026-05-09 14:40:36 +00:00
parent 66e957fd59
commit 368b43cb8e
20 changed files with 292 additions and 196 deletions

View File

@@ -1,6 +1,7 @@
/**
* Detect user's preferred language.
* Priority:
* 0. user-language cookie (explicit user choice, synced with localStorage)
* 1. Most common language among user's notes (DB GROUP BY)
* 2. Browser language hint (passed from server component via Accept-Language)
* 3. Default: 'en'
@@ -8,7 +9,7 @@
import { auth } from '@/auth'
import { prisma } from '@/lib/prisma'
import { unstable_cache } from 'next/cache'
import { unstable_cache, cookies } from 'next/cache'
import { SupportedLanguage } from './load-translations'
const SUPPORTED_LANGUAGES = new Set(['en', 'fr', 'es', 'de', 'fa', 'it', 'pt', 'ru', 'zh', 'ja', 'ko', 'ar', 'hi', 'nl', 'pl'])
@@ -79,6 +80,16 @@ const getCachedUserLanguage = unstable_cache(
* Should be passed from server components that have access to headers().
*/
export async function detectUserLanguage(browserLanguageHint?: SupportedLanguage | null): Promise<SupportedLanguage> {
// 0. Cookie has highest priority — set by the client when user picks a language.
// This guarantees server and client agree on the language (no hydration mismatch).
try {
const cookieStore = await cookies()
const cookieLang = cookieStore.get('user-language')?.value
if (cookieLang && SUPPORTED_LANGUAGES.has(cookieLang)) {
return cookieLang as SupportedLanguage
}
} catch {}
const session = await auth()
if (!session?.user?.id) {