fix(web): remove open PR actions from git controls
- Keep the git action control disabled when the branch is up to date - Omit open PR menu entries and remove their link-opening behavior - Update logic tests for the new states
This commit is contained in:
1 parent
482c46f6e2
commit
8ada620ce8
3 files changed
+55
-73
No files matched your search
@@ -126,7 +126,7 @@ describe("git action result toast timing", () => {
|
||||
});
|
||||
|
||||
describe("when: ref is clean and has an open PR", () => {
|
||||
it("resolveQuickAction opens the existing PR", () => {
|
||||
it("resolveQuickAction rests in the disabled up-to-date state", () => {
|
||||
const quick = resolveQuickAction(
|
||||
status({
|
||||
pr: {
|
||||
@@ -140,10 +140,15 @@ describe("when: ref is clean and has an open PR", () => {
|
||||
}),
|
||||
false,
|
||||
);
|
||||
assert.deepInclude(quick, { kind: "open_pr", label: "View PR", disabled: false });
|
||||
assert.deepInclude(quick, {
|
||||
kind: "show_hint",
|
||||
label: "Commit",
|
||||
disabled: true,
|
||||
hint: "Branch is up to date. No action needed.",
|
||||
});
|
||||
});
|
||||
|
||||
it("buildMenuItems disables commit/push and enables open PR", () => {
|
||||
it("buildMenuItems disables commit/push and omits the PR entry", () => {
|
||||
const items = buildMenuItems(
|
||||
status({
|
||||
pr: {
|
||||
@@ -174,13 +179,6 @@ describe("when: ref is clean and has an open PR", () => {
|
||||
kind: "open_dialog",
|
||||
dialogAction: "push",
|
||||
},
|
||||
{
|
||||
id: "pr",
|
||||
label: "View PR",
|
||||
disabled: false,
|
||||
icon: "pr",
|
||||
kind: "open_pr",
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -263,7 +261,7 @@ describe("when: ref is clean, ahead, and has an open PR", () => {
|
||||
assert.deepInclude(quick, { kind: "run_action", action: "push", label: "Push" });
|
||||
});
|
||||
|
||||
it("buildMenuItems enables push and keeps open PR available", () => {
|
||||
it("buildMenuItems enables push and omits the PR entry", () => {
|
||||
const items = buildMenuItems(
|
||||
status({
|
||||
aheadCount: 2,
|
||||
@@ -295,13 +293,6 @@ describe("when: ref is clean, ahead, and has an open PR", () => {
|
||||
kind: "open_dialog",
|
||||
dialogAction: "push",
|
||||
},
|
||||
{
|
||||
id: "pr",
|
||||
label: "View PR",
|
||||
disabled: false,
|
||||
icon: "pr",
|
||||
kind: "open_pr",
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -730,7 +721,7 @@ describe("when: ref has no upstream configured", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("resolveQuickAction opens PR when clean, no upstream, no local commits are ahead, and PR exists", () => {
|
||||
it("resolveQuickAction rests disabled when clean, no upstream, no local commits are ahead, and PR exists", () => {
|
||||
const quick = resolveQuickAction(
|
||||
status({
|
||||
hasUpstream: false,
|
||||
@@ -747,9 +738,10 @@ describe("when: ref has no upstream configured", () => {
|
||||
false,
|
||||
);
|
||||
assert.deepInclude(quick, {
|
||||
kind: "open_pr",
|
||||
label: "View PR",
|
||||
disabled: false,
|
||||
kind: "show_hint",
|
||||
label: "Commit",
|
||||
disabled: true,
|
||||
hint: "Branch is up to date. No action needed.",
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -19,14 +19,14 @@ export interface GitActionMenuItem {
|
||||
label: string;
|
||||
disabled: boolean;
|
||||
icon: GitActionIconName;
|
||||
kind: "open_dialog" | "open_pr";
|
||||
kind: "open_dialog";
|
||||
dialogAction?: GitDialogAction;
|
||||
}
|
||||
|
||||
export interface GitQuickAction {
|
||||
label: string;
|
||||
disabled: boolean;
|
||||
kind: "run_action" | "run_pull" | "open_pr" | "open_publish" | "show_hint";
|
||||
kind: "run_action" | "run_pull" | "open_publish" | "show_hint";
|
||||
action?: GitStackedAction;
|
||||
hint?: string;
|
||||
}
|
||||
@@ -189,7 +189,6 @@ export function buildMenuItems(
|
||||
hasDefaultBranchDelta &&
|
||||
!isBehind &&
|
||||
(gitStatus.hasUpstream || canPushWithoutUpstream);
|
||||
const canOpenPr = !isBusy && hasOpenPr;
|
||||
|
||||
const commitItem: GitActionMenuItem = {
|
||||
id: "commit",
|
||||
@@ -204,32 +203,32 @@ export function buildMenuItems(
|
||||
return [commitItem];
|
||||
}
|
||||
|
||||
const pushItem: GitActionMenuItem = {
|
||||
id: "push",
|
||||
label: "Push",
|
||||
disabled: !canPush,
|
||||
icon: "push",
|
||||
kind: "open_dialog",
|
||||
dialogAction: "push",
|
||||
};
|
||||
|
||||
// An open change request is surfaced by the standalone attribution row, so
|
||||
// the menu offers no change-request entry at all while one is open.
|
||||
if (hasOpenPr) {
|
||||
return [commitItem, pushItem];
|
||||
}
|
||||
|
||||
return [
|
||||
commitItem,
|
||||
pushItem,
|
||||
{
|
||||
id: "push",
|
||||
label: "Push",
|
||||
disabled: !canPush,
|
||||
icon: "push",
|
||||
id: "pr",
|
||||
label: `Create ${terminology.shortLabel}`,
|
||||
disabled: !canCreatePr,
|
||||
icon: "pr",
|
||||
kind: "open_dialog",
|
||||
dialogAction: "push",
|
||||
dialogAction: "create_pr",
|
||||
},
|
||||
hasOpenPr
|
||||
? {
|
||||
id: "pr",
|
||||
label: `View ${terminology.shortLabel}`,
|
||||
disabled: !canOpenPr,
|
||||
icon: "pr",
|
||||
kind: "open_pr",
|
||||
}
|
||||
: {
|
||||
id: "pr",
|
||||
label: `Create ${terminology.shortLabel}`,
|
||||
disabled: !canCreatePr,
|
||||
icon: "pr",
|
||||
kind: "open_dialog",
|
||||
dialogAction: "create_pr",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -287,9 +286,6 @@ export function resolveQuickAction(
|
||||
|
||||
if (!gitStatus.hasUpstream) {
|
||||
if (!hasPrimaryRemote) {
|
||||
if (hasOpenPr && !isAhead) {
|
||||
return { label: `View ${terminology.shortLabel}`, disabled: false, kind: "open_pr" };
|
||||
}
|
||||
return {
|
||||
label: "Publish repository",
|
||||
disabled: false,
|
||||
@@ -298,7 +294,12 @@ export function resolveQuickAction(
|
||||
}
|
||||
if (!isAhead) {
|
||||
if (hasOpenPr) {
|
||||
return { label: `View ${terminology.shortLabel}`, disabled: false, kind: "open_pr" };
|
||||
return {
|
||||
label: "Commit",
|
||||
disabled: true,
|
||||
kind: "show_hint",
|
||||
hint: "Branch is up to date. No action needed.",
|
||||
};
|
||||
}
|
||||
return {
|
||||
label: "Push",
|
||||
@@ -357,8 +358,15 @@ export function resolveQuickAction(
|
||||
};
|
||||
}
|
||||
|
||||
// An open change request is surfaced by the standalone attribution row in the
|
||||
// details panel, so the action button rests in its disabled up-to-date state.
|
||||
if (hasOpenPr && gitStatus.hasUpstream) {
|
||||
return { label: `View ${terminology.shortLabel}`, disabled: false, kind: "open_pr" };
|
||||
return {
|
||||
label: "Commit",
|
||||
disabled: true,
|
||||
kind: "show_hint",
|
||||
hint: "Branch is up to date. No action needed.",
|
||||
};
|
||||
}
|
||||
|
||||
if (hasDefaultBranchDelta && !isDefaultRef) {
|
||||
|
||||
@@ -103,22 +103,18 @@ import {
|
||||
THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS,
|
||||
} from "./chat/threadDetailsPanelStyles";
|
||||
import { getSourceControlPresentation } from "~/sourceControlPresentation";
|
||||
import { openPullRequestLink } from "~/lib/openPullRequestLink";
|
||||
|
||||
interface GitActionsControlProps {
|
||||
gitCwd: string | null;
|
||||
activeThreadRef: ScopedThreadRef | null;
|
||||
draftId?: DraftId;
|
||||
<<<<<<< HEAD
|
||||
/**
|
||||
* Opens the thread's own change request beside it. Absent when the thread has no project to
|
||||
* place it against, in which case it still opens in the browser.
|
||||
*/
|
||||
onOpenPullRequest?: ((number: number) => void) | undefined;
|
||||
=======
|
||||
displayMode?: "toolbar" | "panel";
|
||||
onOpenChanges?: () => void;
|
||||
>>>>>>> abd5cc5ff8 (Map thread panel into title bar and sidebar)
|
||||
}
|
||||
|
||||
interface PendingDefaultBranchAction {
|
||||
@@ -265,7 +261,6 @@ function getMenuActionDisabledReason({
|
||||
|
||||
const hasBranch = gitStatus.refName !== null;
|
||||
const hasChanges = gitStatus.hasWorkingTreeChanges;
|
||||
const hasOpenPr = gitStatus.pr?.state === "open";
|
||||
const isAhead = gitStatus.aheadCount > 0;
|
||||
const isBehind = gitStatus.behindCount > 0;
|
||||
const terminology = getSourceControlPresentation(gitStatus.sourceControlProvider).terminology;
|
||||
@@ -296,9 +291,6 @@ function getMenuActionDisabledReason({
|
||||
return "Push is currently unavailable.";
|
||||
}
|
||||
|
||||
if (hasOpenPr) {
|
||||
return `View ${terminology.singular} is currently unavailable.`;
|
||||
}
|
||||
if (!hasBranch) {
|
||||
return `Detached HEAD: checkout a refName before creating a ${terminology.singular}.`;
|
||||
}
|
||||
@@ -343,7 +335,6 @@ function GitQuickActionIcon({
|
||||
className?: string;
|
||||
}) {
|
||||
const iconClassName = className;
|
||||
if (quickAction.kind === "open_pr") return <SourceControlIcon className={iconClassName} />;
|
||||
if (quickAction.kind === "open_publish") return <CloudUploadIcon className={iconClassName} />;
|
||||
if (quickAction.kind === "run_pull") return <CloudDownloadIcon className={iconClassName} />;
|
||||
if (quickAction.kind === "run_action") {
|
||||
@@ -386,10 +377,12 @@ function GitActionProgressButtonContent({
|
||||
aria-atomic="false"
|
||||
aria-live="polite"
|
||||
className={cn(
|
||||
"grid min-w-0 flex-1 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-2.5 gap-y-0.5",
|
||||
"grid min-w-0 flex-1 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-2.5",
|
||||
// Pin the title row to the button's minimum content height (min-height
|
||||
// minus vertical padding) so revealing the output row extends the
|
||||
// button downward without re-centering — the title must not shift.
|
||||
// No row gap: the collapsed output row must contribute zero height so
|
||||
// the single-line running button matches the static button exactly.
|
||||
isPanel ? "grid-rows-[1.75rem]" : "grid-rows-[1.25rem] sm:grid-rows-[1rem]",
|
||||
)}
|
||||
role="status"
|
||||
@@ -412,7 +405,7 @@ function GitActionProgressButtonContent({
|
||||
>
|
||||
<div className="min-h-0 overflow-hidden">
|
||||
<p
|
||||
className="truncate text-left text-[11px] font-normal text-muted-foreground"
|
||||
className="truncate pt-0.5 text-left text-[11px] font-normal text-muted-foreground"
|
||||
title={progress.output ?? undefined}
|
||||
>
|
||||
{progress.output}
|
||||
@@ -1030,12 +1023,9 @@ export default function GitActionsControl({
|
||||
gitCwd,
|
||||
activeThreadRef,
|
||||
draftId,
|
||||
<<<<<<< HEAD
|
||||
onOpenPullRequest,
|
||||
=======
|
||||
displayMode = "toolbar",
|
||||
onOpenChanges,
|
||||
>>>>>>> abd5cc5ff8 (Map thread panel into title bar and sidebar)
|
||||
}: GitActionsControlProps) {
|
||||
const isPanel = displayMode === "panel";
|
||||
const ActionGroup = isPanel ? "div" : Group;
|
||||
@@ -1477,10 +1467,6 @@ export default function GitActionsControl({
|
||||
};
|
||||
|
||||
const runQuickAction = () => {
|
||||
if (quickAction.kind === "open_pr") {
|
||||
void openExistingPr();
|
||||
return;
|
||||
}
|
||||
if (quickAction.kind === "open_publish") {
|
||||
setIsPublishDialogOpen(true);
|
||||
return;
|
||||
@@ -1542,10 +1528,6 @@ export default function GitActionsControl({
|
||||
|
||||
const openDialogForMenuItem = (item: GitActionMenuItem) => {
|
||||
if (item.disabled) return;
|
||||
if (item.kind === "open_pr") {
|
||||
void openExistingPr();
|
||||
return;
|
||||
}
|
||||
if (item.dialogAction === "push") {
|
||||
void runGitActionWithToast({ action: "push" });
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user