fix(video): refine the sync to playback button

This commit is contained in:
yiling
2026-12-03 21:40:17 +08:00
parent 659ed5dab4
commit 1f95ecf110
3 changed files with 17 additions and 4 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- **sessions**: See total tokens and estimated cost in the session logs footer, with a breakdown of input, output, and cached tokens.
- **projects**: Middle-click or Command/Ctrl-click a project to open it in a new tab. Use **Open in new tab** in a file or folder's context menu to keep your current view open.
- **video**: Once a video's full proxy is ready, use **Generate Transcripts** in its context menu to transcribe the audio with the local embedding server. Choose a language or let the server detect it automatically. The dialog closes when the transcript is ready.
- **video**: Open saved transcripts from the video player, switch languages, search the text, and jump to the exact start of a segment by selecting it. Drag the divider to resize the transcript panel on desktop. As the video plays, the panel scrolls smoothly to keep upcoming segments in view.
- **video**: Open saved transcripts from the video player, switch languages, search the text, and jump to the exact start of a segment by selecting it. Drag the divider to resize the transcript panel on desktop. As the video plays, the panel scrolls smoothly to keep upcoming segments in view. After scrolling manually, use the solid, rounded **Sync to playback** button to resume following the video.
### Fixed
@@ -9,6 +9,7 @@ test('reads, searches and follows a saved transcript in the video player', async
}) => {
const { page, projectId, fileId } = file
await page.setViewportSize({ width: 1280, height: 720 })
await page.emulateMedia({ colorScheme: 'dark' })
await expect
.poll(() =>
prisma.asset.findUnique({
@@ -178,6 +179,19 @@ test('reads, searches and follows a saved transcript in the video player', async
await viewport.hover()
await page.mouse.wheel(0, -2500)
await expect(sync).toBeVisible()
await expect(page.locator('html')).toHaveClass('dark')
const background = await panel.evaluate((element) => getComputedStyle(element).backgroundColor)
await expect(sync).toHaveCSS('background-color', background)
await expect(sync.locator('svg')).toHaveCount(0)
expect(
await sync.evaluate(
(element) =>
parseFloat(getComputedStyle(element).borderTopLeftRadius) >= element.clientHeight / 2,
),
).toBe(true)
await sync.hover()
await expect(sync).not.toHaveCSS('background-color', background)
await expect(sync).toHaveCSS('background-color', /^oklch\([^/]+\)$/)
await expect(last).not.toBeInViewport()
await expect(last).toHaveAttribute('aria-current', 'true')
await viewport.evaluate((element) => {
@@ -11,7 +11,7 @@ import { m } from '@/ui/paraglide/messages.js'
import { getLocale } from '@/ui/paraglide/runtime.js'
import type { TranscriptSegment } from '@shumai/dtos'
import { useQuery } from '@tanstack/react-query'
import { ChevronDown, ChevronUp, LocateFixed, Search, X } from 'lucide-react'
import { ChevronDown, ChevronUp, Search, X } from 'lucide-react'
import { memo, useEffect, useLayoutEffect, useMemo, useRef, useState, type RefObject } from 'react'
import { createTranscriptTimeline } from './transcript-timeline'
import { useTranscriptScroll } from './use-transcript-scroll'
@@ -379,13 +379,12 @@ export const TranscriptPanel = memo(function TranscriptPanel({
<Button
size="sm"
variant="outline"
className="pointer-events-auto bg-background shadow-md"
className="pointer-events-auto rounded-full shadow-md dark:bg-background dark:hover:bg-accent"
onClick={() => {
viewportRef.current?.focus({ preventScroll: true })
setFollowing(true)
}}
>
<LocateFixed />
{m.transcript_sync_to_playback()}
</Button>
</div>