Files
reflector/.flow/specs/fn-1.2.md
Igor Loskutov 316f7b316d feat: add WebVTT context generation to chat WebSocket endpoint
- Import topics_to_webvtt_named and recordings controller
- Add _get_is_multitrack helper function
- Generate WebVTT context on WebSocket connection
- Add get_context message type to retrieve WebVTT
- Maintain backward compatibility with echo for other messages
- Add test fixture and test for WebVTT context generation

Implements task fn-1.2: WebVTT context generation for transcript chat
2026-01-12 18:24:47 -05:00

44 lines
1.1 KiB
Markdown

# Task 2: WebVTT Context Generation
**File:** `server/reflector/views/transcripts_chat.py` (modify)
**Lines:** ~15
**Dependencies:** Task 1
## Objective
Generate WebVTT transcript context on connection.
## Implementation
```python
from reflector.utils.transcript_formats import topics_to_webvtt_named
from reflector.views.transcripts import _get_is_multitrack
# Add after websocket.accept():
# Get WebVTT context
is_multitrack = await _get_is_multitrack(transcript)
webvtt = topics_to_webvtt_named(
transcript.topics,
transcript.participants,
is_multitrack
)
# Truncate if needed
webvtt_truncated = webvtt[:15000] if len(webvtt) > 15000 else webvtt
# Send to client for verification
await websocket.send_json({
"type": "context",
"webvtt": webvtt_truncated,
"truncated": len(webvtt) > 15000
})
```
## Validation
- [ ] WebVTT generated on connection
- [ ] Truncated to 15k chars if needed
- [ ] Client receives context message
- [ ] Format matches WebVTT spec (timestamps, speaker names)
## Notes
- Log if truncation occurs
- Keep echo functionality for testing