修复完美像素未收口占位交互
Project CI / Repository checks (pull_request) Failing after 11s
Project CI / Backend tests (pull_request) Failing after 11s
Project CI / Frontend tests (pull_request) Failing after 18s
Project CI / Native shell tests (pull_request) Successful in 10m29s

发现已有未收口操作时激活原占位并阻止创建新身份。

拒绝右键删除受保护占位时保留当前图层选择。

补齐生成工作流接线和定向回归测试。
This commit is contained in:
2026-08-04 12:48:39 +00:00
parent f29c7d5918
commit ccf8307a39
5 changed files with 49 additions and 6 deletions
@@ -1490,6 +1490,7 @@ export function ImageCanvasEditorView({
activeCanvasGenerationDialog,
canvasGenerationDialogs,
openCanvasGenerationDialog,
activateCanvasGenerationDialog,
updateCanvasGenerationDialogById,
hasCanvasGenerationDialogById,
archiveActiveCanvasGenerationDialog,
@@ -1824,7 +1825,11 @@ export function ImageCanvasEditorView({
const requestRemoveCanvasGenerationDialog = useCallback(
(dialog: CanvasGenerationDialogState) => {
if (isUnsettledPerfectPixelOperationDialog(dialog)) {
const previousSelectedLayerId = selectedLayerIdRef.current;
const previousSelectedLayerIds = [...selectedLayerIdsRef.current];
activateCanvasGenerationDialog(dialog);
setSelectedLayerId(previousSelectedLayerId);
setSelectedLayerIds(previousSelectedLayerIds);
showGenerationWarning(
'完美像素结果尚未确认,当前占位用于保留原操作身份;请继续核对或按原操作重试。',
);
@@ -1840,6 +1845,8 @@ export function ImageCanvasEditorView({
[
activateCanvasGenerationDialog,
removeCanvasGenerationDialog,
setSelectedLayerId,
setSelectedLayerIds,
showGenerationWarning,
],
);
@@ -152,6 +152,7 @@ function GenerationSurfaceHarness() {
activeCanvasGenerationDialog: activeCanvasDialog,
canvasGenerationDialogs: dialogs.canvasGenerationDialogs,
openCanvasGenerationDialog: dialogs.openCanvasGenerationDialog,
activateCanvasGenerationDialog: dialogs.activateCanvasGenerationDialog,
updateCanvasGenerationDialogById: dialogs.updateCanvasGenerationDialogById,
hasCanvasGenerationDialogById: dialogs.hasCanvasGenerationDialogById,
archiveActiveCanvasGenerationDialog:
@@ -74,6 +74,9 @@ type ImageCanvasGenerationSurfaceOptions = {
openCanvasGenerationDialog: (
dialog: Omit<CanvasGenerationDialogState, 'id'>,
) => string;
activateCanvasGenerationDialog: (
targetDialog: CanvasGenerationDialogState,
) => void;
updateCanvasGenerationDialogById: (
dialogId: string,
updater: CanvasGenerationDialogUpdater,
@@ -169,6 +172,7 @@ export function useImageCanvasGenerationSurface({
activeCanvasGenerationDialog,
canvasGenerationDialogs,
openCanvasGenerationDialog,
activateCanvasGenerationDialog,
updateCanvasGenerationDialogById,
hasCanvasGenerationDialogById,
archiveActiveCanvasGenerationDialog,
@@ -209,6 +213,7 @@ export function useImageCanvasGenerationSurface({
generateDialog,
setGenerateDialog,
openCanvasGenerationDialog,
activateCanvasGenerationDialog,
updateCanvasGenerationDialogById,
hasCanvasGenerationDialogById,
archiveActiveCanvasGenerationDialog,
@@ -397,6 +397,7 @@ function GenerationWorkflowHarness({
generateDialog: dialogs.generateDialog,
setGenerateDialog: dialogs.setGenerateDialog,
openCanvasGenerationDialog: dialogs.openCanvasGenerationDialog,
activateCanvasGenerationDialog: dialogs.activateCanvasGenerationDialog,
updateCanvasGenerationDialogById: dialogs.updateCanvasGenerationDialogById,
hasCanvasGenerationDialogById: dialogs.hasCanvasGenerationDialogById,
removeCanvasGenerationDialogsByLayerId:
@@ -819,6 +820,18 @@ function GenerationWorkflowHarness({
>
</button>
<button
type="button"
onClick={() =>
dialogs.openCanvasGenerationDialog({
mode: 'generate',
prompt: '其它操作',
status: 'idle',
})
}
>
</button>
<button
type="button"
onClick={() => {
@@ -3106,16 +3119,27 @@ describe('useImageCanvasGenerationWorkflow', () => {
'pending-confirmation',
);
});
const firstDialogList =
screen.getByTestId('generation-dialogs').textContent;
fireEvent.click(screen.getByRole('button', { name: '打开其它占位' }));
expect(screen.getByTestId('dialog-prompt').textContent).toBe('其它操作');
const dialogIdsBeforeBlockedClick = screen
.getByTestId('generation-dialogs')
.textContent!.split('|')
.map((item) => item.split(':')[0])
.sort();
fireEvent.click(screen.getByRole('button', { name: '完美像素' }));
expect(screen.getByTestId('dialog').textContent).toContain(
'pending-confirmation',
);
fireEvent.click(screen.getByRole('button', { name: '第二图层完美像素' }));
expect(snapImageToPerfectPixelsMock).toHaveBeenCalledTimes(1);
expect(screen.getByTestId('generation-dialogs').textContent).toBe(
firstDialogList,
);
expect(
screen
.getByTestId('generation-dialogs')
.textContent!.split('|')
.map((item) => item.split(':')[0])
.sort(),
).toEqual(dialogIdsBeforeBlockedClick);
expect(screen.getByTestId('reference-pick-warning').textContent).toBe(
'该素材已有一条未收口的完美像素操作,请在原占位上继续核对或重试。',
);
@@ -893,6 +893,9 @@ type GenerationWorkflowOptions = {
openCanvasGenerationDialog: (
dialog: Omit<CanvasGenerationDialogState, 'id'> & { id?: string },
) => string;
activateCanvasGenerationDialog: (
targetDialog: CanvasGenerationDialogState,
) => void;
updateCanvasGenerationDialogById: (
dialogId: string,
updater: CanvasGenerationDialogUpdater,
@@ -948,6 +951,7 @@ export function useImageCanvasGenerationWorkflow({
generateDialog,
setGenerateDialog,
openCanvasGenerationDialog,
activateCanvasGenerationDialog,
updateCanvasGenerationDialogById,
hasCanvasGenerationDialogById,
archiveActiveCanvasGenerationDialog,
@@ -2210,6 +2214,7 @@ export function useImageCanvasGenerationWorkflow({
Boolean(existingOperation)
) {
if (existingOperation) {
activateCanvasGenerationDialog(existingOperation);
showGenerationWarning(
'该素材已有一条未收口的完美像素操作,请在原占位上继续核对或重试。',
);
@@ -2499,6 +2504,7 @@ export function useImageCanvasGenerationWorkflow({
[
applyProjectSnapshot,
assetFolderId,
activateCanvasGenerationDialog,
canvasGenerationDialogs,
closeGenerationTransientState,
currentUserId,