@devries-cameron20 / t3code-1 / commits / 2216ffe006
Fork 0

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

fix(server): All issues pages skip the signed-in account read (#38431)

Co-authored-by: Grok 4.7 <noreply@x.ai> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Wout Stiens committed Nov 18, 2026 at 05:09 UTC 2216ffe00688aa7e446a6d3b517bce6b804d6886
11 files changed +75 -60
apps/server/src/issue/IssueService.test.ts
+8 -2
@@ -421,7 +421,7 @@ describe("IssueService", () => {
421 expect(result.errors).toEqual([
422 { projectId: "api", projectTitle: "api", message: "The issue tracker request failed." },
423 ]);
424 - expect(result.viewers).toEqual({ "github.com": "julius" });
424 + expect(result.viewers).toEqual({});
425 expect(result.trackers).toEqual([
426 expect.objectContaining({ host: "github.com", projectCount: 4, configured: true }),
427 expect.objectContaining({
@@ -434,7 +434,13 @@ describe("IssueService", () => {
434 ]);
435
436 // Narrowing to one host still names every tracker, so the client can switch between them.
437 - const narrowed = yield* service.list({ state: "open", host: "github.com" });
437 + // Narrowing by involvement reads the account it compares against.
438 + const narrowed = yield* service.list({
439 + state: "open",
440 + host: "github.com",
441 + involvement: "assigned",
442 + });
443 + expect(narrowed.viewers).toEqual({ "github.com": "julius" });
444 expect(narrowed.entries.every((entry) => entry.host === "github.com")).toBe(true);
445 expect(narrowed.trackers.map((tracker) => tracker.host)).toEqual([
446 "github.com",
apps/server/src/issue/IssueService.ts
+13 -5
@@ -36,6 +36,7 @@ import * as SourceControlRateLimit from "@t3tools/source-control-core/server/Sou
36 import {
37 IssueTrackerError,
38 isStandaloneIssueTracker,
39 + type IssueInvolvementFilter,
40 type IssueTrackerApi,
41 type StandaloneIssueTrackerApi,
42 type TrackerIssueDetail,
@@ -339,8 +340,10 @@ const make = Effect.gen(function* () {
340 const errors: IssueListProjectError[] = [];
341 const nextCursors: Record<string, string> = {};
342
343 + const involvement = input.involvement ?? "all";
344 + // Only a narrowed listing compares against the signed-in account; `all` never reads it.
345 const viewerRequests = new Map<string, Effect.Effect<string, IssueTrackerError>>();
343 - for (const project of scopes.values()) {
346 + for (const project of involvement === "all" ? [] : scopes.values()) {
347 if (viewerRequests.has(project.host)) continue;
348 const request = yield* Effect.cached(
349 project.api
@@ -385,15 +388,20 @@ const make = Effect.gen(function* () {
388 // A continuation names the scopes it wants; one not named has nothing to add.
389 if (continuing !== undefined && continuing[key] === undefined) return;
390 const cursor = continuing?.[key];
388 - const page = yield* viewerRequests.get(project.host)!.pipe(
389 - Effect.flatMap((viewer) =>
391 + const filter: Effect.Effect<IssueInvolvementFilter, IssueTrackerError> =
392 + involvement === "all"
393 + ? Effect.succeed({ involvement })
394 + : viewerRequests
395 + .get(project.host)!
396 + .pipe(Effect.map((viewer) => ({ involvement, viewer })));
397 + const page = yield* filter.pipe(
398 + Effect.flatMap((filter) =>
399 project.api.listIssues({
400 + ...filter,
401 cwd: project.project.workspaceRoot,
402 host: project.host,
403 scope: project.scope,
404 state: input.state,
395 - involvement: input.involvement ?? "all",
396 - viewer,
405 limit,
406 query: input.query,
407 labels: input.labels,
packages/contracts/src/issue.ts
+1 -1
@@ -300,7 +300,7 @@ export const IssueListProjectError = Schema.Struct({
300 export type IssueListProjectError = typeof IssueListProjectError.Type;
301
302 export const IssueListResult = Schema.Struct({
303 - /** The signed-in account per host, which is what involvement compares against. */
303 + /** The signed-in account per host that involvement compared against. Empty for `all`. */
304 viewers: Schema.Record(TrimmedNonEmptyString, TrimmedNonEmptyString),
305 trackers: Schema.Array(IssueTrackerSummary),
306 /** By update, newest first, across every scope this answer covers. */
packages/issue-tracker-linear/src/server/LinearIssueTracker.test.ts
-1
@@ -238,7 +238,6 @@ describe("LinearIssueTracker", () => {
238 ...target,
239 state: "open",
240 involvement: "all",
241 - viewer: "julius",
241 sort: "updated",
242 limit: 50,
243 }),
packages/issue-tracker-linear/src/server/LinearIssueTracker.ts
+2 -5
@@ -11,7 +11,6 @@ import {
11 type IssueComment,
12 type IssueEvent,
13 type IssueExternalTemplate,
14 - type IssueInvolvement,
14 type IssueLinkedPullRequest,
15 type IssueReaction,
16 type IssueReactionContent,
@@ -22,6 +21,7 @@ import {
21 } from "@t3tools/contracts";
22 import {
23 IssueTrackerError,
24 + type IssueInvolvementFilter,
25 type StandaloneIssueTrackerApi,
26 type TrackerIssueSummary,
27 } from "@t3tools/source-control-core/server/IssueTracker";
@@ -307,10 +307,7 @@ export function toTemplate(
307 };
308 }
309
310 -function involvementFilter(input: {
311 - readonly involvement: IssueInvolvement;
312 - readonly viewer: string;
313 -}): LinearApi.IssueFilter {
310 +function involvementFilter(input: IssueInvolvementFilter): LinearApi.IssueFilter {
311 switch (input.involvement) {
312 case "assigned":
313 return { assignee: { displayName: { eq: input.viewer } } };
packages/source-control-core/src/server/IssueTracker.ts
+22 -15
@@ -94,6 +94,14 @@ export interface TrackerIssueDetail extends TrackerIssueSummary {
94 readonly linkedPullRequests: ReadonlyArray<IssueLinkedPullRequest>;
95 }
96
97 +/**
98 + * Whose issues a listing keeps. Only a narrowed listing names the signed-in account it compares
99 + * against, so an `all` listing never has to read it.
100 + */
101 +export type IssueInvolvementFilter =
102 + | { readonly involvement: "all" }
103 + | { readonly involvement: Exclude<IssueInvolvement, "all">; readonly viewer: string };
104 +
105 export interface IssueTrackerApi {
106 readonly kind: IssueTrackerKind;
107 readonly capabilities: IssueCapabilities;
@@ -105,21 +113,20 @@ export interface IssueTrackerApi {
113 }) => Effect.Effect<string, IssueTrackerError>;
114
115 readonly listIssues: (
108 - input: IssueScopeTarget & {
109 - readonly state: IssueListState;
110 - readonly involvement: IssueInvolvement;
111 - readonly viewer: string;
112 - readonly limit: number;
113 - /** Free text as the tracker understands it; ignored by a tracker without `search`. */
114 - readonly query?: string | undefined;
115 - /** Label names an issue must carry, every one of them. */
116 - readonly labels?: ReadonlyArray<string> | undefined;
117 - /** The `login` of an assignee, as this tracker's own issues name them. */
118 - readonly assignee?: string | undefined;
119 - readonly sort: IssueListSort;
120 - /** A cursor this tracker handed back from an earlier page. Absent asks for the first. */
121 - readonly cursor?: string | undefined;
122 - },
116 + input: IssueScopeTarget &
117 + IssueInvolvementFilter & {
118 + readonly state: IssueListState;
119 + readonly limit: number;
120 + /** Free text as the tracker understands it; ignored by a tracker without `search`. */
121 + readonly query?: string | undefined;
122 + /** Label names an issue must carry, every one of them. */
123 + readonly labels?: ReadonlyArray<string> | undefined;
124 + /** The `login` of an assignee, as this tracker's own issues name them. */
125 + readonly assignee?: string | undefined;
126 + readonly sort: IssueListSort;
127 + /** A cursor this tracker handed back from an earlier page. Absent asks for the first. */
128 + readonly cursor?: string | undefined;
129 + },
130 ) => Effect.Effect<TrackerIssuePage, IssueTrackerError>;
131
132 /** The issue with its first page of conversation, in one read where the tracker allows. */
packages/source-control-forgejo/src/server/ForgejoIssueTracker.test.ts
-1
@@ -331,7 +331,6 @@ describe("ForgejoIssueTracker", () => {
331 scope: "acme/web",
332 state: "open",
333 involvement: "all",
334 - viewer: "julius",
334 labels: ["bug", "p1"],
335 assignee: "theo",
336 sort: "created",
packages/source-control-forgejo/src/server/ForgejoIssueTracker.ts
+10 -9
@@ -9,6 +9,7 @@ import * as Schema from "effect/Schema";
9 import {
10 IssueTrackerKind,
11 type IssueCapabilities,
12 + type IssueInvolvement,
13 type IssueLinkedPullRequest,
14 type IssueViewerPermissions,
15 } from "@t3tools/contracts";
@@ -61,6 +62,12 @@ const PAGE_SIZE = 50;
62 /** How many pages of a listing with no cursor of its own are read before giving up on the rest. */
63 const MAX_PAGES = 10;
64
65 +const INVOLVEMENT_PARAM: Record<Exclude<IssueInvolvement, "all">, string> = {
66 + assigned: "assigned_by",
67 + authored: "created_by",
68 + mentioned: "mentioned_by",
69 +};
70 +
71 const repoPath = (scope: string) => `repos/${scope.split("/").map(encodeURIComponent).join("/")}`;
72 const issuePath = (scope: string, number: number) => `${repoPath(scope)}/issues/${number}`;
73
@@ -400,15 +407,9 @@ export const make: Effect.Effect<IssueTrackerApi, never, ForgejoCli.ForgejoCli>
407 if (labels.length > 0) params.set("labels", labels.join(","));
408 const text = input.query?.trim() ?? "";
409 if (text.length > 0) params.set("q", text);
403 - const involvement =
404 - input.involvement === "assigned"
405 - ? "assigned_by"
406 - : input.involvement === "authored"
407 - ? "created_by"
408 - : input.involvement === "mentioned"
409 - ? "mentioned_by"
410 - : null;
411 - if (involvement !== null) params.set(involvement, input.viewer);
410 + if (input.involvement !== "all") {
411 + params.set(INVOLVEMENT_PARAM[input.involvement], input.viewer);
412 + }
413 if (input.assignee !== undefined) params.set("assigned_by", input.assignee);
414 // `assigned_by` names one person, so "assigned to me" is kept here beside a named assignee.
415 const alsoAssignedTo =
packages/source-control-github/src/server/GitHubIssueTracker.test.ts
-1
@@ -397,7 +397,6 @@ describe("GitHubIssueTracker", () => {
397 scope: "acme/web",
398 state: "open",
399 involvement: "all",
400 - viewer: "julius",
400 labels: ['needs "repro"'],
401 assignee: "theo",
402 sort: "created",
packages/source-control-github/src/server/GitHubIssueTracker.ts
+15 -14
@@ -9,6 +9,7 @@ import {
9 } from "@t3tools/contracts";
10 import {
11 IssueTrackerError,
12 + type IssueInvolvementFilter,
13 type IssueTrackerApi,
14 } from "@t3tools/source-control-core/server/IssueTracker";
15
@@ -58,29 +59,29 @@ function searchTerms(query: string): ReadonlyArray<string> {
59 .map(quotedTerm);
60 }
61
61 -const INVOLVEMENT_QUALIFIER: Record<IssueInvolvement, string | null> = {
62 - all: null,
62 +const INVOLVEMENT_QUALIFIER: Record<Exclude<IssueInvolvement, "all">, string> = {
63 assigned: "assignee",
64 authored: "author",
65 mentioned: "mentions",
66 };
67
68 -function searchQuery(input: {
69 - readonly scope: string;
70 - readonly state: "all" | "open" | "closed";
71 - readonly involvement: IssueInvolvement;
72 - readonly viewer: string;
73 - readonly query?: string | undefined;
74 - readonly labels?: ReadonlyArray<string> | undefined;
75 - readonly assignee?: string | undefined;
76 - readonly sort: IssueListSort;
77 -}): string {
78 - const qualifier = INVOLVEMENT_QUALIFIER[input.involvement];
68 +function searchQuery(
69 + input: IssueInvolvementFilter & {
70 + readonly scope: string;
71 + readonly state: "all" | "open" | "closed";
72 + readonly query?: string | undefined;
73 + readonly labels?: ReadonlyArray<string> | undefined;
74 + readonly assignee?: string | undefined;
75 + readonly sort: IssueListSort;
76 + },
77 +): string {
78 return [
79 "is:issue",
80 `repo:${input.scope.trim()}`,
81 ...(input.state === "all" ? [] : [`is:${input.state}`]),
83 - ...(qualifier === null ? [] : [`${qualifier}:${input.viewer}`]),
82 + ...(input.involvement === "all"
83 + ? []
84 + : [`${INVOLVEMENT_QUALIFIER[input.involvement]}:${input.viewer}`]),
85 ...(input.labels ?? []).map((label) => `label:${quotedTerm(label)}`),
86 ...(input.assignee === undefined ? [] : [`assignee:${quotedTerm(input.assignee)}`]),
87 `sort:${input.sort}-desc`,
packages/source-control-gitlab/src/server/GitLabIssueTracker.ts
+4 -6
@@ -10,11 +10,11 @@ import {
10 IssueTrackerKind,
11 type IssueCapabilities,
12 type IssueEvent,
13 - type IssueInvolvement,
13 type IssueViewerPermissions,
14 } from "@t3tools/contracts";
15 import {
16 IssueTrackerError,
17 + type IssueInvolvementFilter,
18 type IssueTrackerApi,
19 } from "@t3tools/source-control-core/server/IssueTracker";
20
@@ -137,11 +137,9 @@ function query(params: ReadonlyArray<readonly [string, string]>): string {
137 return params.map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join("&");
138 }
139
140 -function involvementParams(input: {
141 - readonly involvement: IssueInvolvement;
142 - readonly viewer: string;
143 - readonly assignee?: string | undefined;
144 -}): ReadonlyArray<readonly [string, string]> {
140 +function involvementParams(
141 + input: IssueInvolvementFilter & { readonly assignee?: string | undefined },
142 +): ReadonlyArray<readonly [string, string]> {
143 switch (input.involvement) {
144 case "authored":
145 return [["author_username", input.viewer]];