fix(design): show submitted messages immediately
This commit is contained in:
@@ -223,6 +223,50 @@ describe('V2 Living Form store', () => {
|
||||
expect(useImageWorkspaceStore.getState().pendingOperations).toEqual({});
|
||||
});
|
||||
|
||||
it('publishes a pending chat operation before the server result settles', async () => {
|
||||
await loadedStore();
|
||||
const message = '画一只在月球踢球的熊猫';
|
||||
const submission = deferred<Awaited<ReturnType<typeof submitImageWorkspaceCommand>>>();
|
||||
submitCommandMock.mockReturnValueOnce(submission.promise);
|
||||
useImageWorkspaceStore.getState().setChatDraft(message);
|
||||
|
||||
const sendPromise = useImageWorkspaceStore.getState().sendChat();
|
||||
|
||||
expect(useImageWorkspaceStore.getState()).toMatchObject({
|
||||
chatDraft: message,
|
||||
pendingOperations: {
|
||||
'operation-1': {
|
||||
id: 'operation-1',
|
||||
status: 'submitting',
|
||||
clearChatDraft: true,
|
||||
command: {
|
||||
kind: 'apply_input',
|
||||
workspaceId: 'workspace-1',
|
||||
clientOperationId: 'operation-1',
|
||||
input: { kind: 'chat', message },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const workspace = designWorkspaceFixture({
|
||||
turns: [{
|
||||
turnId: 'turn-2',
|
||||
rawTurnSequence: 2,
|
||||
userMessage: message,
|
||||
assistantMessage: '你希望画面更像漫画,还是更像电影?',
|
||||
}],
|
||||
});
|
||||
submission.resolve({ clientOperationId: 'operation-1', runId: 'run-2', workspace });
|
||||
await sendPromise;
|
||||
|
||||
expect(useImageWorkspaceStore.getState()).toMatchObject({
|
||||
workspace,
|
||||
chatDraft: '',
|
||||
pendingOperations: {},
|
||||
});
|
||||
});
|
||||
|
||||
it('settles a definitive reasoner failure without losing the chat draft', async () => {
|
||||
const source = await loadedStore();
|
||||
useImageWorkspaceStore.getState().setChatDraft('画一只会做饭的机器人');
|
||||
|
||||
Reference in New Issue
Block a user