mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 00:39:47 +08:00
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.
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
/**
|
|
* What a learning block shows while Dito fills it.
|
|
*
|
|
* The page decides (it knows which conversation is generating which block);
|
|
* the block only reads. A store rather than DOM events because blocks render
|
|
* lazily: one that mounts after a generation started must still see it.
|
|
*/
|
|
export interface GenerationPreview {
|
|
content: string
|
|
pending: boolean
|
|
error?: string
|
|
/** The conversation filling the block, so the block can open it. */
|
|
sessionId?: string
|
|
}
|
|
|
|
const previews = new Map<string, GenerationPreview>()
|
|
const listeners = new Set<() => void>()
|
|
|
|
export function setGenerationPreview(blockId: string, preview: GenerationPreview | null) {
|
|
const current = previews.get(blockId)
|
|
if (!preview) {
|
|
if (!current) return
|
|
previews.delete(blockId)
|
|
} else {
|
|
if (
|
|
current &&
|
|
current.content === preview.content &&
|
|
current.pending === preview.pending &&
|
|
current.error === preview.error &&
|
|
current.sessionId === preview.sessionId
|
|
)
|
|
return
|
|
previews.set(blockId, preview)
|
|
}
|
|
listeners.forEach(listener => listener())
|
|
}
|
|
|
|
export function generationPreview(blockId: string): GenerationPreview | null {
|
|
return previews.get(blockId) ?? null
|
|
}
|
|
|
|
export function subscribeGenerationPreviews(listener: () => void) {
|
|
listeners.add(listener)
|
|
return () => {
|
|
listeners.delete(listener)
|
|
}
|
|
}
|