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 23, 01:45 UTC
fix(contracts): older clients still load PRs from newer servers (#19899)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Tristan Knight committed
Oct 19, 2026 at 21:25 UTC
833b11fe0f380291cd60af8573529e9a4a185c69
2 files changed
+84
-10
packages/contracts/src/pullRequest.test.ts
+75
-2
@@ -5,19 +5,23 @@ import { describe, expect, it } from "vite-plus/test";
5
import {
6
PullRequestActionInput,
7
PullRequestCapabilities,
8
+ PullRequestDetail,
9
PullRequestFilesViewedResult,
10
PullRequestListInput,
11
PullRequestListResult,
12
PullRequestReviewerRequestInput,
13
PullRequestSetFilesViewedInput,
14
+ PullRequestSubmitReviewInput,
15
pullRequestHostOf,
16
resolvePullRequestAuthorFilter,
17
} from "./pullRequest.ts";
18
17
-const decodeListResult = Schema.decodeUnknownSync(PullRequestListResult);
19
+const decodeListResult = Schema.decodeUnknownSync(Schema.toCodecJson(PullRequestListResult));
20
+const decodeDetail = Schema.decodeUnknownSync(Schema.toCodecJson(PullRequestDetail));
21
const decodeListInput = Schema.decodeUnknownSync(PullRequestListInput);
22
const decodeReviewerRequest = Schema.decodeUnknownSync(PullRequestReviewerRequestInput);
20
-const decodeAction = Schema.decodeUnknownSync(PullRequestActionInput);
23
+const decodeAction = Schema.decodeUnknownSync(Schema.toCodecJson(PullRequestActionInput));
24
+const decodeReview = Schema.decodeUnknownSync(Schema.toCodecJson(PullRequestSubmitReviewInput));
25
const decodeSetFilesViewed = Schema.decodeUnknownSync(PullRequestSetFilesViewedInput);
26
const decodeFilesViewed = Schema.decodeUnknownSync(PullRequestFilesViewedResult);
27
@@ -102,6 +106,18 @@ describe("PullRequestListResult", () => {
106
expect(decoded).toStrictEqual(LIST_RESULT);
107
});
108
109
+ it("loads a newer server's list response, dropping unknown provider actions in order", () => {
110
+ const decoded = decodeListResult({
111
+ ...LIST_RESULT,
112
+ providers: [{ ...LIST_RESULT.providers[0], actions: ["close", "archive", "merge"] }],
113
+ });
114
+
115
+ expect(decoded).toEqual({
116
+ ...LIST_RESULT,
117
+ providers: [{ ...LIST_RESULT.providers[0], actions: ["close", "merge"] }],
118
+ });
119
+ });
120
+
121
it("keys a viewer by host, so two hosts of one kind stay separate accounts", () => {
122
const decoded = decodeListResult({
123
...LIST_RESULT,
@@ -274,6 +290,63 @@ describe("PullRequestCapabilities", () => {
290
expect(decodeCapabilities(base).deleteBranch).toBeUndefined();
291
expect(decodeCapabilities({ ...base, deleteBranch: true }).deleteBranch).toBe(true);
292
});
293
+
294
+ it("loads a newer server's detail response, dropping unknown options in order", () => {
295
+ const options = {
296
+ actions: ["close", "archive", "merge"],
297
+ verdicts: ["request-changes", "block", "approve"],
298
+ updateMethods: ["rebase", "fast-forward", "merge"],
299
+ };
300
+ const detail = {
301
+ ...LIST_RESULT.entries[0],
302
+ workspaceRoot: "/workspace/t3code",
303
+ body: "",
304
+ changedFiles: 1,
305
+ mergedAt: null,
306
+ closedAt: null,
307
+ reviewers: [],
308
+ checks: [],
309
+ mergeCapabilities: { merge: true, squash: true, rebase: true },
310
+ capabilities: {
311
+ ...base,
312
+ actions: options.actions,
313
+ mergeMethods: ["squash", "fast-forward", "merge"],
314
+ updateMethods: options.updateMethods,
315
+ review: { ...base.review, verdicts: options.verdicts },
316
+ },
317
+ viewerPermissions: { ...options, comment: true, resolve: true, requestReviewers: true },
318
+ };
319
+ const decoded = decodeDetail(detail);
320
+
321
+ expect(decoded.capabilities).toEqual({
322
+ ...base,
323
+ actions: ["close", "merge"],
324
+ mergeMethods: ["squash", "merge"],
325
+ updateMethods: ["rebase", "merge"],
326
+ review: { ...base.review, verdicts: ["request-changes", "approve"] },
327
+ });
328
+ expect(decoded.viewerPermissions).toEqual({
329
+ actions: ["close", "merge"],
330
+ verdicts: ["request-changes", "approve"],
331
+ updateMethods: ["rebase", "merge"],
332
+ comment: true,
333
+ resolve: true,
334
+ requestReviewers: true,
335
+ });
336
+ expect(decoded.title).toBe(detail.title);
337
+ });
338
+});
339
+
340
+describe("pull request mutation requests", () => {
341
+ it("still rejects unknown actions, merge methods, and review verdicts on the wire", () => {
342
+ const ref = { projectId: "project-1", repository: "acme/web", number: 7 };
343
+
344
+ expect(() => decodeAction({ ...ref, action: "archive" })).toThrow();
345
+ expect(() => decodeAction({ ...ref, action: "merge", mergeMethod: "fast-forward" })).toThrow();
346
+ const review = { ...ref, body: "", comments: [], verdict: "approve" };
347
+ expect(decodeReview(review).verdict).toBe("approve");
348
+ expect(() => decodeReview({ ...review, verdict: "block" })).toThrow();
349
+ });
350
});
351
352
describe("naming the reader as the author to narrow by", () => {
packages/contracts/src/pullRequest.ts
+9
-8
@@ -3,6 +3,7 @@ import * as HttpServerRespondable from "effect/http/HttpServerRespondable";
3
import * as HttpServerResponse from "effect/http/HttpServerResponse";
4
5
import {
6
+ ForwardCompatibleArray,
7
IsoDateTime,
8
NonNegativeInt,
9
PositiveInt,
@@ -240,7 +241,7 @@ export const PullRequestReviewCapabilities = Schema.Struct({
241
inlineComment: Schema.Boolean,
242
reply: Schema.Boolean,
243
resolve: Schema.Boolean,
243
- verdicts: Schema.Array(PullRequestReviewVerdict),
244
+ verdicts: ForwardCompatibleArray(PullRequestReviewVerdict),
245
});
246
export type PullRequestReviewCapabilities = typeof PullRequestReviewCapabilities.Type;
247
@@ -262,14 +263,14 @@ export type PullRequestViewedFilesStore = typeof PullRequestViewedFilesStore.Typ
263
export const PullRequestCapabilities = Schema.Struct({
264
diff: Schema.Boolean,
265
comment: Schema.Boolean,
265
- actions: Schema.Array(PullRequestAction),
266
- mergeMethods: Schema.Array(PullRequestMergeMethod),
266
+ actions: ForwardCompatibleArray(PullRequestAction),
267
+ mergeMethods: ForwardCompatibleArray(PullRequestMergeMethod),
268
deleteBranch: Schema.optional(Schema.Boolean),
269
/**
270
* Absent where it cannot at all, which is every host that has not said otherwise — so a
271
* provider that says nothing offers nothing.
272
*/
272
- updateMethods: Schema.optional(Schema.Array(PullRequestUpdateMethod)),
273
+ updateMethods: Schema.optional(ForwardCompatibleArray(PullRequestUpdateMethod)),
274
search: Schema.Boolean,
275
reactions: Schema.optional(Schema.Boolean),
276
viewedFiles: Schema.optional(PullRequestViewedFilesStore),
@@ -287,12 +288,12 @@ export type PullRequestCapabilities = typeof PullRequestCapabilities.Type;
288
*/
289
export const PullRequestViewerPermissions = Schema.Struct({
290
stackRebase: Schema.optional(Schema.Boolean),
290
- actions: Schema.Array(PullRequestAction),
291
+ actions: ForwardCompatibleArray(PullRequestAction),
292
comment: Schema.Boolean,
293
resolve: Schema.Boolean,
293
- verdicts: Schema.Array(PullRequestReviewVerdict),
294
+ verdicts: ForwardCompatibleArray(PullRequestReviewVerdict),
295
requestReviewers: Schema.Boolean,
295
- updateMethods: Schema.optional(Schema.Array(PullRequestUpdateMethod)),
296
+ updateMethods: Schema.optional(ForwardCompatibleArray(PullRequestUpdateMethod)),
297
labels: Schema.optional(Schema.Boolean),
298
editChangeRequest: Schema.optional(Schema.Boolean),
299
});
@@ -368,7 +369,7 @@ export const PullRequestProviderSummary = Schema.Struct({
369
host: TrimmedNonEmptyString,
370
kind: SourceControlProviderKind,
371
searchesOnHost: Schema.Boolean,
371
- actions: Schema.optional(Schema.Array(PullRequestAction)),
372
+ actions: Schema.optional(ForwardCompatibleArray(PullRequestAction)),
373
projectCount: PositiveInt,
374
configured: Schema.Boolean,
375
detail: Schema.NullOr(TrimmedNonEmptyString),