@devries-cameron20 / t3code Mirror · read-only / commits / c813e7db51
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, 04:45 UTC

fix(linear): scope issue numbers to the named team (#39809)

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

Adamulek123 committed Nov 20, 2026 at 18:48 UTC c813e7db513aa165863d83f230f0989e3ca845eb
2 files changed +44 -6
packages/issue-tracker-linear/src/server/LinearIssueTracker.test.ts
+33
@@ -135,6 +135,39 @@ function fakeLinear(
135 const target = { cwd: "/w/web", host: "linear.app", scope: "ENG" };
136
137 describe("LinearIssueTracker", () => {
138 + it.effect("matches an issue number only in the team it names", () =>
139 + Effect.gen(function* () {
140 + const numbers: Array<number | undefined> = [];
141 + const { tracker } = fakeLinear({
142 + T3Issues: (variables) => {
143 + const filter = variables.filter as {
144 + or: ReadonlyArray<{ number?: { eq: number } }>;
145 + };
146 + numbers.push(filter.or.find((clause) => clause.number)?.number?.eq);
147 + return { issues: { nodes: [], pageInfo: { hasNextPage: false, endCursor: null } } };
148 + },
149 + });
150 + const api = yield* tracker;
151 + for (const [scope, query] of [
152 + [" eng ", "eng-42"],
153 + ["OTHER", "ENG-42"],
154 + ["OTHER", "42"],
155 + ["OTHER", "#42"],
156 + ] as const) {
157 + yield* api.listIssues({
158 + ...target,
159 + scope,
160 + query,
161 + state: "all",
162 + involvement: "all",
163 + sort: "updated",
164 + limit: 50,
165 + });
166 + }
167 + expect(numbers).toEqual([42, undefined, 42, 42]);
168 + }),
169 + );
170 +
171 it.effect("cancels the in-flight viewer read when the issue is missing", () =>
172 Effect.gen(function* () {
173 const viewerStarted = yield* Deferred.make<void>();
packages/issue-tracker-linear/src/server/LinearIssueTracker.ts
+11 -6
@@ -430,12 +430,17 @@ export const make: Effect.Effect<StandaloneIssueTrackerApi, never, LinearApi.Lin
430 // The id, not the display name: it is what the involvement filters compare against.
431 getViewer: () => linear.viewer().pipe(Effect.map((data) => toActor(data.viewer).login)),
432
433 - listIssues: (input) => {
434 - // `ENG-12`, `#12` or `12` asks for one issue of this team by number.
433 + listIssues: Effect.fn("LinearIssueTracker.listIssues")((input) => {
434 + const team = input.scope.trim().toUpperCase();
435 + // A qualified issue number applies only to its own team. Text can match anywhere.
436 const reference =
437 input.query === undefined
438 ? null
438 - : /^(?:[A-Za-z][A-Za-z0-9]*-|#)?(\d+)$/.exec(input.query.trim());
439 + : /^(?:([A-Za-z][A-Za-z0-9]*)-|#)?(\d+)$/.exec(input.query.trim());
440 + const number =
441 + reference !== null && (reference[1] === undefined || reference[1].toUpperCase() === team)
442 + ? Number(reference[2])
443 + : undefined;
444 // Each is its own clause: an assignee filter must narrow "assigned to me", not replace it.
445 const clauses: LinearApi.IssueFilter[] = [
446 ...(input.assignee === undefined
@@ -444,7 +449,7 @@ export const make: Effect.Effect<StandaloneIssueTrackerApi, never, LinearApi.Lin
449 ...(input.labels ?? []).map((name) => ({ labels: { some: { name: { eq: name } } } })),
450 ];
451 const filter: LinearApi.IssueFilter = {
447 - team: { key: { eq: input.scope.trim().toUpperCase() } },
452 + team: { key: { eq: team } },
453 ...involvementFilter(input),
454 ...(input.state === "all"
455 ? {}
@@ -463,7 +468,7 @@ export const make: Effect.Effect<StandaloneIssueTrackerApi, never, LinearApi.Lin
468 or: [
469 { title: { containsIgnoreCase: input.query } },
470 { description: { containsIgnoreCase: input.query } },
466 - ...(reference === null ? [] : [{ number: { eq: Number(reference[1]) } }]),
471 + ...(number === undefined ? [] : [{ number: { eq: number } }]),
472 ],
473 }),
474 };
@@ -480,7 +485,7 @@ export const make: Effect.Effect<StandaloneIssueTrackerApi, never, LinearApi.Lin
485 nextCursor: page.nextCursor,
486 })),
487 );
483 - },
488 + }),
489
490 getIssue: Effect.fn("LinearIssueTracker.getIssue")(function* (input) {
491 const identifier = yield* requireIdentifier("getIssue", input.key);