Skip to content

Commit 9b8e765

Browse files
fix(web): show checkout error detail from pull request list handoffs
Main moved a copy of the checkout flow into usePullRequestHandoffs, which still read the raw error message. It now shows the same detail-only message as the detail panel, without the server's project path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent dd99797 commit 9b8e765

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

‎apps/web/src/components/pullRequest/usePullRequestActions.ts‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ import { useAtomCommand } from "~/state/use-atom-command";
77
*/
88
import { scopeProjectRef } from "@t3tools/client-runtime/environment";
99
import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
10-
import type {
11-
EnvironmentId,
12-
ProjectId,
13-
PullRequestAction,
14-
PullRequestDetail,
15-
PullRequestMergeMethod,
16-
PullRequestRef,
10+
import {
11+
GitCommandError,
12+
type EnvironmentId,
13+
type ProjectId,
14+
type PullRequestAction,
15+
type PullRequestDetail,
16+
type PullRequestMergeMethod,
17+
type PullRequestRef,
1718
} from "@t3tools/contracts";
19+
import * as Schema from "effect/Schema";
1820
import { useCallback, useRef, useState } from "react";
1921
import { resolveProjectSettings } from "@t3tools/shared/projectSettings";
2022
import { useClientSettings, useEnvironmentSettings } from "~/hooks/useSettings";
@@ -38,6 +40,8 @@ import { handoffPrompt, handoffReviewComments, readableFailure } from "./pullReq
3840
import { pullRequestEntryKey, type EnvironmentPullRequestEntry } from "./pullRequestList.logic";
3941

4042
/** Resolve on demand so hidden quick actions do not rebuild the legacy project grouping. */
43+
const isGitCommandError = Schema.is(GitCommandError);
44+
4145
export function usePullRequestDefaultMergeMethodResolver(
4246
environmentId: EnvironmentId,
4347
projectId: ProjectId,
@@ -394,13 +398,16 @@ export function usePullRequestHandoffs({
394398
if (prepared._tag === "Failure") {
395399
setHandoff(null);
396400
// The server says what to do about it — that the branch is already checked out in the main
397-
// repository, say — and that sentence is the only way out of the failure.
398-
const detailMessage =
399-
prepareThread.error instanceof Error ? prepareThread.error.message : null;
401+
// repository, say — and that sentence is the only way out of the failure. A failed git
402+
// command's message also names the server's project directory, so only its detail is shown.
403+
const failure = squashAtomCommandFailure(prepared);
400404
toastManager.update(toastId, {
401405
type: "error",
402406
title: "Could not prepare the pull request checkout",
403-
...(detailMessage ? { description: detailMessage } : {}),
407+
description: readableFailure(
408+
isGitCommandError(failure) ? failure.detail : failure,
409+
"Check that the branch still exists and is not checked out elsewhere, then try again.",
410+
),
404411
});
405412
return;
406413
}

0 commit comments

Comments
 (0)