Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

feat(views): make every pull request chip a link to the PR (#10574)

Tim6f1f9ff43f15
diff --git a/packages/views/issues/components/board-card.tsx b/packages/views/issues/components/board-card.tsx
index a11257842a..e5259c1ae7 100644
--- a/packages/views/issues/components/board-card.tsx
+++ b/packages/views/issues/components/board-card.tsx
@@ -253,7 +253,7 @@ export const BoardCardContent = memo(function BoardCardContent({
</span>
)}
{showPullRequests && (
- <IssuePullRequestChips pullRequests={pullRequests} max={2} />
+ <IssuePullRequestChips pullRequests={pullRequests} max={2} insideLink />
)}
{cardCustomProperties.map((property) => (
<span
diff --git a/packages/views/issues/components/list-row.tsx b/packages/views/issues/components/list-row.tsx
index a753ba2390..f937d7c2ea 100644
--- a/packages/views/issues/components/list-row.tsx
+++ b/packages/views/issues/components/list-row.tsx
@@ -166,6 +166,7 @@ function ListRowContent({
<IssuePullRequestChips
pullRequests={pullRequests}
max={2}
+ insideLink
className="max-w-[40%]"
/>
)}
diff --git a/packages/views/issues/components/pull-request-chips.test.tsx b/packages/views/issues/components/pull-request-chips.test.tsx
index 15fc248826..60531d0761 100644
--- a/packages/views/issues/components/pull-request-chips.test.tsx
+++ b/packages/views/issues/components/pull-request-chips.test.tsx
@@ -34,12 +34,12 @@ function summary(overrides: Partial<IssuePullRequestSummary>): IssuePullRequestS
};
}
-function Chips({ enabled, linked = false }: { enabled: boolean; linked?: boolean }) {
+function Chips({ enabled }: { enabled: boolean }) {
const pullRequests = useIssuePullRequestSummaries("issue-1", enabled);
- return <IssuePullRequestChips pullRequests={pullRequests} max={2} linked={linked} />;
+ return <IssuePullRequestChips pullRequests={pullRequests} max={2} />;
}
-function renderChips(props: { enabled: boolean; linked?: boolean }, onRowClick = vi.fn()) {
+function renderChips(props: { enabled: boolean }, onRowClick = vi.fn()) {
const qc = new QueryClient({ defaultOptions: { queries: { retry: false } } });
return render(
<QueryClientProvider client={qc}>
@@ -85,7 +85,7 @@ describe("issue pull request chips", () => {
],
});
const onRowClick = vi.fn();
- renderChips({ enabled: true, linked: true }, onRowClick);
+ renderChips({ enabled: true }, onRowClick);
const chips = await screen.findAllByTestId("issue-pull-request-chip");
expect(chips.map((chip) => chip.textContent)).toEqual(["Mergedwidget#3", "Draftapi#2"]);
diff --git a/packages/views/issues/components/pull-request-chips.tsx b/packages/views/issues/components/pull-request-chips.tsx
index e7c4de4a5b..6adbc93d3c 100644
--- a/packages/views/issues/components/pull-request-chips.tsx
+++ b/packages/views/issues/components/pull-request-chips.tsx
@@ -14,6 +14,7 @@ import type { GitHubPullRequestState, IssuePullRequestSummary } from "@multica/c
import { cn } from "@multica/ui/lib/utils";
import { useSingleRowFit } from "../../common/single-row-fit";
import { useT } from "../../i18n";
+import { openExternal } from "../../platform/open-external";
export const PULL_REQUEST_STATE_ICON: Record<
GitHubPullRequestState,
@@ -52,10 +53,57 @@ const CHIP_GAP = 4;
// Room for "+N" (up to "+99" at text-micro) beside the chips that fit.
const OVERFLOW_RESERVE = 24;
+const stopPress = (e: React.SyntheticEvent) => e.stopPropagation();
+
+/**
+ * A chip inside the issue link. An anchor cannot nest in an anchor, so this
+ * is a `role="link"` span that opens the PR itself, the way
+ * IssueDuplicateOfMarker's in-row control does. The PR is always external, so
+ * click, modifier click, middle click and Enter all open it outside the app
+ * and none of them reach the row: not its navigation, peek or drag.
+ */
+function NestedChipLink({
+ href,
+ title,
+ className,
+ children,
+}: {
+ href: string;
+ title: string;
+ className: string;
+ children: React.ReactNode;
+}) {
+ const open = (e: React.SyntheticEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ openExternal(href);
+ };
+ return (
+ <span
+ role="link"
+ tabIndex={0}
+ title={title}
+ data-testid="issue-pull-request-chip"
+ className={className}
+ onMouseDown={stopPress}
+ onPointerDown={stopPress}
+ onClick={open}
+ onAuxClick={(e) => {
+ if (e.button === 1) open(e);
+ }}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") open(e);
+ }}
+ >
+ {children}
+ </span>
+ );
+}
+
/**
* Compact "state icon + #number" chips for issue cards, rows and table cells.
- * Board cards and list rows sit inside the issue link, so their chips stay
- * plain text; the table cell has no wrapping link and opens the PR instead.
+ * Every chip opens its PR: a plain anchor where nothing wraps it (table
+ * cells), a NestedChipLink inside the issue link of board cards and list rows.
*
* The group fits whatever width its slot gives it: the newest PRs that fit at
* their natural width are shown and "+N" counts every PR that is not. At
@@ -65,14 +113,14 @@ const OVERFLOW_RESERVE = 24;
export function IssuePullRequestChips({
pullRequests,
max,
- linked = false,
+ insideLink = false,
className,
}: {
pullRequests: readonly IssuePullRequestSummary[];
/** Most chips to show even when more would fit. */
max: number;
- /** Render each chip as a link to the PR. Never inside another link. */
- linked?: boolean;
+ /** The chips sit inside the issue's own link (board cards, list rows). */
+ insideLink?: boolean;
className?: string;
}) {
const { t } = useT("issues");
@@ -106,6 +154,11 @@ export function IssuePullRequestChips({
const chipClass =
"inline-flex min-w-0 max-w-[140px] items-center gap-1 rounded-full bg-muted/60 px-1.5 py-0.5 text-micro text-muted-foreground tabular-nums";
+ const linkClass = cn(
+ chipClass,
+ // Inset: the chip row clips overflow, which would cut an outer ring.
+ "cursor-pointer transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",
+ );
const chipContent = (pr: IssuePullRequestSummary, label: string) => {
const cfg = isKnownState(pr.state)
? PULL_REQUEST_STATE_ICON[pr.state]
@@ -139,7 +192,11 @@ export function IssuePullRequestChips({
{visible.map((pr) => {
const label = stateLabel(pr.state);
const title = `${pr.repo_owner}/${pr.repo_name}#${pr.number} · ${label}${pr.title ? `\n${pr.title}` : ""}`;
- return linked ? (
+ return insideLink ? (
+ <NestedChipLink key={pr.id} href={pr.html_url} title={title} className={linkClass}>
+ {chipContent(pr, label)}
+ </NestedChipLink>
+ ) : (
<a
key={pr.id}
href={pr.html_url}
@@ -147,21 +204,12 @@ export function IssuePullRequestChips({
rel="noreferrer noopener"
title={title}
data-testid="issue-pull-request-chip"
- className={cn(chipClass, "hover:bg-accent hover:text-foreground")}
+ className={linkClass}
onClick={(event) => event.stopPropagation()}
onAuxClick={(event) => event.stopPropagation()}
>
{chipContent(pr, label)}
</a>
- ) : (
- <span
- key={pr.id}
- title={title}
- data-testid="issue-pull-request-chip"
- className={chipClass}
- >
- {chipContent(pr, label)}
- </span>
);
})}
{hidden > 0 && (
diff --git a/packages/views/issues/components/pull-request-list.tsx b/packages/views/issues/components/pull-request-list.tsx
index 3718645f06..db2ff5f7bb 100644
--- a/packages/views/issues/components/pull-request-list.tsx
+++ b/packages/views/issues/components/pull-request-list.tsx
@@ -484,7 +484,9 @@ function PullRequestRow({
/**
* One PR on a single line — state icon, `#number`, verdict pill — for
* surfaces with no room for PullRequestRow, such as the issue hover card.
- * Not a link: the hover card that hosts it is read-only.
+ * A plain link to the PR on GitHub, like PullRequestRow, so the browser owns
+ * Enter, modifier and middle clicks. The hover card stops click bubbling, so
+ * opening the PR never also follows the mention it hangs off.
*/
export function PullRequestInlineSummary({ pr }: { pr: GitHubPullRequest }) {
const { t } = useT("issues");
@@ -494,11 +496,18 @@ export function PullRequestInlineSummary({ pr }: { pr: GitHubPullRequest }) {
const isTerminal = pr.state === "merged" || pr.state === "closed";
const stale = !isTerminal && pr.snapshot_stale === true;
return (
- <span className="flex min-w-0 items-center gap-1.5" title={pr.title}>
+ <a
+ data-testid="pull-request-inline-summary"
+ href={pr.html_url}
+ target="_blank"
+ rel="noreferrer noopener"
+ title={pr.title}
+ className="-mx-1 flex min-w-0 items-center gap-1.5 rounded-sm px-1 transition-colors hover:bg-accent/50 focus-visible:outline-2 focus-visible:outline-ring"
+ >
<StateIcon className={cn("size-3.5 shrink-0", cfg.className)} />
<span className="shrink-0 font-medium tabular-nums">{prLabel(pr)}</span>
{pill ? <VerdictPill pill={pill} stale={stale} inline /> : null}
- </span>
+ </a>
);
}
diff --git a/packages/views/issues/components/table-view.tsx b/packages/views/issues/components/table-view.tsx
index bada60ad50..cf65e5164c 100644
--- a/packages/views/issues/components/table-view.tsx
+++ b/packages/views/issues/components/table-view.tsx
@@ -1332,7 +1332,7 @@ function PullRequestsCell({ issueId }: { issueId: string }) {
const { t } = useT("issues");
const pullRequests = useIssuePullRequestSummaries(issueId, true);
return pullRequests.length > 0 ? (
- <IssuePullRequestChips pullRequests={pullRequests} max={3} linked />
+ <IssuePullRequestChips pullRequests={pullRequests} max={3} />
) : (
<span className="text-muted-foreground">{t(($) => $.table.empty_value)}</span>
);