mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-25 05:07:05 +00:00
fix(cursor): merge SKU catalog under ACP lock and refcount agent guard (#835)
Fixes incomplete cliModelSkus while agent acp holds the CLI lock (#831) and replace single-pid ACP lock with cross-process refcount (#832). Web picker merges machine/session catalogs and waits for SKU readiness before showing variant labels. Fixes #831 Fixes #832 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { afterEach, describe, expect, test, vi } from 'vitest';
|
||||
|
||||
const listCursorModelsMock = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock('./cursorModels', () => ({
|
||||
listCursorModels: listCursorModelsMock
|
||||
}));
|
||||
|
||||
import { scheduleCursorModelsPrewarm } from './cursorModelsPrewarm';
|
||||
|
||||
afterEach(() => {
|
||||
listCursorModelsMock.mockReset();
|
||||
});
|
||||
|
||||
describe('scheduleCursorModelsPrewarm', () => {
|
||||
test('starts a background listCursorModels call', async () => {
|
||||
listCursorModelsMock.mockResolvedValue({
|
||||
success: true,
|
||||
availableModels: [],
|
||||
currentModelId: null
|
||||
});
|
||||
|
||||
scheduleCursorModelsPrewarm();
|
||||
|
||||
await Promise.resolve();
|
||||
|
||||
expect(listCursorModelsMock).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('swallows listCursorModels failures', async () => {
|
||||
listCursorModelsMock.mockRejectedValue(new Error('agent missing'));
|
||||
|
||||
scheduleCursorModelsPrewarm();
|
||||
|
||||
await Promise.resolve();
|
||||
|
||||
expect(listCursorModelsMock).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user