feat: 8 AI providers, rich text editor, agent notifications, UI contrast & font settings
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 1m25s
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 1m25s
- Add DeepSeek, OpenRouter, Mistral, Z.AI, LM Studio as AI providers with editable model names via Combobox in admin settings - Fix OpenRouter broken by normalizeProvider bug in config.ts - Convert agent-created notes from Markdown to HTML (TipTap rich text) - Add Notification model + in-app notifications for agent results - Agent notification click opens the created note directly - Add note count display on notebook and inbox headers - Fix checklist toggle in card view (persist state via localCheckItems) - Add checklist creation option in tabs/list view (dropdown on + button) - Fix image description ENOENT error with HTTP fallback - Improve UI contrast across all themes (input, border, checkbox visibility) - Add font family setting (Inter vs System Default) in Appearance settings - Fix CSS font-sans variable conflict (removed dead Geist references) - Update README with new features and 8 providers Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,23 +19,43 @@ export interface ImageDescriptionResult {
|
||||
|
||||
const UPLOAD_DIR = path.join(process.cwd(), 'data', 'uploads')
|
||||
|
||||
async function resolveImageAsBase64(imageUrl: string): Promise<string> {
|
||||
async function resolveImageAsBase64(imageUrl: string): Promise<string | null> {
|
||||
const localMatch = imageUrl.match(/\/uploads\/(.+)/)
|
||||
if (localMatch) {
|
||||
const filePath = path.join(UPLOAD_DIR, localMatch[1])
|
||||
const buffer = await readFile(filePath)
|
||||
const ext = path.extname(imageUrl).toLowerCase()
|
||||
const mime = ext === '.png' ? 'image/png' : ext === '.gif' ? 'image/gif' : ext === '.webp' ? 'image/webp' : 'image/jpeg'
|
||||
return `data:${mime};base64,${buffer.toString('base64')}`
|
||||
// Try reading from filesystem first
|
||||
try {
|
||||
const filePath = path.join(UPLOAD_DIR, localMatch[1])
|
||||
const buffer = await readFile(filePath)
|
||||
const ext = path.extname(imageUrl).toLowerCase()
|
||||
const mime = ext === '.png' ? 'image/png' : ext === '.gif' ? 'image/gif' : ext === '.webp' ? 'image/webp' : 'image/jpeg'
|
||||
return `data:${mime};base64,${buffer.toString('base64')}`
|
||||
} catch {
|
||||
// File not on disk — fallback to internal HTTP API (same path the browser uses)
|
||||
try {
|
||||
const baseUrl = process.env.NEXTAUTH_URL || process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'
|
||||
const res = await fetch(`${baseUrl}${imageUrl}`)
|
||||
if (!res.ok) return null
|
||||
const contentType = res.headers.get('content-type') || 'image/jpeg'
|
||||
const arrayBuffer = await res.arrayBuffer()
|
||||
const base64 = Buffer.from(arrayBuffer).toString('base64')
|
||||
return `data:${contentType};base64,${base64}`
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remote URL — fetch and convert
|
||||
const res = await fetch(imageUrl)
|
||||
if (!res.ok) throw new Error(`Failed to fetch image: ${imageUrl}`)
|
||||
const contentType = res.headers.get('content-type') || 'image/jpeg'
|
||||
const arrayBuffer = await res.arrayBuffer()
|
||||
const base64 = Buffer.from(arrayBuffer).toString('base64')
|
||||
return `data:${contentType};base64,${base64}`
|
||||
try {
|
||||
const res = await fetch(imageUrl)
|
||||
if (!res.ok) return null
|
||||
const contentType = res.headers.get('content-type') || 'image/jpeg'
|
||||
const arrayBuffer = await res.arrayBuffer()
|
||||
const base64 = Buffer.from(arrayBuffer).toString('base64')
|
||||
return `data:${contentType};base64,${base64}`
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export async function describeImages(
|
||||
@@ -55,8 +75,9 @@ export async function describeImages(
|
||||
}
|
||||
const langName = langMap[language] || 'English'
|
||||
|
||||
// Resolve all images as base64 data URLs (same approach as the chat route)
|
||||
const imageDataUrls = await Promise.all(imageUrls.map(url => resolveImageAsBase64(url)))
|
||||
// Resolve all images as base64 data URLs — skip any that can't be found
|
||||
const resolved = await Promise.all(imageUrls.map(url => resolveImageAsBase64(url)))
|
||||
const imageDataUrls = resolved.filter((d): d is string => d !== null)
|
||||
|
||||
if (isTitleMode) {
|
||||
const prompt = imageUrls.length === 1
|
||||
|
||||
Reference in New Issue
Block a user