fix: isolate concurrent OpenCode chat runs

This commit is contained in:
brother7 committed 2026-08-17 22:03:37 +08:00
1 parent 7e8d9e3811
commit 65040730ec
29 files changed
+5207 -427

No files matched your search

@@ -108,4 +108,64 @@ describe('Makelore character scene partner profiles', () => {
fireEvent.click(screen.getByRole('button', { name: '返回技能列表' }));
expect(await screen.findByTestId('skill-library-card-agent-browser')).toBeInTheDocument();
});
it('defers the automatic model refresh and applies it only after an explicit click', async () => {
const importUserModelConfig = vi.fn()
.mockResolvedValueOnce({
account: {
id: 'niancode-user-models',
vendorId: 'custom',
label: 'Makelore Models',
authMode: 'api_key',
enabled: true,
isDefault: true,
createdAt: '2026-08-17T00:00:00.000Z',
updatedAt: '2026-08-17T00:00:00.000Z',
},
importedModels: ['gpt-4.1-mini'],
runtimeRefreshRequired: true,
})
.mockResolvedValueOnce({
account: {
id: 'niancode-user-models',
vendorId: 'custom',
label: 'Makelore Models',
authMode: 'api_key',
enabled: true,
isDefault: true,
createdAt: '2026-08-17T00:00:00.000Z',
updatedAt: '2026-08-17T00:00:00.000Z',
},
importedModels: ['gpt-4.1-mini'],
runtimeRefreshRequired: true,
});
useAuthStore.setState({
accessToken: 'access-token',
getValidAccessToken: vi.fn().mockResolvedValue('access-token'),
});
useProviderStore.setState({
refreshProviderSnapshot: vi.fn().mockResolvedValue(undefined),
importUserModelConfig,
});
render(<MemoryRouter><CharacterScene /></MemoryRouter>);
fireEvent.click(screen.getByTestId('resource-card-models'));
expect(await screen.findByTestId('makelore-runtime-refresh-pending')).toBeVisible();
expect(importUserModelConfig).toHaveBeenNthCalledWith(1, 'access-token', {
runtimeRefresh: 'defer',
});
fireEvent.click(screen.getByTestId('makelore-model-config-refresh-button'));
await waitFor(() => {
expect(importUserModelConfig).toHaveBeenNthCalledWith(2, 'access-token', {
runtimeRefresh: 'apply',
});
});
await waitFor(() => {
expect(screen.queryByTestId('makelore-runtime-refresh-pending')).not.toBeInTheDocument();
});
});
});