fix(memory-echo): feedback-adjusted thresholds and remove duplicate close button
- Thumbs down now increases the similarity threshold by +0.15 for the notes involved, making it harder for irrelevant connections to reappear - Thumbs up slightly lowers the threshold by -0.05, boosting similar future connections - Remove duplicate close button in ComparisonModal (kept only the native Dialog close button) - Normalize all embeddings to same model/dimension (2560) to fix random similarity scores caused by mixed embedding models Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import { useState } from 'react'
|
||||
import { Dialog, DialogContent } from '@/components/ui/dialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { X, Sparkles, ThumbsUp, ThumbsDown } from 'lucide-react'
|
||||
import { Sparkles, ThumbsUp, ThumbsDown, GitMerge } from 'lucide-react'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { Note } from '@/lib/types'
|
||||
import { useLanguage } from '@/lib/i18n/LanguageProvider'
|
||||
@@ -14,6 +14,7 @@ interface ComparisonModalProps {
|
||||
notes: Array<Partial<Note>>
|
||||
similarity?: number
|
||||
onOpenNote?: (noteId: string) => void
|
||||
onMergeNotes?: (noteIds: string[]) => void
|
||||
}
|
||||
|
||||
export function ComparisonModal({
|
||||
@@ -21,14 +22,26 @@ export function ComparisonModal({
|
||||
onClose,
|
||||
notes,
|
||||
similarity,
|
||||
onOpenNote
|
||||
onOpenNote,
|
||||
onMergeNotes
|
||||
}: ComparisonModalProps) {
|
||||
const { t } = useLanguage()
|
||||
const [feedback, setFeedback] = useState<'thumbs_up' | 'thumbs_down' | null>(null)
|
||||
|
||||
const handleFeedback = async (type: 'thumbs_up' | 'thumbs_down') => {
|
||||
setFeedback(type)
|
||||
// TODO: Send feedback to backend
|
||||
try {
|
||||
const noteIds = notes.map(n => n.id).filter(Boolean) as string[]
|
||||
if (noteIds.length >= 2) {
|
||||
await fetch('/api/ai/echo', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ action: 'feedback', noteIds, feedback: type })
|
||||
})
|
||||
}
|
||||
} catch {
|
||||
// silent — feedback is best-effort
|
||||
}
|
||||
setTimeout(() => {
|
||||
onClose()
|
||||
}, 500)
|
||||
@@ -76,15 +89,9 @@ export function ComparisonModal({
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="text-gray-500 hover:text-gray-700 dark:hover:text-gray-300"
|
||||
>
|
||||
<X className="h-6 w-6" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* AI Insight Section - Optional for now */}
|
||||
{/* AI Insight Section */}
|
||||
{similarityPercentage >= 80 && (
|
||||
<div className="px-6 py-4 bg-amber-50 dark:bg-amber-950/20 border-b dark:border-zinc-700">
|
||||
<div className="flex items-start gap-2">
|
||||
@@ -137,13 +144,13 @@ export function ComparisonModal({
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* Footer - Feedback */}
|
||||
{/* Footer - Feedback + Actions */}
|
||||
<div className="px-6 py-4 border-t dark:border-zinc-700 bg-gray-50 dark:bg-zinc-800/50">
|
||||
<div className="flex items-center justify-between">
|
||||
<p className="text-sm text-gray-600 dark:text-gray-400">
|
||||
{t('memoryEcho.comparison.helpfulQuestion')}
|
||||
</p>
|
||||
<div className="flex items-center gap-2">
|
||||
<p className="text-sm text-gray-600 dark:text-gray-400">
|
||||
{t('memoryEcho.comparison.helpfulQuestion')}
|
||||
</p>
|
||||
<Button
|
||||
size="sm"
|
||||
variant={feedback === 'thumbs_up' ? 'default' : 'outline'}
|
||||
@@ -167,6 +174,21 @@ export function ComparisonModal({
|
||||
{t('memoryEcho.comparison.notHelpful')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{onMergeNotes && notes.length >= 2 && (
|
||||
<Button
|
||||
size="sm"
|
||||
className="bg-purple-600 hover:bg-purple-700 text-white"
|
||||
onClick={() => {
|
||||
const noteIds = notes.map(n => n.id).filter(Boolean) as string[]
|
||||
onMergeNotes(noteIds)
|
||||
onClose()
|
||||
}}
|
||||
>
|
||||
<GitMerge className="h-4 w-4 mr-2" />
|
||||
{t('memoryEcho.editorSection.mergeAll')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
|
||||
Reference in New Issue
Block a user