fix(design): preserve command outcome certainty

This commit is contained in:
2026-09-03 18:25:06 +08:00
parent 4d8b19eeb5
commit a16dfd0d6f
15 changed files with 576 additions and 23 deletions

View File

@@ -54,6 +54,32 @@ describe('host-api', () => {
});
});
it('preserves command outcome certainty from the Host API error envelope', async () => {
invokeIpcMock.mockResolvedValueOnce({
ok: true,
data: {
status: 502,
ok: false,
json: {
success: false,
code: 'design_reasoner_invalid',
error: 'AI 没有整理好这次想法,请再试一次',
commandOutcome: 'definitive_failure',
},
},
});
const { hostApiFetch } = await import('@/lib/host-api');
await expect(hostApiFetch('/api/works/image-workspace/workspaces/workspace-1/commands'))
.rejects.toMatchObject({
details: expect.objectContaining({
backendCode: 'design_reasoner_invalid',
commandOutcome: 'definitive_failure',
}),
});
});
it('returns undefined for a unified 204 response', async () => {
invokeIpcMock.mockResolvedValueOnce({
ok: true,