The best way to control Claude Code, Codex and more from any computer or phone
chore(gitcafe): pull request listing records how many pages it read (#39867)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 20, 2026 at 15:31 UTC
8a0f19092e8c3582385acaa3f477f47f8b25e5ee
1 file changed
+40
-4
packages/source-control-gitcafe/src/server/GitCafePullRequestProvider.ts
+40
-4
@@ -814,6 +814,20 @@ export const make = Effect.gen(function* () {
814
listChangeRequests: Effect.fn("GitCafePullRequestProvider.listChangeRequests")(
815
function* (input) {
816
const base = yield* repositoryPath("listChangeRequests", input);
817
+ yield* Effect.annotateCurrentSpan({
818
+ "gitcafe.list.limit": input.limit,
819
+ "gitcafe.list.resumed": input.cursor?.resumeAfter !== undefined,
820
+ "gitcafe.list.state": input.state,
821
+ "gitcafe.list.query": Boolean(input.query?.trim()),
822
+ "gitcafe.list.involvement": input.involvement ?? "none",
823
+ "gitcafe.list.author_discovery_pages": 0,
824
+ });
825
+ const annotateOutcome = (pages: number, rows: number, truncated: boolean) =>
826
+ Effect.annotateCurrentSpan({
827
+ "gitcafe.list.pages": pages,
828
+ "gitcafe.list.rows": rows,
829
+ "gitcafe.list.truncated": truncated,
830
+ });
831
const involved = input.involvement === "authored" || input.involvement === "reviewing";
832
let actorId: string | undefined;
833
if (involved) {
@@ -836,8 +850,10 @@ export const make = Effect.gen(function* () {
850
}),
851
);
852
if (Option.isSome(principal)) {
839
- if (principal.value.handle.toLowerCase() !== input.viewer.toLowerCase())
853
+ if (principal.value.handle.toLowerCase() !== input.viewer.toLowerCase()) {
854
+ yield* annotateOutcome(0, 0, false);
855
return { items: [], truncated: false, continues: false };
856
+ }
857
actorId = principal.value.actorId;
858
}
859
}
@@ -845,6 +861,10 @@ export const make = Effect.gen(function* () {
861
{ ...input, authorNarrowed: actorId !== undefined && input.involvement === "authored" },
862
base,
863
);
864
+ yield* Effect.annotateCurrentSpan({
865
+ "gitcafe.list.actor_narrowed": actorId !== undefined,
866
+ "gitcafe.list.author_discovery": unresolvedAuthor !== null,
867
+ });
868
const readPage = Effect.fn("readPage")(function (rows: number, after: string | null) {
869
const query = new URLSearchParams({ limit: String(rows), sort: "newest" });
870
if (input.state !== "all") query.set("state", input.state);
@@ -861,7 +881,15 @@ export const make = Effect.gen(function* () {
881
input,
882
{ path: `${base}/pulls?${query}` },
883
Json.GitCafePulls,
864
- ).pipe(Effect.tap((page) => Effect.sync(() => learnAuthors(input.host, page.items))));
884
+ ).pipe(
885
+ Effect.tap((page) => Effect.sync(() => learnAuthors(input.host, page.items))),
886
+ Effect.tap((page) =>
887
+ Effect.annotateCurrentSpan({
888
+ "gitcafe.page.rows_requested": rows,
889
+ "gitcafe.page.rows_returned": page.items.length,
890
+ }),
891
+ ),
892
+ );
893
});
894
if (unresolvedAuthor !== null) {
895
// Rows are only ever handed out narrowed by actor, so a continuation always carries on
@@ -874,11 +902,15 @@ export const make = Effect.gen(function* () {
902
pages += 1;
903
after = page.items.length === 0 ? null : page.next;
904
} while (!knownAuthors.has(key) && after !== null && pages < AUTHOR_DISCOVERY_PAGES);
905
+ yield* Effect.annotateCurrentSpan("gitcafe.list.author_discovery_pages", pages);
906
const found = knownAuthors.get(key);
878
- if (found === undefined)
907
+ if (found === undefined) {
908
+ yield* annotateOutcome(0, 0, after !== null);
909
return { items: [], truncated: after !== null, continues: false };
910
+ }
911
filterParams.push(["authors", encodeIds([found])]);
912
}
913
+ yield* Effect.annotateCurrentSpan("gitcafe.list.filtered", filterParams.length > 0);
914
const limit = Math.max(1, input.limit);
915
const items: Array<Json.GitCafePull> = [];
916
// GitCafe pages by an opaque token and orders by creation, so a continuation reads from the
@@ -893,16 +925,20 @@ export const make = Effect.gen(function* () {
925
);
926
};
927
let next: string | null = null;
928
+ let listingPages = 0;
929
do {
930
const page: typeof Json.GitCafePulls.Type = yield* readPage(
931
resume === null ? Math.min(PAGE_SIZE, limit - items.length) : PAGE_SIZE,
932
next,
933
);
934
+ listingPages += 1;
935
items.push(...page.items.filter(isNew));
936
next = page.items.length === 0 ? null : page.next;
937
} while (next !== null && items.length < limit);
938
const delivered = items.slice(0, limit);
939
const last = delivered.at(-1);
940
+ const truncated = next !== null || items.length > limit;
941
+ yield* annotateOutcome(listingPages, delivered.length, truncated);
942
return {
943
...(last === undefined ? {} : { resumeAfter: `${last.createdAt}~${last.number}` }),
944
items: delivered.map((pull) => {
@@ -914,7 +950,7 @@ export const make = Effect.gen(function* () {
950
}
951
: item;
952
}),
917
- truncated: next !== null || items.length > limit,
953
+ truncated,
954
continues: true,
955
};
956
},