Skip to content

feat: let authors split videos into chapters and track how far learners watch - #7

Merged
its-gabo merged 1 commit into
mainfrom
gs_feat_add_option_to_create_chapters_for_videos
Nov 20, 2026
Merged

its-gabo merged 1 commit into
mainfrom
gs_feat_add_option_to_create_chapters_for_videos

Conversation

@its-gabo

Copy link
Copy Markdown
Owner

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

  • Chapters tab. It's in the video details sheet, for processed videos. There's one row per chapter, each with a start time, a title and a thumbnail cut from the storyboard.
    • Add chapter at 0:12. Adds a chapter where the player above is. In an empty list, the first one is added at 0:00.
    • Paste list. Opens a dialog that reads a list like 0:00 Intro, or Setup (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.
    • Rows sort themselves. Once a row has both a time and a title and focus leaves it, the row moves to its place in time order.
    • Remove all, then Save chapters, removes them.
  • Rules. The first chapter starts at 0:00, and each chapter lasts at least 1 second, the last one included. There are at most 50 chapters, with titles of up to 100 characters. Errors show under the row they belong to.
  • Player.
    • The seek bar is split into segments with a transparent gap between chapters.
    • Hovering the seek bar shows the chapter title above the preview.
    • The control bar shows the current chapter, which opens a chapter menu with thumbnails for jumping between chapters.
  • Player settings. A new Chapters switch turns all of this off for a library. It's on by default.
  • Dashboard player. The player in the video sheet now uses the library's accent color, controls and title setting. Show the default player switches to the stock player without reloading the video.
  • Analytics.
    • Chapters card. For each chapter, the share of views that reached it and the share that watched it to the end. A legend explains which is which.
    • Retention chart. It marks where chapters start.
    • Stat tiles. The four headline numbers are one compact strip, two by two when there isn't room for all four in a row.
    • Shared cards. Retention, chapters, views per day and the ranking lists all use the same card.
  • Activity log. Thumbnail changes are now logged as "Changed a video's thumbnail" and chapter changes as "Changed a video's chapters". Before, thumbnail changes showed as "Renamed a video".

Changes

API

New endpoints, for members and for library API keys with the videos:manage scope:

Member route Library API route Body
PUT /organizations/:slug/libraries/:id/videos/:videoId/chapters PUT /libraries/:id/videos/:videoId/chapters { "chapters": [{ "title": "Intro", "startSeconds": 0 }, …] }

Public, under the library's playback rules (allowed hosts, signed playback):

Route Returns
GET /libraries/:id/videos/:videoId/chapters.vtt A WebVTT chapters track. It contains only the WEBVTT header when the video has no chapters.
  • Responses. The chapters endpoints return the updated video.

    • The video now includes chapters: [{ title, startSeconds }], in time order.
    • The embed response includes chapters as well.
    • Signed playback URLs include a 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.

    Status Code When
    409 video.not_ready The video isn't processed yet, or is being processed
    422 validation.fail The first chapter isn't at 0:00, two chapters are less than a second apart, a title is blank or too long, or there are more than 50 chapters
    422 video.chapters.out_of_range A chapter starts less than a second before the end of the video
  • Webhook and activity log. A change sends a video.updated webhook. It also adds a video.chapters_updated activity entry with the old and new chapters.

    • Thumbnail changes are now logged as video.poster_updated instead of video.updated, so video.updated is 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 showChapters field, which defaults to true for libraries saved before it existed.

    • Breaking: the dashboard's PUT …/player now requires showChapters. Only the web app calls it.

Processing

  • Reprocessing. If the new file is shorter, chapters that no longer last a second before the end are dropped.
  • WebVTT helpers. The timestamp formatting moved into webvtt.utils.ts, shared by the storyboard and the chapters track.

Migrations

  • 0010_add_video_chapters.sql
    • Adds videos.chapters (jsonb, default []), with a check that it is an array of at most 50 items.
    • Updates the default player_settings of new libraries to include showChapters.
  • 0011_add_chapter_and_poster_activity_actions.sql adds video.poster_updated and video.chapters_updated to the allowed activity actions.

Shared

  • Chapter rules. VIDEO_CHAPTER_LIMITS holds the limits: 50 per video, 100-character titles and a 1-second minimum length. videoChaptersSchema checks the order and the gaps.
  • latestChapterStartSeconds gives the latest a chapter may start in a video of a given length.
  • Player settings. showChapters is added to libraryPlayerSettingsSchema.

Web

  • Chapters editor. New VideoChaptersSection and VideoChaptersPasteDialog components, plus a useVideoChaptersUpdateMutation hook. The form schema applies the API's rules in time order, whatever order the rows are typed in.
  • Player.
    • VideoPlayer takes chapters.
    • PlayerSlider takes breaks and draws one segment per chapter.
    • New PlayerChaptersMenu.
    • New StoryboardTile, which cuts a scaled tile from the storyboard sprite.
    • usePlayerMenuDismiss is a hook the settings menu and the chapter menu share.
  • Analytics. New AnalyticsCard and ChapterBreakdown components. AnalyticsStatTiles is now a single strip that responds to its container's width.
  • Dialogs. The shared Dialog and AlertDialog now always render their backdrop (forceRender), so dialogs opened from a sheet dim it.
  • Video sheet.
    • The tabs wrap on narrow screens, each row with its own divider line.
    • The default-player switch sits under the player.
    • The thumbnail tab's long hint text is removed.
  • Translations. English and Polish for everything new.

Seed

The demo seed adds chapters to "Dashboard walkthrough" and "Lesson 1: Getting started".

Testing

  • New spec. video-chapters.e2e.spec.ts covers:
    • saving, trimming and removing chapters;
    • every invalid list, in a scenarios table;
    • the 1-second minimum, including at the end of the video;
    • videos that aren't ready;
    • dropping chapters when a shorter file is processed;
    • the activity log, webhooks and unchanged saves;
    • access from other organizations and API key scopes;
    • the embed, the WebVTT track and the playback rules.
  • Analytics. New tests cover per-chapter reach and the empty case.
  • Existing specs. Updated for the new fields and activity actions.
  • API results. 605 tests pass, and the per-feature coverage gate passes: libraries 99.4% and analytics 100%, with the new chapter files at 100%.

@its-gabo its-gabo self-assigned this Nov 20, 2026
@its-gabo its-gabo changed the title feat: let owners split videos into chapters and see how far viewers get through each feat: let authors split videos into chapters and track how far learners watch Nov 20, 2026
@its-gabo
its-gabo merged commit cc35340 into main Nov 20, 2026
1 check passed
@its-gabo
its-gabo deleted the gs_feat_add_option_to_create_chapters_for_videos branch November 22, 2026 18:27
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.

1 participant