a03f13d0a5
原问题
```
历史角色动作是一个兼容例外:
后端允许它没有 editor_project_resource 资源行,只要布局自身保存了完整图片序列帧。
```
- 把生成动作的原视频asstetkind改为 video, 只把图片序列作为action
- db asset新增字段image_sequence_frames_json image_seq_duration_ms等, (原来动作的这些数据存在generation-input中,并不合适)
修改了externaljob,把这部分数据正确填写到数据库中。
- 为避免到处fallback,做了数据库迁移, 脚本: `scripts/spacetime-normalize-editor-character-actions.mjs` 手动进行过画布+素材库中动作序列帧+原始视频 迁移的测试
- 移除preview_video_path字段, reason:
>preview video
→ separate resource/asset with assetKind="video"
final transparent action
→ assetKind="character-animation"
→ source_resource_id points to the preview-video resource
→ image_sequence_frames_json contains the actual playable result
>
> So preview_video_path on the final action duplicates the source video resource’s image_src.
- 移除每个frame的index字段 原因: 这个只用于后端内部处理时有一个并发请求, 每个赋一个index方便收集, 后续没有再用到,且与数组本身重复
- 清除副产品preview video的generation_input_json, 因为会影响改造功能, 迁移后预览视频不提供改造(参数), 只有序列帧动作有改造
仍存在的共性问题: #134
- 导出:
下载改为完整序列帧, 封面不再作为fallback, 部分帧读取失败时行为:仍生成 ZIP,并记录失败帧, 不变
画布放置:
before:

after:

精选模块: 主页展示, 审核部分UI:


这两处序列帧们的加载设计为惰式的, 只有hover和单独preview才会全部加载
Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/117
Reviewed-by: 段舒康 <kdletters@qq.com>
Co-authored-by: 王德宇 <kvtodev@outlook.com>
Co-committed-by: 王德宇 <kvtodev@outlook.com>
178 lines
4.5 KiB
TypeScript
178 lines
4.5 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import {
|
|
buildSpacetimeCallArgs,
|
|
encodeSpacetimeCliOption,
|
|
parseProcedureResult,
|
|
} from './spacetime-migration-common.mjs';
|
|
|
|
describe('SpacetimeDB CLI SATS option encoding', () => {
|
|
it('keeps absent options null and wraps present values as Some', () => {
|
|
expect(encodeSpacetimeCliOption(null)).toBeNull();
|
|
expect(encodeSpacetimeCliOption(undefined)).toBeNull();
|
|
expect(encodeSpacetimeCliOption('job-2')).toEqual([0, 'job-2']);
|
|
expect(encodeSpacetimeCliOption(123)).toEqual([0, 123]);
|
|
});
|
|
|
|
it('serializes non-empty maintenance cursors in the CLI procedure input', () => {
|
|
const args = buildSpacetimeCallArgs(
|
|
{
|
|
database: 'genarrative-prod',
|
|
passthrough: [],
|
|
serverUrl: 'http://127.0.0.1:3311',
|
|
},
|
|
'compact_external_generation_job_payloads_and_return',
|
|
{
|
|
dry_run: true,
|
|
limit: 1,
|
|
cursor_job_id: encodeSpacetimeCliOption('job-2'),
|
|
completed_before_micros: encodeSpacetimeCliOption(123),
|
|
},
|
|
);
|
|
|
|
const input = JSON.parse(args.at(-2) ?? 'null');
|
|
expect(input.cursor_job_id).toEqual([0, 'job-2']);
|
|
expect(input.completed_before_micros).toEqual([0, 123]);
|
|
});
|
|
|
|
it('normalizes editor canvas migration procedure results', () => {
|
|
const result = parseProcedureResult(
|
|
JSON.stringify([
|
|
true,
|
|
[
|
|
0,
|
|
[
|
|
'canvas-1',
|
|
'project-1',
|
|
'source-hash',
|
|
'structured-hash',
|
|
7,
|
|
2,
|
|
1,
|
|
'resource-hash',
|
|
1,
|
|
'backfilled',
|
|
7,
|
|
],
|
|
],
|
|
[1],
|
|
]),
|
|
'backfill_editor_canvas_layout_and_return',
|
|
);
|
|
|
|
expect(result).toEqual({
|
|
ok: true,
|
|
migration: {
|
|
canvas_id: 'canvas-1',
|
|
project_id: 'project-1',
|
|
source_layout_sha256: 'source-hash',
|
|
structured_layout_sha256: 'structured-hash',
|
|
verified_revision: 7,
|
|
layer_count: 2,
|
|
dialog_count: 1,
|
|
resource_refs_sha256: 'resource-hash',
|
|
migration_version: 1,
|
|
status: 'backfilled',
|
|
revision: 7,
|
|
},
|
|
error_message: null,
|
|
});
|
|
});
|
|
|
|
it('normalizes editor canvas resource repair procedure results', () => {
|
|
const result = parseProcedureResult(
|
|
JSON.stringify([true, [0, [true, false, 2, 0, 0, 0, 7]], [1]]),
|
|
'repair_editor_canvas_resources_and_return',
|
|
);
|
|
|
|
expect(result).toEqual({
|
|
ok: true,
|
|
repair: {
|
|
dry_run: true,
|
|
already_repaired: false,
|
|
matched_layer_count: 2,
|
|
remapped_layer_count: 0,
|
|
restored_resource_count: 0,
|
|
removed_source_resource_id_count: 0,
|
|
revision: 7,
|
|
},
|
|
error_message: null,
|
|
});
|
|
});
|
|
|
|
it('normalizes character action metadata normalization results', () => {
|
|
const result = parseProcedureResult(
|
|
JSON.stringify([
|
|
true,
|
|
'asset',
|
|
true,
|
|
25,
|
|
3,
|
|
0,
|
|
2,
|
|
1,
|
|
0,
|
|
3,
|
|
2,
|
|
0,
|
|
0,
|
|
1,
|
|
['asset-blocked'],
|
|
[0, 'asset-25'],
|
|
true,
|
|
'a'.repeat(64),
|
|
[1],
|
|
]),
|
|
'normalize_editor_character_animation_metadata_and_return',
|
|
);
|
|
|
|
expect(result).toEqual({
|
|
ok: true,
|
|
scope: 'asset',
|
|
dry_run: true,
|
|
scanned_count: 25,
|
|
matched_count: 3,
|
|
updated_count: 0,
|
|
backfilled_frames_count: 2,
|
|
backfilled_duration_count: 1,
|
|
reclassified_preview_count: 0,
|
|
cleaned_generation_inputs_count: 3,
|
|
cleaned_frame_index_count: 2,
|
|
cleaned_canvas_layer_count: 0,
|
|
materialized_resource_count: 0,
|
|
blocker_count: 1,
|
|
blocker_ids: ['asset-blocked'],
|
|
next_cursor: 'asset-25',
|
|
has_more: true,
|
|
batch_sha256: 'a'.repeat(64),
|
|
error_message: null,
|
|
});
|
|
});
|
|
|
|
it('normalizes object-shaped character action procedure results', () => {
|
|
const result = parseProcedureResult(
|
|
JSON.stringify({
|
|
ok: true,
|
|
scope: 'asset',
|
|
dry_run: true,
|
|
scanned_count: 25,
|
|
matched_count: 3,
|
|
updated_count: 0,
|
|
blocker_count: 0,
|
|
blocker_ids: [],
|
|
next_cursor: 'asset-25',
|
|
has_more: true,
|
|
batch_sha_256: 'b'.repeat(64),
|
|
error_message: null,
|
|
}),
|
|
'normalize_editor_character_animation_metadata_and_return',
|
|
);
|
|
|
|
expect(result).toMatchObject({
|
|
batch_sha256: 'b'.repeat(64),
|
|
next_cursor: 'asset-25',
|
|
});
|
|
expect(result).not.toHaveProperty('batch_sha_256');
|
|
});
|
|
});
|