TypeScript
fix(ui): simplify multiple linked pull request badges (#11104)
mariae784975bbec7
diff --git a/apps/mobile/src/features/threads/thread-list-v2-items.tsx b/apps/mobile/src/features/threads/thread-list-v2-items.tsxindex 834da0af9a6..67a917c0079 100644--- a/apps/mobile/src/features/threads/thread-list-v2-items.tsx+++ b/apps/mobile/src/features/threads/thread-list-v2-items.tsx@@ -871,16 +871,22 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {)}{pr ? (<View className="flex-row items-center gap-1" accessibilityLabel={pr.accessibilityLabel}>- {pr.kind === "stack" ? (+ {pr.kind === "stack" || pr.others > 0 ? (<SymbolView- name="square.3.layers.3d"+ name={pr.kind === "stack" ? "square.3.layers.3d" : "arrow.triangle.pull"}size={12}tintColorClassName={selected? materialYouStyleLayoutActive? "accent-thread-selected-foreground": "accent-user-bubble-foreground"- : "accent-foreground-muted"+ : pr.kind === "stack" || pr.isDraft || pr.state === null+ ? "accent-foreground-muted"+ : pr.state === "open"+ ? "accent-adaptive-emerald-600-400"+ : pr.state === "merged"+ ? "accent-adaptive-violet-600-400"+ : "accent-foreground-muted"}/>) : null}@@ -896,7 +902,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {)}style={{ fontFamily: MONO_FONT }}>- {pr.kind === "stack" ? pr.label : `#${pr.label}`}+ {pr.kind === "stack" || pr.others > 0 ? pr.label : `#${pr.label}`}</Text></View>) : null}diff --git a/apps/mobile/src/state/thread-pr-presentation.ts b/apps/mobile/src/state/thread-pr-presentation.tsindex dd21e2d70ec..48fe3abf5f6 100644--- a/apps/mobile/src/state/thread-pr-presentation.ts+++ b/apps/mobile/src/state/thread-pr-presentation.ts@@ -17,11 +17,12 @@ export interface ThreadPrPresentation {readonly number: number;readonly state: ThreadPr["state"] | null;readonly kind: "pull-request" | "stack";+ readonly others: number;readonly isDraft: boolean;/** Provider-side last activity, bounding when a terminal state landed. */readonly updatedAt: string | null;readonly url: string;- /** Compact pull request number label, e.g. "3774". */+ /** Compact pull request number or linked count, e.g. "3774" or "+2". */readonly label: string;/** Full, provider-aware label for assistive technologies. */readonly accessibilityLabel: string;@@ -42,6 +43,7 @@ export function presentThreadPr(const isDraft = pr.state === "open" && pr.isDraft === true;return {kind: "pull-request",+ others: 0,number: pr.number,state: pr.state,isDraft,@@ -66,9 +68,12 @@ export function presentThreadLinkedPullRequests(const label =badge.kind === "stack"? String(badge.layers)- : `${link.number}${badge.others > 0 ? ` +${badge.others}` : ""}`;+ : badge.others > 0+ ? `+${badge.others}`+ : String(link.number);return {kind: badge.kind,+ others: badge.kind === "pull-request" ? badge.others : 0,number: link.number,state,isDraft,diff --git a/apps/mobile/src/state/use-thread-pr.test.ts b/apps/mobile/src/state/use-thread-pr.test.tsindex 330e31cb017..5fdb90e19c6 100644--- a/apps/mobile/src/state/use-thread-pr.test.ts+++ b/apps/mobile/src/state/use-thread-pr.test.ts@@ -87,7 +87,7 @@ describe("presentThreadLinkedPullRequests", () => {it("counts unrelated links without labelling them a stack", () => {expect(presentThreadLinkedPullRequests([linkedPr(1), linkedPr(2)])).toMatchObject({kind: "pull-request",- label: "1 +1",+ label: "+1",});});diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsxindex 79573635212..72a119cb76b 100644--- a/apps/web/src/components/Sidebar.tsx+++ b/apps/web/src/components/Sidebar.tsx@@ -1485,7 +1485,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {</span>);- // Stacks show their layer count; unrelated links show the current PR and a remainder count.+ // Stacks show their layer count; unrelated links show only the remainder count.// Plain clicks open T3; individual PR links also support opening the host in a new tab.const prBadgeShape = supportsMultiplePullRequests? resolveThreadPullRequestBadge(thread.pullRequests)diff --git a/apps/web/src/components/ThreadStatusIndicators.tsx b/apps/web/src/components/ThreadStatusIndicators.tsxindex 6a73a805fb6..2d724a72650 100644--- a/apps/web/src/components/ThreadStatusIndicators.tsx+++ b/apps/web/src/components/ThreadStatusIndicators.tsx@@ -174,10 +174,11 @@ export function ThreadPullRequestBadgeControl({const content = (<><ThreadPullRequestBadgeIcon icon={badge?.kind ?? "pull-request"} />- {isStack ? badge.layers : number}- {badge?.kind === "pull-request" && badge.others > 0 ? (- <span className="opacity-70">+{badge.others}</span>- ) : null}+ {isStack+ ? badge.layers+ : badge?.kind === "pull-request" && badge.others > 0+ ? `+${badge.others}`+ : number}</>);return (