fix(pi): resolve packaged proxy token lazily

This commit is contained in:
2026-08-24 21:41:29 +08:00
parent fa510c4976
commit f902edefd0
13 changed files with 934 additions and 30 deletions

View File

@@ -676,6 +676,60 @@ describe('coding Conversation store', () => {
expect(store.getState().draftsByConversationId['conversation-a'].text).toBe('Keep this draft');
});
it('leaves a failed recover retryable without losing the target Snapshot, selection, or draft', async () => {
const initialSnapshot = snapshot('conversation-a', 1, 4);
const recoveredSnapshot = snapshot('conversation-a', 2, 5);
const recover = vi.fn()
.mockRejectedValueOnce(new Error('Provider authentication is required'))
.mockResolvedValueOnce(undefined);
const getSnapshot = vi.fn()
.mockResolvedValueOnce(initialSnapshot)
.mockResolvedValueOnce(recoveredSnapshot);
const store = createCodingConversationStore({
getSnapshot,
openEvents: vi.fn(async () => new FakeEventSource() as unknown as EventSource),
submitPrompt: vi.fn(),
recover,
createId: ids(),
});
await store.getState().selectConversation('conversation-a');
store.getState().setDraft('conversation-a', 'Keep retry context', [{
attachmentId: 'attachment-retry',
mime: 'image/png',
previewUrl: 'blob:retry-preview',
}]);
const lastGoodSnapshot = selectCodingConversationSnapshot('conversation-a')(store.getState());
await expect(store.getState().recoverConversation('conversation-a'))
.rejects.toThrow('Provider authentication is required');
expect(store.getState().selectedConversationId).toBe('conversation-a');
expect(store.getState().entriesByConversationId['conversation-a']).toMatchObject({
loadState: 'error',
error: 'Provider authentication is required',
});
expect(selectCodingConversationSnapshot('conversation-a')(store.getState())).toBe(lastGoodSnapshot);
expect(store.getState().draftsByConversationId['conversation-a']).toMatchObject({
text: 'Keep retry context',
attachments: [{
attachmentId: 'attachment-retry',
mime: 'image/png',
previewUrl: 'blob:retry-preview',
}],
});
expect(getSnapshot).toHaveBeenCalledTimes(1);
await store.getState().recoverConversation('conversation-a');
expect(recover).toHaveBeenCalledTimes(2);
expect(getSnapshot).toHaveBeenCalledTimes(2);
expect(store.getState().entriesByConversationId['conversation-a']).toMatchObject({
loadState: 'live',
error: null,
});
expect(selectCodingConversationSnapshot('conversation-a')(store.getState())).toEqual(recoveredSnapshot);
expect(store.getState().draftsByConversationId['conversation-a'].text).toBe('Keep retry context');
});
it('folds a 100 KB thinking batch in one notification without duplicate deltas', () => {
const store = createCodingConversationStore({
getSnapshot: vi.fn(),