Files
DeepTutor/web/features/notes/components/NoteResult.tsx
Bingxi Zhao (Frank) 28c11e2ae8 feat: update notes, chat interactions and workspace UI on preview
Remove course pages, APIs and the course_study capability. Add anchored note
threads and reviewed learning-block generation, queued and withdrawable chat
messages, quote attachments, side chats, and the calendar/favorites/navigation
updates.

Keep preview's existing backend architecture. Wire the new features through
its Python application and existing chat engine, retain legacy selected-text
requests, persist mid-turn messages in replay, and restore note context when
regenerating. Leave stored user data intact.

Validate frontend contracts, dependency boundaries, types, 1290 node tests,
840 rendered tests, lint, localization and the production build. Exercise
session/notes/API regressions, 53 chat-engine tests and 20 Python/native
integration tests with isolated runtime data.
2026-10-26 22:13:34 +08:00

62 lines
2.3 KiB
TypeScript

'use client'
import dynamic from 'next/dynamic'
import { apiUrl } from '@/lib/api'
import { extractMathAnimatorResult } from '@/lib/math-animator-types'
import type { VisualizeResult } from '@/lib/visualize-types'
const Visual = dynamic(() => import('@/components/visualize/VisualizationViewer'), { ssr: false })
const Animation = dynamic(() => import('@/components/math-animator/MathAnimatorViewer'), {
ssr: false,
})
export default function NoteResult({ payload }: { payload: Record<string, unknown> }) {
if (payload.renderer && payload.payload)
return <Visual result={payload as unknown as VisualizeResult} />
if (Array.isArray(payload.artifacts) && payload.artifacts.length) {
const result = extractMathAnimatorResult(payload)
if (result)
return (
<Animation
bare
result={{
...result,
timings: {},
code: { ...result.code, content: '' },
render: { visual_review: result.render.visual_review },
}}
/>
)
}
const items = Array.isArray(payload.workspace_items)
? (payload.workspace_items as Record<string, unknown>[])
: []
return (
<div className="space-y-2">
{items.map((item, i) => {
const url = String(item.url || '')
if (!/^(https?:\/\/|\/(?!\/))/.test(url)) return null
const mime = String(item.mime_type || '')
return (
<div key={i}>
{mime.startsWith('audio/') ? (
<audio className="w-full" controls preload="none" src={apiUrl(url)} />
) : mime.startsWith('video/') ? (
<video className="w-full" controls preload="none" src={apiUrl(url)} />
) : mime.startsWith('image/') ? (
// Generated assets use authenticated/scoped API URLs, not Next's image proxy.
// eslint-disable-next-line @next/next/no-img-element
<img
className="h-auto max-w-full rounded-md"
src={apiUrl(url)}
alt={String(item.title || item.filename || '')}
/>
) : (
<a className="text-[var(--primary)] underline" href={apiUrl(url)}>
{String(item.filename || item.title || '')}
</a>
)}
</div>
)
})}
</div>
)
}