fix(design): preserve command outcome certainty
This commit is contained in:
1 parent
4d8b19eeb5
commit
a16dfd0d6f
15 files changed
+576
-23
No files matched your search
@@ -3,7 +3,10 @@ import { Readable, Writable } from 'node:stream';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { handleImageWorkspaceRoutes } from '@electron/api/routes/image-workspace';
|
||||
import type { HostApiContext } from '@electron/api/context';
|
||||
import type { DesignWorkspaceModule } from '@electron/image-workspace/module';
|
||||
import {
|
||||
DesignWorkspaceModuleError,
|
||||
type DesignWorkspaceModule,
|
||||
} from '@electron/image-workspace/module';
|
||||
import {
|
||||
designBootstrapFixture,
|
||||
designWorkspaceFixture,
|
||||
@@ -250,6 +253,37 @@ describe('AI design V2 Main route boundary', () => {
|
||||
expect(module.submitCommand).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('preserves command outcome certainty in the local error envelope', async () => {
|
||||
const module = moduleFixture({
|
||||
submitCommand: vi.fn().mockRejectedValue(new DesignWorkspaceModuleError(
|
||||
502,
|
||||
'design_reasoner_invalid',
|
||||
'AI 没有整理好这次想法,请再试一次',
|
||||
'definitive_failure',
|
||||
)),
|
||||
});
|
||||
const response = createResponse();
|
||||
|
||||
await handleImageWorkspaceRoutes(
|
||||
createRequest('POST', {
|
||||
kind: 'apply_input',
|
||||
sessionId: 'session-1',
|
||||
expectedDirectionRevision: 4,
|
||||
clientOperationId: 'operation-1',
|
||||
input: { kind: 'chat', message: '画一只会做饭的机器人' },
|
||||
}),
|
||||
response.res,
|
||||
new URL('http://127.0.0.1/api/works/image-workspace/workspaces/workspace-1/commands'),
|
||||
context(module),
|
||||
);
|
||||
|
||||
expect(response.statusCode).toBe(502);
|
||||
expect(response.json()).toMatchObject({
|
||||
code: 'design_reasoner_invalid',
|
||||
commandOutcome: 'definitive_failure',
|
||||
});
|
||||
});
|
||||
|
||||
it('relays resumable normalized events over local SSE', async () => {
|
||||
const close = vi.fn();
|
||||
const openWorkspaceEvents = vi.fn().mockResolvedValue({
|
||||
|
||||
Reference in new issue
Block a user