@devries-cameron20 / t3code Mirror · read-only / commits / ef57728059
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, 08:30 UTC

fix(gitlab): GitLab issues open again; issue reactions come from REST (#38383)

Julius Marminge committed Nov 17, 2026 at 16:28 UTC ef5772805916a97e9522feaaefcf9e0b5c3b92ff
4 files changed +47 -6
packages/source-control-gitlab/src/server/GitLabIssueTracker.test.ts
+12 -2
@@ -92,13 +92,15 @@ function answer(path: string): string {
92 },
93 ]);
94 }
95 + if (path.startsWith("projects/acme%2Fweb/issues/42/award_emoji")) {
96 + return encode([{ id: 11, name: "eyes", user: { username: "theo" } }]);
97 + }
98 if (path === "graphql") {
99 return encode({
100 data: {
101 currentUser: { username: "julius" },
102 project: {
103 mergeRequest: {
101 - awardEmoji: { nodes: [{ name: "eyes", user: { username: "theo" } }] },
104 notes: {
105 pageInfo: { hasNextPage: false },
106 nodes: [
@@ -144,7 +146,15 @@ describe("GitLabIssueTracker", () => {
146 const awardCursors: unknown[] = [];
147 const api = yield* tracker((args, input) => {
148 hosts.add(input.host);
147 - if (args[1] === "graphql") awardCursors.push(JSON.parse(input.stdin!).variables.cursor);
149 + if (args[1] === "graphql") {
150 + const request = JSON.parse(input.stdin!);
151 + // gitlab.com's schema has no `Issue.awardEmoji`; glab exits 1 on such a query.
152 + const issueFields = /issue\(iid: \$iid\) \{([\s\S]*?)notes\(/.exec(request.query)?.[1];
153 + if (issueFields?.includes("awardEmoji")) {
154 + throw new Error("Field 'awardEmoji' doesn't exist on type 'Issue'");
155 + }
156 + awardCursors.push(request.variables.cursor);
157 + }
158 return answer(args[1]!);
159 });
160 const target = { cwd: "/w", host: "gitlab.example.com", scope: "acme/web", key: "42" };
packages/source-control-gitlab/src/server/GitLabIssueTracker.ts
+11 -1
@@ -37,7 +37,9 @@ import {
37 type GitLabTemplateEntry,
38 } from "./gitLabIssueJson.ts";
39 import {
40 + awardReactions,
41 decodeAwardEmojiJson,
42 + decodeAwardListJson,
43 decodeOwnAwardIdJson,
44 decodeViewerJson,
45 gitLabAwardName,
@@ -523,6 +525,13 @@ export const make: Effect.Effect<IssueTrackerApi, never, GitLabCli.GitLabCli> =
525 number,
526 operation: "getIssue",
527 }),
528 + read({
529 + cwd: input.cwd,
530 + host: input.host,
531 + operation: "getIssue",
532 + path: paged(`${path}/award_emoji`, 1),
533 + decode: decodeAwardListJson,
534 + }),
535 ],
536 { concurrency: 4 },
537 ),
@@ -537,6 +546,7 @@ export const make: Effect.Effect<IssueTrackerApi, never, GitLabCli.GitLabCli> =
546 closing,
547 related,
548 awardPage,
549 + issueAwards,
550 ]) => {
551 const closingKeys = new Set(
552 closing.map((link) => `${link.repository}!${link.number}`),
@@ -546,7 +556,7 @@ export const make: Effect.Effect<IssueTrackerApi, never, GitLabCli.GitLabCli> =
556 viewer: viewerLogin,
557 viewerPermissions: VIEWER_PERMISSIONS,
558 states: ISSUE_STATES,
549 - reactions: awardPage.reactions,
559 + reactions: awardReactions(issueAwards, viewerLogin),
560 comments: notes.comments.map((comment) => ({
561 ...comment,
562 reactions: awardPage.reactionsByNoteId.get(comment.id) ?? [],
packages/source-control-gitlab/src/server/gitLabIssueJson.ts
+3 -3
@@ -409,14 +409,14 @@ export function decodeTemplateJson(
409 }
410
411 /**
412 - * Awards on the issue and on every note of it, in one read, shaped exactly like the merge request
413 - * query so its decoder answers for both: `mergeRequest` is an alias for the issue field.
412 + * Awards on every note of the issue, shaped like the merge request query so its decoder answers
413 + * for both: `mergeRequest` is an alias for the issue field. GitLab's `Issue` type has no
414 + * `awardEmoji`, so the issue's own awards are read from REST `award_emoji` instead.
415 */
416 export const ISSUE_AWARD_EMOJI_GRAPHQL_QUERY = `query($fullPath: ID!, $iid: String!, $cursor: String) {
417 currentUser { username }
418 project(fullPath: $fullPath) {
419 mergeRequest: issue(iid: $iid) {
419 - awardEmoji { nodes { name user { username } } }
420 notes(first: ${PAGE_SIZE}, after: $cursor) {
421 pageInfo { hasNextPage endCursor }
422 nodes { id awardEmoji { nodes { name user { username } } } }
packages/source-control-gitlab/src/server/gitLabMergeRequestJson.ts
+21
@@ -1304,6 +1304,27 @@ const RawAwardSchema = Schema.Struct({
1304
1305 const decodeAward = Schema.decodeUnknownExit(RawAwardSchema);
1306
1307 +type GitLabAward = typeof RawAwardSchema.Type;
1308 +
1309 +/** A page of REST `award_emoji`; a row that cannot be read is skipped. */
1310 +export function decodeAwardListJson(
1311 + raw: string,
1312 +): Result.Result<ReadonlyArray<GitLabAward>, DecodeFailure> {
1313 + return Result.map(decodeUnknownList(raw), (rows) =>
1314 + rows.flatMap((entry) => {
1315 + const award = decodeAward(entry);
1316 + return Exit.isSuccess(award) ? [award.value] : [];
1317 + }),
1318 + );
1319 +}
1320 +
1321 +export function awardReactions(
1322 + awards: ReadonlyArray<GitLabAward>,
1323 + viewer: string | null,
1324 +): ReadonlyArray<PullRequestReaction> {
1325 + return toReactions({ nodes: awards }, viewer);
1326 +}
1327 +
1328 export function decodeOwnAwardIdJson(
1329 raw: string,
1330 input: { readonly content: PullRequestReactionContent; readonly viewer: string },