Skip to content

Commit ae6400d

Browse files
committed
test(cursor): fold pagination into the recovery regression
1 parent 98b8b18 commit ae6400d

1 file changed

Lines changed: 13 additions & 36 deletions

File tree

‎packages/provider-cursor/src/server/CursorAgentSdk.test.ts‎

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,13 @@ describe("CursorAgentSdkRunner", () => {
187187
cursorSdkMock.runOperations.length = 0;
188188
cursorSdkMock.listRuns.mockClear();
189189
cursorSdkMock.cancelRun.mockClear();
190-
cursorSdkMock.setStoredRuns([{ id: "run-stale", status: "running" }]);
190+
cursorSdkMock.setStoredRuns([
191+
...Array.from({ length: 50 }, (_, index) => ({
192+
id: `run-terminal-${index}`,
193+
status: index === 0 ? "cancelled" : "finished",
194+
})),
195+
{ id: "run-stale", status: "running" },
196+
]);
191197

192198
const runner = yield* CursorAgentSdk.CursorAgentSdkRunner;
193199
const session = yield* runner.open({
@@ -206,13 +212,19 @@ describe("CursorAgentSdkRunner", () => {
206212
assert.deepStrictEqual(cursorSdkMock.runOperations, [
207213
"run.start",
208214
"agent.listRuns",
215+
"agent.listRuns",
209216
"agent.cancelRun",
210217
"run.start",
211218
]);
212219
assert.deepStrictEqual(cursorSdkMock.listRuns.mock.calls[0], [
213220
"agent-cursor-agent-sdk-test",
214221
{ runtime: "local", cwd: process.cwd() },
215222
]);
223+
assert.strictEqual(cursorSdkMock.listRuns.mock.calls.length, 2);
224+
assert.deepStrictEqual(cursorSdkMock.listRuns.mock.calls[1], [
225+
"agent-cursor-agent-sdk-test",
226+
{ runtime: "local", cwd: process.cwd(), cursor: "50" },
227+
]);
216228
assert.deepStrictEqual(cursorSdkMock.cancelRun.mock.calls[0], [
217229
"run-stale",
218230
{
@@ -223,41 +235,6 @@ describe("CursorAgentSdkRunner", () => {
223235
}).pipe(Effect.provide(layerTest)),
224236
);
225237

226-
it.effect("cancels the abandoned run on a later page behind older terminal runs", () =>
227-
Effect.gen(function* () {
228-
cursorSdkMock.runOperations.length = 0;
229-
cursorSdkMock.listRuns.mockClear();
230-
cursorSdkMock.cancelRun.mockClear();
231-
cursorSdkMock.setStoredRuns([
232-
...Array.from({ length: 50 }, (_, index) => ({
233-
id: `run-terminal-${index}`,
234-
status: index === 0 ? "cancelled" : "finished",
235-
})),
236-
{ id: "run-abandoned-on-second-restart", status: "running" },
237-
]);
238-
239-
const runner = yield* CursorAgentSdk.CursorAgentSdkRunner;
240-
const session = yield* runner.open({
241-
operation: "resume",
242-
agentId: "agent-cursor-agent-sdk-test",
243-
options: { model: { id: "default" }, mode: "agent", local: { cwd: process.cwd() } },
244-
threadId: ThreadId.make("thread-cursor-agent-sdk-second-stale-run-test"),
245-
providerSessionId: ProviderSessionId.make(
246-
"provider-session-cursor-agent-sdk-second-stale-run-test",
247-
),
248-
});
249-
const run = yield* session.send({ message: "continue" });
250-
yield* run.wait;
251-
252-
assert.deepStrictEqual(cursorSdkMock.listRuns.mock.calls.length, 2);
253-
assert.deepStrictEqual(
254-
cursorSdkMock.cancelRun.mock.calls[0]?.[0],
255-
"run-abandoned-on-second-restart",
256-
);
257-
assert.deepStrictEqual(cursorSdkMock.runOperations.at(-1), "run.start");
258-
}).pipe(Effect.provide(layerTest)),
259-
);
260-
261238
it.effect("forwards Run.steer and reports a missing method as a follow-up", () =>
262239
Effect.gen(function* () {
263240
cursorSdkMock.runSteer.mockClear();

0 commit comments

Comments
 (0)