mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-05 07:34:25 +00:00
feat(transcript): add a popup language search
This commit is contained in:
+1
-1
@@ -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**: Update your local embedding server to v0.1.3 to generate video transcripts. Choose a language or detect it automatically, then open the transcript in the video player to switch languages, follow playback, search the text, jump to a segment, or edit its text.
|
||||
- **video**: Generate video transcripts in Simplified or Traditional Chinese. You can save and edit both versions on the same video.
|
||||
- **video**: Search for languages when generating video transcripts. You can save and edit Simplified and Traditional Chinese versions on the same video.
|
||||
- **integrations**: Set and test an embedding server URL under **Team Settings → Integrations**. A URL set through environment variables appears read-only. Once the server is configured, enable the Transcript Agent to generate video transcripts and receive an internal comment if a job fails. The updated embedding and full Docker Compose files create and enable the agent automatically with a distinct avatar.
|
||||
|
||||
For an existing deployment, create and enable the Transcript Agent under **Team Settings → Agents**, or add this line to the Shumai service’s `environment` block in your Compose file.
|
||||
|
||||
@@ -76,7 +76,7 @@ apps/web/e2e/
|
||||
| Owner creates a project with a cover image | `tests/project/create-project.spec.ts` |
|
||||
| Owner opens project cards in new tabs with middle-click and modifier-click | `tests/project/open-in-new-tab.spec.ts` |
|
||||
| Owner opens a folder card and a file row in new tabs from the context menu | `tests/project/open-in-new-tab.spec.ts` |
|
||||
| Owner sees the transcript action only when available, requests both Chinese scripts and English from an archived video's context menu, sees progress in card and list metadata across a refresh, and reuses the project status across folders | `tests/project/generate-transcripts.spec.ts` |
|
||||
| Owner opens the transcript action when available, searches for both Chinese scripts and English without resizing the dialog, tracks progress across a refresh, and reuses the project status across folders | `tests/project/generate-transcripts.spec.ts` |
|
||||
| Owner uploads a file or an unsupported file via the "Upload File" context menu action | `tests/project/upload-file.spec.ts` |
|
||||
| Owner deletes a file, finds it in recently deleted, and restores it | `tests/project/delete-restore.spec.ts` |
|
||||
| Owner deletes a folder and still sees its contents preview and countdown in recently deleted | `tests/project/delete-restore.spec.ts` |
|
||||
|
||||
@@ -93,23 +93,43 @@ test('starts a transcript for an archived video and tracks it in the file metada
|
||||
}
|
||||
await openDialog()
|
||||
const dialog = page.getByRole('dialog', { name: 'Generate Transcripts' })
|
||||
const language = dialog.getByRole('combobox', { name: 'Language' })
|
||||
const language = dialog.getByRole('combobox', { name: 'Language', exact: true })
|
||||
const generate = dialog.getByRole('button', { name: 'Generate', exact: true })
|
||||
const metadata = fileCard(page, fileName).getByTestId('file-card-metadata')
|
||||
const searchBox = dialog.getByRole('combobox', { name: 'Search languages' })
|
||||
const dialogHeight = () => dialog.evaluate((element) => element.clientHeight)
|
||||
|
||||
await expect(language).toBeEnabled()
|
||||
const closedHeight = await dialogHeight()
|
||||
await language.press('ArrowDown')
|
||||
await expect(dialog.getByRole('option', { name: 'English' })).toBeVisible()
|
||||
expect(await dialogHeight()).toBe(closedHeight)
|
||||
await expect(searchBox).toBeFocused()
|
||||
await searchBox.fill('unmatched query')
|
||||
await expect(dialog.getByText('No matching languages.')).toBeVisible()
|
||||
expect(await dialogHeight()).toBe(closedHeight)
|
||||
await searchBox.press('Escape')
|
||||
await expect(searchBox).toBeHidden()
|
||||
await expect(language).toBeFocused()
|
||||
await expect(language).toHaveText('Auto')
|
||||
|
||||
const selectLanguage = async (search: string, name: string) => {
|
||||
await language.fill(search)
|
||||
await language.click()
|
||||
await expect(searchBox).toHaveValue('')
|
||||
await searchBox.fill(search)
|
||||
await expect(dialog.getByRole('option')).toHaveCount(1)
|
||||
await expect(dialog.getByRole('option', { name })).toBeVisible()
|
||||
await language.press('ArrowDown')
|
||||
await expect(language).toHaveAttribute('aria-activedescendant', /.+/)
|
||||
await language.press('Enter')
|
||||
await expect(language).toHaveValue(name)
|
||||
await searchBox.press('ArrowDown')
|
||||
await expect(searchBox).toHaveAttribute('aria-activedescendant', /.+/)
|
||||
await searchBox.press('Enter')
|
||||
await expect(searchBox).toBeHidden()
|
||||
await expect(language).toHaveText(name)
|
||||
}
|
||||
|
||||
await expect(language).toHaveValue('Auto')
|
||||
await selectLanguage('Simplified', 'Chinese (Simplified)')
|
||||
await generate.click()
|
||||
await expect(dialog.getByRole('alert')).toBeVisible()
|
||||
await expect(language).toHaveValue('Chinese (Simplified)')
|
||||
await expect(language).toHaveText('Chinese (Simplified)')
|
||||
await generate.click()
|
||||
await expect(dialog).toBeHidden()
|
||||
await expect(metadata).toHaveText('Transcribing…')
|
||||
|
||||
@@ -13,6 +13,8 @@ import {
|
||||
ComboboxInput,
|
||||
ComboboxItem,
|
||||
ComboboxList,
|
||||
ComboboxTrigger,
|
||||
ComboboxValue,
|
||||
} from '@/ui/components/ui/combobox'
|
||||
import {
|
||||
Dialog,
|
||||
@@ -36,9 +38,11 @@ export function GenerateTranscriptsDialog({
|
||||
onJobAccepted: (assetId: string) => Promise<void>
|
||||
onClose: () => void
|
||||
}) {
|
||||
const dialogRef = useRef<HTMLDivElement>(null)
|
||||
const popupContainerRef = useRef<HTMLDivElement>(null)
|
||||
const languageTriggerRef = useRef<HTMLButtonElement>(null)
|
||||
const queryClient = useQueryClient()
|
||||
const [language, setLanguage] = useState('')
|
||||
const [isLanguagePickerOpen, setLanguagePickerOpen] = useState(false)
|
||||
const param = { fileId: assetId }
|
||||
|
||||
const languages = useQuery({
|
||||
@@ -84,6 +88,7 @@ export function GenerateTranscriptsDialog({
|
||||
})),
|
||||
]
|
||||
const busy = generate.isPending || isTranscribing
|
||||
const searchLabel = m.transcript_search_languages()
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
@@ -92,7 +97,12 @@ export function GenerateTranscriptsDialog({
|
||||
if (!open) onClose()
|
||||
}}
|
||||
>
|
||||
<DialogContent ref={dialogRef} showCloseButton={false}>
|
||||
<DialogContent
|
||||
showCloseButton={false}
|
||||
onEscapeKeyDown={(event) => {
|
||||
if (isLanguagePickerOpen) event.preventDefault()
|
||||
}}
|
||||
>
|
||||
<DialogHeader>
|
||||
<DialogTitle>{m.generate_transcripts()}</DialogTitle>
|
||||
<DialogDescription>{name}</DialogDescription>
|
||||
@@ -100,16 +110,24 @@ export function GenerateTranscriptsDialog({
|
||||
|
||||
<Combobox
|
||||
items={choices}
|
||||
onOpenChange={(isOpen, details) => {
|
||||
const activeElement = dialogRef.current?.ownerDocument.activeElement
|
||||
// WebKit can report focus-out after focus has already returned to the input.
|
||||
open={isLanguagePickerOpen}
|
||||
onOpenChange={(open, details) => {
|
||||
const container = popupContainerRef.current
|
||||
const activeElement = container?.ownerDocument.activeElement
|
||||
// WebKit can report focus-out while focus is still within the language picker.
|
||||
if (
|
||||
!isOpen &&
|
||||
!open &&
|
||||
details.reason === 'focus-out' &&
|
||||
activeElement === details.event.target
|
||||
(activeElement === languageTriggerRef.current ||
|
||||
container?.contains(activeElement ?? null))
|
||||
) {
|
||||
details.cancel()
|
||||
return
|
||||
}
|
||||
if (!open && details.reason === 'escape-key') {
|
||||
languageTriggerRef.current?.focus({ preventScroll: true })
|
||||
}
|
||||
setLanguagePickerOpen(open)
|
||||
}}
|
||||
value={choices.find((choice) => choice.code === language)}
|
||||
onValueChange={(choice) => setLanguage(choice?.code ?? '')}
|
||||
@@ -117,20 +135,40 @@ export function GenerateTranscriptsDialog({
|
||||
isItemEqualToValue={(choice, value) => choice.code === value.code}
|
||||
disabled={busy || languages.isPending || languages.isError}
|
||||
>
|
||||
<label htmlFor="transcript-language" className="text-sm font-medium">
|
||||
{m.language()}
|
||||
</label>
|
||||
<ComboboxInput id="transcript-language" />
|
||||
<ComboboxContent container={dialogRef}>
|
||||
<ComboboxEmpty>{m.transcript_no_languages_found()}</ComboboxEmpty>
|
||||
<ComboboxList>
|
||||
{(choice) => (
|
||||
<ComboboxItem key={choice.code} value={choice}>
|
||||
{choice.name}
|
||||
</ComboboxItem>
|
||||
)}
|
||||
</ComboboxList>
|
||||
</ComboboxContent>
|
||||
<div className="grid gap-2">
|
||||
<label htmlFor="transcript-language" className="text-sm font-medium">
|
||||
{m.language()}
|
||||
</label>
|
||||
<ComboboxTrigger
|
||||
ref={languageTriggerRef}
|
||||
id="transcript-language"
|
||||
render={<Button variant="outline" className="w-full justify-between font-normal" />}
|
||||
>
|
||||
<ComboboxValue />
|
||||
</ComboboxTrigger>
|
||||
</div>
|
||||
{/* Keep the popup inside the modal focus trap and outside the dialog grid. */}
|
||||
<div ref={popupContainerRef} className="absolute top-0 left-0">
|
||||
<ComboboxContent
|
||||
container={popupContainerRef}
|
||||
className="min-w-0"
|
||||
aria-label={m.language()}
|
||||
>
|
||||
<ComboboxInput
|
||||
aria-label={searchLabel}
|
||||
placeholder={searchLabel}
|
||||
showTrigger={false}
|
||||
/>
|
||||
<ComboboxEmpty>{m.transcript_no_languages_found()}</ComboboxEmpty>
|
||||
<ComboboxList>
|
||||
{(choice) => (
|
||||
<ComboboxItem key={choice.code} value={choice}>
|
||||
{choice.name}
|
||||
</ComboboxItem>
|
||||
)}
|
||||
</ComboboxList>
|
||||
</ComboboxContent>
|
||||
</div>
|
||||
</Combobox>
|
||||
|
||||
{languages.isPending && (
|
||||
|
||||
@@ -1828,6 +1828,7 @@
|
||||
"transcript_language_auto": "Auto",
|
||||
"transcript_language_chinese_simplified": "Chinese (Simplified)",
|
||||
"transcript_language_chinese_traditional": "Chinese (Traditional)",
|
||||
"transcript_search_languages": "Search languages",
|
||||
"transcript_generating": "Transcribing…",
|
||||
"transcript_no_speech": "No speech detected.",
|
||||
"transcript_submit_failed": "Could not start transcript generation.",
|
||||
|
||||
@@ -1758,6 +1758,7 @@
|
||||
"transcript_language_auto": "자동 감지",
|
||||
"transcript_language_chinese_simplified": "중국어(간체)",
|
||||
"transcript_language_chinese_traditional": "중국어(번체)",
|
||||
"transcript_search_languages": "언어 검색",
|
||||
"transcript_generating": "전사 중…",
|
||||
"transcript_no_speech": "음성이 감지되지 않았습니다.",
|
||||
"transcript_submit_failed": "전사 생성을 시작할 수 없습니다.",
|
||||
|
||||
@@ -1828,6 +1828,7 @@
|
||||
"transcript_language_auto": "自动检测",
|
||||
"transcript_language_chinese_simplified": "中文(简体)",
|
||||
"transcript_language_chinese_traditional": "中文(繁体)",
|
||||
"transcript_search_languages": "搜索语言",
|
||||
"transcript_generating": "正在转录…",
|
||||
"transcript_no_speech": "未检测到语音。",
|
||||
"transcript_submit_failed": "无法启动转录生成。",
|
||||
|
||||
Reference in New Issue
Block a user