diff --git a/src/components/image-editor/ImageCanvasEditorView.test.tsx b/src/components/image-editor/ImageCanvasEditorView.test.tsx index 49f1b47a7..67b9f73a7 100644 --- a/src/components/image-editor/ImageCanvasEditorView.test.tsx +++ b/src/components/image-editor/ImageCanvasEditorView.test.tsx @@ -1449,6 +1449,40 @@ describe('ImageCanvasEditorView', () => { expect(screen.queryByLabelText('发送给画布 Agent')).toBeNull(); }); + it('keeps the Agent conversation panel open when restored tasks auto-open the task list', async () => { + enableEditorAgentSidebarForTest(); + loadOrCreateRecentEditorProjectMock.mockResolvedValueOnce({ + projectId: 'editor-project-with-restored-task', + title: '恢复任务项目', + viewport: { x: 0, y: 0, scale: 1 }, + layers: [ + ...defaultEditorProjectLayers, + { + layerId: 'generation-dialog:restored-task', + resourceId: 'generation-dialog:restored-task', + itemType: 'generation-dialog', + dialog: { + id: 'restored-task', + mode: 'generate', + prompt: '继续生成', + status: 'idle', + }, + }, + ], + resources: defaultEditorProjectResources, + updatedAt: '2026-07-06T00:00:00.000Z', + }); + + render(); + + expect(await screen.findByLabelText('发送给画布 Agent')).toBeTruthy(); + await waitFor(() => { + expect( + screen.queryByRole('complementary', { name: '画布任务列表' }), + ).toBeNull(); + }); + }); + it('keeps the left resource sidebar independent from right-side task and Agent panels', async () => { enableEditorAgentSidebarForTest(); render(); diff --git a/src/components/image-editor/ImageCanvasEditorView.tsx b/src/components/image-editor/ImageCanvasEditorView.tsx index 687740c30..504334bf5 100644 --- a/src/components/image-editor/ImageCanvasEditorView.tsx +++ b/src/components/image-editor/ImageCanvasEditorView.tsx @@ -1199,13 +1199,19 @@ export function ImageCanvasEditorView({ [toggleSidebarPanel], ); useEffect(() => { + if (!isAgentConversationEnabled && isAgentConversationOpen) { + setIsAgentConversationOpen(false); + return; + } if ( - (!isAgentConversationEnabled || generationSurface.isTaskSidebarOpen) && + isAgentConversationEnabled && + generationSurface.isTaskSidebarOpen && isAgentConversationOpen ) { - setIsAgentConversationOpen(false); + generationSurface.toggleTaskSidebar(); } }, [ + generationSurface, generationSurface.isTaskSidebarOpen, isAgentConversationEnabled, isAgentConversationOpen,