Skip to content

Implement token-by-token streaming for topic and class AI descriptions - #114

Open
claude[bot] wants to merge 1 commit into
masterfrom
109-implement-token-by-token-streaming-for-topic-and-class-ai-descriptions
Open

claude[bot] wants to merge 1 commit into
masterfrom
109-implement-token-by-token-streaming-for-topic-and-class-ai-descriptions

Conversation

@claude

@claude claude Bot commented Mar 21, 2026

Copy link
Copy Markdown

Summary

  • Backend: Switch TopicDescriptionGenerationService and ClassDescriptionGenerationService to use a streaming LLM call (plain-text prompt) that publishes TOKEN_DELTA events for each token, then a separate structured JSON call for keywords and AI title
  • Backend: Create ClassDescriptionStreamEmitter and ClassDescriptionStreamService mirroring existing topic stream infrastructure; add GET /api/classes/description/stream/{classId} SSE endpoint to ClassesController
  • Backend: Fix TopicDescriptionStreamService.subscribe() to return STREAM_DONE immediately when aiDescription already exists (not just manual description), enabling safe on-load subscription without hasProcessingDocuments guard
  • Frontend: Fix TopicDetailPage stream trigger to subscribe on page load regardless of hasProcessingDocuments; add cleanup return to tear down streams on unmount
  • Frontend: Create useClassDescriptionStream hook; integrate class description streaming in ClassDetailPage showing tokens in the inline description field
  • Frontend: Add per-topic description streaming in ClassDetailPage for topic preview cards; streamed descriptions flow through TopicList → TopicCard

Issue

Closes #109

Generated with Claude Code

Implements #109

- Switch TopicDescriptionGenerationService to streaming LLM call using
  a plain-text prompt; publishes TOKEN_DELTA events for each token then
  STREAM_DONE on completion; falls back to structured JSON call for
  keywords and aiTitle
- Create ClassDescriptionStreamEmitter and ClassDescriptionStreamService
  mirroring the existing topic stream infrastructure
- Switch ClassDescriptionGenerationService to streaming with the same
  two-phase approach
- Add SSE endpoint GET /api/classes/description/stream/{classId} to
  ClassesController
- Fix TopicDescriptionStreamService.subscribe() to return STREAM_DONE
  immediately when aiDescription already exists (not just manualDescription)
- Add streaming-system prompts to topics.yaml and classes.yaml for
  plain-text description generation
- Fix TopicDetailPage stream trigger: subscribe on page load regardless
  of hasProcessingDocuments; add cleanup return to abort on unmount
- Create useClassDescriptionStream hook mirroring useTopicDescriptionStream
- Integrate class description streaming in ClassDetailPage; show
  streamedClassDescription while generating
- Add per-topic description streaming in ClassDetailPage for topic
  preview cards; pass streamed descriptions through TopicList to TopicCard

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@claude claude Bot linked an issue Mar 21, 2026 that may be closed by this pull request
2 of 4 tasks

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement token-by-token streaming for topic and class AI descriptions

0 participants