Skip to content

Defer highlight reel generation until requested#65

Merged
SamuelZ12 merged 3 commits into
SamuelZ12:mainfrom
Liamzhangg:liamzhang-GitHub-defer-highlight-reels-generation
Apr 29, 2026
Merged

Defer highlight reel generation until requested#65
SamuelZ12 merged 3 commits into
SamuelZ12:mainfrom
Liamzhangg:liamzhang-GitHub-defer-highlight-reels-generation

Conversation

@Liamzhangg
Copy link
Copy Markdown
Contributor

Summary

  • Load the video/transcript workspace before highlight reels are generated.
  • Gate highlight reel generation behind the Generate highlight reels button.
  • Keep cached reels hidden until the user clicks generate.
  • Keep transcript seeking and workspace interactions usable while reels generate.

Details

  • Summary generation now runs as a non-blocking background task.
  • Summary failures stay local to the summary/chat area instead of triggering a full-page error.
  • Highlight generation errors stay inside the highlights panel with retry behavior.
  • The transcript/right-column layout gets a defensive minimum height so the transcript is visible before reels exist.
  • The custom highlight timeline only appears after generated topics exist.
  • YouTube iframe origin is set for more reliable local seeking.

Validation

  • node --import tsx --test components/__tests__/youtube-player.timeline.test.ts components/__tests__/highlights-panel.generate.test.tsx app/analyze/__tests__/right-column-layout.test.ts app/analyze/__tests__/summary-background-flow.test.ts
  • npm run lint
  • npm run build

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 26, 2026

@Liamzhangg is attempting to deploy a commit to the samuelz12's projects Team on Vercel.

A member of the Team first needs to authorize it.

@SamuelZ12 SamuelZ12 marked this pull request as ready for review April 29, 2026 02:00
Copilot AI review requested due to automatic review settings April 29, 2026 02:00
@SamuelZ12 SamuelZ12 merged commit 098192d into SamuelZ12:main Apr 29, 2026
2 of 3 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the analyze workspace flow so the transcript/video UI loads and remains usable before highlight reels are generated, deferring highlight generation until the user explicitly requests it while moving summary generation into a non-blocking background task.

Changes:

  • Gate highlight reel generation behind a “Generate highlight reels” CTA (including cached-reel reveal) and keep highlight errors localized to the highlights UI.
  • Refactor the YouTube player to support direct transcript seeking via an imperative ref handle, scoped iframe container IDs, and safer command queuing.
  • Add layout hardening (defensive right-column min height) and introduce targeted tests covering the new flows.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
components/youtube-player.tsx Adds player helpers, scoped element IDs, command queueing, and an imperative seekTo handle for transcript-driven seeking.
components/video-progress-bar.tsx Extracts density normalization into a helper used by tests.
components/topic-card.tsx Updates React import style to align with other components/tests.
components/highlights-panel.tsx Adds “generate highlights” CTA state, localized error/loading UI, and hides Play All controls until topics exist.
components/tests/youtube-player.timeline.test.ts Adds unit coverage for new YouTube player helpers/queueing behavior and density normalization.
components/tests/highlights-panel.generate.test.tsx Verifies generate-CTA, elapsed-time display, and Play All visibility rules.
app/analyze/tests/summary-background-flow.test.ts Ensures summary failures stay local (no full-page throw) for background generation paths.
app/analyze/tests/right-column-layout.test.ts Verifies right-column min-height/resize behavior and player remount + direct seek attempt behavior.
app/analyze/tests/cached-highlights-flow.test.ts Verifies cached highlights are stored but hidden until user generates, and cached reveal ordering/behavior.
app/analyze/[videoId]/page.tsx Defers highlights generation behind a button, runs takeaways generation in background, adds cached highlight payload ref, and adjusts layout/seek behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


let lastUpdateTime = 0;
timeUpdateIntervalRef.current = setInterval(() => {
if (!shouldPollPlayerTime(playerRef.current, true)) return;
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

startTimeUpdateInterval calls shouldPollPlayerTime(playerRef.current, true), which bypasses the readiness guard that shouldPollPlayerTime is meant to enforce. This makes the helper misleading and risks polling before the iframe is actually ready if this code is refactored/reused.

Use playerReadyRef.current (or the playerReady state) instead of the hard-coded true so polling is consistently gated on readiness.

Suggested change
if (!shouldPollPlayerTime(playerRef.current, true)) return;
if (!shouldPollPlayerTime(playerRef.current, playerReadyRef.current)) return;

Copilot uses AI. Check for mistakes.
}, [selectedLanguage, onRequestTranslation]);

const hasTopics = topics.length > 0;
const showGenerateState = !hasTopics && onGenerateHighlights;
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

showGenerateState is currently computed as !hasTopics && onGenerateHighlights, which makes its type false | (() => void) (truthy function) rather than an explicit boolean. This is easy to misread and can lead to accidental non-boolean usage later.

Prefer const showGenerateState = !hasTopics && Boolean(onGenerateHighlights); (or !!onGenerateHighlights) to keep the intent and type clear.

Suggested change
const showGenerateState = !hasTopics && onGenerateHighlights;
const showGenerateState = !hasTopics && Boolean(onGenerateHighlights);

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ee45ae838f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +408 to +410
if (youtubePlayerRef.current?.seekTo(time)) {
return;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Cancel queued playback command on direct seeks

Short-circuiting requestSeek when youtubePlayerRef.current.seekTo(time) succeeds leaves any previously queued playbackCommand intact, so a stale command can still fire ~50ms later in YouTubePlayer and override the user's newer seek. This is user-visible when a prior command (for example PLAY_TOPIC) has already scheduled execution and the user clicks another timestamp immediately afterward; before this change, updating playbackCommand to SEEK would replace and cancel the older command.

Useful? React with 👍 / 👎.

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.

3 participants