fix: improve note interactions and markdown LaTeX support
## Bug Fixes ### Note Card Actions - Fix broken size change functionality (missing state declaration) - Implement React 19 useOptimistic for instant UI feedback - Add startTransition for non-blocking updates - Ensure smooth animations without page refresh - All note actions now work: pin, archive, color, size, checklist ### Markdown LaTeX Rendering - Add remark-math and rehype-katex plugins - Support inline equations with dollar sign syntax - Support block equations with double dollar sign syntax - Import KaTeX CSS for proper styling - Equations now render correctly instead of showing raw LaTeX ## Technical Details - Replace undefined currentNote references with optimistic state - Add optimistic updates before server actions for instant feedback - Use router.refresh() in transitions for smart cache invalidation - Install remark-math, rehype-katex, and katex packages ## Testing - Build passes successfully with no TypeScript errors - Dev server hot-reloads changes correctly
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { getAIProvider } from '@/lib/ai/factory';
|
||||
import { getSystemConfig } from '@/lib/config';
|
||||
import { z } from 'zod';
|
||||
|
||||
const requestSchema = z.object({
|
||||
@@ -11,16 +12,16 @@ export async function POST(req: NextRequest) {
|
||||
const body = await req.json();
|
||||
const { content } = requestSchema.parse(body);
|
||||
|
||||
const provider = getAIProvider();
|
||||
const config = await getSystemConfig();
|
||||
const provider = getAIProvider(config);
|
||||
const tags = await provider.generateTags(content);
|
||||
console.log('[API Tags] Generated tags:', tags);
|
||||
|
||||
return NextResponse.json({ tags });
|
||||
} catch (error: any) {
|
||||
console.error('Erreur API tags:', error);
|
||||
|
||||
if (error instanceof z.ZodError) {
|
||||
return NextResponse.json({ error: error.errors }, { status: 400 });
|
||||
return NextResponse.json({ error: error.issues }, { status: 400 });
|
||||
}
|
||||
|
||||
return NextResponse.json(
|
||||
|
||||
@@ -1,27 +1,57 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { getAIProvider } from '@/lib/ai/factory';
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { getAIProvider } from '@/lib/ai/factory'
|
||||
import { getSystemConfig } from '@/lib/config'
|
||||
|
||||
export async function GET() {
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const provider = getAIProvider();
|
||||
const providerName = process.env.AI_PROVIDER || 'openai';
|
||||
|
||||
// Test simple de génération de tags sur un texte bidon
|
||||
const testContent = "J'adore cuisiner des pâtes le dimanche soir avec ma famille.";
|
||||
const tags = await provider.generateTags(testContent);
|
||||
|
||||
const config = await getSystemConfig()
|
||||
const provider = getAIProvider(config)
|
||||
|
||||
// Test with a simple embedding request
|
||||
const testText = 'test'
|
||||
const embeddings = await provider.getEmbeddings(testText)
|
||||
|
||||
if (!embeddings || embeddings.length === 0) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
provider: config.AI_PROVIDER || 'ollama',
|
||||
error: 'No embeddings returned',
|
||||
details: {
|
||||
provider: config.AI_PROVIDER || 'ollama',
|
||||
baseUrl: config.OLLAMA_BASE_URL || process.env.OLLAMA_BASE_URL || 'http://localhost:11434',
|
||||
model: config.AI_MODEL_EMBEDDING || process.env.OLLAMA_EMBEDDING_MODEL || 'embeddinggemma:latest'
|
||||
}
|
||||
},
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
status: 'success',
|
||||
provider: providerName,
|
||||
test_tags: tags,
|
||||
message: 'Infrastructure IA opérationnelle'
|
||||
});
|
||||
success: true,
|
||||
provider: config.AI_PROVIDER || 'ollama',
|
||||
embeddingLength: embeddings.length,
|
||||
firstValues: embeddings.slice(0, 5),
|
||||
details: {
|
||||
provider: config.AI_PROVIDER || 'ollama',
|
||||
baseUrl: config.OLLAMA_BASE_URL || process.env.OLLAMA_BASE_URL || 'http://localhost:11434',
|
||||
model: config.AI_MODEL_EMBEDDING || process.env.OLLAMA_EMBEDDING_MODEL || 'embeddinggemma:latest'
|
||||
}
|
||||
})
|
||||
} catch (error: any) {
|
||||
console.error('Erreur test IA détaillée:', error);
|
||||
return NextResponse.json({
|
||||
status: 'error',
|
||||
message: error.message,
|
||||
stack: error.stack
|
||||
}, { status: 500 });
|
||||
console.error('AI test error:', error)
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
error: error.message || 'Unknown error',
|
||||
stack: process.env.NODE_ENV === 'development' ? error.stack : undefined,
|
||||
details: {
|
||||
provider: process.env.AI_PROVIDER || 'ollama',
|
||||
baseUrl: process.env.OLLAMA_BASE_URL || 'http://localhost:11434',
|
||||
model: process.env.OLLAMA_EMBEDDING_MODEL || 'embeddinggemma:latest'
|
||||
}
|
||||
},
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user