故事基准板
@@ -71,8 +86,9 @@ function removeVariant(entity: StoryEntity, kind: 'forms' | 'appearances', id: s
v-model="entity.name"
aria-label="角色名称"
/>
vi.restoreAllMocks())
+
+it('uses the final asset for this story and discards a late response after navigation', async () => {
+ const film = {
+ asset: { id: 'final', kind: 'video', preview_url: '/preview/final' },
+ draft_revision: 37,
+ }
+ let resolveOld!: (value: any) => void
+ const fetch = vi
+ .spyOn(api, 'storyFilm')
+ .mockImplementationOnce(
+ () =>
+ new Promise((resolve) => {
+ resolveOld = resolve
+ }),
+ )
+ .mockResolvedValueOnce(film as any)
+ const view = setupHarness(StoryFilmPreview, { draftId: 'old' })
+ try {
+ view.setProps({ draftId: 'current' })
+ await settle()
+ expect(fetch).toHaveBeenLastCalledWith('current')
+ resolveOld(null)
+ await settle()
+ expect(view.bindings.film.value?.asset.preview_url).toBe('/preview/final')
+ } finally {
+ view.unmount()
+ }
+})
diff --git a/frontend/src/components/studio/StoryFilmPreview.vue b/frontend/src/components/studio/StoryFilmPreview.vue
new file mode 100644
index 0000000..0b68f35
--- /dev/null
+++ b/frontend/src/components/studio/StoryFilmPreview.vue
@@ -0,0 +1,114 @@
+
+
+
+
+
+
成片预览
+ 刷新成片
+
+
+
+
+
+ 最新完成成片 · r{{ film.draft_revision }}
+
+ · {{ film.asset.duration_seconds.toFixed(2) }} 秒
+
+ · {{ film.asset.width }} × {{ film.asset.height }}
+
+
+
+
+
+ 读取成片失败,请刷新重试。{{ error }}
+
+
+ {{ loading ? '正在读取成片…' : pending ? '成片正在合成。' : '还没有已完成的成片。' }}
+
+
+
diff --git a/frontend/src/components/studio/StoryShotEditor.native.test.ts b/frontend/src/components/studio/StoryShotEditor.native.test.ts
new file mode 100644
index 0000000..e8a4442
--- /dev/null
+++ b/frontend/src/components/studio/StoryShotEditor.native.test.ts
@@ -0,0 +1,162 @@
+import { expect, it } from 'vitest'
+import { createSSRApp, defineComponent, h } from 'vue'
+import { renderToString } from 'vue/server-renderer'
+import StoryShotEditor from './StoryShotEditor.vue'
+import { dialogueFixture } from '../../utils/dialogueFixture'
+import { setupHarness } from '../../utils/setupHarness'
+import { emptyStory, validateStory } from '../../domain/stories/rules'
+import { videoProfileCapability } from '../../domain/creation/videoProfile'
+
+function props() {
+ const { manifest } = dialogueFixture()
+ if (manifest.schema_version !== 3) throw new Error('V3 fixture required')
+ manifest.spec.dialogue.generation = 'native_av'
+ return { spec: manifest.spec, shot: manifest.spec.shots[0]!, nativeTp2Available: false }
+}
+it('describes native video mapping and never promises a silent output for a native dialogue story', async () => {
+ const p = props()
+ p.shot.edit.duration_frames = 124
+ const original = JSON.stringify(p.shot.video_parameters)
+ const app = createSSRApp(StoryShotEditor, p)
+ for (const name of [
+ 'ElInput',
+ 'ElSelect',
+ 'ElOption',
+ 'ElButton',
+ 'ElCheckbox',
+ 'ElInputNumber',
+ 'ElSwitch',
+ ])
+ app.component(
+ name,
+ defineComponent({
+ setup(_, { slots, attrs }) {
+ return () => h('div', [String(attrs.label ?? ''), ...(slots.default?.() ?? [])])
+ },
+ }),
+ )
+ const html = await renderToString(app)
+ expect(html).toContain('H3原生音画')
+ expect(html).toContain('单卡')
+ expect(html).toContain('双卡')
+ expect(html).not.toContain('输出静音视频')
+ expect(html).not.toContain('Wan2.2(历史兼容)')
+ expect(html).not.toContain('超过待生成源')
+ expect(JSON.stringify(p.shot.video_parameters)).toBe(original)
+})
+it('requires the independent native dual-card capability before an explicit dual-card selection', () => {
+ const p = props()
+ const view = setupHarness(StoryShotEditor, { ...p, tp2Available: true })
+ try {
+ view.bindings.setVideoProfile('minimax-h3-fl2va-bf16-tp2-v1')
+ expect(p.shot.video_parameters.profile).toBe('minimax-h3-fl2va-bf16-v1')
+ view.setProps({
+ nativeTp2Available: true,
+ videoCapability: {
+ available: true,
+ defaults: {},
+ constraints: {},
+ video_profiles: [
+ {
+ profile: 'minimax-h3-fl2va-native-av-tp2-v1',
+ available: true,
+ defaults: {},
+ constraints: {},
+ canvases: [[1344, 768]],
+ },
+ ],
+ },
+ })
+ view.bindings.setVideoProfile('minimax-h3-fl2va-bf16-tp2-v1')
+ expect(p.shot.video_parameters.profile).toBe('minimax-h3-fl2va-bf16-tp2-v1')
+ } finally {
+ view.unmount()
+ }
+})
+it('accepts direct native profiles with their real frame limits and rejects oversized dual-card lengths', () => {
+ const p = props()
+ p.shot.video_parameters = {
+ profile: 'minimax-h3-fl2va-native-av-v1',
+ seed: 42,
+ source_frames: 175,
+ num_inference_steps: 50,
+ upscale: false,
+ }
+ expect(() => validateStory(p.spec)).not.toThrow()
+ p.shot.video_parameters.profile = 'minimax-h3-fl2va-native-av-tp2-v1'
+ expect(() => validateStory(p.spec)).toThrow()
+})
+it('does not inherit native profile availability from a silent H3 certificate', () => {
+ const capability = {
+ available: true,
+ defaults: { profile: 'minimax-h3-fl2va-bf16-v1' },
+ constraints: {},
+ } as any
+ expect(
+ videoProfileCapability({ profile: 'minimax-h3-fl2va-native-av-v1' }, capability)?.available,
+ ).toBe(false)
+})
+
+it('does not enable the native dual-card choice for an uncertified portrait canvas or missing evidence', () => {
+ const p = props()
+ p.spec.profile = 'portrait_1080_v1'
+ const capability = {
+ available: true,
+ defaults: {},
+ constraints: {},
+ video_profiles: [
+ {
+ profile: 'minimax-h3-fl2va-native-av-tp2-v1',
+ available: true,
+ defaults: {},
+ constraints: {},
+ canvases: [[1344, 768]],
+ },
+ ],
+ }
+ const view = setupHarness(StoryShotEditor, {
+ ...p,
+ nativeTp2Available: true,
+ videoCapability: capability,
+ })
+ const previous = JSON.stringify(p.shot.video_parameters)
+ try {
+ expect(view.bindings.nativeDualAllowed.value).toBe(false)
+ view.bindings.setVideoProfile('minimax-h3-fl2va-bf16-tp2-v1')
+ expect(JSON.stringify(p.shot.video_parameters)).toBe(previous)
+ view.setProps({
+ videoCapability: {
+ ...capability,
+ video_profiles: [
+ {
+ ...capability.video_profiles[0],
+ canvases: [
+ [1344, 768],
+ [768, 1344],
+ ],
+ },
+ ],
+ },
+ })
+ expect(view.bindings.nativeDualAllowed.value).toBe(true)
+ view.bindings.setVideoProfile('minimax-h3-fl2va-bf16-tp2-v1')
+ expect(p.shot.video_parameters.profile).toBe('minimax-h3-fl2va-bf16-tp2-v1')
+ view.setProps({ videoCapability: undefined })
+ expect(view.bindings.nativeDualAllowed.value).toBe(false)
+ } finally {
+ view.unmount()
+ }
+})
+
+it('retains independent silent portrait selection without native canvas restrictions', () => {
+ const spec = emptyStory()
+ spec.profile = 'portrait_1080_v1'
+ const view = setupHarness(StoryShotEditor, { spec, shot: spec.shots[0]!, tp2Available: true })
+ try {
+ view.bindings.setVideoProfile('minimax-h3-fl2va-bf16-tp2-v1')
+ expect(spec.shots[0]!.video_parameters.profile).toBe('minimax-h3-fl2va-bf16-tp2-v1')
+ expect(spec.profile).toBe('portrait_1080_v1')
+ } finally {
+ view.unmount()
+ }
+})
diff --git a/frontend/src/components/studio/StoryShotEditor.vue b/frontend/src/components/studio/StoryShotEditor.vue
index cab3d32..678e8eb 100644
--- a/frontend/src/components/studio/StoryShotEditor.vue
+++ b/frontend/src/components/studio/StoryShotEditor.vue
@@ -2,14 +2,22 @@
import { computed, ref } from 'vue'
import type { StorySpec, StoryShot, SelectionDTO } from '../../types/stories'
import { addCast, effectiveScene, videoGenerationIssue } from '../../domain/stories/rules'
+import { sequenceForShot, setSpeakerVisible } from '../../domain/creation/dialogue'
+import type { StoryShotV5 } from '../../types/stories'
+import type { Capability } from '../../types/capabilities'
import {
H3_VIDEO_PROFILE,
+ H3_NATIVE_AV_PROFILE,
+ H3_NATIVE_AV_TP2_PROFILE,
H3_TP2_VIDEO_PROFILE,
H3_TP2_WAITING_DESCRIPTION,
H3_TP2_UNAVAILABLE_REASON,
LEGACY_VIDEO_PROFILE,
isH3Video,
storySourceBounds,
+ nativeStoryVideoCapability,
+ nativeLandscapeOnly,
+ H3_NATIVE_LANDSCAPE_ONLY_DESCRIPTION,
} from '../../domain/creation/videoProfile'
import {
changeNativeFrames,
@@ -22,6 +30,10 @@ const props = defineProps<{
manualVideo?: boolean
tp2Available?: boolean
tp2Reason?: string | null
+ nativeTp2Available?: boolean
+ nativeTp2Reason?: string | null
+ videoCapability?: Capability
+ continuityAvailable?: boolean
}>()
const emit = defineEmits<{ timing: [] }>()
const mention = ref(false),
@@ -29,9 +41,63 @@ const mention = ref(false),
const effective = computed(() => effectiveScene(props.spec, props.shot))
const selectedVideoSeconds = computed(() => props.videoSelection?.asset?.duration_seconds)
const h3Video = computed(() => isH3Video(props.shot.video_parameters))
-const tp2Video = computed(() => props.shot.video_parameters.profile === H3_TP2_VIDEO_PROFILE)
+const nativeDialogue = computed(
+ () => props.spec.schema_version === 5 && props.spec.dialogue.generation === 'native_av',
+)
+const tp2Video = computed(() =>
+ [H3_TP2_VIDEO_PROFILE, H3_NATIVE_AV_TP2_PROFILE].includes(
+ props.shot.video_parameters.profile ?? '',
+ ),
+)
+const nativeSingleProfile = computed(() =>
+ props.shot.video_parameters.source_frames !== undefined ? H3_NATIVE_AV_PROFILE : H3_VIDEO_PROFILE,
+)
+const nativeDualProfile = computed(() =>
+ props.shot.video_parameters.source_frames !== undefined
+ ? H3_NATIVE_AV_TP2_PROFILE
+ : H3_TP2_VIDEO_PROFILE,
+)
+const nativeDualAllowed = computed(
+ () =>
+ props.nativeTp2Available === true &&
+ nativeDualCapability.value?.available === true &&
+ (props.shot.video_parameters.source_frames ?? 124) <= 158,
+)
+const nativeDualCapability = computed(() =>
+ nativeStoryVideoCapability(
+ { profile: H3_NATIVE_AV_TP2_PROFILE },
+ props.spec.profile,
+ props.videoCapability,
+ ),
+)
+const nativeSingleCapability = computed(() =>
+ nativeStoryVideoCapability(
+ { profile: H3_NATIVE_AV_PROFILE },
+ props.spec.profile,
+ props.videoCapability,
+ ),
+)
const tp2UnavailableReason = computed(() => props.tp2Reason || H3_TP2_UNAVAILABLE_REASON)
const sourceBounds = computed(() => storySourceBounds(props.shot.video_parameters))
+const dialogueSequence = computed(() =>
+ props.spec.schema_version === 5
+ ? sequenceForShot(props.spec, props.shot as StoryShotV5)
+ : undefined,
+)
+function setScene(sceneId: string | null) {
+ if (dialogueSequence.value && dialogueSequence.value.shot_ids.length > 1) return
+ props.shot.scene_id = sceneId
+ if (dialogueSequence.value) dialogueSequence.value.scene_id = sceneId
+}
+function removeCast(id: string) {
+ const member = props.shot.cast.find((item) => item.id === id)
+ props.shot.cast = props.shot.cast.filter((item) => item.id !== id)
+ if (props.spec.schema_version === 5 && member) {
+ for (const speaker of props.spec.dialogue.speakers)
+ if (speaker.entity_id === member.entity_id)
+ setSpeakerVisible(props.spec, props.shot as StoryShotV5, speaker.id, false, 0)
+ }
+}
function changeDedup(value: string) {
props.shot.edit.dedup_frames = value === '1' ? 1 : 0
emit('timing')
@@ -45,12 +111,18 @@ function nativeFrames(value: string) {
emit('timing')
}
function setVideoProfile(profile: string) {
- if (profile === H3_TP2_VIDEO_PROFILE && props.tp2Available !== true) return
+ if (nativeDialogue.value) {
+ if (![nativeSingleProfile.value, nativeDualProfile.value].includes(profile)) return
+ if (profile === nativeDualProfile.value && !nativeDualAllowed.value) return
+ if (profile === nativeSingleProfile.value && nativeSingleCapability.value?.available !== true)
+ return
+ } else if (profile === H3_TP2_VIDEO_PROFILE && props.tp2Available !== true) return
props.shot.video_parameters.profile = profile
if (isH3Video({ profile })) {
props.shot.video_parameters.num_inference_steps = 50
delete props.shot.video_parameters.guidance_scale
- if (profile === H3_TP2_VIDEO_PROFILE) props.shot.video_parameters.upscale = false
+ if (nativeDialogue.value || profile === H3_TP2_VIDEO_PROFILE)
+ props.shot.video_parameters.upscale = false
} else props.shot.video_parameters.guidance_scale ??= 5
}
const selectedVideoFrames = computed(() =>
@@ -81,7 +153,10 @@ function mentionEntity(id: string) {
当前镜头
镜头名称
场景 c.id !== cast.id)"
+ @click="removeCast(cast.id)"
>移除
@@ -266,7 +343,38 @@ function mentionEntity(id: string) {
>当前选段会裁掉端点,请检查选用范围。
- 原生视频生成方式
+
+
+
+ H3原生音画直接生成画面、对白和口型。计划会显示实际原生源帧;历史保存的模型配置与时长仅在明确编辑时改变。双卡需要独立的原生音频能力。
+ {{ H3_NATIVE_LANDSCAPE_ONLY_DESCRIPTION }}。
+
+ 视频生成模型
H3
输出静音视频,不使用视频引导系数和负提示词;基准板负提示词仍用于首帧图像。配音和背景音乐沿用成片音轨。
{{ H3_TP2_WAITING_DESCRIPTION }}
H3双卡暂不可用:{{ tp2UnavailableReason }}
{{ videoGenerationIssue(shot) }}
@@ -339,7 +447,7 @@ function mentionEntity(id: string) {
@change="nativeFrames(($event.target as HTMLSelectElement).value)"
>
{{ 124 + 17 * (k - 1) }}
@@ -417,9 +525,9 @@ function mentionEntity(id: string) {
>视频步数引导系数 使用增强片作为候选产物
diff --git a/frontend/src/domain/creation/continuity.test.ts b/frontend/src/domain/creation/continuity.test.ts
index 0a34edc..d135590 100644
--- a/frontend/src/domain/creation/continuity.test.ts
+++ b/frontend/src/domain/creation/continuity.test.ts
@@ -42,8 +42,7 @@ it('upgrades without replacing historical profiles, locks or generation inputs',
expect(upgradeContinuity(m)).toBe(false)
})
it('validates sample-accurate native footage with deduplicated joins', () => {
- const spec = emptyStory()
- spec.schema_version = 4
+ const spec = { ...emptyStory(), schema_version: 4 as const }
spec.shots = [createShot(4), createShot(4)]
spec.shots[1]!.edit.dedup_frames = 1
spec.shots[1]!.continuity!.transition = 'continue'
diff --git a/frontend/src/domain/creation/continuity.ts b/frontend/src/domain/creation/continuity.ts
index 0bcbe8b..d16263f 100644
--- a/frontend/src/domain/creation/continuity.ts
+++ b/frontend/src/domain/creation/continuity.ts
@@ -8,7 +8,7 @@ export function upgradeContinuity(manifest: EditorManifest) {
)
return false
manifest.schema_version = 2
- manifest.spec.schema_version = 4
+ Object.assign(manifest.spec, { schema_version: 4 })
for (const shot of manifest.spec.shots) shot.continuity = continuityState()
manifest.audio.layers = []
manifest.audio.ducking = true
@@ -16,6 +16,7 @@ export function upgradeContinuity(manifest: EditorManifest) {
}
export function writableManifest(editor: number, spec: number, kind: string) {
+ if (editor === 3) return kind === 'story' && spec === 5
if (editor !== 1 && editor !== 2) return false
return kind === 'story'
? spec === 3 || (editor === 2 && spec === 4)
diff --git a/frontend/src/domain/creation/dialogue.test.ts b/frontend/src/domain/creation/dialogue.test.ts
new file mode 100644
index 0000000..d6f02e0
--- /dev/null
+++ b/frontend/src/domain/creation/dialogue.test.ts
@@ -0,0 +1,165 @@
+import { afterEach, expect, it, vi } from 'vitest'
+import { dialogueFixture } from '../../utils/dialogueFixture'
+import { validateStory } from '../stories/rules'
+import { editorFrames } from './editor'
+import { writableManifest } from './continuity'
+import { defaultPerformance, nativeUtterancesForShot, upgradeNativeDialogue } from './dialogue'
+
+it('upgrades only the local authoring spec and retains historical media and dialogue text', () => {
+ const { manifest } = dialogueFixture()
+ if (manifest.schema_version !== 3) throw new Error('V3 fixture required')
+ manifest.bindings['synced_video:old'] = { asset_id: 'old', kind: 'video', source: 'generated' }
+ const before = JSON.stringify(manifest)
+ expect(manifest.spec.dialogue).not.toHaveProperty('generation')
+ expect(upgradeNativeDialogue(manifest.spec)).toBe(true)
+ expect(manifest.spec.dialogue).toMatchObject({ generation: 'native_av', language: 'Chinese' })
+ expect(manifest.spec.dialogue.utterances[0]!.text).toBe('灯亮了。')
+ expect(manifest.bindings['synced_video:old']!.asset_id).toBe('old')
+ expect(upgradeNativeDialogue(manifest.spec)).toBe(false)
+ expect(JSON.parse(before).spec.dialogue).not.toHaveProperty('generation')
+})
+
+it('requires explicit whole-line allocation for multi-shot sequences without guessing or duplicating speech', () => {
+ const { manifest } = dialogueFixture()
+ if (manifest.schema_version !== 3) throw new Error('V3 fixture required')
+ const spec = manifest.spec
+ const first = spec.shots[0]!
+ expect(nativeUtterancesForShot(spec, first)).toEqual([])
+ first.performance.native_utterance_ids = [spec.dialogue.utterances[0]!.id, 'removed']
+ expect(nativeUtterancesForShot(spec, first).map((line) => line.text)).toEqual(['灯亮了。'])
+ expect(nativeUtterancesForShot(spec, spec.shots[1]!)).toEqual([])
+ spec.dialogue.sequences[0]!.shot_ids = [first.id]
+ delete first.performance.native_utterance_ids
+ expect(nativeUtterancesForShot(spec, first).map((line) => line.text)).toEqual(['灯亮了。'])
+})
+
+it('removes a deleted utterance from every explicit native shot allocation', async () => {
+ const { removeUtterance } = await import('./dialogue')
+ const { manifest } = dialogueFixture()
+ if (manifest.schema_version !== 3) throw new Error('V3 fixture required')
+ const lineId = manifest.spec.dialogue.utterances[0]!.id
+ for (const shot of manifest.spec.shots) shot.performance.native_utterance_ids = [lineId]
+ removeUtterance(manifest, lineId)
+ expect(manifest.spec.shots.map((shot) => shot.performance.native_utterance_ids)).toEqual([[], []])
+})
+
+it('clears a shot allocation when the author explicitly moves it to a new dialogue sequence', async () => {
+ const { setShotSequence } = await import('./dialogue')
+ const { manifest } = dialogueFixture()
+ if (manifest.schema_version !== 3) throw new Error('V3 fixture required')
+ const shot = manifest.spec.shots[0]!
+ shot.performance.native_utterance_ids = [manifest.spec.dialogue.utterances[0]!.id]
+ setShotSequence(manifest.spec, shot, '')
+ expect(shot.performance.native_utterance_ids).toBeUndefined()
+ expect(nativeUtterancesForShot(manifest.spec, shot)).toEqual([])
+})
+
+it('keeps a new native voice description nullable until the author supplies one', async () => {
+ const { addSpeaker } = await import('./dialogue')
+ const { manifest } = dialogueFixture()
+ if (manifest.schema_version !== 3) throw new Error('V3 fixture required')
+ upgradeNativeDialogue(manifest.spec)
+ expect(addSpeaker(manifest.spec, null).native_voice).toBeNull()
+})
+
+afterEach(() => vi.restoreAllMocks())
+it('starts a new dialogue shot at zero lip-sync offset', () => {
+ expect(defaultPerformance()).toHaveProperty('audio_context_shift_frames', 0)
+})
+
+it('accepts V5/V3 on the story editor save path without treating it as a workflow', () => {
+ const { manifest } = dialogueFixture()
+ expect(writableManifest(3, 5, 'story')).toBe(true)
+ expect(writableManifest(1, 5, 'story')).toBe(false)
+ expect(writableManifest(3, 2, 'workflow')).toBe(false)
+ expect(() => validateStory(manifest.spec as Parameters[0])).not.toThrow()
+})
+
+it('subtracts deduplication while computing the V3 timeline', () => {
+ const { manifest } = dialogueFixture()
+ const shot = manifest.spec.shots[1]!
+ if ('edit' in shot) shot.edit.dedup_frames = 1
+ expect(editorFrames(manifest)).toBe(239)
+})
+
+it('keeps one authored utterance shared by all shots in a continuous sequence', async () => {
+ const { utterancesForShot } = await import('./dialogue')
+ const { manifest } = dialogueFixture()
+ if (manifest.spec.schema_version !== 5) throw new Error('V5 fixture required')
+ const [first, second] = manifest.spec.shots
+ const firstLines = utterancesForShot(manifest.spec, first!)
+ const secondLines = utterancesForShot(manifest.spec, second!)
+ expect(firstLines[0]).toBe(secondLines[0])
+ firstLines[0]!.text = '又亮了。'
+ expect(manifest.spec.dialogue.utterances.map((line) => line.text)).toEqual(['又亮了。'])
+})
+
+it('binds only visible cast members and blocks unauthenticated two-face selection', async () => {
+ const { setSpeakerVisible } = await import('./dialogue')
+ const { manifest } = dialogueFixture()
+ if (manifest.spec.schema_version !== 5) throw new Error('V5 fixture required')
+ const spec = manifest.spec
+ const shot = spec.shots[0]!
+ const speaker = spec.dialogue.speakers[0]!
+ expect(setSpeakerVisible(spec, shot, speaker.id, true, 1)).toBe(false)
+ shot.cast.push({
+ id: '6'.repeat(32),
+ entity_id: speaker.entity_id!,
+ form_id: null,
+ appearance_id: null,
+ position: '',
+ action: '',
+ })
+ expect(setSpeakerVisible(spec, shot, speaker.id, true, 1)).toBe(true)
+ const second = { ...speaker, id: '7'.repeat(32), entity_id: '8'.repeat(32) }
+ spec.dialogue.speakers.push(second)
+ shot.cast.push({ ...shot.cast[0]!, id: '9'.repeat(32), entity_id: second.entity_id })
+ expect(setSpeakerVisible(spec, shot, second.id, true, 1)).toBe(false)
+ expect(shot.performance.visible_speaker_ids).toEqual([speaker.id])
+})
+
+it('creates an utterance subtitle override without modifying speech or narration', async () => {
+ const { setUtteranceCaption } = await import('./dialogue')
+ const { manifest } = dialogueFixture()
+ if (manifest.schema_version !== 3) throw new Error('V3 manifest required')
+ const line = manifest.spec.dialogue.utterances[0]!
+ setUtteranceCaption(manifest, line, '字幕改字')
+ expect(manifest.captions.cues[0]).toMatchObject({
+ anchor: 'utterance',
+ utterance_id: line.id,
+ text: '字幕改字',
+ text_override: true,
+ timing_override: false,
+ })
+ expect(line.text).toBe('灯亮了。')
+ expect(manifest.audio.segments).toEqual([])
+})
+
+it('projects scene-anchored music from the first contributing shot', async () => {
+ const { audioTimelineEntries } = await import('./dialogue')
+ const { manifest } = dialogueFixture()
+ if (manifest.schema_version !== 3) throw new Error('V3 manifest required')
+ const sceneId = 'a'.repeat(32)
+ manifest.spec.shots[0]!.edit.dedup_frames = 1
+ manifest.spec.shots[1]!.scene_id = sceneId
+ manifest.audio.layers = [
+ {
+ id: 'c'.repeat(32),
+ role: 'bgm',
+ asset_id: 'b'.repeat(32),
+ anchor: 'scene',
+ scene_id: sceneId,
+ offset_sample: 24000,
+ },
+ {
+ id: 'd'.repeat(32),
+ role: 'sfx',
+ asset_id: 'e'.repeat(32),
+ anchor: 'absolute',
+ offset_sample: 12000,
+ },
+ ]
+ expect(audioTimelineEntries(manifest).map(({ startSample }) => startSample)).toEqual([
+ 12000, 262000,
+ ])
+})
diff --git a/frontend/src/domain/creation/dialogue.ts b/frontend/src/domain/creation/dialogue.ts
new file mode 100644
index 0000000..44e0e78
--- /dev/null
+++ b/frontend/src/domain/creation/dialogue.ts
@@ -0,0 +1,268 @@
+import type { EditorManifestV3 } from '../../types/editors'
+import type {
+ DialogueSequence,
+ DialogueSpeaker,
+ DialogueUtterance,
+ DialogueVoice,
+ ShotPerformance,
+ StoryShotV5,
+ StorySpecV5,
+} from '../../types/stories'
+import { newRequestId } from '../../utils/requestId'
+
+const id = () => newRequestId().replaceAll('-', '')
+export const NATIVE_DIALOGUE_UNAVAILABLE = '上游H3原生音频尚未升级'
+
+export function upgradeNativeDialogue(spec: StorySpecV5) {
+ if (spec.dialogue.generation === 'native_av') return false
+ // 只修改作者正在编辑的版本;历史素材与旧配音配置留给保存时的兼容处理。
+ spec.dialogue.generation = 'native_av'
+ spec.dialogue.language = 'Chinese'
+ return true
+}
+
+export function nativeUtterancesForShot(spec: StorySpecV5, shot: StoryShotV5) {
+ const sequence = sequenceForShot(spec, shot)
+ const lines = utterancesForSequence(spec, sequence)
+ const selected = shot.performance.native_utterance_ids
+ if (selected == null) return sequence?.shot_ids.length === 1 ? lines : []
+ return lines.filter((line) => selected.includes(line.id))
+}
+
+export const defaultPerformance = (): ShotPerformance => ({
+ sequence_id: null,
+ visible_speaker_ids: [],
+ lip_sync: 'auto',
+ audio_context_shift_frames: 0,
+ duration_mode: 'auto',
+ structure_locked: false,
+ original_audio: 'discard',
+})
+
+export function defaultVoice(provider: DialogueVoice['provider'] = 'kokoro'): DialogueVoice {
+ return {
+ provider,
+ model: provider === 'kokoro' ? 'kokoro-82m' : 'voxcpm2',
+ voice: provider === 'kokoro' ? 'zf_xiaobei' : '',
+ reference_asset_id: null,
+ reference_text: '',
+ style: '',
+ speed: 1,
+ seed: 42,
+ revision: 1,
+ }
+}
+
+export function addSpeaker(spec: StorySpecV5, entityId: string | null) {
+ const entity = spec.entities.find((item) => item.id === entityId && item.kind === 'person')
+ const speaker: DialogueSpeaker = {
+ id: id(),
+ entity_id: entity?.id ?? null,
+ name: entity?.name || '旁白',
+ voice: defaultVoice(),
+ ...(spec.dialogue.generation === 'native_av' ? { native_voice: null } : {}),
+ }
+ spec.dialogue.speakers.push(speaker)
+ return speaker
+}
+
+export function bindSpeaker(spec: StorySpecV5, speaker: DialogueSpeaker, entityId: string | null) {
+ speaker.entity_id = entityId
+ for (const shot of spec.shots) {
+ if (!entityId || !shot.cast.some((member) => member.entity_id === entityId))
+ setSpeakerVisible(spec, shot, speaker.id, false, 0)
+ }
+}
+
+export function sequenceForShot(spec: StorySpecV5, shot: StoryShotV5) {
+ return spec.dialogue.sequences.find((item) => item.id === shot.performance.sequence_id)
+}
+
+export function utterancesForSequence(spec: StorySpecV5, sequence?: DialogueSequence) {
+ const lines = new Map(spec.dialogue.utterances.map((line) => [line.id, line]))
+ return (sequence?.utterance_ids ?? []).flatMap((lineId) => {
+ const line = lines.get(lineId)
+ return line ? [line] : []
+ })
+}
+
+export function utterancesForShot(spec: StorySpecV5, shot: StoryShotV5) {
+ return utterancesForSequence(spec, sequenceForShot(spec, shot))
+}
+
+export function beginSequence(spec: StorySpecV5, shot: StoryShotV5) {
+ const sequence: DialogueSequence = {
+ id: id(),
+ scene_id: shot.scene_id,
+ shot_ids: [shot.id],
+ utterance_ids: [],
+ timing_mode: 'auto',
+ }
+ shot.performance.sequence_id = sequence.id
+ shot.performance.visible_speaker_ids = []
+ delete shot.performance.native_utterance_ids
+ spec.dialogue.sequences.push(sequence)
+ return sequence
+}
+
+export function detachShot(spec: StorySpecV5, shot: StoryShotV5) {
+ const sequence = sequenceForShot(spec, shot)
+ if (!sequence) return
+ sequence.shot_ids = sequence.shot_ids.filter((shotId) => shotId !== shot.id)
+ if (!sequence.shot_ids.length)
+ spec.dialogue.sequences = spec.dialogue.sequences.filter((item) => item !== sequence)
+ shot.performance.sequence_id = null
+ shot.performance.visible_speaker_ids = []
+ delete shot.performance.native_utterance_ids
+}
+
+export function canChangeSequence(spec: StorySpecV5, shot: StoryShotV5) {
+ const sequence = sequenceForShot(spec, shot)
+ return (
+ !shot.performance.structure_locked &&
+ (!sequence ||
+ (!sequence.utterance_ids.length && sequence.shot_ids.length === 1) ||
+ (sequence.shot_ids.length > 1 &&
+ [sequence.shot_ids.at(0), sequence.shot_ids.at(-1)].includes(shot.id)))
+ )
+}
+
+export function adjacentSequences(spec: StorySpecV5, shot: StoryShotV5) {
+ const index = spec.shots.indexOf(shot)
+ return [spec.shots[index - 1], spec.shots[index + 1]].flatMap((neighbor) => {
+ const sequence = neighbor && sequenceForShot(spec, neighbor)
+ if (sequence?.scene_id === shot.scene_id && sequence.id !== shot.performance.sequence_id)
+ return [sequence]
+ return []
+ })
+}
+
+export function setShotSequence(spec: StorySpecV5, shot: StoryShotV5, sequenceId: string) {
+ if (!canChangeSequence(spec, shot)) return
+ if (!sequenceId) {
+ detachShot(spec, shot)
+ beginSequence(spec, shot)
+ return
+ }
+ const sequence = adjacentSequences(spec, shot).find((item) => item.id === sequenceId)
+ if (!sequence) return
+ detachShot(spec, shot)
+ shot.performance.sequence_id = sequence.id
+ sequence.shot_ids = spec.shots
+ .filter((item) => item.performance.sequence_id === sequence.id)
+ .map((item) => item.id)
+}
+
+export function setSpeakerVisible(
+ spec: StorySpecV5,
+ shot: StoryShotV5,
+ speakerId: string,
+ visible: boolean,
+ limit: number,
+) {
+ const speakers = shot.performance.visible_speaker_ids
+ if (!visible) {
+ shot.performance.visible_speaker_ids = speakers.filter((item) => item !== speakerId)
+ return true
+ }
+ if (speakers.includes(speakerId)) return true
+ const entity = spec.dialogue.speakers.find((item) => item.id === speakerId)?.entity_id
+ if (!entity || !shot.cast.some((item) => item.entity_id === entity) || speakers.length >= limit)
+ return false
+ speakers.push(speakerId)
+ return true
+}
+
+export function addUtterance(spec: StorySpecV5, sequence: DialogueSequence, speakerId: string) {
+ const line: DialogueUtterance = {
+ id: id(),
+ speaker_id: speakerId,
+ text: '',
+ spoken_text: null,
+ source: 'tts',
+ asset_id: null,
+ source_start_sample: 0,
+ source_end_sample: null,
+ gap_after_sample: 9600,
+ delivery: '',
+ locked: false,
+ }
+ spec.dialogue.utterances.push(line)
+ sequence.utterance_ids.push(line.id)
+}
+
+export function removeUtterance(manifest: EditorManifestV3, lineId: string) {
+ const line = manifest.spec.dialogue.utterances.find((item) => item.id === lineId)
+ if (!line || line.locked) return
+ manifest.spec.dialogue.utterances = manifest.spec.dialogue.utterances.filter(
+ (item) => item.id !== lineId,
+ )
+ for (const sequence of manifest.spec.dialogue.sequences)
+ sequence.utterance_ids = sequence.utterance_ids.filter((item) => item !== lineId)
+ for (const shot of manifest.spec.shots)
+ if (shot.performance.native_utterance_ids)
+ shot.performance.native_utterance_ids = shot.performance.native_utterance_ids.filter(
+ (item) => item !== lineId,
+ )
+ manifest.captions.cues = manifest.captions.cues.filter((cue) => cue.utterance_id !== lineId)
+}
+
+export function setUtteranceCaption(
+ manifest: EditorManifestV3,
+ line: DialogueUtterance,
+ text: string,
+) {
+ const existing = manifest.captions.cues.find(
+ (cue) => cue.anchor === 'utterance' && cue.utterance_id === line.id,
+ )
+ if (existing) {
+ existing.text = text
+ existing.text_override = true
+ return
+ }
+ manifest.captions.cues.push({
+ id: id(),
+ anchor: 'utterance',
+ utterance_id: line.id,
+ start_frame: 0,
+ end_frame: 1,
+ text,
+ text_override: true,
+ timing_override: false,
+ })
+}
+
+export function audioTimelineEntries(manifest: EditorManifestV3) {
+ const shots = new Map()
+ const scenes = new Map()
+ let sample = 0
+ for (const shot of manifest.spec.shots) {
+ const start = sample
+ sample += (shot.edit.duration_frames - (shot.edit.dedup_frames ?? 0)) * 2000
+ shots.set(shot.id, start)
+ if (shot.scene_id) {
+ const span = scenes.get(shot.scene_id)
+ scenes.set(
+ shot.scene_id,
+ span === null || (span && span.end !== start)
+ ? null
+ : { start: span?.start ?? start, end: sample },
+ )
+ }
+ }
+ return (manifest.audio.layers ?? [])
+ .map((layer) => {
+ const anchor = layer.anchor ?? 'shot'
+ const origin =
+ anchor === 'absolute'
+ ? 0
+ : anchor === 'scene'
+ ? scenes.get(layer.scene_id ?? '')?.start
+ : shots.get(layer.shot_id ?? '')
+ return {
+ layer,
+ startSample: origin === undefined ? null : origin + (layer.offset_sample ?? 0),
+ }
+ })
+ .sort((a, b) => (a.startSample ?? Infinity) - (b.startSample ?? Infinity))
+}
diff --git a/frontend/src/domain/creation/editor.ts b/frontend/src/domain/creation/editor.ts
index 6eb425d..0abf84a 100644
--- a/frontend/src/domain/creation/editor.ts
+++ b/frontend/src/domain/creation/editor.ts
@@ -1,18 +1,21 @@
import { replaceWorkflowShots } from '../workflows/timeline'
-import type { StoryShot } from '../../types/stories'
+import type { StoryShot, StoryShotV5, StorySpecV5 } from '../../types/stories'
import type { WorkflowShot } from '../../types/workflows'
import type { EditorManifest, EditorSegment } from '../../types/editors'
import { newRequestId } from '../../utils/requestId'
+import { beginSequence, canChangeSequence, detachShot } from './dialogue'
export const editorId = () => newRequestId().replaceAll('-', '')
function renumber(m: EditorManifest) {
// 显式修改结构或时长才升级历史 v1;稳定 ID 与素材绑定不参与旧 key 编号。
if (m.source_kind === 'workflow' && (m.spec.schema_version === 1 || m.spec.schema_version === 2))
m.spec = replaceWorkflowShots(m.spec, m.spec.shots)
- else if (m.spec.schema_version === 4) m.spec.render.total_frames = editorFrames(m)
+ else if (m.spec.schema_version === 4 || m.spec.schema_version === 5)
+ m.spec.render.total_frames = editorFrames(m)
}
export function addEditorShot(m: EditorManifest, shot: StoryShot | WorkflowShot, id: string) {
m.spec.shots.push(shot as never)
m.shot_ids.push(id)
+ if (m.schema_version === 3 && 'performance' in shot) beginSequence(m.spec, shot as StoryShotV5)
renumber(m)
}
export function setEditorShotDuration(m: EditorManifest, index: number, frames: number) {
@@ -23,14 +26,39 @@ export function setEditorShotDuration(m: EditorManifest, index: number, frames:
renumber(m)
}
export function moveEditorShot(m: EditorManifest, index: number, target: number) {
- if (target < 0 || target >= m.shot_ids.length) return
+ if (!canMoveEditorShot(m, index, target)) return false
const id = m.shot_ids.splice(index, 1)[0]!,
shot = m.spec.shots.splice(index, 1)[0]!
m.shot_ids.splice(target, 0, id)
m.spec.shots.splice(target, 0, shot as never)
+ if (m.schema_version === 3)
+ for (const sequence of m.spec.dialogue.sequences)
+ sequence.shot_ids = m.shot_ids.filter((shotId) => sequence.shot_ids.includes(shotId))
renumber(m)
+ return true
+}
+export function canMoveEditorShot(m: EditorManifest, index: number, target: number) {
+ if (target < 0 || target >= m.shot_ids.length || !m.shot_ids[index]) return false
+ if (m.schema_version !== 3) return true
+ const spec: StorySpecV5 = m.spec
+ if (
+ spec.shots[index]?.performance.structure_locked ||
+ spec.shots[target]?.performance.structure_locked
+ )
+ return false
+ const next = [...m.shot_ids]
+ next.splice(target, 0, next.splice(index, 1)[0]!)
+ return spec.dialogue.sequences.every(({ shot_ids }) => {
+ const positions = shot_ids.map((id) => next.indexOf(id)).sort((a, b) => a - b)
+ return positions.at(-1)! - positions[0]! + 1 === positions.length
+ })
}
export function removeEditorShot(m: EditorManifest, index: number) {
+ if (m.schema_version === 3) {
+ const shot = m.spec.shots[index]
+ if (!shot || !canChangeSequence(m.spec, shot)) return false
+ detachShot(m.spec, shot)
+ }
const id = m.shot_ids.splice(index, 1)[0]
m.spec.shots.splice(index, 1)
delete m.bindings[`frame:${id}`]
@@ -45,13 +73,14 @@ export function removeEditorShot(m: EditorManifest, index: number) {
(c) => c.shot_id !== id && !removed.has(c.segment_id || ''),
)
renumber(m)
+ return true
}
export function editorFrames(m: EditorManifest) {
return m.spec.shots.reduce(
(n, s) =>
n +
('edit' in s
- ? s.edit.duration_frames - (m.schema_version === 2 ? (s.edit.dedup_frames ?? 0) : 0)
+ ? s.edit.duration_frames - (m.schema_version === 1 ? 0 : (s.edit.dedup_frames ?? 0))
: (s.duration_frames ?? 120)),
0,
)
diff --git a/frontend/src/domain/creation/videoProfile.native.test.ts b/frontend/src/domain/creation/videoProfile.native.test.ts
new file mode 100644
index 0000000..8ed97d5
--- /dev/null
+++ b/frontend/src/domain/creation/videoProfile.native.test.ts
@@ -0,0 +1,82 @@
+import { expect, it } from 'vitest'
+import {
+ H3_NATIVE_AV_TP2_PROFILE,
+ H3_TP2_VIDEO_PROFILE,
+ nativeStoryVideoCapability,
+ videoProfileCapability,
+} from './videoProfile'
+
+function capability(canvases?: unknown) {
+ return {
+ available: true,
+ defaults: {},
+ constraints: {},
+ canvases: [
+ [1344, 768],
+ [768, 1344],
+ ],
+ video_profiles: [
+ {
+ profile: H3_NATIVE_AV_TP2_PROFILE,
+ available: true,
+ defaults: {},
+ constraints: {},
+ ...(canvases === undefined ? {} : { canvases }),
+ },
+ ],
+ } as any
+}
+
+it('maps the historical dual-card choice but certifies only its exact native canvas', () => {
+ const caps = capability([[1344, 768]])
+ const parameters = { profile: H3_TP2_VIDEO_PROFILE, source_seconds: 6 }
+ const before = JSON.stringify(parameters)
+ expect(nativeStoryVideoCapability(parameters, 'landscape_1080_v1', caps)?.available).toBe(true)
+ const portrait = nativeStoryVideoCapability(parameters, 'portrait_1080_v1', caps)
+ expect(portrait?.available).toBe(false)
+ expect(portrait?.reason).toContain('当前仅横屏原生对白通过验收,竖屏原生暂不可生成')
+ expect(
+ videoProfileCapability({ profile: H3_NATIVE_AV_TP2_PROFILE, width: 768, height: 1344 }, caps)
+ ?.available,
+ ).toBe(false)
+ expect(
+ videoProfileCapability({ profile: H3_NATIVE_AV_TP2_PROFILE, width: 1344, height: 768 }, caps)
+ ?.available,
+ ).toBe(true)
+ expect(JSON.stringify(parameters)).toBe(before)
+})
+
+it('cannot inherit top-level canvas evidence when the native profile omits it', () => {
+ const caps = capability()
+ expect(
+ videoProfileCapability({ profile: H3_NATIVE_AV_TP2_PROFILE }, caps)?.canvases,
+ ).toBeUndefined()
+ expect(
+ nativeStoryVideoCapability({ profile: H3_NATIVE_AV_TP2_PROFILE }, 'landscape_1080_v1', caps)
+ ?.available,
+ ).toBe(false)
+})
+
+it('accepts both orientations only when both exact canvases are certified', () => {
+ const caps = capability([
+ [1344, 768],
+ [768, 1344],
+ ])
+ expect(
+ nativeStoryVideoCapability({ profile: H3_NATIVE_AV_TP2_PROFILE }, 'portrait_1080_v1', caps)
+ ?.available,
+ ).toBe(true)
+ expect(
+ nativeStoryVideoCapability({ profile: H3_NATIVE_AV_TP2_PROFILE }, 'unknown', caps)?.available,
+ ).toBe(false)
+ caps.video_profiles[0].canvases = [[768, 1344, 24]]
+ expect(
+ nativeStoryVideoCapability({ profile: H3_NATIVE_AV_TP2_PROFILE }, 'portrait_1080_v1', caps)
+ ?.available,
+ ).toBe(false)
+ caps.video_profiles[0].canvases = [[768, '1344']]
+ expect(
+ nativeStoryVideoCapability({ profile: H3_NATIVE_AV_TP2_PROFILE }, 'portrait_1080_v1', caps)
+ ?.available,
+ ).toBe(false)
+})
diff --git a/frontend/src/domain/creation/videoProfile.ts b/frontend/src/domain/creation/videoProfile.ts
index 8070047..64f9ac2 100644
--- a/frontend/src/domain/creation/videoProfile.ts
+++ b/frontend/src/domain/creation/videoProfile.ts
@@ -2,11 +2,16 @@ import type { Capability } from '../../types'
export const H3_VIDEO_PROFILE = 'minimax-h3-fl2va-bf16-v1'
export const H3_TP2_VIDEO_PROFILE = 'minimax-h3-fl2va-bf16-tp2-v1'
+export const H3_NATIVE_AV_PROFILE = 'minimax-h3-fl2va-native-av-v1'
+export const H3_NATIVE_AV_TP2_PROFILE = 'minimax-h3-fl2va-native-av-tp2-v1'
+export const H3_NATIVE_LANDSCAPE_ONLY_DESCRIPTION = '当前仅横屏原生对白通过验收,竖屏原生暂不可生成'
export const H3_TP2_WAITING_DESCRIPTION = '双卡任务会在队列中等待两张空闲GPU一起开始。'
export const H3_TP2_UNAVAILABLE_REASON = '上游H3双卡尚未完成认证。'
export const LEGACY_VIDEO_PROFILE = 'wan2.2-ti2v-5b-v1'
export const isH3Video = (parameters: Record) =>
- parameters.profile === H3_VIDEO_PROFILE || parameters.profile === H3_TP2_VIDEO_PROFILE
+ [H3_VIDEO_PROFILE, H3_TP2_VIDEO_PROFILE, H3_NATIVE_AV_PROFILE, H3_NATIVE_AV_TP2_PROFILE].includes(
+ parameters.profile,
+ )
export function storySourceBounds(parameters: Record) {
return {
@@ -37,6 +42,30 @@ export function videoProfileCapability(
if (!capability) return undefined
const profile = parameters.profile ?? LEGACY_VIDEO_PROFILE
const selected = capability.video_profiles?.find((item) => item.profile === profile)
+ if ([H3_NATIVE_AV_PROFILE, H3_NATIVE_AV_TP2_PROFILE].includes(profile)) {
+ const hasDimensions = parameters.width !== undefined || parameters.height !== undefined
+ const canvasIssue =
+ hasDimensions && !includesCanvas(selected?.canvases, parameters.width, parameters.height)
+ ? parameters.width === 768 &&
+ parameters.height === 1344 &&
+ includesCanvas(selected?.canvases, 1344, 768)
+ ? H3_NATIVE_LANDSCAPE_ONLY_DESCRIPTION
+ : '当前请求画布尚无原生对白认证证据,暂不可生成。'
+ : undefined
+ return {
+ ...capability,
+ ...selected,
+ available: selected?.available === true && !canvasIssue,
+ canvases: selected?.canvases,
+ reason:
+ selected?.available === true
+ ? canvasIssue || null
+ : selected?.reason || '上游H3原生音频尚未升级',
+ constraints: selected?.constraints ?? {
+ num_frames: { min: 124, max: profile === H3_NATIVE_AV_TP2_PROFILE ? 158 : 345, step: 17 },
+ },
+ }
+ }
// 首版双卡容量固定为六秒;旧能力快照不能继承默认模型的可用状态或更长时长。
if (profile === H3_TP2_VIDEO_PROFILE)
return {
@@ -84,6 +113,58 @@ export function videoProfileCapability(
}
}
+function includesCanvas(canvases: unknown, width: number, height: number) {
+ return (
+ Array.isArray(canvases) &&
+ canvases.some(
+ (canvas) =>
+ Array.isArray(canvas) &&
+ canvas.length === 2 &&
+ Number.isInteger(canvas[0]) &&
+ Number.isInteger(canvas[1]) &&
+ canvas[0] === width &&
+ canvas[1] === height,
+ )
+ )
+}
+
+export function nativeCanvasIssue(storyProfile: string, canvases: unknown): string | undefined {
+ if (!['landscape_1080_v1', 'portrait_1080_v1'].includes(storyProfile))
+ return '当前故事画布尚无原生对白认证证据,暂不可生成。'
+ const portrait = storyProfile === 'portrait_1080_v1'
+ if (includesCanvas(canvases, portrait ? 768 : 1344, portrait ? 1344 : 768)) return
+ return portrait && includesCanvas(canvases, 1344, 768)
+ ? H3_NATIVE_LANDSCAPE_ONLY_DESCRIPTION
+ : '当前故事画布尚无原生对白认证证据,暂不可生成。'
+}
+
+export function nativeLandscapeOnly(capability?: Capability) {
+ const canvases = capability?.video_profiles
+ ?.filter(
+ (profile) =>
+ [H3_NATIVE_AV_PROFILE, H3_NATIVE_AV_TP2_PROFILE].includes(profile.profile) &&
+ profile.available === true,
+ )
+ .flatMap((profile) => profile.canvases ?? [])
+ return includesCanvas(canvases, 1344, 768) && !includesCanvas(canvases, 768, 1344)
+}
+
+export function nativeStoryVideoCapability(
+ parameters: Record,
+ storyProfile: string,
+ capability?: Capability,
+): Capability | undefined {
+ const profile = [H3_TP2_VIDEO_PROFILE, H3_NATIVE_AV_TP2_PROFILE].includes(parameters.profile)
+ ? H3_NATIVE_AV_TP2_PROFILE
+ : H3_NATIVE_AV_PROFILE
+ const selected = videoProfileCapability({ profile }, capability)
+ if (!selected) return undefined
+ const issue = selected.available
+ ? nativeCanvasIssue(storyProfile, selected.canvases)
+ : selected.reason
+ return { ...selected, available: selected.available === true && !issue, reason: issue || null }
+}
+
export function selectVideoProfile(parameters: Record, profile: string) {
const portrait = parameters.width < parameters.height
const h3 = isH3Video({ profile })
diff --git a/frontend/src/domain/stories/rules.ts b/frontend/src/domain/stories/rules.ts
index e167333..041d25c 100644
--- a/frontend/src/domain/stories/rules.ts
+++ b/frontend/src/domain/stories/rules.ts
@@ -1,6 +1,8 @@
import type {
StorySpec,
StoryShot,
+ StoryShotV5,
+ StorySpecV3,
StoryEntity,
StoryScene,
StoryVariant,
@@ -10,6 +12,8 @@ import { validateWorkflow } from '../workflows/timeline'
import { newRequestId } from '../../utils/requestId'
import {
H3_VIDEO_PROFILE,
+ H3_NATIVE_AV_PROFILE,
+ H3_NATIVE_AV_TP2_PROFILE,
H3_TP2_VIDEO_PROFILE,
LEGACY_VIDEO_PROFILE,
isH3Video,
@@ -28,6 +32,9 @@ export function createScene(): StoryScene {
return { ...createVariant('新场景'), location: '', time: '', weather: '', lighting: '' }
}
import { continuityState } from '../creation/continuity'
+import { defaultPerformance } from '../creation/dialogue'
+export function createShot(version: 5): StoryShotV5
+export function createShot(version?: number): StoryShot
export function createShot(version: number = 3): StoryShot {
const shot: StoryShot = {
id: stableId(),
@@ -51,6 +58,12 @@ export function createShot(version: number = 3): StoryShot {
shot.continuity = continuityState()
selectNativeProfile(shot)
}
+ if (version === 5)
+ return {
+ ...shot,
+ continuity: continuityState(),
+ performance: defaultPerformance(),
+ } as StoryShotV5
return shot
}
export function selectNativeProfile(shot: StoryShot) {
@@ -64,7 +77,7 @@ export function selectNativeProfile(shot: StoryShot) {
delete shot.video_parameters.guidance_scale
shot.video_parameters.num_inference_steps = Math.max(2, shot.video_parameters.num_inference_steps)
}
-export function emptyStory(): StorySpec {
+export function emptyStory(): StorySpecV3 {
return {
schema_version: 3,
profile: 'landscape_1080_v1',
@@ -100,7 +113,10 @@ export function videoGenerationIssue(shot: StoryShot) {
? `选用区间 ${shot.edit.start_frame}–${end} 帧超过待生成源 ${shot.video_parameters.source_seconds} 秒(${sourceFrames} 帧)。请增加生成长度或调整选用区间;人工视频按实际素材范围校验。`
: ''
}
-export function replaceShots(spec: StorySpec, shots: StoryShot[]): StorySpec {
+export function replaceShots(
+ spec: StorySpecV3 | import('../../types/stories').StorySpecV4,
+ shots: StoryShot[],
+): StorySpecV3 | import('../../types/stories').StorySpecV4 {
return {
...spec,
shots,
@@ -157,18 +173,28 @@ function integer(value: number, min: number, max: number, label: string) {
throw new Error(`${label}须为 ${min}–${max} 的整数`)
}
export function validateStory(spec: StorySpec, maxShots = 120) {
+ const hasSampleTiming = spec.schema_version === 4 || spec.schema_version === 5
keys(
spec,
- ['schema_version', 'profile', 'context', 'scenes', 'entities', 'shots', 'render'],
+ [
+ 'schema_version',
+ 'profile',
+ 'context',
+ 'scenes',
+ 'entities',
+ 'shots',
+ 'render',
+ ...(spec.schema_version === 5 ? ['dialogue'] : []),
+ ],
'故事',
)
if (
- ![3, 4].includes(spec.schema_version) ||
+ ![3, 4, 5].includes(spec.schema_version) ||
!Array.isArray(spec.shots) ||
!Array.isArray(spec.entities) ||
!Array.isArray(spec.scenes)
)
- throw new Error('故事须为版本 3')
+ throw new Error('故事版本或结构无效')
integer(spec.shots.length, 1, maxShots, '镜头数量')
keys(spec.context, ['era', 'style', 'palette', 'lighting', 'negative_prompt'], '故事上下文')
Object.values(spec.context).forEach(text)
@@ -218,7 +244,8 @@ export function validateStory(spec: StorySpec, maxShots = 120) {
'frame_parameters',
'video_parameters',
'edit',
- ...(spec.schema_version === 4 ? ['continuity'] : []),
+ ...(hasSampleTiming ? ['continuity'] : []),
+ ...(spec.schema_version === 5 ? ['performance'] : []),
],
'镜头',
)
@@ -252,7 +279,7 @@ export function validateStory(spec: StorySpec, maxShots = 120) {
'profile',
'seed',
'source_seconds',
- ...(spec.schema_version === 4 ? ['source_frames'] : []),
+ ...(hasSampleTiming ? ['source_frames'] : []),
'num_inference_steps',
'guidance_scale',
'upscale',
@@ -261,10 +288,18 @@ export function validateStory(spec: StorySpec, maxShots = 120) {
)
integer(shot.video_parameters.seed, 0, 4294967295, '视频种子')
const native =
- spec.schema_version === 4 && shot.video_parameters.profile === 'minimax-h3-fl2va-bf16-v2'
+ hasSampleTiming &&
+ ['minimax-h3-fl2va-bf16-v2', H3_NATIVE_AV_PROFILE, H3_NATIVE_AV_TP2_PROFILE].includes(
+ shot.video_parameters.profile ?? '',
+ )
if (native) {
const frames = shot.video_parameters.source_frames ?? 0
- integer(frames, 124, 345, '原生帧数')
+ integer(
+ frames,
+ 124,
+ shot.video_parameters.profile === H3_NATIVE_AV_TP2_PROFILE ? 158 : 345,
+ '原生帧数',
+ )
if ((frames - 124) % 17) throw new Error('原生帧数步长为17')
} else integer(shot.video_parameters.source_seconds ?? 0, 1, 15, '源视频秒数')
if (
@@ -294,7 +329,7 @@ export function validateStory(spec: StorySpec, maxShots = 120) {
throw new Error('视频引导系数或增强参数不合法')
keys(
shot.edit,
- ['start_frame', 'duration_frames', ...(spec.schema_version === 4 ? ['dedup_frames'] : [])],
+ ['start_frame', 'duration_frames', ...(hasSampleTiming ? ['dedup_frames'] : [])],
'选用区间',
)
if (!Number.isSafeInteger(shot.edit.start_frame) || shot.edit.start_frame < 0)
@@ -311,7 +346,7 @@ export function validateStory(spec: StorySpec, maxShots = 120) {
const samples = audio && 'sample_rate' in audio ? audio : null
if (samples) {
if (
- spec.schema_version !== 4 ||
+ !hasSampleTiming ||
samples.sample_rate !== 48000 ||
!samples.asset_id ||
![samples.offset_sample, samples.source_start_sample, samples.source_end_sample].every(
diff --git a/frontend/src/services/recordDeletion.ts b/frontend/src/services/recordDeletion.ts
index a61398b..9d85d7f 100644
--- a/frontend/src/services/recordDeletion.ts
+++ b/frontend/src/services/recordDeletion.ts
@@ -1,9 +1,10 @@
import { useJobsStore } from '../stores/jobs'
import { useWorkflowsStore } from '../stores/workflows'
import { useStoriesStore } from '../stores/stories'
+import { useAssetsStore } from '../stores/assets'
import type { DeletedRecords } from '../types'
-// 删除响应中的 ID 是权威级联范围;这里只清记录和本地引用,生成素材由素材库独立管理。
+// 以服务端实际清理的 ID 为准,故事之外仍有引用或已收藏的素材保留在缓存中。
export function applyDeleted(deleted: Partial) {
const jobs = useJobsStore(),
workflows = useWorkflowsStore()
@@ -14,4 +15,9 @@ export function applyDeleted(deleted: Partial) {
useStoriesStore().forgetStory(id)
}
for (const id of deleted.batch_ids || []) workflows.forgetBatch(id)
+ if (deleted.asset_ids?.length) {
+ const assets = useAssetsStore()
+ for (const id of deleted.asset_ids) assets.forget(id)
+ assets.notifyRemote()
+ }
}
diff --git a/frontend/src/stores/capabilities.ts b/frontend/src/stores/capabilities.ts
index 968e711..bfe5b87 100644
--- a/frontend/src/stores/capabilities.ts
+++ b/frontend/src/stores/capabilities.ts
@@ -2,6 +2,7 @@ import { defineStore } from 'pinia'
import { ref } from 'vue'
import { api } from '../api'
import type { Capability, Scheduler, TaskType, ExecutionPolicy, WorkflowLimits } from '../types'
+import type { DialogueCapability } from '../types/capabilities'
const legacyWorkflowLimits: WorkflowLimits = {
max_shots: 120,
@@ -21,6 +22,7 @@ export const useCapabilitiesStore = defineStore('capabilities', () => {
max_total_frames: number
}>()
const editableProduction = ref(false)
+ const dialogue = ref()
const items = ref([])
const scheduler = ref(null)
const loading = ref(false)
@@ -32,6 +34,7 @@ export const useCapabilitiesStore = defineStore('capabilities', () => {
const databaseBackend = ref<'mysql' | 'sqlite' | null>(null)
async function load() {
continuity.value = undefined
+ dialogue.value = undefined
editableProduction.value = false
loading.value = true
try {
@@ -39,6 +42,7 @@ export const useCapabilitiesStore = defineStore('capabilities', () => {
items.value = response.items
editableProduction.value = response.editable_production?.schema_version === 1
const editor = response.editable_production
+ dialogue.value = response.dialogue ?? editor?.dialogue
if (
editor?.supported_schema_versions?.includes(2) &&
editor.story_schema_versions?.includes(4)
@@ -65,6 +69,7 @@ export const useCapabilitiesStore = defineStore('capabilities', () => {
}
return {
continuity,
+ dialogue,
editableProduction,
inferenceOnline,
executionPolicy,
diff --git a/frontend/src/stores/stories.ts b/frontend/src/stores/stories.ts
index 6e6e5e3..fac3db8 100644
--- a/frontend/src/stores/stories.ts
+++ b/frontend/src/stores/stories.ts
@@ -300,8 +300,8 @@ export const useStoriesStore = defineStore('stories', () => {
const result = await guarded(() => api.deleteStory(story.id, story.version), session)
if (result) {
if (result.deleted) applyDeleted(result.deleted)
- forgetStory(story.id)
- return true
+ if (!deleted.value[story.id]) forgetStory(story.id)
+ return result
}
}
async function removeCandidate(story: StoryDTO, candidate: CandidateDTO, session = epoch) {
diff --git a/frontend/src/styles/forms.css b/frontend/src/styles/forms.css
index 9792775..78333b8 100644
--- a/frontend/src/styles/forms.css
+++ b/frontend/src/styles/forms.css
@@ -4,7 +4,9 @@
--ui-control-height: 36px;
--ui-control-gap: 12px;
--ui-form-row-gap: 16px;
+ --ui-label-height: 20px;
--ui-label-gap: 8px;
+ --ui-label-slot: calc(var(--ui-label-height) + var(--ui-label-gap));
--ui-button-min-width: 96px;
--el-component-size: var(--ui-control-height);
--el-component-size-small: var(--ui-control-height);
@@ -91,8 +93,22 @@
.ui-actions {
align-items: center;
}
-.ui-form-row:has(> :is(label, .ui-field, .el-form-item)) {
- /* 带标签的字段与旁边按钮按控件底边对齐,纯按钮组仍按自身内容对齐。 */
+/* 标题不参与控件的中线计算;36px输入、勾选项和按钮共享同一条控件行。
+ * :root保证公共布局优先于组件内普通toolbar的默认居中,纯操作组保持紧凑。 */
+:root
+ :is(.ui-form-row, .ui-form-grid):has(
+ > label
+ > :is(
+ input:not([type='checkbox'], [type='radio'], [type='file'], [type='hidden']),
+ select,
+ textarea,
+ .el-input,
+ .el-select,
+ .el-input-number
+ ),
+ > .ui-field,
+ > .el-form-item
+ ) {
align-items: flex-end;
}
:is(.ui-form-grid, .ui-form-row) > :is(label, .ui-field) {
@@ -106,12 +122,77 @@
max-width: 100%;
margin: 0;
font-size: 13px;
+ line-height: var(--ui-label-height);
}
-:is(.ui-form-grid, .ui-form-row) > label:has(input:is([type='checkbox'], [type='radio'])) {
+:is(.ui-form-grid, .ui-form-row, .ui-actions)
+ > label:has(input:is([type='checkbox'], [type='radio'])) {
+ display: flex;
flex-direction: row;
align-items: center;
+ gap: var(--ui-label-gap);
width: auto;
flex-basis: auto;
+ min-height: var(--ui-control-height);
+ margin: 0;
+ font-size: 13px;
+ line-height: var(--ui-label-height);
+}
+:is(.ui-form-grid, .ui-form-row, .ui-actions) > label input:is([type='checkbox'], [type='radio']) {
+ margin: 0;
+}
+/* 无独立标题的勾选项也保留标题槽,换行后仍与同组的输入区域对齐。 */
+:root
+ :is(.ui-form-row, .ui-form-grid):has(
+ > label
+ > :is(
+ input:not([type='checkbox'], [type='radio'], [type='file'], [type='hidden']),
+ select,
+ textarea,
+ .el-input,
+ .el-select,
+ .el-input-number
+ ),
+ > .ui-field,
+ > .el-form-item
+ )
+ > label:has(input:is([type='checkbox'], [type='radio'])) {
+ width: auto;
+ flex-basis: auto;
+ min-height: calc(var(--ui-label-slot) + var(--ui-control-height));
+ padding-block-start: var(--ui-label-slot);
+}
+/* 裸控件无需逐页包假label;占位用外边距承担,不改变控件本身36px高度。 */
+:root
+ :is(.ui-form-row, .ui-form-grid):has(
+ > label
+ > :is(
+ input:not([type='checkbox'], [type='radio'], [type='file'], [type='hidden']),
+ select,
+ textarea,
+ .el-input,
+ .el-select,
+ .el-input-number
+ ),
+ > .ui-field,
+ > .el-form-item
+ )
+ > :is(
+ button,
+ select,
+ input:not([type='checkbox'], [type='radio'], [type='file'], [type='hidden'], [type='range']),
+ .el-input,
+ .el-select,
+ .el-input-number,
+ .ui-actions
+ ) {
+ margin-block-start: var(--ui-label-slot);
+ margin-block-end: 0;
+ min-height: var(--ui-control-height);
+}
+/* 复合控件可显式声明一个无标题字段,语义label仍由实际控件提供。 */
+:is(.ui-form-grid, .ui-form-row) > .ui-field--unlabelled::before {
+ content: '';
+ flex: 0 0 var(--ui-label-height);
}
:is(.ui-form-grid, .ui-form-row) > .el-form-item {
width: var(--ui-control-width);
@@ -121,6 +202,10 @@
/* 行距由布局统一承担,避免组件自带margin再与gap叠加。 */
margin: 0;
}
+:is(.ui-form-grid, .ui-form-row) > .el-form-item:not(:has(> .el-form-item__label)) {
+ /* Element字段省略label时仍占标题槽,不让其内容与相邻标题错误居中。 */
+ padding-block-start: var(--ui-label-slot);
+}
.ui-field--full,
:is(.ui-form-grid, .ui-form-row) > .ui-field--full {
grid-column: 1 / -1;
diff --git a/frontend/src/styles/studio.css b/frontend/src/styles/studio.css
index cf423f1..f9e80a4 100644
--- a/frontend/src/styles/studio.css
+++ b/frontend/src/styles/studio.css
@@ -288,6 +288,18 @@
max-width: 100%;
flex: 0 0 auto;
}
+.story-film-player {
+ display: block;
+ width: min(100%, 28rem);
+ max-height: min(38vh, 320px);
+ background: #101216;
+ border-radius: 6px;
+}
+.editable-production > .story-film-preview {
+ padding: 0 0 12px;
+ border-right: 0;
+ border-bottom: 1px solid var(--line);
+}
.story-film-details {
min-width: 0;
flex: 1 1 200px;
@@ -321,7 +333,7 @@
border-radius: 14px;
padding: 16px;
}
-.story-studio.is-shots {
+.story-studio:is(.is-shots, .has-dialogue) {
display: flex;
flex-direction: column;
max-width: none;
@@ -333,7 +345,7 @@
display: flex;
overflow: hidden;
}
-.story-studio.is-shots > .editable-production {
+.story-studio:is(.is-shots, .has-dialogue) > .editable-production {
flex: 1;
min-height: 0;
margin-bottom: 0;
@@ -361,7 +373,8 @@
background: #607885;
}
}
-.story-studio.is-shots > :is(.story-studio-toolbar, .story-navigation, .notice, .story-save-hint) {
+.story-studio:is(.is-shots, .has-dialogue)
+ > :is(.story-studio-toolbar, .story-navigation, .notice, .story-save-hint) {
flex-shrink: 0;
}
.story-studio.is-shots > .story-workspace {
diff --git a/frontend/src/types/capabilities.ts b/frontend/src/types/capabilities.ts
index e8ac431..23a6811 100644
--- a/frontend/src/types/capabilities.ts
+++ b/frontend/src/types/capabilities.ts
@@ -16,6 +16,7 @@ export interface Capability {
defaults: Record
constraints: Record
description: string
+ canvases?: [number, number][]
video_profiles?: {
profile: string
model: string
@@ -24,6 +25,7 @@ export interface Capability {
defaults: Record
constraints: Record
description: string
+ canvases?: [number, number][]
}[]
}
@@ -67,12 +69,31 @@ export interface WorkflowLimits {
max_clip_frames: number
fps: number
}
+export interface DialogueCapability {
+ available: boolean
+ authoring_available?: boolean
+ production_available?: boolean
+ reason?: string | null
+ max_visible_speakers?: number
+ supports_single_face?: boolean
+ supports_two_faces?: boolean
+ native_av?: {
+ available: boolean
+ reason?: string | null
+ languages?: string[]
+ max_visible_speakers?: number
+ profiles?: string[]
+ readiness?: unknown
+ }
+}
export interface CapabilitiesResponse {
+ dialogue?: DialogueCapability
editable_production?: {
schema_version: number
supported_schema_versions?: number[]
story_schema_versions?: number[]
+ dialogue?: DialogueCapability
continuity?: {
available: boolean
reason?: string
diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.ts
index b31193e..f4a2e75 100644
--- a/frontend/src/types/common.ts
+++ b/frontend/src/types/common.ts
@@ -1,4 +1,5 @@
export interface DeletedRecords {
+ asset_ids?: string[]
job_ids: string[]
run_ids: string[]
draft_ids: string[]
@@ -7,6 +8,7 @@ export interface DeletedRecords {
export interface DeleteResult {
deleted: DeletedRecords
+ pending?: boolean
}
export interface Page {
diff --git a/frontend/src/types/editors.ts b/frontend/src/types/editors.ts
index e7d9249..0c93a5f 100644
--- a/frontend/src/types/editors.ts
+++ b/frontend/src/types/editors.ts
@@ -1,5 +1,5 @@
import type { Asset } from './assets'
-import type { StorySpec, StoryDTO } from './stories'
+import type { StorySpecV3, StorySpecV4, StorySpecV5, StoryDTO } from './stories'
import type { WorkflowSpec } from './workflows'
export interface EditorBinding {
asset_id: string
@@ -35,9 +35,10 @@ export interface EditorSegment extends AudioPosition {
}
export interface EditorCue {
id: string
- anchor: 'absolute' | 'shot' | 'audio_segment'
+ anchor: 'absolute' | 'shot' | 'audio_segment' | 'utterance'
shot_id?: string
segment_id?: string
+ utterance_id?: string
start_frame: number
end_frame: number
text: string
@@ -51,12 +52,9 @@ export interface EditingCapabilities {
manual: boolean
auto: boolean
}
-export interface EditorManifest {
+interface EditorManifestBase {
editing_mode?: EditingMode
base_run_id?: string | null
- schema_version: 1 | 2
- source_kind: 'story' | 'workflow'
- spec: StorySpec | WorkflowSpec
shot_ids: string[]
bindings: Record
audio: {
@@ -79,6 +77,17 @@ export interface EditorManifest {
}
captions: { mode: 'none' | 'manual' | 'script' | 'ai_script'; cues: EditorCue[] }
}
+export type EditorManifestLegacy = EditorManifestBase & { schema_version: 1 | 2 } & (
+ | { source_kind: 'story'; spec: StorySpecV3 | StorySpecV4 }
+ | { source_kind: 'workflow'; spec: WorkflowSpec }
+ )
+export interface EditorManifestV3 extends EditorManifestBase {
+ schema_version: 3
+ source_kind: 'story'
+ spec: StorySpecV5
+ audio: EditorManifestBase['audio'] & { mix_mode: 'composed' | 'manual_mix' }
+}
+export type EditorManifest = EditorManifestLegacy | EditorManifestV3
export interface EditorDTO {
editing_mode?: EditingMode
capabilities?: EditingCapabilities
@@ -91,6 +100,9 @@ export interface EditorDTO {
issues: { code: string; message: string; shot_id?: string }[]
assets: Asset[]
}
+export interface PreparedDialogueFork extends EditorDTO {
+ origin: { source_draft_id: string; source_run_id: string }
+}
export interface EditorPlanInput {
expected_version: number
output_goal: 'media' | 'film'
diff --git a/frontend/src/types/jobs.ts b/frontend/src/types/jobs.ts
index e4dd66e..eb02470 100644
--- a/frontend/src/types/jobs.ts
+++ b/frontend/src/types/jobs.ts
@@ -9,6 +9,8 @@ export type TaskType =
| 'defect.generate'
| 'audio.transcribe'
| 'audio.speech'
+ | 'audio.dialogue.speech'
+ | 'video.lipsync'
| 'audio.assemble'
| 'text.script.generate'
| 'math.solve'
diff --git a/frontend/src/types/stories.ts b/frontend/src/types/stories.ts
index cf80b9e..3998909 100644
--- a/frontend/src/types/stories.ts
+++ b/frontend/src/types/stories.ts
@@ -48,8 +48,66 @@ export interface StoryShot {
}
edit: { dedup_frames?: 0 | 1; start_frame: number; duration_frames: number }
}
-export interface StorySpec {
- schema_version: 3 | 4
+export interface DialogueVoice {
+ provider: 'kokoro' | 'voxcpm2'
+ model: string
+ voice: string
+ reference_asset_id: string | null
+ reference_text: string
+ style: string
+ speed: number
+ seed: number
+ revision: number
+}
+export interface DialogueSpeaker {
+ id: string
+ entity_id: string | null
+ name: string
+ voice: DialogueVoice
+ native_voice?: string | null
+}
+export interface DialogueUtterance {
+ id: string
+ speaker_id: string
+ text: string
+ spoken_text: string | null
+ source: 'tts' | 'asset'
+ asset_id: string | null
+ source_start_sample: number
+ source_end_sample: number | null
+ gap_after_sample: number
+ delivery: string
+ locked: boolean
+}
+export interface DialogueSequence {
+ id: string
+ scene_id: string | null
+ shot_ids: string[]
+ utterance_ids: string[]
+ timing_mode: 'auto' | 'fixed'
+}
+export interface ShotPerformance {
+ sequence_id: string | null
+ visible_speaker_ids: string[]
+ lip_sync: 'auto' | 'required' | 'off'
+ audio_context_shift_frames?: number
+ duration_mode: 'auto' | 'fixed'
+ structure_locked: boolean
+ original_audio: 'discard' | 'preserve'
+ native_utterance_ids?: string[] | null
+}
+export interface DialogueSpec {
+ enabled: boolean
+ generation?: 'native_av' | null
+ language?: string | null
+ speakers: DialogueSpeaker[]
+ utterances: DialogueUtterance[]
+ sequences: DialogueSequence[]
+}
+export interface StoryShotV5 extends StoryShot {
+ performance: ShotPerformance
+}
+interface StorySpecBase {
profile: WorkflowSpec['profile']
context: {
era: string
@@ -63,8 +121,18 @@ export interface StorySpec {
shots: StoryShot[]
render: Omit & { audio: EditorManifest['audio']['track'] }
}
-export type StorySpecV3 = StorySpec & { schema_version: 3 }
-export type StorySpecV4 = StorySpec & { schema_version: 4 }
+export interface StorySpecV3 extends StorySpecBase {
+ schema_version: 3
+}
+export interface StorySpecV4 extends StorySpecBase {
+ schema_version: 4
+}
+export interface StorySpecV5 extends Omit {
+ schema_version: 5
+ shots: StoryShotV5[]
+ dialogue: DialogueSpec
+}
+export type StorySpec = StorySpecV3 | StorySpecV4 | StorySpecV5
export type CandidateKind = 'frame' | 'end_frame' | 'video'
export interface StoryIssue {
shot_id?: string
diff --git a/frontend/src/types/workflows.ts b/frontend/src/types/workflows.ts
index 163e656..b9cdda5 100644
--- a/frontend/src/types/workflows.ts
+++ b/frontend/src/types/workflows.ts
@@ -61,6 +61,7 @@ export interface RunDTO {
run_kind?: string
output_goal?: 'media' | 'film'
apply_state?: string | null
+ production_materialized?: boolean
editor_manifest?: EditorManifest | null
folder_id?: string | null
output_folder_id?: string | null
diff --git a/frontend/src/utils/dialogueFixture.ts b/frontend/src/utils/dialogueFixture.ts
new file mode 100644
index 0000000..ee7f188
--- /dev/null
+++ b/frontend/src/utils/dialogueFixture.ts
@@ -0,0 +1,115 @@
+import { emptyStory } from '../domain/stories/rules'
+import type { EditorDTO, EditorManifest } from '../types/editors'
+
+export function dialogueFixture(): EditorDTO {
+ const story = emptyStory()
+ const first = story.shots[0]!
+ const secondId = '1'.repeat(32)
+ const entityId = '2'.repeat(32)
+ const speakerId = '3'.repeat(32)
+ const sequenceId = '4'.repeat(32)
+ const utteranceId = '5'.repeat(32)
+ const performance = {
+ sequence_id: sequenceId,
+ visible_speaker_ids: [],
+ lip_sync: 'auto',
+ audio_context_shift_frames: 0,
+ duration_mode: 'auto',
+ structure_locked: false,
+ original_audio: 'discard',
+ }
+ const spec = {
+ ...story,
+ schema_version: 5,
+ entities: [
+ {
+ id: entityId,
+ kind: 'person',
+ name: '修理师',
+ description: '',
+ reference_asset_ids: [],
+ forms: [],
+ appearances: [],
+ },
+ ],
+ shots: [
+ { ...first, performance },
+ {
+ ...first,
+ id: secondId,
+ edit: { ...first.edit },
+ performance: { ...performance, visible_speaker_ids: [] },
+ },
+ ],
+ render: { ...story.render, total_frames: 240 },
+ dialogue: {
+ enabled: true,
+ speakers: [
+ {
+ id: speakerId,
+ name: '修理师',
+ entity_id: entityId,
+ voice: {
+ provider: 'kokoro',
+ model: 'kokoro-82m',
+ voice: 'zf_xiaobei',
+ reference_asset_id: null,
+ reference_text: '',
+ style: '',
+ speed: 1,
+ seed: 42,
+ revision: 1,
+ },
+ },
+ ],
+ sequences: [
+ {
+ id: sequenceId,
+ scene_id: null,
+ shot_ids: [first.id, secondId],
+ utterance_ids: [utteranceId],
+ timing_mode: 'auto',
+ },
+ ],
+ utterances: [
+ {
+ id: utteranceId,
+ speaker_id: speakerId,
+ text: '灯亮了。',
+ spoken_text: null,
+ source: 'tts',
+ asset_id: null,
+ source_start_sample: 0,
+ source_end_sample: null,
+ gap_after_sample: 9600,
+ delivery: '',
+ locked: false,
+ },
+ ],
+ },
+ }
+ return {
+ draft_id: 'd',
+ version: 1,
+ revision: 1,
+ name: 'd',
+ issues: [],
+ assets: [],
+ manifest: {
+ schema_version: 3,
+ source_kind: 'story',
+ spec,
+ shot_ids: [first.id, secondId],
+ bindings: {},
+ audio: {
+ mode: 'silent',
+ voice: 'default',
+ speed: 1,
+ track: null,
+ segments: [],
+ mix_mode: 'composed',
+ },
+ captions: { mode: 'script', cues: [] },
+ } as EditorManifest,
+ }
+}
diff --git a/frontend/src/utils/format.ts b/frontend/src/utils/format.ts
index 0e3f373..a8ccf93 100644
--- a/frontend/src/utils/format.ts
+++ b/frontend/src/utils/format.ts
@@ -8,6 +8,8 @@ export const taskLabels: Record = {
'defect.generate': '缺陷样本',
'audio.transcribe': '语音转写',
'audio.speech': '语音生成',
+ 'audio.dialogue.speech': '角色配音',
+ 'video.lipsync': '对白口型',
'audio.assemble': '旁白音轨装配',
'text.script.generate': '旁白文案生成',
'math.solve': '数学推演',
@@ -123,6 +125,8 @@ export function workflowState(value: string) {
needs_attention: '需要处理',
succeeded: '已完成',
failed: '失败',
+ accepted: '已选用',
+ rejected: '未选用',
cancelled: '已取消',
cancelling: '取消中',
completed_with_errors: '完成(含失败)',
@@ -152,7 +156,37 @@ export function holdLabel(value: string) {
)
}
+const dialogueStepLabels: Record = {
+ nv: ['镜', 'H3原生音画'],
+ na: ['镜', '提取原生音轨'],
+ nq: ['镜', '原生对白识别'],
+ nr: ['镜', '原生画面质检'],
+ ng: ['镜', '原生对白验收'],
+ sp: ['句', '配音'],
+ sn: ['句', '音频归一化'],
+ sq: ['句', '语音质检'],
+ np: ['段', '旁白配音'],
+ nn: ['段', '旁白归一化'],
+ ln: ['条', '音轨归一化'],
+ frame: ['镜', '首帧生成'],
+ video: ['镜', '原片生成'],
+ sel: ['镜', '画面选段'],
+ review: ['镜', '原片质检'],
+ face: ['镜', '人物定位'],
+ stem: ['镜', '对白干声'],
+ lip: ['镜', '口型同步'],
+ syncqa: ['镜', '口型质检'],
+ accepted: ['镜', '确认选用'],
+ orig: ['镜', '原声提取'],
+}
+
export function workflowStepLabel(key: string) {
+ const match = /^([a-z]+)_(\d{4})(?:_(\d+))?$/.exec(key)
+ const meaning = match && dialogueStepLabels[match[1]!]
+ if (match && meaning) {
+ const speaker = match[3] ? ` · 说话人 ${Number(match[3])}` : ''
+ return `第${Number(match[2])}${meaning[0]}${meaning[1]}${speaker}`
+ }
return (
(
{
@@ -161,10 +195,20 @@ export function workflowStepLabel(key: string) {
shot_3: '镜头三',
render: '成片渲染',
compose: '成片渲染',
+ timing: '对白时序准备',
+ dialogue_mix: '对白与音乐混音',
+ dialogue_captions: '生成对白字幕',
} as Record
)[key] || (/^shot_[1-9]\d*$/.test(key) ? `镜头${Number(key.slice(5))}` : key)
)
}
+export function workflowQualityVerdict(value?: string | null) {
+ return value
+ ? ({ pass: '通过', reject: '未通过', indeterminate: '结果待确认' } as Record)[
+ value
+ ] || value
+ : '待质检'
+}
export function workflowErrorLabel(error: { code: string; message?: string; step_key?: string }) {
if (error.message?.trim()) return error.message
const step = error.step_key ? workflowStepLabel(error.step_key) : '工作流阶段'
diff --git a/frontend/src/views/Folders.integration.test.ts b/frontend/src/views/Folders.integration.test.ts
index f4cb307..a9f478b 100644
--- a/frontend/src/views/Folders.integration.test.ts
+++ b/frontend/src/views/Folders.integration.test.ts
@@ -8,6 +8,8 @@ import { ElMessage, ElMessageBox } from 'element-plus'
import StoriesView from './StoriesView.vue'
import ToolsView from './ToolsView.vue'
import { useWorkflowsStore } from '../stores/workflows'
+import { useAssetsStore } from '../stores/assets'
+import { useStoriesStore } from '../stores/stories'
import { useCapabilitiesStore } from '../stores/capabilities'
import { emptyStory } from '../domain/stories/rules'
import { emptyWorkflow } from '../domain/workflows/timeline'
@@ -81,6 +83,53 @@ it('story list creates a named automatic folder, existing folder, or explicit un
await v.create()
expect(request.mock.calls[2]?.[2]).toEqual({ folder_id: null })
})
+it('explains the story cleanup in one prompt and cancel keeps the story', async () => {
+ const story = { id: 's', name: '雨夜', version: 3, spec: emptyStory(), selections: [] }
+ const view = await mount(StoriesView)
+ const confirm = vi.spyOn(ElMessageBox, 'confirm').mockRejectedValue('cancel')
+ const remove = vi.spyOn(api, 'deleteStory')
+ await view.remove(story)
+ const [message, , options] = confirm.mock.calls[0]!
+ for (const word of ['雨夜', '工作流', '未收藏', '已收藏', '保留', '取消'])
+ expect(message).toContain(word)
+ expect(options).toMatchObject({ confirmButtonText: '删除故事', cancelButtonText: '保留故事' })
+ expect(remove).not.toHaveBeenCalled()
+})
+it('confirms only once while deletion is pending and reports background cleanup', async () => {
+ const view = await mount(StoriesView)
+ const story = { id: 's', name: '雨夜', version: 3, spec: emptyStory(), selections: [] }
+ const confirm = vi.spyOn(ElMessageBox, 'confirm').mockResolvedValue('confirm' as any)
+ let complete!: (value: any) => void
+ const response = new Promise((resolve) => {
+ complete = resolve
+ })
+ const remove = vi.spyOn(api, 'deleteStory').mockReturnValue(response)
+ const pending = view.remove(story)
+ const duplicate = view.remove(story)
+ await Promise.resolve()
+ complete({
+ pending: true,
+ deleted: { draft_ids: ['s'], run_ids: [], job_ids: [], batch_ids: [] },
+ })
+ await Promise.all([pending, duplicate])
+ expect(confirm).toHaveBeenCalledTimes(1)
+ expect(remove).toHaveBeenCalledExactlyOnceWith('s', 3)
+ expect(useStoriesStore().deleted.s).toBe(true)
+ expect(ElMessage.success).toHaveBeenCalledWith(expect.stringContaining('后台'))
+})
+it('evicts only the assets actually removed by a confirmed story deletion', async () => {
+ const view = await mount(StoriesView)
+ const assets = useAssetsStore()
+ assets.upsert({ id: 'unused' } as any)
+ assets.upsert({ id: 'favorite', favorite: true } as any)
+ vi.spyOn(ElMessageBox, 'confirm').mockResolvedValue('confirm' as any)
+ vi.spyOn(api, 'deleteStory').mockResolvedValue({
+ deleted: { draft_ids: ['s'], job_ids: [], run_ids: [], batch_ids: [], asset_ids: ['unused'] },
+ } as any)
+ await view.remove({ id: 's', name: '雨夜', version: 1 })
+ expect(assets.byId.unused).toBeUndefined()
+ expect(assets.byId.favorite?.favorite).toBe(true)
+})
it('shared workflow store keeps independent classification and frozen result target', async () => {
const spec = emptyWorkflow()
spec.shots.forEach((s) => (s.prompt = 'scene'))
diff --git a/frontend/src/views/StoriesView.vue b/frontend/src/views/StoriesView.vue
index 0417284..4b0118c 100644
--- a/frontend/src/views/StoriesView.vue
+++ b/frontend/src/views/StoriesView.vue
@@ -18,6 +18,7 @@ const folders = useFoldersStore(),
const router = useRouter(),
store = useStoriesStore(),
loading = ref(false),
+ deleting = ref(new Set()),
error = ref(''),
caps = ref()
const items = computed(() =>
@@ -64,17 +65,25 @@ async function create() {
}
}
async function remove(story: StoryDTO) {
+ if (deleting.value.has(story.id)) return
const session = store.sessionId()
+ deleting.value.add(story.id)
try {
await ElMessageBox.confirm(
- `删除故事“${story.name}”?运行历史按服务端引用保护处理,独立素材仍留在素材库。`,
+ `删除故事“${story.name}”后,它的工作流、子任务和仅此故事使用的未收藏素材将一并删除,无法恢复。正在执行的任务会自动取消。已收藏的素材和其他作品仍在使用的素材会保留。`,
'删除故事',
- { type: 'warning' },
+ { type: 'warning', confirmButtonText: '删除故事', cancelButtonText: '保留故事' },
)
if (session !== store.sessionId()) return
- await store.remove(story, session)
+ const result = await store.remove(story, session)
+ if (result && session === store.sessionId())
+ ElMessage.success(
+ result.pending ? '故事已移除,后台正在停止任务并清理关联内容' : '故事及关联内容已删除',
+ )
} catch (e) {
if (e instanceof Error) ElMessage.error(errorMessage(e))
+ } finally {
+ deleting.value.delete(story.id)
}
}
watch(
@@ -174,6 +183,7 @@ onMounted(load)
>删除故事
diff --git a/frontend/src/views/StoryStudioView.test.ts b/frontend/src/views/StoryStudioView.test.ts
index 78f8df6..6f2ae10 100644
--- a/frontend/src/views/StoryStudioView.test.ts
+++ b/frontend/src/views/StoryStudioView.test.ts
@@ -67,8 +67,9 @@ async function editor(initial: StoryDTO, withChild = false) {
setup(props: any, ctx: any) {
bindings = (StoryStudioView as any).setup(props, ctx)
return () =>
- withChild && bindings.base.value && bindings.editorEnabled.value
+ withChild && bindings.base.value && bindings.useEditorSurface.value
? h(childComponent, {
+ key: `${bindings.base.value.id}:${bindings.editorEnabled.value}`,
draftId: bindings.base.value.id,
ref: bindings.editable,
draftName: bindings.canEditName.value ? bindings.name.value : undefined,
@@ -128,6 +129,31 @@ afterEach(() => {
vi.unstubAllGlobals()
})
+it('shares the render details request across SSE updates and applies its slow response', async () => {
+ const view = await editor(story())
+ view.bindings.mode.value = 'render'
+ const response = { shots: [], errors: [{ code: 'missing_frame', message: '缺少镜头首帧' }] }
+ let respond!: (value: Awaited>) => void
+ const preview = vi
+ .mocked(api.storyPreview)
+ .mockClear()
+ .mockImplementationOnce(() => new Promise((resolve) => (respond = resolve)))
+ const history = vi.mocked(api.storyRuns).mockClear()
+
+ view.bindings.jobs.cursor++
+ await settle()
+ view.bindings.jobs.cursor++
+ await settle()
+ view.bindings.jobs.cursor++
+ await settle()
+ expect(preview).toHaveBeenCalledTimes(1)
+ expect(history).toHaveBeenCalledTimes(1)
+
+ respond(response)
+ await settle()
+ expect(view.bindings.preview.value).toEqual(response)
+})
+
it('uses the independent TP2 certificate for current and all-story generated candidates without changing saved profiles', async () => {
const initial = story()
const shot = initial.spec.shots[0]!
@@ -230,33 +256,6 @@ it('passes the independent TP2 availability through automatic production and sto
expect(v.child.notice.value).toBe('双卡尚未完成认证')
})
describe('story studio session and staged editing', () => {
- it('previews the latest completed video while a newer render is still pending and clears it on story changes', async () => {
- const view = await editor(story())
- expect(view.bindings.previewAsset.value).toBeUndefined()
- view.bindings.runs.value = [
- { id: 'pending', state: 'running', result_assets: [{ id: 'unfinished', kind: 'video' }] },
- {
- id: 'media-run',
- output_goal: 'media',
- state: 'succeeded',
- result_assets: [{ id: 'raw-video', kind: 'video' }],
- },
- { id: 'image-only', state: 'succeeded', result_assets: [{ id: 'image', kind: 'image' }] },
- { id: 'failed', state: 'failed', result_assets: [{ id: 'rejected', kind: 'video' }] },
- { id: 'ready', state: 'succeeded', result_assets: [{ id: 'movie', kind: 'video' }] },
- ]
- expect(view.bindings.latestPreviewRun.value.id).toBe('ready')
- expect(view.bindings.previewAsset.value.id).toBe('movie')
- view.bindings.runs.value.unshift({
- id: 'new-ready',
- state: 'succeeded',
- result_assets: [{ id: 'new-movie', kind: 'video' }],
- })
- expect(view.bindings.previewAsset.value.id).toBe('new-movie')
- await view.router.push('/studio/b')
- await settle()
- expect(view.bindings.previewAsset.value).toBeUndefined()
- })
it('protects every route departure and same-view story switch while local edits remain', async () => {
vi.spyOn(ElMessageBox, 'confirm').mockRejectedValue('cancel')
const view = await editor(story())
@@ -386,6 +385,7 @@ describe('story studio session and staged editing', () => {
it('keeps a removed mirror shot removed when a queued candidate arrives', async () => {
const initial = story(),
removed = createShot()
+ if (initial.spec.schema_version === 5) throw new Error('historical story required')
initial.spec.shots.push(removed)
initial.spec.render.total_frames = 240
const view = await editor(initial)
@@ -811,8 +811,7 @@ it('keeps the old editable contents and new store snapshot when cross-tab synchr
})
it('shows saved editor contribution frames in the parent studio header', async () => {
const v = await editor({ ...story(), editing_mode: 'auto', editor_manifest: {} } as any)
- const spec = emptyStory()
- spec.schema_version = 4
+ const spec = { ...emptyStory(), schema_version: 4 as const }
spec.shots.push(createShot(4))
spec.shots[1]!.edit.duration_frames = 125
spec.shots[1]!.edit.dedup_frames = 1
@@ -824,3 +823,70 @@ it('shows saved editor contribution frames in the parent studio header', async (
})
expect(v.bindings.headerStats.value).toEqual({ shots: 2, frames: 244 })
})
+
+it('enables multiplayer dialogue through its explicit versioned command only after capability approval', async () => {
+ const { dialogueFixture } = await import('../utils/dialogueFixture')
+ const initial = story()
+ const view = await editor(initial)
+ const fixture = dialogueFixture()
+ if (fixture.manifest.schema_version !== 3) throw new Error('Expected dialogue fixture')
+ const enable = vi.spyOn(api, 'enableDialogue').mockResolvedValue({
+ ...fixture,
+ draft_id: initial.id,
+ version: 3,
+ revision: 3,
+ editing_mode: 'auto',
+ })
+ view.bindings.productionCaps.dialogue = { available: false, reason: '未认证' }
+ await view.bindings.enableDialogue()
+ expect(enable).not.toHaveBeenCalled()
+ expect(view.bindings.spec.value.schema_version).toBe(3)
+ view.bindings.productionCaps.dialogue = { available: false, authoring_available: true }
+ await view.bindings.enableDialogue()
+ expect(enable).toHaveBeenCalledWith(initial.id, 2)
+ expect(view.bindings.useEditorSurface.value).toBe(true)
+ expect(view.bindings.spec.value.shots[0].continuity?.transition).not.toBe('continue')
+})
+
+it('continues editing the V5 contract after switching to manual production', async () => {
+ const { dialogueFixture } = await import('../utils/dialogueFixture')
+ const fixture = dialogueFixture()
+ if (fixture.manifest.schema_version !== 3) throw new Error('Expected dialogue fixture')
+ const initial = {
+ ...story(),
+ spec: fixture.manifest.spec,
+ editor_manifest: fixture.manifest,
+ editing_mode: 'auto' as const,
+ capabilities: { name_edit: true, mode_switch: true, auto: true, manual: true },
+ }
+ const manual = { ...initial, editing_mode: 'manual' as const, version: 3, revision: 3 }
+ const response = {
+ ...fixture,
+ draft_id: initial.id,
+ editing_mode: 'manual' as const,
+ version: 3,
+ revision: 3,
+ story: manual,
+ manifest: { ...fixture.manifest, editing_mode: 'manual' as const },
+ }
+ const read = vi
+ .spyOn(api, 'editor')
+ .mockResolvedValue({ ...fixture, version: 2, draft_id: initial.id })
+ vi.spyOn(api, 'setEditorMode').mockResolvedValue(response)
+ vi.spyOn(api, 'runs').mockResolvedValue({ items: [], total: 0, page: 1, page_size: 100 })
+ const view = await editor(initial, true)
+ read.mockResolvedValue(response)
+ await view.bindings.changeEditingMode('manual')
+ await settle()
+ expect(view.bindings.editorEnabled.value).toBe(false)
+ expect(view.bindings.useEditorSurface.value).toBe(true)
+ expect(view.child.manifest.value.spec.dialogue.utterances[0].text).toBe('灯亮了。')
+ const save = vi.spyOn(api, 'saveEditor').mockResolvedValue(response)
+ view.child.manifest.value.spec.dialogue.utterances[0].text = '新台词'
+ await view.bindings.save()
+ expect(save.mock.calls[0]?.[2]).toMatchObject({
+ schema_version: 3,
+ editing_mode: 'manual',
+ spec: { schema_version: 5, dialogue: { utterances: [{ text: '新台词' }] } },
+ })
+})
diff --git a/frontend/src/views/StoryStudioView.vue b/frontend/src/views/StoryStudioView.vue
index a22e9c9..2eab131 100644
--- a/frontend/src/views/StoryStudioView.vue
+++ b/frontend/src/views/StoryStudioView.vue
@@ -1,6 +1,6 @@