fix(keep-notes): sidebar chevron, labels sync, batch org errors, perf guards

- Notebooks: chevron visible when expanded (remove overflow clip), functional expand state
- Labels: sync/cleanup by notebookId, reconcile after note move
- Settings: refresh notebooks after cleanup; label dialog routing
- ConnectionsBadge lazy-load; reminder check persistence; i18n keys

Made-with: Cursor
This commit is contained in:
Sepehr Ramezani
2026-04-13 22:07:09 +02:00
parent fa7e166f3e
commit 39671c6472
16 changed files with 469 additions and 303 deletions

View File

@@ -1,16 +1,24 @@
'use client'
import React, { useState } from 'react'
import { SettingsNav, SettingsSection } from '@/components/settings'
import { useRouter } from 'next/navigation'
import { SettingsSection } from '@/components/settings'
import { Button } from '@/components/ui/button'
import { Loader2, CheckCircle, XCircle, RefreshCw, Database, BrainCircuit } from 'lucide-react'
import { cleanupAllOrphans, syncAllEmbeddings } from '@/app/actions/notes'
import { toast } from 'sonner'
import { useLanguage } from '@/lib/i18n'
import Link from 'next/link'
import { useLabels } from '@/context/LabelContext'
import { useNotebooks } from '@/context/notebooks-context'
import { useNoteRefresh } from '@/context/NoteRefreshContext'
export default function SettingsPage() {
const { t } = useLanguage()
const router = useRouter()
const { refreshLabels } = useLabels()
const { refreshNotebooks } = useNotebooks()
const { triggerRefresh } = useNoteRefresh()
const [loading, setLoading] = useState(false)
const [cleanupLoading, setCleanupLoading] = useState(false)
const [syncLoading, setSyncLoading] = useState(false)
@@ -52,11 +60,13 @@ export default function SettingsPage() {
try {
const result = await syncAllEmbeddings()
if (result.success) {
toast.success(`Indexing complete: ${result.count} notes processed`)
toast.success(t('settings.indexingComplete', { count: result.count ?? 0 }))
triggerRefresh()
router.refresh()
}
} catch (error) {
console.error(error)
toast.error("Error during indexing")
toast.error(t('settings.indexingError'))
} finally {
setSyncLoading(false)
}
@@ -67,11 +77,26 @@ export default function SettingsPage() {
try {
const result = await cleanupAllOrphans()
if (result.success) {
toast.success(result.message || `Cleanup complete: ${result.created} created, ${result.deleted} removed`)
const errCount = Array.isArray(result.errors) ? result.errors.length : 0
if (result.created === 0 && result.deleted === 0 && errCount === 0) {
toast.info(t('settings.cleanupNothing'))
} else {
const base = t('settings.cleanupDone', {
created: result.created ?? 0,
deleted: result.deleted ?? 0,
})
toast.success(errCount > 0 ? `${base} (${t('settings.cleanupWithErrors')})` : base)
}
await refreshLabels()
await refreshNotebooks()
triggerRefresh()
router.refresh()
} else {
toast.error(t('settings.cleanupError'))
}
} catch (error) {
console.error(error)
toast.error("Error during cleanup")
toast.error(t('settings.cleanupError'))
} finally {
setCleanupLoading(false)
}
@@ -82,7 +107,7 @@ export default function SettingsPage() {
<div className="space-y-6">
<div>
<h1 className="text-3xl font-bold mb-2">{t('settings.title')}</h1>
<p className="text-gray-600 dark:text-gray-400">
<p className="text-muted-foreground">
{t('settings.description')}
</p>
</div>
@@ -176,31 +201,31 @@ export default function SettingsPage() {
description={t('settings.maintenanceDescription')}
>
<div className="space-y-4 py-4">
<div className="flex items-center justify-between p-4 border rounded-lg">
<div>
<div className="flex items-center justify-between gap-4 p-4 border border-border rounded-lg bg-card">
<div className="min-w-0">
<h3 className="font-medium flex items-center gap-2">
{t('settings.cleanTags')}
</h3>
<p className="text-sm text-gray-600 dark:text-gray-400">
<p className="text-sm text-muted-foreground">
{t('settings.cleanTagsDescription')}
</p>
</div>
<Button variant="secondary" onClick={handleCleanup} disabled={cleanupLoading}>
<Button variant="secondary" onClick={handleCleanup} disabled={cleanupLoading} className="shrink-0">
{cleanupLoading ? <Loader2 className="w-4 h-4 animate-spin mr-2" /> : <Database className="w-4 h-4 mr-2" />}
{t('general.clean')}
</Button>
</div>
<div className="flex items-center justify-between p-4 border rounded-lg">
<div>
<div className="flex items-center justify-between gap-4 p-4 border border-border rounded-lg bg-card">
<div className="min-w-0">
<h3 className="font-medium flex items-center gap-2">
{t('settings.semanticIndexing')}
</h3>
<p className="text-sm text-gray-600 dark:text-gray-400">
<p className="text-sm text-muted-foreground">
{t('settings.semanticIndexingDescription')}
</p>
</div>
<Button variant="secondary" onClick={handleSync} disabled={syncLoading}>
<Button variant="secondary" onClick={handleSync} disabled={syncLoading} className="shrink-0">
{syncLoading ? <Loader2 className="w-4 h-4 animate-spin mr-2" /> : <BrainCircuit className="w-4 h-4 mr-2" />}
{t('general.indexAll')}
</Button>