From 62cf884e81b816a80808776b46e052f1a1db5509 Mon Sep 17 00:00:00 2001 From: Michael Suchacz <203725896+ibetitsmike@users.noreply.github.com> Date: Thu, 19 Mar 2026 16:53:38 +0100 Subject: [PATCH] fix(site): show PR number instead of title on mobile top bar (#23296) --- .../AgentsPage/AgentDetail/TopBar.stories.tsx | 83 +++++++++++++++++++ .../pages/AgentsPage/AgentDetail/TopBar.tsx | 45 ++-------- 2 files changed, 91 insertions(+), 37 deletions(-) diff --git a/site/src/pages/AgentsPage/AgentDetail/TopBar.stories.tsx b/site/src/pages/AgentsPage/AgentDetail/TopBar.stories.tsx index 2d0aa50819..a269aef5a8 100644 --- a/site/src/pages/AgentsPage/AgentDetail/TopBar.stories.tsx +++ b/site/src/pages/AgentsPage/AgentDetail/TopBar.stories.tsx @@ -143,6 +143,89 @@ export const WithClosedPR: Story = { }, }; +// --------------------------------------------------------------- +// Mobile viewport stories — constrain width to 390px so the +// responsive md: breakpoint triggers the compact PR number. +// --------------------------------------------------------------- + +const mobileDecorator: Story["decorators"] = [ + (Story) => ( +
+ +
+ ), +]; + +export const MobileWithOpenPR: Story = { + decorators: mobileDecorator, + parameters: { chromatic: { viewports: [390] } }, + args: { + diffStatusData: { + chat_id: "chat-1", + url: "https://github.com/coder/coder/pull/123", + pull_request_title: "fix: resolve race condition in workspace builds", + pull_request_draft: false, + changes_requested: false, + additions: 42, + deletions: 7, + changed_files: 5, + }, + }, +}; + +export const MobileWithDraftPR: Story = { + decorators: mobileDecorator, + parameters: { chromatic: { viewports: [390] } }, + args: { + diffStatusData: { + chat_id: "chat-1", + url: "https://github.com/coder/coder/pull/456", + pull_request_title: "feat: add new notification system", + pull_request_draft: true, + changes_requested: false, + additions: 120, + deletions: 30, + changed_files: 8, + }, + }, +}; + +export const MobileWithMergedPR: Story = { + decorators: mobileDecorator, + parameters: { chromatic: { viewports: [390] } }, + args: { + diffStatusData: { + chat_id: "chat-1", + url: "https://github.com/coder/coder/pull/789", + pull_request_title: "chore: update dependencies", + pull_request_state: "merged", + pull_request_draft: false, + changes_requested: false, + additions: 5, + deletions: 3, + changed_files: 1, + }, + }, +}; + +export const MobileWithClosedPR: Story = { + decorators: mobileDecorator, + parameters: { chromatic: { viewports: [390] } }, + args: { + diffStatusData: { + chat_id: "chat-1", + url: "https://github.com/coder/coder/pull/101", + pull_request_title: "fix: deprecated API cleanup", + pull_request_state: "closed", + pull_request_draft: false, + changes_requested: false, + additions: 0, + deletions: 50, + changed_files: 3, + }, + }, +}; + export const ArchivedWithUnarchive: Story = { args: { isArchived: true, diff --git a/site/src/pages/AgentsPage/AgentDetail/TopBar.tsx b/site/src/pages/AgentsPage/AgentDetail/TopBar.tsx index d833c54e62..3581a4d62c 100644 --- a/site/src/pages/AgentsPage/AgentDetail/TopBar.tsx +++ b/site/src/pages/AgentsPage/AgentDetail/TopBar.tsx @@ -16,10 +16,6 @@ import { CopyIcon, EllipsisIcon, ExternalLinkIcon, - GitMergeIcon, - GitPullRequestArrowIcon, - GitPullRequestClosedIcon, - GitPullRequestDraftIcon, MonitorIcon, PanelLeftIcon, PanelRightCloseIcon, @@ -32,6 +28,7 @@ import { useNavigate } from "react-router"; import { toast } from "sonner"; import { cn } from "utils/cn"; import { useEmbedContext } from "../EmbedContext"; +import { PrStateIcon } from "../GitPanel"; import { parsePullRequestUrl } from "../pullRequest"; interface SidebarPanelState { @@ -64,35 +61,6 @@ type AgentDetailTopBarProps = { diffStatusData?: ChatDiffStatus; }; -const PrStateIcon: FC<{ - state?: string; - draft?: boolean; - className?: string; -}> = ({ state, draft, className }) => { - if (state === "merged") { - return ; - } - if (state === "closed") { - return ( - - ); - } - if (draft) { - return ( - - ); - } - return ( - - ); -}; - export const AgentDetailTopBar: FC = ({ chatTitle, parentChat, @@ -169,9 +137,9 @@ export const AgentDetailTopBar: FC = ({ )} - {/* PR link — visible on mobile always, hidden on desktop - when the sidebar panel is open (which already shows PR - info). */} + {/* PR link — mobile: icon + number; desktop: icon + title. + Hidden on desktop when the sidebar panel is open + (which already shows PR info). */} {prUrl && hasPR && ( = ({ draft={prDraft} className="!size-3.5 shrink-0" /> - + {prTitle || (prNumberMatch ? `#${prNumberMatch}` : "PR")} + + {prNumberMatch ? prNumberMatch : "PR"} + )} {/* Actions area */}