Skip to content

Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.

fix(creator): preserve source video during subtitle invalidation

Leggett37bc38694c5c
diff --git a/apps/daemon/src/creator/templates/registry.ts b/apps/daemon/src/creator/templates/registry.ts
index 2807b80c..531b9d37 100644
--- a/apps/daemon/src/creator/templates/registry.ts
+++ b/apps/daemon/src/creator/templates/registry.ts
@@ -124,6 +124,7 @@ function propagateArtifacts(
// Reusing a previous version does not make the stage's upstream outputs downstream.
if (stage.outputArtifacts.some(output => output.kind === current)) continue;
for (const output of stage.outputArtifacts) {
+ if (stage.inputArtifacts.some(input => input.kind === output.kind)) continue;
if (!result.has(output.kind)) {
result.add(output.kind);
queue.push(output.kind);
diff --git a/apps/daemon/test/unit/creator-agent-context.test.ts b/apps/daemon/test/unit/creator-agent-context.test.ts
index 9ca59ff0..98a6afbf 100644
--- a/apps/daemon/test/unit/creator-agent-context.test.ts
+++ b/apps/daemon/test/unit/creator-agent-context.test.ts
@@ -28,7 +28,7 @@ describe('creator agent context', () => {
},
stateTruncated: true,
templateGuidance: expect.stringContaining('input.patch'),
- availableStageIds: ['subtitle', 'tts', 'render-horizontal', 'render-vertical'],
+ availableStageIds: ['subtitle', 'tts', 'render-horizontal', 'render-vertical', 'prepare-source-video'],
stages: [
{
stageId: 'subtitle',
diff --git a/apps/daemon/test/unit/creator-service.test.ts b/apps/daemon/test/unit/creator-service.test.ts
index d276e499..4cf804df 100644
--- a/apps/daemon/test/unit/creator-service.test.ts
+++ b/apps/daemon/test/unit/creator-service.test.ts
@@ -736,7 +736,7 @@ describe('creator service', () => {
db.close();
});
- it('stales only artifacts linked to the edited subtitle version', () => {
+ it('stales subtitle-dependent outputs without invalidating source video or other versions', () => {
const { db, repository, service } = setup();
const job = service.createJob({
projectId: 'project_1',
@@ -776,6 +776,14 @@ describe('creator service', () => {
sourceArtifactIds: [],
metadata: { resultVersion: 2 }
});
+ const sourceVideo = repository.insertArtifact({
+ jobId: job.id,
+ kind: 'source_video',
+ status: 'completed',
+ path: join(tempDir, 'source.mp4'),
+ sourceArtifactIds: [subtitleV2.id],
+ metadata: { resultVersion: 2 }
+ });
const audioV2 = repository.insertArtifact({
jobId: job.id,
kind: 'dubbed_audio',
@@ -827,6 +835,7 @@ describe('creator service', () => {
stageId: 'render-horizontal',
description: '生成项目 V2',
artifactRefs: {
+ source_video: [sourceVideo.id],
target_subtitle: [subtitleV2.id],
dubbed_audio: [audioV2.id],
horizontal_video: [videoV2.id]
@@ -857,6 +866,7 @@ describe('creator service', () => {
});
const artifacts = service.getJob(job.id)!.artifacts;
+ expect(artifacts.find(item => item.id === sourceVideo.id)?.status).toBe('completed');
expect(artifacts.find(item => item.id === audioV1.id)?.status).toBe('completed');
expect(artifacts.find(item => item.id === audioV2.id)?.status).toBe('stale');
expect(artifacts.find(item => item.id === videoV2.id)?.status).toBe('stale');
@@ -890,6 +900,7 @@ describe('creator service', () => {
{
version: 2,
artifactRefs: {
+ source_video: [sourceVideo.id],
target_subtitle: [editedSubtitle.id],
bilingual_subtitle: [editedBilingual.id],
source_subtitle: [editedSource.id],
diff --git a/apps/daemon/test/unit/creator-stickman-krillin.test.ts b/apps/daemon/test/unit/creator-stickman-krillin.test.ts
index 5bd2231b..7de843a5 100644
--- a/apps/daemon/test/unit/creator-stickman-krillin.test.ts
+++ b/apps/daemon/test/unit/creator-stickman-krillin.test.ts
@@ -91,7 +91,7 @@ describe('stickman KrillinAI mapping', () => {
undefined
);
expect(translationArgs).not.toContain('--source-only');
- expect(translationArgs).toContain('--prepare-video');
+ expect(translationArgs).not.toContain('--prepare-video');
});
it('rejects undeclared or missing stickman outputs and aliases valid subtitles', async () => {
diff --git a/apps/daemon/test/unit/creator-template-registry.test.ts b/apps/daemon/test/unit/creator-template-registry.test.ts
index 5f13bac2..835b34e5 100644
--- a/apps/daemon/test/unit/creator-template-registry.test.ts
+++ b/apps/daemon/test/unit/creator-template-registry.test.ts
@@ -250,10 +250,33 @@ describe('creator template registry', () => {
});
});
- it('resolves the video translation stale graph from target subtitles only', () => {
- const registry = createCreatorTemplateRegistry([
- createVideoTranslationTemplate()
+ it.each([1, 2])('resolves the video translation v%s stale graph from target subtitles only', version => {
+ const registry = createDefaultCreatorTemplateRegistry();
+
+ expect(registry.resolveInvalidatedArtifactKinds(
+ 'video-translation',
+ version,
+ 'edit-subtitle'
+ )).toEqual([
+ 'dubbed_audio',
+ 'dubbed_video',
+ 'horizontal_video',
+ 'vertical_video'
]);
+ });
+
+ it('does not invalidate source-only consumers when subtitles change', () => {
+ const template = createVideoTranslationTemplate();
+ const registry = createCreatorTemplateRegistry([{
+ ...template,
+ stages: [...template.stages, {
+ id: 'source-preview',
+ executor: 'download',
+ allowedJobStatuses: ['completed'],
+ inputArtifacts: [{ kind: 'source_video', selector: 'latest-completed' }],
+ outputArtifacts: [{ kind: 'source_preview', status: 'completed' }]
+ }]
+ }]);
expect(registry.resolveInvalidatedArtifactKinds(
'video-translation',