Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
fix(web): align pull request action menu rows (#6534)
Bilal Bakr8c628f14993c
diff --git a/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx b/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsxindex 2f4e84dc3..015371a86 100644--- a/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx+++ b/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx@@ -103,6 +103,7 @@ import {handoffPrompt,handoffReviewComments,pullRequestActionNeedsHostRefresh,+ pullRequestActionMenuHasGroup,pullRequestFindingKey,pullRequestHandoffLabels,readableFailure,@@ -1033,6 +1034,26 @@ export function PullRequestDetailPanel({: allowedMergeMethods.length > 0? "merge": null;+ // What the menu's action group holds. Named once so the separators around it are drawn from+ // the same answer as its contents, rather than on the assumption that it has any.+ const showsDraftToggle =+ detail?.state === "open" &&+ can(detail.isDraft ? "ready" : "draft") &&+ !(detail.isDraft && primaryAction === "ready");+ const showsAutoMerge =+ detail?.state === "open" &&+ ((autoMergeArmed && can("disable-auto-merge")) ||+ (!autoMergeArmed &&+ !detail.isDraft &&+ !conflicting &&+ can("enable-auto-merge") &&+ allowedMergeMethods.length > 0));+ const showsMergeMethods =+ detail?.state === "open" &&+ can("merge") &&+ !detail.isDraft &&+ !conflicting &&+ allowedMergeMethods.length > 1;// The pull request number carries this state in the overview and the right-panel tab mirrors// it. Conflicts keep their own row below: an open pull request remains green there.const statePresentation = detail@@ -1191,8 +1212,7 @@ export function PullRequestDetailPanel({{/* Only where the button row could not take it: "Ready for review" on adraft is the primary header button, so offering it here as well wouldshow the same action twice. */}- {can(detail.isDraft ? "ready" : "draft") &&- !(detail.isDraft && primaryAction === "ready") ? (+ {showsDraftToggle ? (<MenuItemdisabled={actionPending}onClick={() => void perform(detail.isDraft ? "ready" : "draft")}@@ -1236,12 +1256,12 @@ export function PullRequestDetailPanel({Hidden while conflicting: every method would fail. */}{/* Only where merging is on offer at all: a strategy to merge with is nota choice for someone who may not merge. */}- {can("merge") &&- !detail.isDraft &&- !conflicting &&- allowedMergeMethods.length > 1 ? (+ {showsMergeMethods ? (<>- <MenuSeparator />+ {/* Only below the draft control. A host with no draft of its own, or+ a draft whose control is already the header button, would leave+ this against the separator that opened the group. */}+ {showsDraftToggle ? <MenuSeparator /> : null}<MenuRadioGroupvalue={selectedMergeMethod}onValueChange={(method) =>@@ -1261,7 +1281,13 @@ export function PullRequestDetailPanel({</MenuRadioGroup></>) : null}- <MenuSeparator />+ {pullRequestActionMenuHasGroup(+ showsDraftToggle,+ showsAutoMerge,+ showsMergeMethods,+ ) ? (+ <MenuSeparator />+ ) : null}</>) : null}<MenuItem onClick={() => void readLocalApi()?.shell.openExternal(detail.url)}>diff --git a/apps/web/src/components/pullRequest/pullRequestDetail.logic.test.ts b/apps/web/src/components/pullRequest/pullRequestDetail.logic.test.tsindex 9b247002f..faab9d847 100644--- a/apps/web/src/components/pullRequest/pullRequestDetail.logic.test.ts+++ b/apps/web/src/components/pullRequest/pullRequestDetail.logic.test.ts@@ -19,6 +19,7 @@ import {isThreadOwnPullRequest,orderPullRequestComments,pullRequestActionNeedsHostRefresh,+ pullRequestActionMenuHasGroup,pullRequestFindingKey,pullRequestHandoffLabels,readableFailure,@@ -53,6 +54,12 @@ const TIMELINE_SOURCE: Pick<closedAt: null,};+describe("pull request action menu", () => {+ it("keeps the group divider when auto-merge is the only action", () => {+ expect(pullRequestActionMenuHasGroup(false, true, false)).toBe(true);+ });+});+describe("pull request state description", () => {it("keeps draft and conflicts orthogonal to the terminal states", () => {expect(describePullRequestState("open", true)).toBe("Draft");diff --git a/apps/web/src/components/pullRequest/pullRequestDetail.logic.ts b/apps/web/src/components/pullRequest/pullRequestDetail.logic.tsindex ddb4e813b..26054f6ef 100644--- a/apps/web/src/components/pullRequest/pullRequestDetail.logic.ts+++ b/apps/web/src/components/pullRequest/pullRequestDetail.logic.ts@@ -57,6 +57,15 @@ export function pullRequestHandoffLabels(inThisThread: boolean) {};}+/** Whether the open pull-request action group contains at least one action. */+export function pullRequestActionMenuHasGroup(+ showsDraftToggle: boolean,+ showsAutoMerge: boolean,+ showsMergeMethods: boolean,+): boolean {+ return showsDraftToggle || showsAutoMerge || showsMergeMethods;+}+/** Plain-language state, shown beside the author. Conflicts are a merge signal, not a state. */export function describePullRequestState(state: PullRequestState, isDraft: boolean): string {if (state === "merged") return "Merged";diff --git a/apps/web/src/components/ui/menu.test.tsx b/apps/web/src/components/ui/menu.test.tsxnew file mode 100644index 000000000..079d2a179--- /dev/null+++ b/apps/web/src/components/ui/menu.test.tsx@@ -0,0 +1,23 @@+import { renderToStaticMarkup } from "react-dom/server";+import { describe, expect, it } from "vite-plus/test";++import { Menu, MenuRadioGroup, MenuRadioItem } from "./menu";++describe("menu radio item geometry", () => {+ it("keeps radio-item icons on the same text grid as menu items", () => {+ const html = renderToStaticMarkup(+ <Menu>+ <MenuRadioGroup value="merge">+ <MenuRadioItem value="merge">+ <span className="flex items-center gap-2">+ <svg aria-hidden className="size-3.5" />+ <span>Merge</span>+ </span>+ </MenuRadioItem>+ </MenuRadioGroup>+ </Menu>,+ );++ expect(html).toContain("-mx-0.5");+ });+});diff --git a/apps/web/src/components/ui/menu.tsx b/apps/web/src/components/ui/menu.tsxindex 803d6c198..b66782ebe 100644--- a/apps/web/src/components/ui/menu.tsx+++ b/apps/web/src/components/ui/menu.tsx@@ -166,7 +166,7 @@ function MenuRadioItem({return (<MenuPrimitive.RadioItemclassName={cn(- "flex min-h-8 in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] cursor-pointer items-center rounded-sm px-2 py-1 text-base text-foreground outline-none data-checked:bg-foreground/[0.08] data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",+ "[&_svg]:-mx-0.5 flex min-h-8 in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] cursor-pointer items-center rounded-sm px-2 py-1 text-base text-foreground outline-none data-checked:bg-foreground/[0.08] data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",className,)}data-slot="menu-radio-item"