Repository navigation
feat: add TranscriptsDrawer component for managing video transcripts - #4
Conversation
- Implemented TranscriptsDrawer to display and manage transcripts for video content. - Added functionality to parse and display transcript segments, including editing capabilities. - Integrated approval and rejection workflows for transcripts with backend service calls. - Enhanced user experience with loading states, error handling, and status updates. test: add unit tests for useEditor transcript generation logic - Created tests to verify transcript creation on video upload based on user input. - Ensured that transcript creation is skipped for non-video files and unchecked options. - Validated that upload success is not blocked by failed transcript creation. - Confirmed that transcript creation logic is correctly decoupled from other submission actions.
There was a problem hiding this comment.
Pull request overview
Adds end-to-end transcript support for video content in the generic editor: users can opt in to transcript generation during upload, view/manage transcript languages and segments in a new drawer, and pass live captions into the preview player.
Changes:
- Introduces
TranscriptsDrawerUI (language list, segment view/edit, approve/reject flows) and supporting styling/icons/i18n. - Adds transcript-related service APIs (
create/update/approve/reject/readTranscripts) plusreadContentcache: 'no-store'behavior. - Updates upload flow to optionally kick off transcript generation for videos, and adds unit tests across hook/UI/service.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/useEditor.ts | Adds upload-time transcript kickoff + header gating state (hasTranscripts). |
| src/useEditor.test.ts | Tests transcript creation behavior triggered by uploadFile. |
| src/types.ts | Extends drawer kinds + adds transcript data/segment types. |
| src/test/mockEd.ts | Extends mock service with transcript endpoints for tests. |
| src/services/ContentEditorService.ts | Implements transcript endpoints; adds cache: 'no-store' for readContent; adds readTranscripts via /portal. |
| src/services/ContentEditorService.test.ts | Adds unit tests for caching and transcript service endpoints. |
| src/icons.tsx | Adds CaptionsIcon. |
| src/i18n/translations.en.ts | Adds transcript-related strings. |
| src/editor.scss | Adds styles for the video transcript confirm step + transcripts drawer. |
| src/ContentEditor.tsx | Mounts TranscriptsDrawer. |
| src/constants.ts | Adds video mime/extension helpers (isVideoMimeType, etc.). |
| src/components/UploadCanvas.tsx | Adds “generate transcripts?” confirm step for video uploads. |
| src/components/UploadCanvas.test.tsx | Tests video confirm step + checkbox behavior. |
| src/components/TranscriptsDrawer.tsx | New drawer component for viewing/editing/approving/rejecting transcripts. |
| src/components/TranscriptsDrawer.test.tsx | Comprehensive tests for drawer states, segment parsing/editing, approve/reject flows. |
| src/components/Header.tsx | Adds “View transcript” button (currently gated by hasTranscripts). |
| src/components/Header.test.tsx | Tests transcript button visibility and drawer open. |
| src/components/EditorPreview.tsx | Fetches live transcripts and injects them into preview metadata. |
| src/components/EditorPreview.test.tsx | Tests transcript fetch/mapping behavior for preview. |
| package.json | Bumps package version to 2.0.5. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…unctionality and clarity - Enhanced TranscriptsDrawer to utilize translation functions for timestamps and status messages. - Simplified comments and improved documentation for better readability. - Updated UploadCanvas to reset transcript generation checkbox when uploading a new video. - Added tests for transcript polling behavior in useEditor hook. - Improved styling and removed unnecessary comments in editor.scss. - Updated translations to include new time-related strings. - Refactored ContentEditorService to clarify API endpoint usage and improve documentation.
pallakartheekreddy
left a comment
There was a problem hiding this comment.
Code review of the transcripts feature. Typecheck and lint are clean, and the new tests pass locally (the 21 failing service tests are the pre-existing localStorage.getItem is not a function jsdom issue, also failing on main — not caused by this PR).
12 inline findings below, roughly ordered by impact:
Correctness / data integrity
TranscriptsDrawer.openSegmentshas no request-sequence guard — a slow fetch for language A can land under language B and be saved onto B.saveSegmentsPATCHes the parsed segment list back as the full replacement, dropping every fieldparseSegmentsdid not keep (Whisper'sseek/tokens/avg_logprob, non-numericstart/end, whole segments with non-stringtext).- A failing confirmation re-read after a successful approve/reject is reported to the user as "Couldn't complete this action".
handleRecheckStatushas no.catch→ unhandled rejection and no feedback when the re-read fails.
Cost / lifecycle
useEditorpolls the expensive?enrich=allread every 20s forever for any video whose transcripts never materialise (e.g. the user unchecked the box).EditorPreviewfetches the same data a third time and remounts the renderer iframe when it resolves.
Smaller / polish
- Inconsistent default for a missing
status(Live in the player mapping vs Draft in the drawer), unreachablestatusLabeldefault, possibly-undefined Reactkey, cross-origindownloadattribute, hardcoded/portal/prefix that ignoresapiSlug, and EN-only translations.
Nothing here blocks the overall design — the feature is well structured and the test coverage is good.
- Added scoped styles for the transcripts drawer in editor.scss to maintain consistent font and button styles. - Implemented new translations for transcripts in Arabic, English, French, Hindi, Portuguese, and Tamil, including various UI strings related to transcript generation, viewing, and status updates. - Updated ContentEditorService to handle transcript reading and updating with improved caching strategies, including Cache-Control headers to prevent stale responses. - Enhanced tests for ContentEditorService to ensure proper handling of transcript-related functionality and caching behavior. - Modified useEditor hook to manage transcript state, including polling for transcript availability and handling non-video content scenarios.
test: add unit tests for useEditor transcript generation logic