feat: workerize external generation

This commit is contained in:
2026-06-05 17:29:08 +08:00
parent 5150925947
commit 8d54ea3374
60 changed files with 5285 additions and 700 deletions

View File

@@ -4769,6 +4769,60 @@ test('running puzzle form generation creates a new puzzle draft on same template
});
});
test('queued puzzle form generation stays on generation progress', async () => {
const user = userEvent.setup();
const queuedSession = buildMockPuzzleAgentSession({
sessionId: 'puzzle-queued-session-1',
progressPercent: 5,
lastAssistantReply: '拼图生成任务已进入后台队列。',
});
vi.mocked(createPuzzleAgentSession).mockResolvedValueOnce({
session: queuedSession,
});
vi.mocked(executePuzzleAgentAction).mockResolvedValueOnce({
operation: {
operationId: 'compile-puzzle-queued-1',
type: 'compile_puzzle_draft',
status: 'queued',
phaseLabel: '已进入后台队列',
phaseDetail: '拼图草稿生成已进入后台队列。',
progress: 5,
error: null,
},
session: queuedSession,
});
vi.mocked(getPuzzleAgentSession).mockResolvedValue({
session: {
...queuedSession,
progressPercent: 12,
},
});
render(<TestWrapper withAuth />);
await openCreateTemplateHub(user);
await user.click(await findCreationTypeButton('拼图'));
await user.click(await screen.findByRole('button', { name: '生成草稿' }));
const progressbar = await screen.findByRole('progressbar', {
name: '拼图图片生成进度',
});
expect(progressbar).toBeTruthy();
expect(updatePuzzleWork).not.toHaveBeenCalled();
expect(startLocalPuzzleRun).not.toHaveBeenCalled();
expect(screen.queryByText('拼图结果页')).toBeNull();
expect(window.location.pathname).not.toBe('/runtime/puzzle');
await user.click(screen.getByRole('button', { name: '返回创作中心' }));
await openDraftHub(user);
await waitFor(() => {
expect(
within(getPlatformTabPanel('saves')).getAllByRole('button', {
name: /继续创作《[^》]+》,生成中/u,
}).length,
).toBeGreaterThanOrEqual(1);
});
});
test('failed parallel puzzle generations stay as separate non-generating drafts', async () => {
const user = userEvent.setup();
const firstSession = buildMockPuzzleAgentSession({