Skip to content

Commit 206afbe

Browse files
committed
Fix overly broad GitLab error matching and deduplicate ChangeRequestIcon
- Narrow normalizeGitLabCliError 'not found' patterns to only match merge-request-specific errors instead of any 404/not-found response, preventing misleading 'Merge request not found' messages for project or repository lookups. - Remove duplicate ChangeRequestIcon from GitActionsControl.tsx and reuse the already-exported ChangeRequestStatusIcon from ThreadStatusIndicators.tsx.
1 parent 0e387b9 commit 206afbe

2 files changed

Lines changed: 11 additions & 25 deletions

File tree

apps/server/src/sourceControl/GitLabCli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ function normalizeGitLabCliError(operation: "execute" | "stdout", error: unknown
116116

117117
if (
118118
lower.includes("merge request not found") ||
119-
lower.includes("not found") ||
120-
lower.includes("404")
119+
lower.includes("no merge request found") ||
120+
(lower.includes("merge_requests") && lower.includes("404"))
121121
) {
122122
return new GitLabCliError({
123123
operation,

apps/web/src/components/GitActionsControl.tsx

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,8 @@ import type {
77
} from "@t3tools/contracts";
88
import { useIsMutating, useMutation, useQueryClient } from "@tanstack/react-query";
99
import { useCallback, useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
10-
import {
11-
ChevronDownIcon,
12-
CloudUploadIcon,
13-
GitCommitIcon,
14-
GitPullRequestIcon,
15-
InfoIcon,
16-
} from "lucide-react";
17-
import { GitHubIcon, GitLabIcon } from "./Icons";
10+
import { ChevronDownIcon, CloudUploadIcon, GitCommitIcon, InfoIcon } from "lucide-react";
11+
import { ChangeRequestStatusIcon } from "./ThreadStatusIndicators";
1812
import {
1913
buildGitActionProgressStages,
2014
buildMenuItems,
@@ -202,18 +196,6 @@ const COMMIT_DIALOG_TITLE = "Commit changes";
202196
const COMMIT_DIALOG_DESCRIPTION =
203197
"Review and confirm your commit. Leave the message blank to auto-generate one.";
204198

205-
function ChangeRequestIcon({
206-
presentation,
207-
className,
208-
}: {
209-
presentation: ChangeRequestPresentation;
210-
className?: string;
211-
}) {
212-
if (presentation.icon === "github") return <GitHubIcon className={className} />;
213-
if (presentation.icon === "gitlab") return <GitLabIcon className={className} />;
214-
return <GitPullRequestIcon className={className} />;
215-
}
216-
217199
function GitActionItemIcon({
218200
icon,
219201
changeRequestPresentation,
@@ -223,7 +205,7 @@ function GitActionItemIcon({
223205
}) {
224206
if (icon === "commit") return <GitCommitIcon />;
225207
if (icon === "push") return <CloudUploadIcon />;
226-
return <ChangeRequestIcon presentation={changeRequestPresentation} />;
208+
return <ChangeRequestStatusIcon icon={changeRequestPresentation.icon} />;
227209
}
228210

229211
function GitQuickActionIcon({
@@ -235,15 +217,19 @@ function GitQuickActionIcon({
235217
}) {
236218
const iconClassName = "size-3.5";
237219
if (quickAction.kind === "open_pr") {
238-
return <ChangeRequestIcon presentation={changeRequestPresentation} className={iconClassName} />;
220+
return (
221+
<ChangeRequestStatusIcon icon={changeRequestPresentation.icon} className={iconClassName} />
222+
);
239223
}
240224
if (quickAction.kind === "run_pull") return <InfoIcon className={iconClassName} />;
241225
if (quickAction.kind === "run_action") {
242226
if (quickAction.action === "commit") return <GitCommitIcon className={iconClassName} />;
243227
if (quickAction.action === "push" || quickAction.action === "commit_push") {
244228
return <CloudUploadIcon className={iconClassName} />;
245229
}
246-
return <ChangeRequestIcon presentation={changeRequestPresentation} className={iconClassName} />;
230+
return (
231+
<ChangeRequestStatusIcon icon={changeRequestPresentation.icon} className={iconClassName} />
232+
);
247233
}
248234
if (quickAction.label === "Commit") return <GitCommitIcon className={iconClassName} />;
249235
return <InfoIcon className={iconClassName} />;

0 commit comments

Comments
 (0)