Repository navigation
feat: let authors split videos into chapters and track how far learners watch - #7
Merged
Conversation
its-gabo
deleted the
gs_feat_add_option_to_create_chapters_for_videos
branch
November 22, 2026 18:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Owners can now split a video into chapters. The embedded player splits its seek bar at each chapter and lists them in a chapter menu with thumbnails. Video analytics show how many views reached each chapter and how many watched it to the end. Other players can read the chapters as a WebVTT chapters track.
This PR also makes the dashboard's player look like the library's player settings, with a switch to show the default player. Thumbnail and chapter changes get their own activity entries, and the analytics views are tidied up so they share one look.
What owners see
0:00 Intro, orSetup (1:23)with the time last. It shows what it found before using it, and leaves out chapters that start too close to the end of the video.Changes
API
New endpoints, for members and for library API keys with the
videos:managescope:PUT /organizations/:slug/libraries/:id/videos/:videoId/chaptersPUT /libraries/:id/videos/:videoId/chapters{ "chapters": [{ "title": "Intro", "startSeconds": 0 }, …] }Public, under the library's playback rules (allowed hosts, signed playback):
GET /libraries/:id/videos/:videoId/chapters.vttWEBVTTheader when the video has no chapters.Responses. The chapters endpoints return the updated video.
chapters: [{ title, startSeconds }], in time order.chaptersas well.chaptersUrl.Saving. The body replaces all of a video's chapters, and an empty list removes them. Titles are trimmed and start times are kept to the millisecond. Saving the same chapters again changes and records nothing.
Errors.
video.not_readyvalidation.failvideo.chapters.out_of_rangeWebhook and activity log. A change sends a
video.updatedwebhook. It also adds avideo.chapters_updatedactivity entry with the old and new chapters.video.poster_updatedinstead ofvideo.updated, sovideo.updatedis left for renames.Video analytics. These now include
chapters: [{ title, startSeconds, endSeconds, views, completedViews }], counted from each view's furthest position, like retention.Player settings. These have a new
showChaptersfield, which defaults totruefor libraries saved before it existed.PUT …/playernow requiresshowChapters. Only the web app calls it.Processing
webvtt.utils.ts, shared by the storyboard and the chapters track.Migrations
0010_add_video_chapters.sqlvideos.chapters(jsonb, default[]), with a check that it is an array of at most 50 items.player_settingsof new libraries to includeshowChapters.0011_add_chapter_and_poster_activity_actions.sqladdsvideo.poster_updatedandvideo.chapters_updatedto the allowed activity actions.Shared
VIDEO_CHAPTER_LIMITSholds the limits: 50 per video, 100-character titles and a 1-second minimum length.videoChaptersSchemachecks the order and the gaps.latestChapterStartSecondsgives the latest a chapter may start in a video of a given length.showChaptersis added tolibraryPlayerSettingsSchema.Web
VideoChaptersSectionandVideoChaptersPasteDialogcomponents, plus auseVideoChaptersUpdateMutationhook. The form schema applies the API's rules in time order, whatever order the rows are typed in.VideoPlayertakeschapters.PlayerSlidertakesbreaksand draws one segment per chapter.PlayerChaptersMenu.StoryboardTile, which cuts a scaled tile from the storyboard sprite.usePlayerMenuDismissis a hook the settings menu and the chapter menu share.AnalyticsCardandChapterBreakdowncomponents.AnalyticsStatTilesis now a single strip that responds to its container's width.DialogandAlertDialognow always render their backdrop (forceRender), so dialogs opened from a sheet dim it.Seed
The demo seed adds chapters to "Dashboard walkthrough" and "Lesson 1: Getting started".
Testing
video-chapters.e2e.spec.tscovers: