perf: memo GridCard, fuse save fns, fix slash tab active color
Some checks failed
CI / Lint, Unit Tests & Build (push) Failing after 1m32s
CI / Deploy production (on server) (push) Has been skipped

This commit is contained in:
Antigravity
2026-06-14 14:06:05 +00:00
parent a8785ed4f1
commit a623454347
120 changed files with 12301 additions and 785 deletions

View File

@@ -18,19 +18,36 @@ export class GoogleProvider implements AIProvider {
async generateTags(content: string): Promise<TagSuggestion[]> {
try {
const { object } = await generateObject({
model: this.model,
schema: z.object({
tags: z.array(z.object({
tag: z.string().describe('Short tag name in lowercase'),
confidence: z.number().min(0).max(1).describe('Confidence level between 0 and 1')
}))
}),
prompt: `Analyze the following note and suggest 1 to 5 relevant tags.
Note content: "${content}"`,
});
try {
const { object } = await generateObject({
model: this.model,
schema: z.object({
tags: z.array(z.object({
tag: z.string().describe('Short tag name in lowercase'),
confidence: z.number().min(0).max(1).describe('Confidence level between 0 and 1')
}))
}),
prompt: `Analyze the following note and suggest 1 to 5 relevant tags.
Note content: "${content}"`,
});
return object.tags;
return object.tags;
} catch (err) {
console.warn('Google generateObject tags failed, falling back to generateText:', err);
const { text } = await aiGenerateText({
model: this.model,
prompt: `Analyze the following note and suggest 1 to 5 relevant tags.
Note content: "${content.substring(0, 1500)}"
Return ONLY a JSON array of tag objects, like: [{"tag":"example","confidence":0.9}]`,
});
const cleaned = text.replace(/<think>[\s\S]*?<\/think>/gi, '').replace(/^```json\n?/, '').replace(/\n?```$/, '').trim();
const parsed = JSON.parse(cleaned);
const arr = Array.isArray(parsed) ? parsed : (parsed.tags || parsed.suggestions || []);
return arr.map((t: any) => ({
tag: t.tag || t.label || t.name || '',
confidence: t.confidence || t.score || 0.7,
}));
}
} catch (e) {
console.error('Error generating tags (Google):', e);
return [];
@@ -52,18 +69,33 @@ export class GoogleProvider implements AIProvider {
async generateTitles(prompt: string): Promise<TitleSuggestion[]> {
try {
const { object } = await generateObject({
model: this.model,
schema: z.object({
titles: z.array(z.object({
title: z.string().describe('Suggested title'),
confidence: z.number().min(0).max(1).describe('Confidence level between 0 and 1')
}))
}),
prompt: prompt,
});
try {
const { object } = await generateObject({
model: this.model,
schema: z.object({
titles: z.array(z.object({
title: z.string().describe('Suggested title'),
confidence: z.number().min(0).max(1).describe('Confidence level between 0 and 1')
}))
}),
prompt: prompt,
});
return object.titles;
return object.titles;
} catch (err) {
console.warn('Google generateObject titles failed, falling back to generateText:', err);
const { text } = await aiGenerateText({
model: this.model,
prompt: prompt + '\n\nRespond ONLY as a JSON array of title suggestions: [{"title": "Suggested title", "confidence": 0.9}]',
});
const cleaned = text.replace(/<think>[\s\S]*?<\/think>/gi, '').replace(/^```json\n?/, '').replace(/\n?```$/, '').trim();
const parsed = JSON.parse(cleaned);
const arr = Array.isArray(parsed) ? parsed : (parsed.titles || parsed.suggestions || []);
return arr.map((t: any) => ({
title: typeof t === 'string' ? t : t.title || t.name || '',
confidence: typeof t === 'number' ? t : (t.confidence || t.score || 0.8),
}));
}
} catch (e) {
console.error('Error generating titles (Google):', e);
return [];