修复队列与 Web 吞掉并存的 sliceWarning
风格归一化与像素规整新增的通用 warning 可以与 sliceWarning 并存,openapi 已放开该组合,但两个消费端仍是二选一:队列 extract_editor_generation_warning 在 warning 存在时根本不读 sliceWarning,Web inline resolveEditorGenerationWarningMessage 同样直接返回通用告警。 两侧改为与 inline 响应相同的归一策略:只有一条时原样保留,两条并存时按 "通用在前、拆分在后"拼接,队列侧 code 收敛为 multiple-generation-warnings 并复用既有长度上界收敛。同步修正三处仍声明二者互斥的文档。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -2413,6 +2413,65 @@ describe('useImageCanvasGenerationSubmissionWorkflow', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('keeps both the common warning and the slice warning when they coexist', async () => {
|
||||
generateEditorIconSpritesheetMock.mockResolvedValueOnce({
|
||||
spritesheetImageSrc: 'data:image/png;base64,sheet',
|
||||
spritesheetWidth: 512,
|
||||
spritesheetHeight: 512,
|
||||
prompt: '图标素材',
|
||||
actualPrompt: '图标素材',
|
||||
model: 'gpt-image-2',
|
||||
provider: 'VectorEngine',
|
||||
taskId: 'task-icons',
|
||||
iconImageSrcs: [],
|
||||
warning: {
|
||||
code: 'unsupported-image-style',
|
||||
reason: '不支持的图片风格,已按无风格继续生成。',
|
||||
},
|
||||
sliceWarning: {
|
||||
code: 'insufficient-connected-components',
|
||||
reason: '连通域数量不足',
|
||||
},
|
||||
});
|
||||
render(
|
||||
<SubmissionWorkflowHarness
|
||||
projectId="editor-project-1"
|
||||
initialDialog={{
|
||||
id: 'dialog-icon',
|
||||
mode: 'icon',
|
||||
prompt: '返回按钮',
|
||||
status: 'idle',
|
||||
composerOpen: true,
|
||||
imageModel: 'gpt-image-2',
|
||||
iconSpecReference: {
|
||||
id: 'spec',
|
||||
label: '图标规范',
|
||||
src: 'data:image/png;base64,c3BlYw==',
|
||||
},
|
||||
iconDescriptions: [],
|
||||
placeholder: {
|
||||
x: 140,
|
||||
y: 160,
|
||||
width: 360,
|
||||
height: 360,
|
||||
originalWidth: 512,
|
||||
originalHeight: 512,
|
||||
},
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: '设置初始对话' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: '提交图标' }));
|
||||
|
||||
// 风格归一化告警与拆分告警可以并存,两者都必须出现在同一条提示里。
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId('generation-warning').textContent).toBe(
|
||||
'不支持的图片风格,已按无风格继续生成。 图集已生成,但自动拆分未完成:连通域数量不足',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('submits uploaded objectKey icon references before submitting spritesheets', async () => {
|
||||
generateEditorIconSpritesheetMock.mockResolvedValueOnce({
|
||||
spritesheetImageSrc: 'data:image/png;base64,sheet',
|
||||
|
||||
@@ -457,14 +457,17 @@ function resolveEditorGenerationWarningMessage(
|
||||
warning: string | null | undefined,
|
||||
sliceWarning: string | null | undefined,
|
||||
) {
|
||||
// 风格归一化和像素规整产生的通用 warning 可以与 sliceWarning 并存,
|
||||
// 这里按“通用在前、拆分在后”拼接成单条提示,不允许其中任何一条被丢弃。
|
||||
const commonReason = warning?.trim();
|
||||
if (commonReason) {
|
||||
return commonReason;
|
||||
}
|
||||
const sliceReason = sliceWarning?.trim();
|
||||
return sliceReason
|
||||
const prefixedSliceReason = sliceReason
|
||||
? `${EDITOR_SPRITESHEET_SLICE_WARNING_PREFIX}${sliceReason}`
|
||||
: undefined;
|
||||
if (commonReason && prefixedSliceReason) {
|
||||
return `${commonReason} ${prefixedSliceReason}`;
|
||||
}
|
||||
return commonReason || prefixedSliceReason;
|
||||
}
|
||||
|
||||
async function runEditorGenerationWithWalletRefresh<T>(
|
||||
|
||||
Reference in New Issue
Block a user