TypeScript
fix(vcs): stop Check out here from discarding local pull request work (#15036)
Alex Southwell23b550dde920
diff --git a/apps/server/src/git/GitManager.test.ts b/apps/server/src/git/GitManager.test.tsindex e4cdc78e50a..9bd7f45c17d 100644--- a/apps/server/src/git/GitManager.test.ts+++ b/apps/server/src/git/GitManager.test.ts@@ -103,11 +103,14 @@ interface FakeGhScenario {isCrossRepository?: boolean;headRepositoryNameWithOwner?: string | null;headRepositoryOwnerLogin?: string | null;+ headSha?: string;};repositoryCloneUrls?: Record<string, { url: string; sshUrl: string }>;failWith?: string;failCause?: unknown;failAfterCalls?: number;+ /** Check out the pull request head the way gh does: fast-forward only unless forced. */+ syncCheckoutWithPullHead?: boolean;}function fakeGhOutput(stdout: string): VcsProcess.VcsProcessOutput {@@ -514,7 +517,29 @@ function createGitHubProviderWithFakeGh(scenario: FakeGhScenario = {}): {return Effect.try({try: () => {const headBranch = scenario.pullRequest?.headRefName;- if (headBranch) {+ if (headBranch && scenario.syncCheckoutWithPullHead) {+ runGitSyncForFakeGh(input.cwd, [+ "fetch",+ "origin",+ `refs/pull/${scenario.pullRequest?.number}/head`,+ ]);+ const existingBranch = NodeChildProcess.spawnSync(+ "git",+ ["show-ref", "--verify", "--quiet", `refs/heads/${headBranch}`],+ { cwd: input.cwd },+ );+ if (existingBranch.status === 0) {+ runGitSyncForFakeGh(input.cwd, ["checkout", headBranch]);+ runGitSyncForFakeGh(+ input.cwd,+ args.includes("--force")+ ? ["reset", "--hard", "FETCH_HEAD"]+ : ["merge", "--ff-only", "FETCH_HEAD"],+ );+ } else {+ runGitSyncForFakeGh(input.cwd, ["checkout", "-b", headBranch, "FETCH_HEAD"]);+ }+ } else if (headBranch) {const existingBranch = NodeChildProcess.spawnSync("git",["show-ref", "--verify", "--quiet", `refs/heads/${headBranch}`],@@ -6261,10 +6286,317 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {expect(result.worktreePath).toBeNull();const branch = (yield* runGit(repoDir, ["branch", "--show-current"])).stdout.trim();expect(branch).toBe("feature/pr-local");- expect(ghCalls).toContain("pr checkout 64 --force");+ expect(ghCalls).toContain("pr checkout 64");+ }),+ );++ const setUpLocalCheckoutPullRequest = Effect.fnUntraced(function* (+ reportedHead: (pullHead: string) => string | undefined = (pullHead) => pullHead,+ syncCheckoutWithPullHead = true,+ gitSpawnGate?: NonNullable<Parameters<typeof makeManager>[0]>["gitSpawnGate"],+ ) {+ const repoDir = yield* makeTempDir("t3code-git-manager-");+ yield* initRepo(repoDir);+ const remoteDir = yield* createBareRemote();+ yield* runGit(repoDir, ["remote", "add", "origin", remoteDir]);+ yield* runGit(repoDir, ["push", "-u", "origin", "main"]);+ yield* runGit(repoDir, ["checkout", "-b", "feature/pr-safe"]);+ NodeFS.writeFileSync(NodePath.join(repoDir, "pr.txt"), "first\n");+ yield* runGit(repoDir, ["add", "pr.txt"]);+ yield* runGit(repoDir, ["commit", "-m", "PR first"]);+ const firstCommit = (yield* runGit(repoDir, ["rev-parse", "HEAD"])).stdout.trim();+ NodeFS.writeFileSync(NodePath.join(repoDir, "pr.txt"), "second\n");+ yield* runGit(repoDir, ["commit", "-am", "PR second"]);+ const pullHead = (yield* runGit(repoDir, ["rev-parse", "HEAD"])).stdout.trim();+ yield* runGit(repoDir, ["push", "origin", "HEAD:refs/pull/91/head"]);+ yield* runGit(repoDir, ["reset", "--hard", firstCommit]);+ const headSha = reportedHead(pullHead);+ const { manager, ghCalls } = yield* makeManager({+ ...(gitSpawnGate ? { gitSpawnGate } : {}),+ ghScenario: {+ pullRequest: {+ number: 91,+ title: "Safe checkout PR",+ url: "https://github.com/pingdotgg/codething-mvp/pull/91",+ baseRefName: "main",+ headRefName: "feature/pr-safe",+ state: "open",+ ...(headSha === undefined ? {} : { headSha }),+ },+ syncCheckoutWithPullHead,+ },+ });+ return { repoDir, manager, ghCalls, firstCommit, pullHead };+ });++ it.effect.each(["switch", "create-and-switch", "feature-branch"] as const)(+ "local PR checkout excludes a concurrent %s from a nested project with an alternate root",+ (operation) =>+ Effect.gen(function* () {+ const gate = {+ matches: (args: ReadonlyArray<string>) =>+ args[0] === "rev-parse" && args[1] === "--verify" && args[2] === "HEAD^{commit}",+ reached: yield* Deferred.make<void>(),+ release: yield* Deferred.make<void>(),+ };+ const { repoDir, manager, pullHead } = yield* setUpLocalCheckoutPullRequest(+ (head) => head,+ false,+ gate,+ );+ const nestedCwd = NodePath.join(repoDir, "nested-project");+ yield* makeDirectory(nestedCwd);+ const mainCommit = (yield* runGit(repoDir, ["rev-parse", "main"])).stdout.trim();+ yield* runGit(repoDir, ["checkout", "main"]);+ const registry = yield* Layer.build(+ VcsDriverRegistry.layer.pipe(+ Layer.provide(VcsProjectConfig.layer),+ Layer.provide(VcsProcess.layer),+ ),+ );+ const handle = yield* Context.get(registry, VcsDriverRegistry.VcsDriverRegistry).resolve({+ cwd: repoDir,+ });+ const resolvedHandle = {+ ...handle,+ repository: { ...handle.repository, rootPath: `${handle.repository.rootPath}/.` },+ };+ const fileSystem = yield* FileSystem.FileSystem;+ const canonicalRoot = yield* fileSystem.realPath(resolvedHandle.repository.rootPath);+ const git = yield* GitVcsDriver.GitVcsDriver;+ const events: string[] = [];+ const workflows = yield* Effect.forEach([0, 1], () =>+ GitWorkflowService.make.pipe(+ // Cache the real filesystem result so startImmediately reaches lease acquisition.+ Effect.provideService(FileSystem.FileSystem, {+ ...fileSystem,+ realPath: (root) =>+ root === resolvedHandle.repository.rootPath+ ? Effect.succeed(canonicalRoot)+ : fileSystem.realPath(root),+ }),+ Effect.provideService(GitManager.GitManager, {+ ...manager,+ runStackedAction: (input, options) =>+ Effect.sync(() => {+ events.push("feature-branch");+ NodeFS.writeFileSync(+ NodePath.join(repoDir, "second-client.txt"),+ "second client\n",+ );+ }).pipe(Effect.andThen(manager.runStackedAction(input, options))),+ }),+ Effect.provideService(VcsDriverRegistry.VcsDriverRegistry, {+ ...Context.get(registry, VcsDriverRegistry.VcsDriverRegistry),+ resolve: ({ cwd }) => Effect.succeed(cwd === repoDir ? handle : resolvedHandle),+ }),+ Effect.provideService(GitVcsDriver.GitVcsDriver, {+ ...git,+ switchRef: (input) =>+ Effect.sync(() => events.push("switch")).pipe(Effect.andThen(git.switchRef(input))),+ createRef: (input) =>+ Effect.sync(() => events.push("create-and-switch")).pipe(+ Effect.andThen(git.createRef(input)),+ ),+ }),+ ),+ );+ const preparing = yield* Effect.forkChild(+ workflows[0]!.preparePullRequestThread({ cwd: repoDir, reference: "91", mode: "local" }),+ );+ yield* Deferred.await(gate.reached);+ const switching = yield* Effect.forkChild(+ operation === "switch"+ ? workflows[1]!.switchRef({ cwd: nestedCwd, refName: "main" })+ : operation === "create-and-switch"+ ? workflows[1]!.createRef({+ cwd: nestedCwd,+ refName: "second-client",+ switchRef: true,+ })+ : workflows[1]!.runStackedAction({+ cwd: nestedCwd,+ actionId: "second-client-feature-branch",+ action: "commit",+ featureBranch: true,+ commitMessage: "Second client commit",+ }),+ { startImmediately: true },+ );+ // Both independent server workflows have started, but the second cannot touch Git yet.+ expect(events).toEqual([]);+ yield* Deferred.succeed(gate.release, undefined);+ const prepared = yield* Fiber.join(preparing);+ const switched = yield* Fiber.join(switching);+ expect(events).toEqual([operation]);+ expect(prepared).toMatchObject({ branch: "feature/pr-safe", isOnPullRequestHead: true });+ expect((yield* runGit(repoDir, ["rev-parse", "main"])).stdout.trim()).toBe(mainCommit);+ expect((yield* runGit(repoDir, ["rev-parse", "feature/pr-safe"])).stdout.trim()).toBe(+ pullHead,+ );+ expect((yield* runGit(repoDir, ["branch", "--show-current"])).stdout.trim()).toBe(+ operation === "switch"+ ? "main"+ : "branch" in switched+ ? switched.branch.name+ : "second-client",+ );+ if ("commit" in switched) {+ expect(switched.commit.status).toBe("created");+ expect((yield* runGit(repoDir, ["rev-parse", "HEAD^"])).stdout.trim()).toBe(pullHead);+ }+ }),+ );++ it.effect.each([false, true])(+ "local PR checkout refuses and preserves tracked edits (staged: %s)",+ (staged) =>+ Effect.gen(function* () {+ const { repoDir, manager, ghCalls, firstCommit } = yield* setUpLocalCheckoutPullRequest();+ NodeFS.writeFileSync(NodePath.join(repoDir, "README.md"), "my unsaved edit\n");+ if (staged) {+ yield* runGit(repoDir, ["add", "README.md"]);+ }+ const beforeStatus = (yield* runGit(repoDir, ["status", "--porcelain"])).stdout;++ const error = yield* preparePullRequestThread(manager, {+ cwd: repoDir,+ reference: "91",+ mode: "local",+ }).pipe(Effect.flip);++ expect(error.message).toContain("uncommitted changes");+ expect(NodeFS.readFileSync(NodePath.join(repoDir, "README.md"), "utf8")).toBe(+ "my unsaved edit\n",+ );+ expect((yield* runGit(repoDir, ["status", "--porcelain"])).stdout).toBe(beforeStatus);+ expect((yield* runGit(repoDir, ["rev-parse", "HEAD"])).stdout.trim()).toBe(firstCommit);+ expect(ghCalls.some((call) => call.startsWith("pr checkout"))).toBe(false);+ }),+ );++ it.effect("local PR checkout refuses a diverged branch and keeps its extra commit", () =>+ Effect.gen(function* () {+ const { repoDir, manager, ghCalls } = yield* setUpLocalCheckoutPullRequest();+ NodeFS.writeFileSync(NodePath.join(repoDir, "mine.txt"), "mine\n");+ yield* runGit(repoDir, ["add", "mine.txt"]);+ yield* runGit(repoDir, ["commit", "-m", "My unpublished commit"]);+ const localCommit = (yield* runGit(repoDir, ["rev-parse", "HEAD"])).stdout.trim();+ yield* runGit(repoDir, ["checkout", "main"]);++ const error = yield* preparePullRequestThread(manager, {+ cwd: repoDir,+ reference: "91",+ mode: "local",+ }).pipe(Effect.flip);++ // gh's fast-forward-only update fails rather than resetting the branch.+ expect(error.message).toContain("GitHub request failed");+ expect(ghCalls).toContain("pr checkout 91");+ expect((yield* runGit(repoDir, ["rev-parse", "feature/pr-safe"])).stdout.trim()).toBe(+ localCommit,+ );+ expect((yield* runGit(repoDir, ["rev-parse", "HEAD"])).stdout.trim()).toBe(localCommit);+ expect(NodeFS.readFileSync(NodePath.join(repoDir, "mine.txt"), "utf8")).toBe("mine\n");}),);+ it.effect.each([false, true])(+ "local PR checkout lands cleanly (existing branch: %s)",+ (existing) =>+ Effect.gen(function* () {+ const { repoDir, manager, pullHead } = yield* setUpLocalCheckoutPullRequest();+ yield* runGit(repoDir, ["checkout", "main"]);+ if (!existing) {+ yield* runGit(repoDir, ["branch", "-D", "feature/pr-safe"]);+ }+ NodeFS.writeFileSync(NodePath.join(repoDir, "untracked.txt"), "keep me\n");++ const result = yield* preparePullRequestThread(manager, {+ cwd: repoDir,+ reference: "91",+ mode: "local",+ });++ expect(result).toMatchObject({+ branch: "feature/pr-safe",+ worktreePath: null,+ isOnPullRequestHead: true,+ });+ expect((yield* runGit(repoDir, ["rev-parse", "HEAD"])).stdout.trim()).toBe(pullHead);+ expect(NodeFS.readFileSync(NodePath.join(repoDir, "untracked.txt"), "utf8")).toBe(+ "keep me\n",+ );+ }),+ );++ it.effect("local PR checkout fast-forwards a branch the host's checkout only switched to", () =>+ Effect.gen(function* () {+ // Like Bitbucket or Forgejo without `force`: the existing branch is checked out as it was.+ const { repoDir, manager, firstCommit, pullHead } = yield* setUpLocalCheckoutPullRequest(+ (head) => head.slice(0, 12),+ false,+ );+ yield* runGit(repoDir, ["checkout", "main"]);+ expect((yield* runGit(repoDir, ["rev-parse", "feature/pr-safe"])).stdout.trim()).toBe(+ firstCommit,+ );++ const result = yield* preparePullRequestThread(manager, {+ cwd: repoDir,+ reference: "91",+ mode: "local",+ });++ expect(result).toMatchObject({ branch: "feature/pr-safe", isOnPullRequestHead: true });+ expect((yield* runGit(repoDir, ["rev-parse", "HEAD"])).stdout.trim()).toBe(pullHead);+ }),+ );++ it.effect(+ "local PR checkout keeps a branch that is ahead and reports it is not on the head",+ () =>+ Effect.gen(function* () {+ const { repoDir, manager, pullHead } = yield* setUpLocalCheckoutPullRequest();+ yield* runGit(repoDir, ["reset", "--hard", pullHead]);+ NodeFS.writeFileSync(NodePath.join(repoDir, "mine.txt"), "mine\n");+ yield* runGit(repoDir, ["add", "mine.txt"]);+ yield* runGit(repoDir, ["commit", "-m", "My unpublished commit"]);+ const localCommit = (yield* runGit(repoDir, ["rev-parse", "HEAD"])).stdout.trim();+ yield* runGit(repoDir, ["checkout", "main"]);++ const result = yield* preparePullRequestThread(manager, {+ cwd: repoDir,+ reference: "91",+ mode: "local",+ });++ expect(result).toMatchObject({ branch: "feature/pr-safe", isOnPullRequestHead: false });+ expect((yield* runGit(repoDir, ["rev-parse", "HEAD"])).stdout.trim()).toBe(localCommit);+ expect(NodeFS.readFileSync(NodePath.join(repoDir, "mine.txt"), "utf8")).toBe("mine\n");+ }),+ );++ it.effect.each([undefined, "0".repeat(40)])(+ "local PR checkout cannot confirm an unavailable provider head (%s)",+ (reportedHead) =>+ Effect.gen(function* () {+ const { repoDir, manager, pullHead } = yield* setUpLocalCheckoutPullRequest(+ () => reportedHead,+ );+ yield* runGit(repoDir, ["checkout", "main"]);++ const result = yield* preparePullRequestThread(manager, {+ cwd: repoDir,+ reference: "91",+ mode: "local",+ });++ expect((yield* runGit(repoDir, ["rev-parse", "HEAD"])).stdout.trim()).toBe(pullHead);+ expect(result.isOnPullRequestHead).toBe(false);+ }),+ );+it.effect("restores same-repository upstream tracking after local PR checkout without a remote ref",() =>diff --git a/apps/server/src/git/GitManager.ts b/apps/server/src/git/GitManager.tsindex df5a17ce63f..76d4b1e72ce 100644--- a/apps/server/src/git/GitManager.ts+++ b/apps/server/src/git/GitManager.ts@@ -2719,6 +2719,36 @@ export const make = Effect.gen(function* () {return { pullRequest };});+ const ensureNoTrackedChanges = Effect.fn("ensureNoTrackedChanges")(function* (+ cwd: string,+ pullRequestNumber: number,+ ) {+ const trackedChanges = yield* gitCore.execute({+ operation: "GitManager.preparePullRequestThread.trackedChanges",+ cwd,+ args: ["status", "--porcelain", "--untracked-files=no"],+ });+ if (trackedChanges.stdout.trim().length > 0) {+ return yield* new GitManagerError({+ operation: "preparePullRequestThread",+ cwd,+ detail: `This repository has uncommitted changes. Commit or stash them before checking out pull request #${pullRequestNumber} here, or check it out in its own folder.`,+ });+ }+ });++ // Some hosts only switch branches on checkout; use the existing lossless refresh to advance them.+ const moveToPullRequestHead = (cwd: string, headSha: string | undefined) =>+ headSha === undefined || !/^[0-9a-f]{7,64}$/i.test(headSha)+ ? Effect.succeed(false)+ : gitCore.resolveCommit({ cwd, revision: headSha }).pipe(+ Effect.flatMap(({ commitSha }) =>+ gitCore.refreshCheckedOutBranch({ cwd, targetCommit: commitSha }),+ ),+ Effect.map((refreshed) => refreshed.onTarget),+ Effect.orElseSucceed(() => false),+ );+const preparePullRequestThread: GitManager["Service"]["preparePullRequestThread"] = Effect.fn("preparePullRequestThread",)(function* (input) {@@ -2752,25 +2782,26 @@ export const make = Effect.gen(function* () {const pullRequest = toResolvedPullRequest(pullRequestSummary);if (input.mode === "local") {+ yield* ensureNoTrackedChanges(input.cwd, pullRequest.number);yield* (yield* sourceControlProvider(input.cwd)).checkoutChangeRequest({cwd: input.cwd,reference: normalizedReference,- force: true,});const details = yield* gitCore.statusDetails(input.cwd);+ const branch = details.branch ?? pullRequest.headBranch;yield* configurePullRequestHeadUpstream(input.cwd,{...pullRequest,...toPullRequestHeadRemoteInfo(pullRequestSummary),},- details.branch ?? pullRequest.headBranch,+ branch,);return {pullRequest,- branch: details.branch ?? pullRequest.headBranch,+ branch,worktreePath: null,- isOnPullRequestHead: true,+ isOnPullRequestHead: yield* moveToPullRequestHead(input.cwd, pullRequestSummary.headSha),};}diff --git a/apps/server/src/git/GitWorkflowService.test.ts b/apps/server/src/git/GitWorkflowService.test.tsindex 4617965803b..89f0e645de8 100644--- a/apps/server/src/git/GitWorkflowService.test.ts+++ b/apps/server/src/git/GitWorkflowService.test.ts@@ -1,4 +1,4 @@-import { assert, describe, expect, it, vi } from "@effect/vitest";+import { assert, expect, it, vi } from "@effect/vitest";import * as DateTime from "effect/DateTime";import * as Effect from "effect/Effect";import * as Layer from "effect/Layer";@@ -30,7 +30,7 @@ function layer(input: {);}-describe("GitWorkflowService", () => {+it.layer(NodeServices.layer)("GitWorkflowService", (it) => {it.effect("reports a non-Git VCS repository as not a Git repository", () =>Effect.gen(function* () {const workflow = yield* GitWorkflowService.GitWorkflowService;diff --git a/apps/server/src/git/GitWorkflowService.ts b/apps/server/src/git/GitWorkflowService.tsindex 68ca19ad518..e0de28c9386 100644--- a/apps/server/src/git/GitWorkflowService.ts+++ b/apps/server/src/git/GitWorkflowService.ts@@ -1,6 +1,7 @@import * as Context from "effect/Context";import * as Effect from "effect/Effect";import * as Layer from "effect/Layer";+import * as FileSystem from "effect/FileSystem";import {GitManagerError,@@ -31,6 +32,7 @@ import {import * as GitManager from "./GitManager.ts";import * as GitVcsDriver from "../vcs/GitVcsDriver.ts";import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";+import { withWorkspaceLease } from "../workspace/workspaceLease.ts";export class GitWorkflowService extends Context.Service<GitWorkflowService,@@ -171,6 +173,14 @@ export const make = Effect.gen(function* () {const registry = yield* VcsDriverRegistry.VcsDriverRegistry;const git = yield* GitVcsDriver.GitVcsDriver;const gitManager = yield* GitManager.GitManager;+ const fileSystem = yield* FileSystem.FileSystem;++ // Nested projects and path aliases must share the checkout's branch-mutation lease.+ const withCheckoutLease = <A, E, R>(rootPath: string, effect: Effect.Effect<A, E, R>) =>+ fileSystem.realPath(rootPath).pipe(+ Effect.orElseSucceed(() => rootPath),+ Effect.flatMap((cwd) => withWorkspaceLease(cwd, effect)),+ );const ensureGit = Effect.fn("GitWorkflowService.ensureGit")(function* (operation: string,@@ -194,6 +204,7 @@ export const make = Effect.gen(function* () {detail: `The ${operation} workflow currently supports Git repositories only; detected ${handle.kind}. (${cwd})`,});}+ return handle;});const ensureGitCommand = Effect.fn("GitWorkflowService.ensureGitCommand")(function* (@@ -220,6 +231,7 @@ export const make = Effect.gen(function* () {detail: `The ${operation} command currently supports Git repositories only; detected ${handle.kind}.`,});}+ return handle;});const detectGitRepositoryForStatus = Effect.fn("GitWorkflowService.detectGitRepositoryForStatus")(@@ -360,16 +372,30 @@ export const make = Effect.gen(function* () {),runStackedAction: (input, options) =>ensureGit("GitWorkflowService.runStackedAction", input.cwd).pipe(- Effect.andThen(gitManager.runStackedAction(input, options)),+ Effect.flatMap((handle) =>+ input.featureBranch+ ? withCheckoutLease(+ handle.repository.rootPath,+ gitManager.runStackedAction(input, options),+ )+ : gitManager.runStackedAction(input, options),+ ),),resolvePullRequest: routeGitManager("GitWorkflowService.resolvePullRequest",gitManager.resolvePullRequest,),- preparePullRequestThread: routeGitManager(- "GitWorkflowService.preparePullRequestThread",- gitManager.preparePullRequestThread,- ),+ preparePullRequestThread: (input) =>+ ensureGit("GitWorkflowService.preparePullRequestThread", input.cwd).pipe(+ Effect.flatMap((handle) =>+ input.mode === "local"+ ? withCheckoutLease(+ handle.repository.rootPath,+ gitManager.preparePullRequestThread(input),+ )+ : gitManager.preparePullRequestThread(input),+ ),+ ),listRefs: (input) =>detectGitRepositoryForCommand("GitWorkflowService.listRefs", input.cwd).pipe(Effect.flatMap((isGitRepository) =>@@ -422,11 +448,17 @@ export const make = Effect.gen(function* () {),createRef: (input) =>ensureGitCommand("GitWorkflowService.createRef", input.cwd).pipe(- Effect.andThen(git.createRef(input)),+ Effect.flatMap((handle) =>+ input.switchRef+ ? withCheckoutLease(handle.repository.rootPath, git.createRef(input))+ : git.createRef(input),+ ),),switchRef: (input) =>ensureGitCommand("GitWorkflowService.switchRef", input.cwd).pipe(- Effect.andThen(Effect.scoped(git.switchRef(input))),+ Effect.flatMap((handle) =>+ withCheckoutLease(handle.repository.rootPath, Effect.scoped(git.switchRef(input))),+ ),),renameBranch: (input) =>ensureGit("GitWorkflowService.renameBranch", input.cwd).pipe(diff --git a/apps/web/src/components/PullRequestThreadDialog.test.ts b/apps/web/src/components/PullRequestThreadDialog.test.tsindex c852a853da3..4637d58df84 100644--- a/apps/web/src/components/PullRequestThreadDialog.test.ts+++ b/apps/web/src/components/PullRequestThreadDialog.test.ts@@ -82,6 +82,7 @@ vi.mock("~/state/git", () => ({return AsyncResult.success({branch: "feature/pr",worktreePath: mode === "worktree" ? "/worktree" : null,+ isOnPullRequestHead: true,});},},@@ -102,6 +103,7 @@ vi.mock("~/state/vcs", () => ({vi.mock("./ui/button", () => ({ Button: "Button" }));vi.mock("./ui/input", () => ({ Input: "Input" }));vi.mock("./ui/spinner", () => ({ Spinner: "Spinner" }));+vi.mock("./ui/toast", () => ({ toastManager: { add: vi.fn() } }));vi.mock("./ui/dialog", () => ({Dialog: "Dialog",DialogDescription: "DialogDescription",diff --git a/apps/web/src/components/PullRequestThreadDialog.tsx b/apps/web/src/components/PullRequestThreadDialog.tsxindex 4121984edc9..5ca4e4ad6d8 100644--- a/apps/web/src/components/PullRequestThreadDialog.tsx+++ b/apps/web/src/components/PullRequestThreadDialog.tsx@@ -21,6 +21,7 @@ import { getSourceControlPresentation } from "~/sourceControlPresentation";import { useEnvironmentQuery } from "~/state/query";import { readEnvironmentScope, useEnvironmentScope } from "~/state/session";import { vcsEnvironment } from "~/state/vcs";+import { OFF_HEAD_PULL_REQUEST_CHECKOUT_TOAST } from "./pullRequest/pullRequestCheckoutToast";import { Button } from "./ui/button";import {Dialog,@@ -33,6 +34,7 @@ import {} from "./ui/dialog";import { Input } from "./ui/input";import { Spinner } from "./ui/spinner";+import { toastManager } from "./ui/toast";interface PullRequestThreadDialogProps {open: boolean;@@ -171,6 +173,9 @@ export function PullRequestThreadDialog({branch: result.value.branch,worktreePath: result.value.worktreePath,});+ if (!result.value.isOnPullRequestHead) {+ toastManager.add(OFF_HEAD_PULL_REQUEST_CHECKOUT_TOAST);+ }onOpenChange(false);};diff --git a/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx b/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsxindex da98ff9df58..071b77b39db 100644--- a/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx+++ b/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx@@ -77,6 +77,7 @@ import {} from "~/keybindings";import { primaryServerKeybindingsAtom } from "~/state/server";import { usePullRequestDefaultMergeMethodResolver } from "./usePullRequestActions";+import { OFF_HEAD_PULL_REQUEST_CHECKOUT_TOAST } from "./pullRequestCheckoutToast";import { changeRequestRepositoryUrl, gitHubPullRequestBrowserUrl } from "~/lib/openPullRequestLink";import { usePreparePullRequestThreadAction } from "~/lib/sourceControlActions";import { cn } from "~/lib/utils";@@ -1264,12 +1265,6 @@ export function PullRequestDetailPanel({return;}setHandoff(null);- const staleCheckoutToast = {- type: "warning",- title: "Checked out, but not on the latest commits",- description:- "The checkout could not be moved onto the pull request's latest commits, so the code there is older than the pull request. Uncommitted work or local commits keep it where it is.",- } as const;if (task === null) {toastManager.update(toastId,@@ -1282,7 +1277,7 @@ export function PullRequestDetailPanel({? "This repository is on the pull request's branch, with a thread open on it.": "The pull request is in its own worktree, with a thread open on it.",}- : staleCheckoutToast,+ : OFF_HEAD_PULL_REQUEST_CHECKOUT_TOAST,);return;}@@ -1295,7 +1290,7 @@ export function PullRequestDetailPanel({title: "Checkout ready",description: "The task is in the composer — read it over, then send.",}- : staleCheckoutToast,+ : OFF_HEAD_PULL_REQUEST_CHECKOUT_TOAST,);};diff --git a/apps/web/src/components/pullRequest/pullRequestCheckoutToast.ts b/apps/web/src/components/pullRequest/pullRequestCheckoutToast.tsnew file mode 100644index 00000000000..bea670056e2--- /dev/null+++ b/apps/web/src/components/pullRequest/pullRequestCheckoutToast.ts@@ -0,0 +1,6 @@+export const OFF_HEAD_PULL_REQUEST_CHECKOUT_TOAST = {+ type: "warning",+ title: "Checked out, but not confirmed on the latest commit",+ description:+ "This checkout could not be confirmed at the pull request's latest commit, so its code may differ. Local commits or uncommitted work keep a checkout where it is.",+} as const;diff --git a/apps/web/src/components/pullRequest/usePullRequestActions.ts b/apps/web/src/components/pullRequest/usePullRequestActions.tsindex eaaf92d77ea..68effbe5780 100644--- a/apps/web/src/components/pullRequest/usePullRequestActions.ts+++ b/apps/web/src/components/pullRequest/usePullRequestActions.ts@@ -31,6 +31,7 @@ import type { ReviewCommentContext } from "~/reviewCommentContext";import { pullRequestEnvironment } from "~/state/pullRequests";import { toastManager } from "../ui/toast";+import { OFF_HEAD_PULL_REQUEST_CHECKOUT_TOAST } from "./pullRequestCheckoutToast";import {checkoutFailureDescription,handoffPrompt,@@ -372,12 +373,6 @@ export function usePullRequestHandoffs({return;}setHandoff(null);- const staleCheckoutToast = {- type: "warning",- title: "Checked out, but not on the latest commits",- description:- "The checkout could not be moved onto the pull request's latest commits, so the code there is older than the pull request. Uncommitted work or local commits keep it where it is.",- } as const;if (task === null) {toastManager.update(toastId,@@ -390,7 +385,7 @@ export function usePullRequestHandoffs({? "This repository is on the pull request's branch, with a thread open on it.": "The pull request is in its own worktree, with a thread open on it.",}- : staleCheckoutToast,+ : OFF_HEAD_PULL_REQUEST_CHECKOUT_TOAST,);return;}@@ -403,7 +398,7 @@ export function usePullRequestHandoffs({title: "Checkout ready",description: "The task is in the composer — read it over, then send.",}- : staleCheckoutToast,+ : OFF_HEAD_PULL_REQUEST_CHECKOUT_TOAST,);};diff --git a/packages/source-control-azure-devops/src/server/AzureDevOpsCli.test.ts b/packages/source-control-azure-devops/src/server/AzureDevOpsCli.test.tsindex 0a6b4fd6fc5..acbe828d05f 100644--- a/packages/source-control-azure-devops/src/server/AzureDevOpsCli.test.ts+++ b/packages/source-control-azure-devops/src/server/AzureDevOpsCli.test.ts@@ -43,6 +43,7 @@ describe("AzureDevOpsCli.layer", () => {title: "Add Azure provider",sourceRefName: "refs/heads/feature/source-control",targetRefName: "refs/heads/main",+ lastMergeSourceCommit: { commitId: "a".repeat(40) },status: "active",creationDate: "2026-01-02T00:00:00.000Z",closedDate: null,@@ -67,6 +68,7 @@ describe("AzureDevOpsCli.layer", () => {assert.strictEqual(result.url, "https://dev.azure.com/acme/project/_git/repo/pullrequest/42");assert.strictEqual(result.baseRefName, "main");assert.strictEqual(result.headRefName, "feature/source-control");+ assert.strictEqual(result.headSha, "a".repeat(40));assert.strictEqual(result.state, "open");assert.deepStrictEqual(result.updatedAt._tag, Option.some(1)._tag);assert.deepStrictEqual(mockRun.mock.calls.at(-1)?.[0], {diff --git a/packages/source-control-azure-devops/src/server/AzureDevOpsSourceControlProvider.test.ts b/packages/source-control-azure-devops/src/server/AzureDevOpsSourceControlProvider.test.tsindex f4a8b2ec9c0..8ce503035c3 100644--- a/packages/source-control-azure-devops/src/server/AzureDevOpsSourceControlProvider.test.ts+++ b/packages/source-control-azure-devops/src/server/AzureDevOpsSourceControlProvider.test.ts@@ -23,6 +23,7 @@ it.effect("maps Azure DevOps PR summaries into provider-neutral change requests"url: "https://dev.azure.com/acme/project/_git/repo/pullrequest/42",baseRefName: "main",headRefName: "feature/source-control",+ headSha: "a".repeat(40),state: "closed",isCrossRepository: false,closedAt: "2026-08-23T10:00:00Z",@@ -42,6 +43,7 @@ it.effect("maps Azure DevOps PR summaries into provider-neutral change requests"url: "https://dev.azure.com/acme/project/_git/repo/pullrequest/42",baseRefName: "main",headRefName: "feature/source-control",+ headSha: "a".repeat(40),state: "closed",closedAt: "2026-08-23T10:00:00Z",mergedAt: null,diff --git a/packages/source-control-azure-devops/src/server/AzureDevOpsSourceControlProvider.ts b/packages/source-control-azure-devops/src/server/AzureDevOpsSourceControlProvider.tsindex 355ae29cb72..da254510c74 100644--- a/packages/source-control-azure-devops/src/server/AzureDevOpsSourceControlProvider.ts+++ b/packages/source-control-azure-devops/src/server/AzureDevOpsSourceControlProvider.ts@@ -3,6 +3,7 @@ import * as Effect from "effect/Effect";import { SourceControlProviderError, type ChangeRequest } from "@t3tools/contracts";import * as AzureDevOpsCli from "./AzureDevOpsCli.ts";+import type { NormalizedAzureDevOpsPullRequestRecord } from "./azureDevOpsPullRequests.ts";import * as SourceControlProvider from "@t3tools/source-control-core/server/SourceControlProvider";import {combinedAuthOutput,@@ -54,19 +55,7 @@ export const discovery = {"Install the Azure command-line tools (`az`), then enable Azure DevOps support with `az extension add --name azure-devops`.",} satisfies SourceControlCliDiscoverySpec;-function toChangeRequest(summary: {- readonly number: number;- readonly title: string;- readonly url: string;- readonly baseRefName: string;- readonly headRefName: string;- readonly state: "open" | "closed" | "merged";- readonly isDraft?: boolean;- readonly isCrossRepository: boolean;- readonly closedAt?: string | null;- readonly mergedAt?: string | null;- readonly updatedAt: ChangeRequest["updatedAt"];-}): ChangeRequest {+function toChangeRequest(summary: NormalizedAzureDevOpsPullRequestRecord): ChangeRequest {return {provider: SourceControlProviderKind.make("azure-devops"),number: summary.number,@@ -74,6 +63,7 @@ function toChangeRequest(summary: {url: summary.url,baseRefName: summary.baseRefName,headRefName: summary.headRefName,+ ...(summary.headSha !== undefined ? { headSha: summary.headSha } : {}),state: summary.state,...(summary.isDraft === true ? { isDraft: true } : {}),closedAt: summary.closedAt ?? null,diff --git a/packages/source-control-azure-devops/src/server/azureDevOpsPullRequests.ts b/packages/source-control-azure-devops/src/server/azureDevOpsPullRequests.tsindex 2608cc73fb4..cd72fbad62c 100644--- a/packages/source-control-azure-devops/src/server/azureDevOpsPullRequests.ts+++ b/packages/source-control-azure-devops/src/server/azureDevOpsPullRequests.ts@@ -13,6 +13,7 @@ export interface NormalizedAzureDevOpsPullRequestRecord {readonly url: string;readonly baseRefName: string;readonly headRefName: string;+ readonly headSha?: string;readonly state: "open" | "closed" | "merged";readonly isDraft?: boolean;readonly isCrossRepository: boolean;@@ -38,6 +39,10 @@ const AzureDevOpsPullRequestSchema = Schema.Struct({),sourceRefName: TrimmedNonEmptyString,targetRefName: TrimmedNonEmptyString,+ /** The source branch's tip as of Azure's last merge evaluation: the pull request's head. */+ lastMergeSourceCommit: Schema.optional(+ Schema.NullOr(Schema.Struct({ commitId: Schema.optional(Schema.NullOr(Schema.String)) })),+ ),status: Schema.String,isDraft: Schema.optional(Schema.Boolean),/** `az` prints `null` for a pull request from the same repo. */@@ -158,6 +163,7 @@ function normalizeAzureDevOpsPullRequestRecord(raw: Schema.Schema.Type<typeof AzureDevOpsPullRequestSchema>,): NormalizedAzureDevOpsPullRequestRecord {const state = normalizeAzureDevOpsPullRequestState(raw.status);+ const headSha = trimOptionalString(raw.lastMergeSourceCommit?.commitId);const terminalAt = Option.match(raw.closedDate ?? Option.none(), {onNone: () => null,onSome: DateTime.formatIso,@@ -168,6 +174,7 @@ function normalizeAzureDevOpsPullRequestRecord(url: normalizeAzureDevOpsPullRequestUrl(raw),baseRefName: normalizeRefName(raw.targetRefName),headRefName: normalizeRefName(raw.sourceRefName),+ ...(headSha ? { headSha } : {}),state,...(raw.isDraft === true ? { isDraft: true } : {}),isCrossRepository: raw.forkSource != null,diff --git a/packages/source-control-bitbucket/src/server/BitbucketSourceControlProvider.test.ts b/packages/source-control-bitbucket/src/server/BitbucketSourceControlProvider.test.tsindex e3e4b669c5e..aff363bfdb4 100644--- a/packages/source-control-bitbucket/src/server/BitbucketSourceControlProvider.test.ts+++ b/packages/source-control-bitbucket/src/server/BitbucketSourceControlProvider.test.ts@@ -3,9 +3,16 @@ import { assert, it } from "@effect/vitest";import * as Effect from "effect/Effect";import * as Layer from "effect/Layer";import * as Option from "effect/Option";+import * as Schema from "effect/Schema";import * as BitbucketApi from "./BitbucketApi.ts";import * as BitbucketSourceControlProvider from "./BitbucketSourceControlProvider.ts";+import {+ BitbucketPullRequestSchema,+ normalizeBitbucketPullRequestRecord,+} from "./bitbucketPullRequests.ts";++const decodePullRequest = Schema.decodeEffect(BitbucketPullRequestSchema);function makeProvider(bitbucket: Partial<BitbucketApi.BitbucketApi["Service"]>) {return BitbucketSourceControlProvider.make.pipe(@@ -17,18 +24,21 @@ it.effect("maps Bitbucket PR summaries into provider-neutral change requests", (Effect.gen(function* () {const provider = yield* makeProvider({getPullRequest: () =>- Effect.succeed({- number: 42,+ decodePullRequest({+ id: 42,title: "Add Bitbucket provider",- url: "https://bitbucket.org/pingdotgg/t3code/pull-requests/42",- baseRefName: "main",- headRefName: "feature/source-control",- state: "open",- updatedAt: Option.none(),- isCrossRepository: true,- headRepositoryNameWithOwner: "fork/t3code",- headRepositoryOwnerLogin: "fork",- }),+ links: { html: { href: "https://bitbucket.org/pingdotgg/t3code/pull-requests/42" } },+ source: {+ branch: { name: "feature/source-control" },+ commit: { hash: "a".repeat(40) },+ repository: { full_name: "fork/t3code" },+ },+ destination: {+ branch: { name: "main" },+ repository: { full_name: "pingdotgg/t3code" },+ },+ state: "OPEN",+ }).pipe(Effect.orDie, Effect.map(normalizeBitbucketPullRequestRecord)),});const changeRequest = yield* provider.getChangeRequest({@@ -43,6 +53,7 @@ it.effect("maps Bitbucket PR summaries into provider-neutral change requests", (url: "https://bitbucket.org/pingdotgg/t3code/pull-requests/42",baseRefName: "main",headRefName: "feature/source-control",+ headSha: "a".repeat(40),state: "open",updatedAt: Option.none(),isCrossRepository: true,diff --git a/packages/source-control-bitbucket/src/server/BitbucketSourceControlProvider.ts b/packages/source-control-bitbucket/src/server/BitbucketSourceControlProvider.tsindex e4b4b1311ab..976fa1231ba 100644--- a/packages/source-control-bitbucket/src/server/BitbucketSourceControlProvider.ts+++ b/packages/source-control-bitbucket/src/server/BitbucketSourceControlProvider.ts@@ -16,6 +16,7 @@ function toChangeRequest(summary: NormalizedBitbucketPullRequestRecord): ChangeRurl: summary.url,baseRefName: summary.baseRefName,headRefName: summary.headRefName,+ ...(summary.headSha !== undefined ? { headSha: summary.headSha } : {}),state: summary.state,...(summary.isDraft === true ? { isDraft: true } : {}),updatedAt: summary.updatedAt ?? Option.none(),diff --git a/packages/source-control-bitbucket/src/server/bitbucketPullRequests.ts b/packages/source-control-bitbucket/src/server/bitbucketPullRequests.tsindex 3b07334a804..27147057782 100644--- a/packages/source-control-bitbucket/src/server/bitbucketPullRequests.ts+++ b/packages/source-control-bitbucket/src/server/bitbucketPullRequests.ts@@ -9,6 +9,7 @@ export interface NormalizedBitbucketPullRequestRecord {readonly url: string;readonly baseRefName: string;readonly headRefName: string;+ readonly headSha?: string;readonly state: "open" | "closed" | "merged";readonly isDraft?: boolean;readonly updatedAt: Option.Option<DateTime.Utc>;@@ -33,6 +34,9 @@ export const BitbucketPullRequestBranchSchema = Schema.Struct({branch: Schema.Struct({name: TrimmedNonEmptyString,}),+ commit: Schema.optional(+ Schema.NullOr(Schema.Struct({ hash: Schema.optional(Schema.NullOr(Schema.String)) })),+ ),});export const BitbucketPullRequestSchema = Schema.Struct({@@ -85,6 +89,7 @@ export function normalizeBitbucketPullRequestRecord(): NormalizedBitbucketPullRequestRecord {const headRepositoryNameWithOwner = trimOptionalString(raw.source.repository?.full_name);const baseRepositoryNameWithOwner = trimOptionalString(raw.destination.repository?.full_name);+ const headSha = trimOptionalString(raw.source.commit?.hash);const headRepositoryOwnerLogin = raw.source.repository? repositoryOwner(raw.source.repository): null;@@ -99,6 +104,7 @@ export function normalizeBitbucketPullRequestRecord(url: raw.links.html.href,baseRefName: raw.destination.branch.name,headRefName: raw.source.branch.name,+ ...(headSha ? { headSha } : {}),state: normalizeBitbucketPullRequestState(raw.state),...(raw.draft === true ? { isDraft: true } : {}),updatedAt: raw.updated_on ?? Option.none(),diff --git a/packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.test.ts b/packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.test.tsindex f71ef955913..7819cf87bc2 100644--- a/packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.test.ts+++ b/packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.test.ts@@ -555,6 +555,7 @@ it.effect("loads Forgejo pull request references from files and commits views",const result = yield* provider.getChangeRequest({ cwd: "/repo", reference });assert.strictEqual(result.number, 42);assert.strictEqual(result.title, "Forgejo view reference");+ assert.strictEqual(result.headSha, "head");}const invalid = yield* provider.getChangeRequest({diff --git a/packages/source-control-forgejo/src/server/forgejoPullRequests.ts b/packages/source-control-forgejo/src/server/forgejoPullRequests.tsindex dc084d93253..57e2c316df1 100644--- a/packages/source-control-forgejo/src/server/forgejoPullRequests.ts+++ b/packages/source-control-forgejo/src/server/forgejoPullRequests.ts@@ -35,6 +35,7 @@ export function toForgejoChangeRequest(raw: typeof ForgejoPullRequestSchema.TypeisDraft: raw.draft ?? /^(?:\[WIP\]|WIP:)/i.test(raw.title),baseRefName: raw.base.ref,headRefName: raw.head.ref,+ ...(raw.head.sha.trim().length > 0 ? { headSha: raw.head.sha.trim() } : {}),closedAt: raw.closed_at ?? null,mergedAt: raw.merged_at ?? null,updatedAt: raw.updated_at ?? Option.none(),diff --git a/packages/source-control-gitlab/src/server/GitLabCli.test.ts b/packages/source-control-gitlab/src/server/GitLabCli.test.tsindex 1b1e0b9d12a..e8046b89f11 100644--- a/packages/source-control-gitlab/src/server/GitLabCli.test.ts+++ b/packages/source-control-gitlab/src/server/GitLabCli.test.ts@@ -40,6 +40,7 @@ layer("GitLabCli.layer", (it) => {web_url: "https://gitlab.com/pingdotgg/t3code/-/merge_requests/42",target_branch: "main",source_branch: "feature/mr-threads",+ sha: "a".repeat(40),state: "closed",closed_at: "2026-08-23T10:00:00Z",source_project_id: 101,@@ -66,6 +67,7 @@ layer("GitLabCli.layer", (it) => {url: "https://gitlab.com/pingdotgg/t3code/-/merge_requests/42",baseRefName: "main",headRefName: "feature/mr-threads",+ headSha: "a".repeat(40),state: "closed",closedAt: "2026-08-23T10:00:00Z",mergedAt: null,diff --git a/packages/source-control-gitlab/src/server/GitLabCli.ts b/packages/source-control-gitlab/src/server/GitLabCli.tsindex 00b900b8ab7..aea251144e8 100644--- a/packages/source-control-gitlab/src/server/GitLabCli.ts+++ b/packages/source-control-gitlab/src/server/GitLabCli.ts@@ -244,6 +244,7 @@ export interface GitLabMergeRequestSummary {readonly url: string;readonly baseRefName: string;readonly headRefName: string;+ readonly headSha?: string;readonly state?: "open" | "closed" | "merged";readonly isDraft?: boolean;readonly closedAt?: string | null;diff --git a/packages/source-control-gitlab/src/server/GitLabSourceControlProvider.test.ts b/packages/source-control-gitlab/src/server/GitLabSourceControlProvider.test.tsindex b5130a3a887..97a413278b6 100644--- a/packages/source-control-gitlab/src/server/GitLabSourceControlProvider.test.ts+++ b/packages/source-control-gitlab/src/server/GitLabSourceControlProvider.test.ts@@ -35,6 +35,7 @@ it.effect("maps GitLab MR summaries into provider-neutral change requests", () =url: "https://gitlab.com/pingdotgg/t3code/-/merge_requests/42",baseRefName: "main",headRefName: "feature/source-control",+ headSha: "a".repeat(40),state: "closed",closedAt: "2026-08-23T10:00:00Z",isCrossRepository: true,@@ -55,6 +56,7 @@ it.effect("maps GitLab MR summaries into provider-neutral change requests", () =url: "https://gitlab.com/pingdotgg/t3code/-/merge_requests/42",baseRefName: "main",headRefName: "feature/source-control",+ headSha: "a".repeat(40),state: "closed",closedAt: "2026-08-23T10:00:00Z",mergedAt: null,diff --git a/packages/source-control-gitlab/src/server/GitLabSourceControlProvider.ts b/packages/source-control-gitlab/src/server/GitLabSourceControlProvider.tsindex 5f69581aad2..38c404e6523 100644--- a/packages/source-control-gitlab/src/server/GitLabSourceControlProvider.ts+++ b/packages/source-control-gitlab/src/server/GitLabSourceControlProvider.ts@@ -35,6 +35,7 @@ function toChangeRequest(summary: GitLabCli.GitLabMergeRequestSummary): ChangeReurl: summary.url,baseRefName: summary.baseRefName,headRefName: summary.headRefName,+ ...(summary.headSha !== undefined ? { headSha: summary.headSha } : {}),state: summary.state ?? "open",...(summary.isDraft === true ? { isDraft: true } : {}),closedAt: summary.closedAt ?? null,diff --git a/packages/source-control-gitlab/src/server/gitLabMergeRequests.ts b/packages/source-control-gitlab/src/server/gitLabMergeRequests.tsindex d03d4341122..d8e5a818488 100644--- a/packages/source-control-gitlab/src/server/gitLabMergeRequests.ts+++ b/packages/source-control-gitlab/src/server/gitLabMergeRequests.ts@@ -13,6 +13,7 @@ export interface NormalizedGitLabMergeRequestRecord {readonly url: string;readonly baseRefName: string;readonly headRefName: string;+ readonly headSha?: string;readonly state: "open" | "closed" | "merged";readonly isDraft?: boolean;readonly closedAt?: string | null;@@ -43,6 +44,7 @@ const GitLabMergeRequestSchema = Schema.Struct({web_url: TrimmedNonEmptyString,source_branch: TrimmedNonEmptyString,target_branch: TrimmedNonEmptyString,+ sha: Schema.optional(Schema.NullOr(Schema.String)),state: Schema.optional(Schema.NullOr(Schema.String)),draft: Schema.optional(Schema.Boolean),work_in_progress: Schema.optional(Schema.Boolean),@@ -107,6 +109,7 @@ function normalizeGitLabMergeRequestRecord(? sourceProjectPath.toLowerCase() !== targetProjectPath.toLowerCase(): undefined;const headRepositoryOwnerLogin = ownerLoginFromPathWithNamespace(sourceProjectPath);+ const headSha = trimOptionalString(raw.sha);return {number: raw.iid,@@ -114,6 +117,7 @@ function normalizeGitLabMergeRequestRecord(url: raw.web_url,baseRefName: raw.target_branch,headRefName: raw.source_branch,+ ...(headSha ? { headSha } : {}),state: normalizeGitLabMergeRequestState(raw.state),...(raw.draft === true || raw.work_in_progress === true ? { isDraft: true } : {}),closedAt: raw.closed_at ?? null,