fix(pi): retain ownership for uncertain mutations

This commit is contained in:
2026-08-25 23:53:54 +08:00
parent 621ebb1781
commit 019cbb115a
21 changed files with 1113 additions and 67 deletions

View File

@@ -587,7 +587,21 @@ describe('coding Conversation store', () => {
})).rejects.toThrow('Delivery is uncertain');
source.fail();
source.open();
source.emit('snapshot', snapshotEvent(snapshot('conversation-a')));
const activeSnapshot = snapshot('conversation-a');
source.emit('snapshot', snapshotEvent({
...activeSnapshot,
run: {
status: 'running',
runId: 'run-uncertain',
mode: 'prompt',
startedAt: 1_000,
error: {
code: 'CODING_REQUEST_UNCERTAIN',
message: '请求确认延迟,可能仍在执行。',
recoverable: true,
},
},
}));
expect(store.getState().draftsByConversationId['conversation-a'].text).toBe('Do not replay');
expect(store.getState().requestsByConversationId['conversation-a']['request-1'])
@@ -596,6 +610,22 @@ describe('coding Conversation store', () => {
expect(selectCodingConversationSnapshot('conversation-a')(store.getState())?.nodes[0])
.toMatchObject({ id: 'node-1', status: 'optimistic' });
expect(submitPrompt).toHaveBeenCalledTimes(1);
store.getState().applyPatchBatchEvent(patchBatch('conversation-a', 1, [{
op: 'run.state',
run: {
status: 'idle',
runId: 'run-uncertain',
mode: 'prompt',
startedAt: 1_000,
settledAt: 12_000,
terminalReason: 'completed',
},
}]));
expect(store.getState().requestsByConversationId['conversation-a']).toEqual({});
expect(store.getState().draftsByConversationId['conversation-a'].text).toBe('Do not replay');
expect(store.getState().entriesByConversationId['conversation-a'].error).toBeNull();
});
it('keeps a primed first Conversation usable while runtime preparation is still held', async () => {