authorgravatar for jakeleventhal@me.comJake Leventhal <jakeleventhal@me.com> 2026-09-01 21:15:07-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-02 00:15:07-04:00
logcde12790d721ab2a90471750fd75d9f5bf13f57d
tree85fbc476b49f5356b00a8f83878dc5add60718b2
parenta1a2bb1cd9f000f53fbeae752ed5c38f152eadf2
signature Signed by PGP key B5690EEEBB952194

fix(contracts): accept legacy pull request checkout results (#8238)


2 files changed, 43 insertions(+), 1 deletions(-)

packages/contracts/src/git.test.ts+41
...@@ -4,6 +4,7 @@ import * as Schema from "effect/Schema";...@@ -4,6 +4,7 @@ import * as Schema from "effect/Schema";
4import {4import {
5 VcsCreateWorktreeInput,5 VcsCreateWorktreeInput,
6 GitPreparePullRequestThreadInput,6 GitPreparePullRequestThreadInput,
7 GitPreparePullRequestThreadResult,
7 GitRunStackedActionResult,8 GitRunStackedActionResult,
8 GitRunStackedActionInput,9 GitRunStackedActionInput,
9 GitResolvePullRequestResult,10 GitResolvePullRequestResult,
...@@ -13,6 +14,9 @@ const decodeCreateWorktreeInput = Schema.decodeUnknownSync(VcsCreateWorktreeInpu...@@ -13,6 +14,9 @@ const decodeCreateWorktreeInput = Schema.decodeUnknownSync(VcsCreateWorktreeInpu
13const decodePreparePullRequestThreadInput = Schema.decodeUnknownSync(14const decodePreparePullRequestThreadInput = Schema.decodeUnknownSync(
14 GitPreparePullRequestThreadInput,15 GitPreparePullRequestThreadInput,
15);16);
17const decodePreparePullRequestThreadResult = Schema.decodeUnknownSync(
18 GitPreparePullRequestThreadResult,
19);
16const decodeRunStackedActionInput = Schema.decodeUnknownSync(GitRunStackedActionInput);20const decodeRunStackedActionInput = Schema.decodeUnknownSync(GitRunStackedActionInput);
17const decodeRunStackedActionResult = Schema.decodeUnknownSync(GitRunStackedActionResult);21const decodeRunStackedActionResult = Schema.decodeUnknownSync(GitRunStackedActionResult);
18const decodeResolvePullRequestResult = Schema.decodeUnknownSync(GitResolvePullRequestResult);22const decodeResolvePullRequestResult = Schema.decodeUnknownSync(GitResolvePullRequestResult);
...@@ -55,6 +59,43 @@ describe("GitPreparePullRequestThreadInput", () => {...@@ -55,6 +59,43 @@ describe("GitPreparePullRequestThreadInput", () => {
55 });59 });
56});60});
5761
62describe("GitPreparePullRequestThreadResult", () => {
63 it("defaults legacy responses to the pull request head", () => {
64 const parsed = decodePreparePullRequestThreadResult({
65 pullRequest: {
66 number: 42,
67 title: "PR threads",
68 url: "https://github.com/pingdotgg/codething-mvp/pull/42",
69 baseBranch: "main",
70 headBranch: "feature/pr-threads",
71 state: "open",
72 },
73 branch: "feature/pr-threads",
74 worktreePath: "/tmp/pr-threads",
75 });
76
77 expect(parsed.isOnPullRequestHead).toBe(true);
78 });
79
80 it("preserves an explicit stale pull request checkout result", () => {
81 const parsed = decodePreparePullRequestThreadResult({
82 pullRequest: {
83 number: 42,
84 title: "PR threads",
85 url: "https://github.com/pingdotgg/codething-mvp/pull/42",
86 baseBranch: "main",
87 headBranch: "feature/pr-threads",
88 state: "open",
89 },
90 branch: "feature/pr-threads",
91 worktreePath: "/tmp/pr-threads",
92 isOnPullRequestHead: false,
93 });
94
95 expect(parsed.isOnPullRequestHead).toBe(false);
96 });
97});
98
58describe("GitResolvePullRequestResult", () => {99describe("GitResolvePullRequestResult", () => {
59 it("decodes resolved pull request metadata", () => {100 it("decodes resolved pull request metadata", () => {
60 const parsed = decodeResolvePullRequestResult({101 const parsed = decodeResolvePullRequestResult({
packages/contracts/src/git.ts+2-1
...@@ -1,3 +1,4 @@...@@ -1,3 +1,4 @@
1import * as Effect from "effect/Effect";
1import * as Schema from "effect/Schema";2import * as Schema from "effect/Schema";
2import { NonNegativeInt, PositiveInt, ThreadId, TrimmedNonEmptyString } from "./baseSchemas.ts";3import { NonNegativeInt, PositiveInt, ThreadId, TrimmedNonEmptyString } from "./baseSchemas.ts";
3import { SourceControlProviderError, SourceControlProviderInfo } from "./sourceControl.ts";4import { SourceControlProviderError, SourceControlProviderInfo } from "./sourceControl.ts";
...@@ -289,7 +290,7 @@ export const GitPreparePullRequestThreadResult = Schema.Struct({...@@ -289,7 +290,7 @@ export const GitPreparePullRequestThreadResult = Schema.Struct({
289 * holding local commits or uncommitted changes keeps its own state, so the code being handed290 * holding local commits or uncommitted changes keeps its own state, so the code being handed
290 * over is older than the pull request.291 * over is older than the pull request.
291 */292 */
292 isOnPullRequestHead: Schema.Boolean,293 isOnPullRequestHead: Schema.Boolean.pipe(Schema.withDecodingDefaultKey(Effect.succeed(true))),
293});294});
294export type GitPreparePullRequestThreadResult = typeof GitPreparePullRequestThreadResult.Type;295export type GitPreparePullRequestThreadResult = typeof GitPreparePullRequestThreadResult.Type;
295296