fix: quiet settled threads and simplify PR badges (#11101)
This commit is contained in:
1 parent
0882431e0f
commit
0527ddf06d
6 files changed
+26
-23
No files matched your search
@@ -44,11 +44,11 @@ export const THREAD_LIST_COMPACT_INSET = HOME_HORIZONTAL_INSET;
|
||||
const SIDEBAR_ROW_RADIUS = 12;
|
||||
|
||||
function pullRequestTintColor(
|
||||
pr: Pick<ThreadPrPresentation, "state" | "isDraft">,
|
||||
pr: Pick<ThreadPrPresentation, "state" | "isDraft" | "others">,
|
||||
colorScheme: "light" | "dark",
|
||||
) {
|
||||
const dark = colorScheme === "dark";
|
||||
if (pr.state === "open" && pr.isDraft === true) {
|
||||
if (pr.others > 0 || (pr.state === "open" && pr.isDraft === true)) {
|
||||
return dark ? "#a1a1aa" : "#71717a";
|
||||
}
|
||||
switch (pr.state) {
|
||||
|
||||
@@ -880,13 +880,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
|
||||
? materialYouStyleLayoutActive
|
||||
? "accent-thread-selected-foreground"
|
||||
: "accent-user-bubble-foreground"
|
||||
: 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"
|
||||
: "accent-foreground-muted"
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
@@ -65,11 +65,12 @@ export function presentThreadLinkedPullRequests(
|
||||
const snapshot = link.snapshot;
|
||||
const state = badge.kind === "stack" ? badge.state : (snapshot?.state ?? null);
|
||||
const isDraft = snapshot?.isDraft === true && state === "open";
|
||||
const linkedCount = badge.kind === "pull-request" && badge.others > 0 ? badge.others + 1 : null;
|
||||
const label =
|
||||
badge.kind === "stack"
|
||||
? String(badge.layers)
|
||||
: badge.others > 0
|
||||
? `+${badge.others}`
|
||||
: linkedCount !== null
|
||||
? `+${linkedCount}`
|
||||
: String(link.number);
|
||||
return {
|
||||
kind: badge.kind,
|
||||
@@ -84,7 +85,10 @@ export function presentThreadLinkedPullRequests(
|
||||
badge.kind === "stack"
|
||||
? `${badge.layers} pull requests in stack, ${state ?? "status pending"}`
|
||||
: `#${link.number} pull request ${state === null ? "status pending" : isDraft ? "draft" : state}${badge.others > 0 ? `, ${badge.others} more linked` : ""}`,
|
||||
textClassName: state === null || isDraft ? "text-foreground-muted" : PR_STATE_TEXT_CLASS[state],
|
||||
textClassName:
|
||||
linkedCount !== null || state === null || isDraft
|
||||
? "text-foreground-muted"
|
||||
: PR_STATE_TEXT_CLASS[state],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,9 @@ describe("presentThreadLinkedPullRequests", () => {
|
||||
it("counts unrelated links without labelling them a stack", () => {
|
||||
expect(presentThreadLinkedPullRequests([linkedPr(1), linkedPr(2)])).toMatchObject({
|
||||
kind: "pull-request",
|
||||
label: "+1",
|
||||
label: "+2",
|
||||
others: 1,
|
||||
textClassName: "text-foreground-muted",
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1387,6 +1387,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
|
||||
// content; surface is reserved for interaction (hover, multi-select, route).
|
||||
const rowSurfaceClassName = cn(
|
||||
"group/sidebar-row relative w-full cursor-pointer overflow-hidden rounded-md text-left outline-none select-none",
|
||||
variantAction === "unsettle" && "[&:not(:hover):not(:focus-within)_*]:text-secondary-label/70",
|
||||
props.isActive
|
||||
? "bg-sidebar-row-active text-sidebar-foreground"
|
||||
: isSelected
|
||||
@@ -1469,7 +1470,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
|
||||
: "text-foreground/90",
|
||||
)
|
||||
: cn(
|
||||
"truncate group-hover/sidebar-row:text-foreground",
|
||||
"truncate group-focus-within/sidebar-row:text-foreground group-hover/sidebar-row:text-foreground",
|
||||
shouldRecede
|
||||
? "text-secondary-label/70"
|
||||
: props.isActive || isWoke
|
||||
@@ -1485,7 +1486,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
|
||||
</span>
|
||||
);
|
||||
|
||||
// Stacks show their layer count; unrelated links show only the remainder count.
|
||||
// Stacks show their layer count; multiple unrelated links show their total count.
|
||||
// Plain clicks open T3; individual PR links also support opening the host in a new tab.
|
||||
const prBadgeShape = supportsMultiplePullRequests
|
||||
? resolveThreadPullRequestBadge(thread.pullRequests)
|
||||
@@ -1597,8 +1598,8 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
|
||||
<span
|
||||
className={cn(
|
||||
"shrink-0 transition-opacity",
|
||||
!props.isActive &&
|
||||
"opacity-40 grayscale group-hover/sidebar-row:opacity-100 group-hover/sidebar-row:grayscale-0",
|
||||
(!props.isActive || variantAction === "unsettle") &&
|
||||
"opacity-40 grayscale group-focus-within/sidebar-row:opacity-100 group-focus-within/sidebar-row:grayscale-0 group-hover/sidebar-row:opacity-100 group-hover/sidebar-row:grayscale-0",
|
||||
)}
|
||||
>
|
||||
{props.project ? <ProjectFavicon project={props.project} className="size-4" /> : null}
|
||||
@@ -1617,6 +1618,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
|
||||
the time/jump label yields to the settle affordance. */}
|
||||
{prBadge}
|
||||
{prBadge &&
|
||||
variantAction !== "unsettle" &&
|
||||
pr &&
|
||||
(supportsMultiplePullRequests
|
||||
? visibleThreadPullRequests(thread.pullRequests).length === 0
|
||||
|
||||
@@ -154,6 +154,7 @@ export function ThreadPullRequestBadgeControl({
|
||||
onOpenPullRequest: (event: MouseEvent<HTMLAnchorElement>) => void;
|
||||
}) {
|
||||
const isStack = badge?.kind === "stack";
|
||||
const linkedCount = badge?.kind === "pull-request" && badge.others > 0 ? badge.others + 1 : null;
|
||||
if (!isStack && (number === undefined || url === undefined)) return null;
|
||||
const label = isStack
|
||||
? `Stack of ${badge.layers} pull requests, ${badge.state}`
|
||||
@@ -169,16 +170,16 @@ export function ThreadPullRequestBadgeControl({
|
||||
"text-xs tabular-nums",
|
||||
variant === "ghost" &&
|
||||
"font-normal text-xs! active:scale-100 [--control-icon-color:currentColor]",
|
||||
isStack ? PR_STATE_COLOR_CLASS[badge.state] : (status?.colorClass ?? "text-muted-foreground"),
|
||||
linkedCount !== null
|
||||
? "text-secondary-label"
|
||||
: isStack
|
||||
? PR_STATE_COLOR_CLASS[badge.state]
|
||||
: (status?.colorClass ?? "text-muted-foreground"),
|
||||
);
|
||||
const content = (
|
||||
<>
|
||||
<ThreadPullRequestBadgeIcon icon={badge?.kind ?? "pull-request"} />
|
||||
{isStack
|
||||
? badge.layers
|
||||
: badge?.kind === "pull-request" && badge.others > 0
|
||||
? `+${badge.others}`
|
||||
: number}
|
||||
{isStack ? badge.layers : linkedCount !== null ? `+${linkedCount}` : number}
|
||||
</>
|
||||
);
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user