@devries-cameron20 / t3code Mirror · read-only / commits / 11e5b13f38
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

perf(linear): skip viewer lookup for comments without reactions (#39189)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Adamulek123 committed Nov 19, 2026 at 18:15 UTC 11e5b13f38fbdf07d704ba423ec6a9b892d8c8cb
2 files changed +49 -4
packages/issue-tracker-linear/src/server/LinearIssueTracker.test.ts
+41
@@ -304,6 +304,47 @@ describe("LinearIssueTracker", () => {
304 }),
305 );
306
307 + it.effect("reads the viewer only for comment pages with reactions", () =>
308 + Effect.gen(function* () {
309 + const { tracker, requests } = fakeLinear({
310 + T3Comments: ({ after }) => ({
311 + issue: {
312 + comments: {
313 + nodes: [
314 + {
315 + id: "cmt_1",
316 + body: "hi",
317 + createdAt: "2026-07-02T01:00:00.000Z",
318 + url: "https://linear.app/acme/issue/ENG-7#comment-cmt_1",
319 + user: THEO,
320 + botActor: null,
321 + reactions: after === "reacted" ? [{ id: "r1", emoji: "+1", user: JULIUS }] : [],
322 + },
323 + ],
324 + pageInfo: { hasNextPage: false, endCursor: null },
325 + },
326 + },
327 + }),
328 + T3Viewer: () => ({
329 + viewer: JULIUS,
330 + organization: { urlKey: "acme" },
331 + teams: { nodes: [] },
332 + }),
333 + });
334 + const api = yield* tracker;
335 + const viewerReads = () => requests.filter((r) => r.operation === "T3Viewer").length;
336 + const ref = { ...target, key: "ENG-7" };
337 + const plain = yield* api.getComments({ ...ref, cursor: "plain" });
338 + expect(plain.comments[0]?.reactions).toEqual([]);
339 + expect(viewerReads()).toBe(0);
340 + const reacted = yield* api.getComments({ ...ref, cursor: "reacted" });
341 + expect(reacted.comments[0]?.reactions).toEqual([
342 + { content: "thumbs-up", count: 1, actors: [], viewerHasReacted: true },
343 + ]);
344 + expect(viewerReads()).toBe(1);
345 + }),
346 + );
347 +
348 it.effect("reads an issue with its comments, reactions, history and linked pull requests", () =>
349 Effect.gen(function* () {
350 const { tracker } = fakeLinear({
packages/issue-tracker-linear/src/server/LinearIssueTracker.ts
+8 -4
@@ -512,10 +512,14 @@ export const make: Effect.Effect<StandaloneIssueTrackerApi, never, LinearApi.Lin
512
513 getComments: Effect.fn("LinearIssueTracker.getComments")(function* (input) {
514 const identifier = yield* requireIdentifier("getComments", input.key);
515 - const [page, viewer] = yield* Effect.all([
516 - linear.getComments({ identifier, first: COMMENTS_PAGE, after: input.cursor }),
517 - viewerId,
518 - ]);
515 + const page = yield* linear.getComments({
516 + identifier,
517 + first: COMMENTS_PAGE,
518 + after: input.cursor,
519 + });
520 + const viewer = page.nodes.some((comment) => comment.reactions.length > 0)
521 + ? yield* viewerId
522 + : null;
523 return {
524 comments: page.nodes.map((comment) => toComment(comment, viewer)),
525 nextCursor: page.nextCursor,