fix(design): show submitted messages immediately
Some checks failed
Electron E2E / Electron E2E (macos-latest) (push) Has been cancelled
Electron E2E / Electron E2E (ubuntu-latest) (push) Has been cancelled
Electron E2E / Electron E2E (windows-latest) (push) Has been cancelled

This commit is contained in:
2026-09-04 08:38:13 +08:00
parent c6b0490d7f
commit 403236115b
4 changed files with 208 additions and 13 deletions

View File

@@ -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('画一只会做饭的机器人');