从改造入口排除原位快速编辑

移除 image.edit 的可改造 action 能力
保留快速编辑入口并隐藏改造按钮
说明原位替换结果无法可靠恢复旧 source
同步权威设计文档和回归测试
This commit is contained in:
2026-08-07 15:15:18 +08:00
parent 0b44253c9d
commit e088106541
6 changed files with 33 additions and 38 deletions
File diff suppressed because one or more lines are too long
@@ -35,10 +35,13 @@ const REMIXABLE_CANVAS_GENERATION_ACTIONS = new Set<CanvasGenerationAction>([
'audio.sound-effect.generate',
'audio.background-music.generate',
'character-animation.generate',
'image.edit',
'ui-design.extract-assets',
]);
// 中文注释:image.edit 是图片快速编辑的原位替换记录,结果层就是被覆盖后的原层;
// 其 source 指向替换前的编辑目标,不能再作为“改造”新产物可靠恢复。继续修改应重新
// 使用“快速编辑”,所以 image.edit 只属于已知 action,不属于可改造 action。
const CANVAS_GENERATION_ACTION_SET = new Set<string>(CANVAS_GENERATION_ACTIONS);
const V2_GENERATION_INPUT_KEYS = new Set([
'version',
@@ -496,6 +496,7 @@ describe('ImageCanvasGenerationModel', () => {
}),
).toBe(true);
for (const action of [
'image.edit',
'image.perfect-pixel',
'spritesheet.split',
'image.remove-background',
@@ -391,6 +391,31 @@ describe('ImageCanvasSelectedLayerToolbarView', () => {
expect(screen.queryByRole('button', { name: '改造' })).toBeNull();
});
it('hides redraw for in-place quick-edit results', () => {
renderSelectedToolbar({
selectedLayer: createLayer({
generationInputs: {
version: 2,
action: 'image.edit',
fields: [
{ id: 'prompt', title: '快速编辑提示词', value: '改成夜景' },
],
references: [
{
id: 'source',
title: '原图',
refType: 'project-resource',
refId: 'resource-before-in-place-edit',
},
],
},
}),
});
expect(screen.getByRole('button', { name: '快速编辑' })).toBeTruthy();
expect(screen.queryByRole('button', { name: '改造' })).toBeNull();
});
it('removes raster edit actions for video and character animation layers', () => {
renderSelectedToolbar({
selectedLayer: createLayer({
@@ -5096,40 +5096,6 @@ describe('useImageCanvasGenerationWorkflow', () => {
);
});
it('refuses redraw only when quick edit cannot replace its missing source', () => {
render(
<GenerationWorkflowHarness
initialLayers={[
createLayer({
sourceType: 'generated',
generationInputs: {
version: 2,
action: 'image.edit',
fields: [
{ id: 'prompt', title: '修改要求', value: '改成夜景' },
],
references: [
{
id: 'source',
title: '原图',
refType: 'project-resource',
refId: 'resource-missing-source',
},
],
},
}),
]}
/>,
);
fireEvent.click(screen.getByRole('button', { name: '打开图片改造' }));
expect(screen.getByTestId('dialog').textContent).toBe('-');
expect(screen.getByTestId('reference-pick-warning').textContent).toBe(
'原编辑目标不在当前画布,当前快速编辑面板无法重新选择编辑目标,无法改造。',
);
});
it('keeps character animation asset names synchronized with the dialog', () => {
render(<GenerationWorkflowHarness />);
@@ -172,8 +172,6 @@ function getCanvasGenerationRedrawWarning({
const NON_REPLACEABLE_SOURCE_WARNING_BY_ACTION: Partial<
Record<CanvasGenerationAction, string>
> = {
'image.edit':
'原编辑目标不在当前画布,当前快速编辑面板无法重新选择编辑目标,无法改造。',
'character-animation.generate':
'原角色图层不在当前画布,当前角色动作面板无法重新选择来源角色,无法改造。',
'ui-design.extract-assets':