GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): include Cursor team usage in account history by Yash-Singh1 · Pull Request #36237 · pingdotgg/t3code

fix(server): include Cursor team usage in account history #36237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Yash-Singh1 merged 3 commits into main from t3/fix-cursor-usage-totals
Nov 13, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

fix(server): include Cursor team usage in account history #36237

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit Hold shift + click to select a range
4d4eb71
fix(server): include Cursor team usage in account history
Yash-Singh1 Nov 13, 2026
15fe2f4
Merge remote-tracking branch 'origin/main' into t3/fix-cursor-usage-t…
Yash-Singh1 Nov 13, 2026
f53dbf2
fix(cursor): start page timeout after acquiring request slot
Yash-Singh1 Nov 13, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
fix(cursor): start page timeout after acquiring request slot
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@Yash-Singh1
Yash-Singh1 committed Nov 13, 2026
commit f53dbf288f820e70dabc20bcb7a88051450ac247

Some comments aren't visible on the classic Files Changed page.

There are no files selected for viewing

102 changes: 71 additions & 31 deletions 102 packages/provider-cursor/src/server/accountUsage.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
import * as Layer from "effect/Layer";
import { assert, describe, it } from "@effect/vitest";
import * as Deferred from "effect/Deferred";
import * as Queue from "effect/Queue";
import * as Context from "effect/Context";
import * as Effect from "effect/Effect";
import * as Fiber from "effect/Fiber";
Expand Down Expand Up @@ -510,37 +511,76 @@ describe("readCursorAccountUsage", () => {
}).pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
);

it.effect("reads the pages behind the first together and keeps them in page order", () =>
Effect.gen(function* () {
const accessToken = `header.${Buffer.from(JSON.stringify({ sub: "auth|demo" })).toString("base64url")}.signature`;
let inFlight = 0;
let mostInFlight = 0;
const result = yield* readAccountUsage(
{ kind: "apiKey", apiKey: accessToken },
0,
1781000000000,
async ({ page }) => {
inFlight++;
mostInFlight = Math.max(mostInFlight, inFlight);
for (let turn = page; turn < 9; turn++) await Promise.resolve();
inFlight--;
return Response.json({
totalUsageEventsCount: 8001,
usageEventsDisplay: Array.from({ length: page === 9 ? 1 : 1000 }, (_, index) => ({
timestamp: String(1780000000000 + (page - 1) * 1000 + index),
model: "gpt-5",
tokenUsage: { inputTokens: 1 },
})),
});
},
);
assert.isNull(result.error);
assert.strictEqual(mostInFlight, 6);
assert.deepStrictEqual(
result.records.map((record) => record.timestampMs),
Array.from({ length: 8001 }, (_, index) => 1780000000000 + index),
);
}).pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
it.effect.each([{ queued: false }, { queued: true }])(
"reads concurrent pages in order with a full request deadline after queuing: $queued",
({ queued }) =>
Effect.gen(function* () {
const accessToken = `header.${Buffer.from(JSON.stringify({ sub: "auth|demo" })).toString("base64url")}.signature`;
const started = yield* Queue.unbounded<void>();
const firstBatch = yield* Deferred.make<void>();
const secondBatch = yield* Deferred.make<void>();
let delayedRequests = 0;
let inFlight = 0;
let mostInFlight = 0;
const client = dashboard(
async ({ page }) => {
inFlight++;
mostInFlight = Math.max(mostInFlight, inFlight);
for (let turn = page; turn < 9; turn++) await Promise.resolve();
inFlight--;
return Response.json({
totalUsageEventsCount: 8001,
usageEventsDisplay: Array.from({ length: page === 9 ? 1 : 1000 }, (_, index) => ({
timestamp: String(1780000000000 + (page - 1) * 1000 + index),
model: "gpt-5",
tokenUsage: { inputTokens: 1 },
})),
});
},
{ userId: 42, teamIds: queued ? [7] : [] },
).pipe(
HttpClient.transform((response, request) => {
if (!queued || !request.url.endsWith("/GetFilteredUsageEvents")) return response;
const body =
request.body._tag === "Uint8Array"
? JSON.parse(new TextDecoder().decode(request.body.body))
: {};
if (body.page === 1) return response;
return Effect.gen(function* () {
const batch = delayedRequests++ < 6 ? firstBatch : secondBatch;
yield* Queue.offer(started, undefined);
yield* Deferred.await(batch);
return yield* response;
});
}),
);
const read = yield* Effect.forkChild(
makeCursorAccountUsageReader.pipe(
Effect.flatMap((reader) =>
reader({ kind: "apiKey", apiKey: accessToken }, 0, 1781000000000),
),
Effect.provideService(HttpClient.HttpClient, client),
),
);
if (queued) {
yield* Effect.all(Array.from({ length: 6 }, () => Queue.take(started)));
yield* TestClock.adjust("6 seconds");
yield* Deferred.succeed(firstBatch, undefined);
yield* Effect.all(Array.from({ length: 6 }, () => Queue.take(started)));
yield* TestClock.adjust("6 seconds");
yield* Deferred.succeed(secondBatch, undefined);
}
const result = yield* Fiber.join(read);
assert.isNull(result.error);
assert.strictEqual(mostInFlight, 6);
assert.deepStrictEqual(
result.records.map((record) => record.timestampMs),
Array.from(
{ length: queued ? 16002 : 8001 },
(_, index) => 1780000000000 + (index % 8001),
),
);
}).pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
);

it.effect("ends like a page-by-page read when a page fails, leaving no request open", () =>
Expand Down
2 changes: 1 addition & 1 deletion 2 packages/provider-cursor/src/server/accountUsage.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,11 @@ export const makeCursorAccountUsageReader = Effect.gen(function* () {
if (typeof count === "number") total = count;
return events as unknown[];
},
pageSlots.withPermit,
Effect.timeoutOrElse({
duration: Duration.seconds(10),
orElse: () => invalid("Account usage request timed out"),
}),
pageSlots.withPermit,
);
// Cursor caps a page at 1,000 events and takes about a second to answer one, so the pages
// the first one's count implies are requested up to six ahead and consumed in page order.
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.