Preserve speech recognition text when restoring canvas nodes
This commit is contained in:
parent
60c8109d09
commit
58b4695d17
@ -2,6 +2,7 @@
|
||||
import { fetchUploadWithRetry } from "@/lib/client/upload-with-retry";
|
||||
import { useCanvasGroupRuns } from "@/hooks/use-canvas-group-runs";
|
||||
import { hasRecoverableCanvasTask } from "@/lib/video-canvas/task-recovery";
|
||||
import { restoreTextResourceContent } from "@/lib/video-canvas/text-resource";
|
||||
import { GroupStoryboardPreview } from "./GroupStoryboardPreview";
|
||||
import { CanvasGroupToolbar } from "./CanvasGroupToolbar";
|
||||
import { isCanvasGroup, groupMembers, makeCanvasGroup, ungroupCanvasNodes, moveCanvasSelection, layoutCanvasGroup, migrateLegacyGroups, exportCanvasGroup, instantiateCanvasGroup, groupBounds, assignGroupMembers } from "@/lib/video-canvas/groups";
|
||||
@ -4145,7 +4146,7 @@ function normalizeTextResourceNode(node: CloneNode, fallbackIndex: number): Clon
|
||||
draftValues: {
|
||||
...(node.draftValues || {}),
|
||||
action: "TEXT_RESOURCE",
|
||||
content: Array.isArray(node.draftValues?.content) ? node.draftValues?.content : [],
|
||||
content: restoreTextResourceContent(node.draftValues),
|
||||
nodeType: "text",
|
||||
scriptRole: "resource",
|
||||
viewMode: undefined,
|
||||
@ -21478,12 +21479,7 @@ function PureTextResourceCanvasNode({
|
||||
onTextResourceChange: (content: string) => void;
|
||||
selected: boolean;
|
||||
}) {
|
||||
const contentValues = node.draftValues?.content;
|
||||
const textContent = typeof contentValues === "string"
|
||||
? contentValues
|
||||
: Array.isArray(contentValues) && typeof contentValues[0] === "string"
|
||||
? contentValues[0]
|
||||
: "";
|
||||
const textContent = restoreTextResourceContent(node.draftValues)[0] || "";
|
||||
|
||||
return (
|
||||
<div className="h-full w-full">
|
||||
|
||||
@ -139,6 +139,10 @@
|
||||
|
||||
本轮修复语音识别成功后画布结果为空的问题:新结果采用画布文本结构,已保存的字符串结果也可直接显示和编辑;重复查询不会覆盖人工修改。音频生成节点显示排队、处理中及失败信息,不再以空播放器及默认三秒时长表示未完成任务。相关回归 72 项和 TypeScript 检查通过;内置浏览器独立页面已验证新旧文字显示、中文与尺寸编辑、空格保留及等待/失败状态,待正式发布。
|
||||
|
||||
画布恢复时统一读取字符串和数组格式的文本,保留中文、尺寸及空格;缺少内容的历史识别节点从已保存的识别文本恢复,人工编辑和主动清空保持优先。恢复与任务相关回归 46 项、TypeScript 检查及内置浏览器的实际恢复组件验收通过,等待生产画布刷新验收。
|
||||
|
||||
音乐原任务已成功完成并保存七牛,网页解码时长约 150 秒并可播放。供应商核对确认只受理及扣费一次;本项目工作进程续查一次原任务,没有重新派发。声音克隆与声音设计在内置浏览器均播放到结尾。
|
||||
|
||||
### 剩余上游事项
|
||||
|
||||
| 型号 | 当前阻塞 | 处理方 |
|
||||
|
||||
9
lib/video-canvas/text-resource.ts
Normal file
9
lib/video-canvas/text-resource.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export function restoreTextResourceContent(draft?: Record<string, any>): string[] {
|
||||
const content = draft?.content;
|
||||
if (typeof content === "string") return [content];
|
||||
// An empty string in the array is an intentional edit and must stay empty.
|
||||
if (Array.isArray(content) && content.length) return content;
|
||||
if (draft?.audioMeta?.outputType === "text" && typeof draft.text === "string")
|
||||
return [draft.text];
|
||||
return [];
|
||||
}
|
||||
@ -16,6 +16,7 @@ import {
|
||||
type CanvasGenerationTask,
|
||||
} from "@/lib/video-canvas/task-contract";
|
||||
import { chooseStoryVideoSettings } from "@/lib/video-canvas/model-matching";
|
||||
import { restoreTextResourceContent } from "@/lib/video-canvas/text-resource";
|
||||
type TaskNode = { id: string; draftValues?: Record<string, any>; [key: string]: any };
|
||||
const node: TaskNode = {
|
||||
id: "n1",
|
||||
@ -88,6 +89,18 @@ test("does not resurrect nodes removed after task creation or hidden on the serv
|
||||
),
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
test("saved speech text survives reload and retains subsequent edits, including an empty edit", () => {
|
||||
const text = "这是由壹点测试画布的语音验收,尺寸 15mm。 ";
|
||||
const saved = { content: text, text, audioMeta: { outputType: "text" } };
|
||||
expect(restoreTextResourceContent(JSON.parse(JSON.stringify(saved)))).toEqual([text]);
|
||||
expect(restoreTextResourceContent({ ...saved, content: [] })).toEqual([text]);
|
||||
for (const edit of ["已校对的中文 20mm。 ", ""]) {
|
||||
const updated = { ...saved, content: [edit] };
|
||||
expect(restoreTextResourceContent(JSON.parse(JSON.stringify(updated)))).toEqual([edit]);
|
||||
}
|
||||
expect(restoreTextResourceContent({ content: [] })).toEqual([]);
|
||||
});
|
||||
test("late result from an older request cannot overwrite a new generation on the same node", () => {
|
||||
const current = {
|
||||
...node,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user