teqo-backup/src/components/campaign/speech/SpeechResultThumbnail.tsx
Francisco Solla d204ff5416 feat(C192): busca semântica no acervo de falas (Closes #1147)
Modo "Por tema" no acervo de falas: expansão determinística do tema via
DeepSeek (generateObject, timeout, fallback null) alimenta o motor lexical
existente (searchText/keywords OR), mantendo facetas AND, paginação por fala,
o OR de cortes do C174 e o access control intacto. Resultado de tema mostra
selo e "Por que apareceu" com trecho real (frase contínua), sem score;
degradação honesta para termo exato com aviso e vazio honesto com saídas.

- URL: mode=tema (default omitido; canonicaliza sem q), seletor otimista
- ai/expandSpeechSearchTheme + lib/speechThemeTerms (sanitiza saída do modelo)
- view model com themeMatchTerm + espelho speechMatchesSearchTerm
- UI do card de tema (selos, proveniência, ações) e aviso degradado
- sem migration/Consent/exposição pública; gate de leitura inalterado
- testes unit/int/e2e; design hi-fi estendido e certificado pelo designer
2026-09-18 17:26:18 -03:00

58 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use client'
import Link from 'next/link'
import { useEffect, useRef, useState } from 'react'
import { Skeleton } from '@/components/ui/skeleton'
import { cn } from '@/lib/utils'
/**
* C175/C182 — the trecho thumbnail on the acervo list: a fixed 128×80 slot so
* the lazy image never shifts the card, with the skeleton filling it until the
* image paints (a missing image settles into the neutral slot). The link reuses
* the card's watch target, with the same accessible name as the CTA.
* C192 — theme results take the full width on mobile (`h-28`), like the gate.
*/
export const SpeechResultThumbnail = ({
href,
src,
label,
fullWidthOnMobile = false,
}: {
href: string
src: string
label: string
fullWidthOnMobile?: boolean
}) => {
const [settled, setSettled] = useState(false)
const imageRef = useRef<HTMLImageElement>(null)
// A cached image can finish before hydration, when `onLoad` never fires.
useEffect(() => {
if (imageRef.current?.complete) setSettled(true)
}, [])
return (
<Link
href={href}
aria-label={label}
className={cn(
'relative block shrink-0 overflow-hidden rounded-lg border bg-muted',
fullWidthOnMobile ? 'h-28 w-full md:h-20 md:w-32' : 'h-20 w-32',
)}
>
{settled ? null : <Skeleton className="absolute inset-0 rounded-lg" />}
{/* eslint-disable-next-line @next/next/no-img-element -- external static image (poster route or YouTube cover). */}
<img
ref={imageRef}
src={src}
alt=""
loading="lazy"
decoding="async"
onLoad={() => setSettled(true)}
onError={() => setSettled(true)}
className="h-full w-full object-cover"
/>
</Link>
)
}