fix(web): render draft PRs in gray (#9537)

This commit is contained in:
Exotic authored and GitHub committed 2026-09-04 02:17:18 -04:00
1 parent 5cc369b7eb
commit caab2fdbac
30 files changed
+152 -36

No files matched your search

@@ -23,7 +23,7 @@ import { relativeTime } from "../../lib/time";
import { themeColorWithAlpha } from "../../lib/mobileTheme";
import { useUniwindTheme } from "../../lib/useUniwindTheme";
import type { PendingNewTask } from "../../state/use-pending-new-tasks";
import { useThreadPr, type ThreadPr } from "../../state/use-thread-pr";
import { useThreadPr, type ThreadPrPresentation } from "../../state/use-thread-pr";
import type { HomeGroupDisplayAction } from "../home/homeListItems";
import { ThreadSwipeable } from "../home/thread-swipe-actions";
import { buildThreadTitleRegenerationMenuItems } from "./thread-title-regeneration-menu";
@@ -42,9 +42,15 @@ export type ThreadListVariant = "compact" | "sidebar";
export const THREAD_LIST_COMPACT_INSET = HOME_HORIZONTAL_INSET;
const SIDEBAR_ROW_RADIUS = 12;
function pullRequestTintColor(state: ThreadPr["state"], colorScheme: "light" | "dark") {
function pullRequestTintColor(
pr: Pick<ThreadPrPresentation, "state" | "isDraft">,
colorScheme: "light" | "dark",
) {
const dark = colorScheme === "dark";
switch (state) {
if (pr.state === "open" && pr.isDraft === true) {
return dark ? "#a1a1aa" : "#71717a";
}
switch (pr.state) {
case "open":
return dark ? "#34d399" : "#059669";
case "merged":
@@ -548,9 +554,7 @@ export const ThreadListRow = memo(function ThreadListRow(props: {
<PullRequestIcon
size={compact ? 13 : 11}
color={
selected
? String(selectedForegroundColor)
: pullRequestTintColor(pr.state, colorScheme)
selected ? String(selectedForegroundColor) : pullRequestTintColor(pr, colorScheme)
}
/>
<Text
@@ -6,6 +6,7 @@ export type ThreadPr = NonNullable<VcsStatusResult["pr"]>;
export interface ThreadPrPresentation {
readonly number: number;
readonly state: ThreadPr["state"];
readonly isDraft: boolean;
/** Provider-side last activity, bounding when a terminal state landed. */
readonly updatedAt: string | null;
readonly url: string;
@@ -27,13 +28,15 @@ export function presentThreadPr(
provider: VcsStatusResult["sourceControlProvider"] | null | undefined,
): ThreadPrPresentation {
const presentation = resolveChangeRequestPresentation(provider);
const isDraft = pr.state === "open" && pr.isDraft === true;
return {
number: pr.number,
state: pr.state,
isDraft,
updatedAt: pr.updatedAt ?? null,
url: pr.url,
label: String(pr.number),
accessibilityLabel: `#${pr.number} ${presentation.longName} ${pr.state}`,
textClassName: PR_STATE_TEXT_CLASS[pr.state],
accessibilityLabel: `#${pr.number} ${presentation.longName} ${isDraft ? "draft" : pr.state}`,
textClassName: isDraft ? "text-adaptive-zinc-500-400" : PR_STATE_TEXT_CLASS[pr.state],
};
}
@@ -33,4 +33,13 @@ describe("presentThreadPr", () => {
accessibilityLabel: "#3774 merge request merged",
});
});
it("uses gray for draft pull requests", () => {
expect(
presentThreadPr({ ...pullRequest, state: "open", isDraft: true }, undefined),
).toMatchObject({
accessibilityLabel: "#3774 pull request draft",
textClassName: "text-adaptive-zinc-500-400",
});
});
});
+10 -5
View File
@@ -54,6 +54,7 @@ interface FakeGhScenario {
baseRefName: string;
headRefName: string;
state?: "open" | "closed" | "merged";
isDraft?: boolean;
isCrossRepository?: boolean;
headRepositoryNameWithOwner?: string | null;
headRepositoryOwnerLogin?: string | null;
@@ -116,6 +117,7 @@ function normalizeFakePullRequestSummary(raw: unknown): GitHubCli.GitHubPullRequ
? "closed"
: "merged"
: undefined;
const isDraft = typeof record.isDraft === "boolean" ? record.isDraft : undefined;
const isCrossRepository =
typeof record.isCrossRepository === "boolean" ? record.isCrossRepository : undefined;
const headRepositoryNameWithOwner =
@@ -138,6 +140,7 @@ function normalizeFakePullRequestSummary(raw: unknown): GitHubCli.GitHubPullRequ
baseRefName,
headRefName,
...(state ? { state } : {}),
...(isDraft === true ? { isDraft: true } : {}),
...(isCrossRepository !== undefined ? { isCrossRepository } : {}),
...(headRepositoryNameWithOwner ? { headRepositoryNameWithOwner } : {}),
...(headRepositoryOwnerLogin ? { headRepositoryOwnerLogin } : {}),
@@ -508,7 +511,7 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
"--limit",
String(input.limit ?? 1),
"--json",
"number,title,url,baseRefName,headRefName,state,mergedAt,isCrossRepository,headRepository,headRepositoryOwner",
"number,title,url,baseRefName,headRefName,state,isDraft,mergedAt,isCrossRepository,headRepository,headRepositoryOwner",
],
}).pipe(
Effect.map((result) => JSON.parse(result.stdout) as unknown[]),
@@ -552,7 +555,7 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
"view",
input.reference,
"--json",
"number,title,url,baseRefName,headRefName,state,mergedAt,isCrossRepository,headRepository,headRepositoryOwner",
"number,title,url,baseRefName,headRefName,state,isDraft,mergedAt,isCrossRepository,headRepository,headRepositoryOwner",
],
}).pipe(
Effect.map((result) => JSON.parse(result.stdout) as GitHubCli.GitHubPullRequestSummary),
@@ -699,7 +702,7 @@ const GitManagerTestLayer = GitVcsDriver.layer.pipe(
);
it.layer(GitManagerTestLayer)("GitManager", (it) => {
it.effect("status includes PR metadata when branch already has an open PR", () =>
it.effect("status includes draft PR metadata when branch already has a draft PR", () =>
Effect.gen(function* () {
const repoDir = yield* makeTempDir("t3code-git-manager-");
yield* initRepo(repoDir);
@@ -719,6 +722,7 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
url: "https://github.com/pingdotgg/codething-mvp/pull/13",
baseRefName: "main",
headRefName: "feature/status-open-pr",
isDraft: true,
},
]),
],
@@ -737,6 +741,7 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
baseRef: "main",
headRef: "feature/status-open-pr",
state: "open",
isDraft: true,
updatedAt: null,
});
}),
@@ -1686,7 +1691,7 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
updatedAt: "2026-03-10T07:00:00.000Z",
});
expect(ghCalls).toContain(
"pr list --head jasonLaster:statemachine --state all --limit 20 --json number,title,url,baseRefName,headRefName,state,mergedAt,updatedAt,isCrossRepository,headRepository,headRepositoryOwner",
"pr list --head jasonLaster:statemachine --state all --limit 20 --json number,title,url,baseRefName,headRefName,state,isDraft,mergedAt,updatedAt,isCrossRepository,headRepository,headRepositoryOwner",
);
}),
20_000,
@@ -1752,7 +1757,7 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
updatedAt: "2026-03-10T07:00:00.000Z",
});
expect(ghCalls).toContain(
"pr list --head contributor:main --state all --limit 20 --json number,title,url,baseRefName,headRefName,state,mergedAt,updatedAt,isCrossRepository,headRepository,headRepositoryOwner",
"pr list --head contributor:main --state all --limit 20 --json number,title,url,baseRefName,headRefName,state,isDraft,mergedAt,updatedAt,isCrossRepository,headRepository,headRepositoryOwner",
);
}),
20_000,
+5 -5
View File
@@ -170,6 +170,7 @@ interface OpenPrInfo {
interface PullRequestInfo extends OpenPrInfo, PullRequestHeadRemoteInfo {
state: "open" | "closed" | "merged";
isDraft?: boolean;
updatedAt: Option.Option<DateTime.Utc>;
}
@@ -404,6 +405,7 @@ function toPullRequestInfo(summary: ChangeRequest): PullRequestInfo {
baseRefName: summary.baseRefName,
headRefName: summary.headRefName,
state: summary.state ?? "open",
...(summary.isDraft === true ? { isDraft: true } : {}),
updatedAt: summary.updatedAt,
...(summary.isCrossRepository !== undefined
? { isCrossRepository: summary.isCrossRepository }
@@ -558,6 +560,7 @@ function toStatusPr(pr: PullRequestInfo): {
baseRef: string;
headRef: string;
state: "open" | "closed" | "merged";
isDraft?: boolean;
updatedAt: string | null;
} {
return {
@@ -567,6 +570,7 @@ function toStatusPr(pr: PullRequestInfo): {
baseRef: pr.baseRefName,
headRef: pr.headRefName,
state: pr.state,
...(pr.isDraft === true ? { isDraft: true } : {}),
updatedAt: Option.match(pr.updatedAt, {
onNone: () => null,
onSome: (updatedAt) => DateTime.formatIso(updatedAt),
@@ -1518,11 +1522,7 @@ export const make = Effect.gen(function* () {
);
if (firstPullRequest) {
return {
number: firstPullRequest.number,
title: firstPullRequest.title,
url: firstPullRequest.url,
baseRefName: firstPullRequest.baseRefName,
headRefName: firstPullRequest.headRefName,
...firstPullRequest,
state: "open",
updatedAt: Option.none(),
} satisfies PullRequestInfo;
@@ -468,6 +468,7 @@ export class GitHubPullRequestCli extends Context.Service<
readonly headBranch: string;
readonly baseBranch: string;
readonly state: "open" | "closed" | "merged";
readonly isDraft?: boolean;
readonly updatedAt: string;
},
GitHubPullRequestCliError
@@ -1650,6 +1651,7 @@ export const make = Effect.gen(function* () {
headBranch: summary.headRefName,
baseBranch: summary.baseRefName,
state: summary.state ?? "open",
...(summary.isDraft === true ? { isDraft: true } : {}),
updatedAt: summary.updatedAt,
}),
),
@@ -96,6 +96,8 @@ export interface ProviderChangeRequestSummary {
readonly headBranch: string;
readonly baseBranch: string;
readonly state: PullRequestState;
/** Present when the host says an open pull request is still a draft. */
readonly isDraft?: boolean;
readonly updatedAt: string;
}
@@ -1254,6 +1254,7 @@ export const make = Effect.gen(function* () {
title: changeRequest.title,
url: changeRequest.url,
state: changeRequest.state,
...(changeRequest.isDraft === true ? { isDraft: true } : {}),
headBranch: changeRequest.headBranch,
baseBranch: changeRequest.baseBranch,
updatedAt: changeRequest.updatedAt,
@@ -2278,6 +2279,7 @@ export const make = Effect.gen(function* () {
title: detail.title,
url: detail.url,
state: detail.state,
...(detail.isDraft === true ? { isDraft: true } : {}),
headBranch: detail.headBranch,
baseBranch: detail.baseBranch,
updatedAt: detail.updatedAt,
@@ -61,6 +61,7 @@ function toChangeRequest(summary: {
readonly baseRefName: string;
readonly headRefName: string;
readonly state: "open" | "closed" | "merged";
readonly isDraft?: boolean;
readonly updatedAt: ChangeRequest["updatedAt"];
}): ChangeRequest {
return {
@@ -71,6 +72,7 @@ function toChangeRequest(summary: {
baseRefName: summary.baseRefName,
headRefName: summary.headRefName,
state: summary.state,
...(summary.isDraft === true ? { isDraft: true } : {}),
updatedAt: summary.updatedAt,
isCrossRepository: false,
};
@@ -17,6 +17,7 @@ function toChangeRequest(summary: NormalizedBitbucketPullRequestRecord): ChangeR
baseRefName: summary.baseRefName,
headRefName: summary.headRefName,
state: summary.state,
...(summary.isDraft === true ? { isDraft: true } : {}),
updatedAt: summary.updatedAt ?? Option.none(),
...(summary.isCrossRepository !== undefined
? { isCrossRepository: summary.isCrossRepository }
@@ -65,6 +65,7 @@ describe("GitHubCli.layer", () => {
baseRefName: "main",
headRefName: "feature/pr-threads",
state: "OPEN",
isDraft: true,
mergedAt: null,
updatedAt: "2026-08-24T12:34:56Z",
isCrossRepository: true,
@@ -92,6 +93,7 @@ describe("GitHubCli.layer", () => {
baseRefName: "main",
headRefName: "feature/pr-threads",
state: "open",
isDraft: true,
updatedAt: "2026-08-24T12:34:56.000Z",
isCrossRepository: true,
headRepositoryNameWithOwner: "octocat/codething-mvp",
@@ -105,7 +107,7 @@ describe("GitHubCli.layer", () => {
"view",
"#42",
"--json",
"number,title,url,baseRefName,headRefName,state,mergedAt,updatedAt,isCrossRepository,headRepository,headRepositoryOwner",
"number,title,url,baseRefName,headRefName,state,isDraft,mergedAt,updatedAt,isCrossRepository,headRepository,headRepositoryOwner",
],
cwd: "/repo",
timeoutMs: 30_000,
+3 -2
View File
@@ -205,6 +205,7 @@ export interface GitHubPullRequestSummary {
readonly baseRefName: string;
readonly headRefName: string;
readonly state?: "open" | "closed" | "merged";
readonly isDraft?: boolean;
readonly updatedAt?: string;
readonly isCrossRepository?: boolean;
readonly headRepositoryNameWithOwner?: string | null;
@@ -366,7 +367,7 @@ export const make = Effect.gen(function* () {
"--limit",
String(input.limit ?? 1),
"--json",
"number,title,url,baseRefName,headRefName,state,mergedAt,isCrossRepository,headRepository,headRepositoryOwner",
"number,title,url,baseRefName,headRefName,state,isDraft,mergedAt,isCrossRepository,headRepository,headRepositoryOwner",
],
}).pipe(
Effect.map((result) => result.stdout.trim()),
@@ -398,7 +399,7 @@ export const make = Effect.gen(function* () {
"view",
input.reference,
"--json",
"number,title,url,baseRefName,headRefName,state,mergedAt,updatedAt,isCrossRepository,headRepository,headRepositoryOwner",
"number,title,url,baseRefName,headRefName,state,isDraft,mergedAt,updatedAt,isCrossRepository,headRepository,headRepositoryOwner",
],
}).pipe(
Effect.map((result) => result.stdout.trim()),
@@ -150,7 +150,7 @@ it.effect("uses gh json listing for non-open change request state queries", () =
"--limit",
"10",
"--json",
"number,title,url,baseRefName,headRefName,state,mergedAt,updatedAt,isCrossRepository,headRepository,headRepositoryOwner",
"number,title,url,baseRefName,headRefName,state,isDraft,mergedAt,updatedAt,isCrossRepository,headRepository,headRepositoryOwner",
]);
assert.strictEqual(changeRequests[0]?.provider, "github");
assert.strictEqual(changeRequests[0]?.state, "merged");
@@ -30,6 +30,7 @@ function toChangeRequest(summary: GitHubCli.GitHubPullRequestSummary): ChangeReq
baseRefName: summary.baseRefName,
headRefName: summary.headRefName,
state: summary.state ?? "open",
...(summary.isDraft === true ? { isDraft: true } : {}),
updatedAt:
summary.updatedAt === undefined
? Option.none()
@@ -153,7 +154,7 @@ export const make = Effect.gen(function* () {
"--limit",
String(input.limit ?? 20),
"--json",
"number,title,url,baseRefName,headRefName,state,mergedAt,updatedAt,isCrossRepository,headRepository,headRepositoryOwner",
"number,title,url,baseRefName,headRefName,state,isDraft,mergedAt,updatedAt,isCrossRepository,headRepository,headRepositoryOwner",
],
})
.pipe(
@@ -246,6 +246,7 @@ export interface GitLabMergeRequestSummary {
readonly baseRefName: string;
readonly headRefName: string;
readonly state?: "open" | "closed" | "merged";
readonly isDraft?: boolean;
readonly updatedAt?: Option.Option<DateTime.Utc>;
readonly isCrossRepository?: boolean;
readonly headRepositoryNameWithOwner?: string | null;
@@ -26,6 +26,7 @@ function toChangeRequest(summary: GitLabCli.GitLabMergeRequestSummary): ChangeRe
baseRefName: summary.baseRefName,
headRefName: summary.headRefName,
state: summary.state ?? "open",
...(summary.isDraft === true ? { isDraft: true } : {}),
updatedAt: summary.updatedAt ?? Option.none(),
...(summary.isCrossRepository !== undefined
? { isCrossRepository: summary.isCrossRepository }
@@ -14,6 +14,7 @@ export interface NormalizedAzureDevOpsPullRequestRecord {
readonly baseRefName: string;
readonly headRefName: string;
readonly state: "open" | "closed" | "merged";
readonly isDraft?: boolean;
readonly updatedAt: Option.Option<DateTime.Utc>;
}
@@ -35,6 +36,7 @@ const AzureDevOpsPullRequestSchema = Schema.Struct({
sourceRefName: TrimmedNonEmptyString,
targetRefName: TrimmedNonEmptyString,
status: Schema.String,
isDraft: Schema.optional(Schema.Boolean),
creationDate: Schema.optional(Schema.OptionFromNullOr(Schema.DateTimeUtcFromString)),
closedDate: Schema.optional(Schema.OptionFromNullOr(Schema.DateTimeUtcFromString)),
_links: Schema.optional(
@@ -168,6 +170,7 @@ function normalizeAzureDevOpsPullRequestRecord(
baseRefName: normalizeRefName(raw.targetRefName),
headRefName: normalizeRefName(raw.sourceRefName),
state: normalizeAzureDevOpsPullRequestState(raw.status),
...(raw.isDraft === true ? { isDraft: true } : {}),
updatedAt: (raw.closedDate ?? Option.none()).pipe(
Option.orElse(() => raw.creationDate ?? Option.none()),
),
@@ -10,6 +10,7 @@ export interface NormalizedBitbucketPullRequestRecord {
readonly baseRefName: string;
readonly headRefName: string;
readonly state: "open" | "closed" | "merged";
readonly isDraft?: boolean;
readonly updatedAt: Option.Option<DateTime.Utc>;
readonly isCrossRepository?: boolean;
readonly headRepositoryNameWithOwner?: string | null;
@@ -38,6 +39,7 @@ export const BitbucketPullRequestSchema = Schema.Struct({
id: PositiveInt,
title: TrimmedNonEmptyString,
state: Schema.optional(Schema.NullOr(Schema.String)),
draft: Schema.optional(Schema.Boolean),
updated_on: Schema.optional(Schema.OptionFromNullOr(Schema.DateTimeUtcFromString)),
links: Schema.Struct({
html: Schema.Struct({
@@ -98,6 +100,7 @@ export function normalizeBitbucketPullRequestRecord(
baseRefName: raw.destination.branch.name,
headRefName: raw.source.branch.name,
state: normalizeBitbucketPullRequestState(raw.state),
...(raw.draft === true ? { isDraft: true } : {}),
updatedAt: raw.updated_on ?? Option.none(),
...(isCrossRepository ? { isCrossRepository: true } : {}),
...(headRepositoryNameWithOwner ? { headRepositoryNameWithOwner } : {}),
@@ -14,6 +14,7 @@ export interface NormalizedGitHubPullRequestRecord {
readonly baseRefName: string;
readonly headRefName: string;
readonly state: "open" | "closed" | "merged";
readonly isDraft?: boolean;
readonly updatedAt: Option.Option<DateTime.Utc>;
readonly isCrossRepository?: boolean;
readonly headRepositoryNameWithOwner?: string | null;
@@ -27,6 +28,7 @@ const GitHubPullRequestSchema = Schema.Struct({
baseRefName: TrimmedNonEmptyString,
headRefName: TrimmedNonEmptyString,
state: Schema.optional(Schema.NullOr(Schema.String)),
isDraft: Schema.optional(Schema.Boolean),
mergedAt: Schema.optional(Schema.NullOr(Schema.String)),
updatedAt: Schema.optional(Schema.OptionFromNullOr(Schema.DateTimeUtcFromString)),
isCrossRepository: Schema.optional(Schema.Boolean),
@@ -93,6 +95,7 @@ function normalizeGitHubPullRequestRecord(
baseRefName: raw.baseRefName,
headRefName: raw.headRefName,
state: normalizeGitHubPullRequestState(raw),
...(raw.isDraft === true ? { isDraft: true } : {}),
updatedAt: raw.updatedAt ?? Option.none(),
...(typeof raw.isCrossRepository === "boolean"
? { isCrossRepository: raw.isCrossRepository }
@@ -14,6 +14,7 @@ export interface NormalizedGitLabMergeRequestRecord {
readonly baseRefName: string;
readonly headRefName: string;
readonly state: "open" | "closed" | "merged";
readonly isDraft?: boolean;
readonly updatedAt: Option.Option<DateTime.Utc>;
readonly isCrossRepository?: boolean;
readonly headRepositoryNameWithOwner?: string | null;
@@ -41,6 +42,8 @@ const GitLabMergeRequestSchema = Schema.Struct({
source_branch: TrimmedNonEmptyString,
target_branch: TrimmedNonEmptyString,
state: Schema.optional(Schema.NullOr(Schema.String)),
draft: Schema.optional(Schema.Boolean),
work_in_progress: Schema.optional(Schema.Boolean),
updated_at: Schema.optional(Schema.OptionFromNullOr(Schema.DateTimeUtcFromString)),
source_project_id: Schema.optional(Schema.NullOr(Schema.Number)),
target_project_id: Schema.optional(Schema.NullOr(Schema.Number)),
@@ -108,6 +111,7 @@ function normalizeGitLabMergeRequestRecord(
baseRefName: raw.target_branch,
headRefName: raw.source_branch,
state: normalizeGitLabMergeRequestState(raw.state),
...(raw.draft === true || raw.work_in_progress === true ? { isDraft: true } : {}),
updatedAt: raw.updated_at ?? Option.none(),
...(typeof isCrossRepository === "boolean" ? { isCrossRepository } : {}),
...(sourceProjectPath ? { headRepositoryNameWithOwner: sourceProjectPath } : {}),
+1 -1
View File
@@ -954,7 +954,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
linkedPullRequestStatus,
});
const prStatus = prStatusIndicator(pr, prProvider);
const settledPrHoverClass = pr ? settledPrHoverColorClass(pr.state) : undefined;
const settledPrHoverClass = pr ? settledPrHoverColorClass(pr.state, pr.isDraft) : undefined;
useEffect(() => {
const nextSnapshot = nextThreadChangeRequestSnapshot({
threadBranch: thread.branch,
@@ -10,6 +10,7 @@ import {
resolveDisplayedThreadPrProvider,
resolveThreadPr,
settledPrHoverColorClass,
threadChangeRequestSnapshotsEqual,
threadChangeRequestSnapshotsAtom,
type ThreadChangeRequestSnapshot,
} from "./ThreadStatusIndicators";
@@ -559,6 +560,18 @@ describe("resolveDisplayedThreadPr + nextThreadChangeRequestSnapshot", () => {
});
expect(displayed?.state).toBe("merged");
});
it("refreshes a cached snapshot when a pull request becomes ready", () => {
const readyPr = { ...mergedPr, state: "open" as const };
const draftPr = { ...readyPr, isDraft: true };
expect(
threadChangeRequestSnapshotsEqual(
snapshotFor(featureBranch, draftPr),
snapshotFor(featureBranch, readyPr),
),
).toBe(false);
});
});
describe("threadChangeRequestSnapshotsAtom", () => {
@@ -600,6 +613,17 @@ describe("prStatusIndicator", () => {
"text-red-600",
);
});
it("uses gray and draft wording for draft pull requests", () => {
const draftPr = status().pr;
if (!draftPr) throw new Error("Expected pull request fixture");
expect(prStatusIndicator({ ...draftPr, isDraft: true }, undefined)).toMatchObject({
label: "PR draft",
colorClass: "text-zinc-500 dark:text-zinc-400/80",
tooltipLead: "PR #42 - Draft",
});
});
});
describe("settledPrHoverColorClass", () => {
@@ -610,4 +634,8 @@ describe("settledPrHoverColorClass", () => {
] as const)("restores the %s pull request color on row hover", (state, colorClass) => {
expect(settledPrHoverColorClass(state)).toContain(`group-hover/v2-row:${colorClass}`);
});
it("keeps draft pull requests gray on row hover", () => {
expect(settledPrHoverColorClass("open", true)).toContain("group-hover/v2-row:text-zinc-500");
});
});
@@ -84,9 +84,15 @@ export function useLinkedThreadPullRequest(
);
}
export function settledPrHoverColorClass(state: NonNullable<ThreadPr>["state"]): string {
export function settledPrHoverColorClass(
state: NonNullable<ThreadPr>["state"],
isDraft = false,
): string {
switch (state) {
case "open":
if (isDraft) {
return "group-hover/v2-row:text-zinc-500 dark:group-hover/v2-row:text-zinc-400/80";
}
return "group-hover/v2-row:text-emerald-600 dark:group-hover/v2-row:text-emerald-300/90";
case "merged":
return "group-hover/v2-row:text-violet-600 dark:group-hover/v2-row:text-violet-300/90";
@@ -99,12 +105,13 @@ export function prStatusIndicator(
pr: ThreadPr,
provider: VcsStatusResult["sourceControlProvider"] | null | undefined,
): PrStatusIndicator | null {
function formatPrState(state: NonNullable<ThreadPr>["state"]): string {
return state.charAt(0).toUpperCase() + state.slice(1);
function formatPrState(pr: NonNullable<ThreadPr>): string {
if (pr.state === "open" && pr.isDraft === true) return "Draft";
return pr.state.charAt(0).toUpperCase() + pr.state.slice(1);
}
function formatPrStatusLead(pr: NonNullable<ThreadPr>, changeRequestShortName: string): string {
return `${changeRequestShortName} #${pr.number} - ${formatPrState(pr.state)}`;
return `${changeRequestShortName} #${pr.number} - ${formatPrState(pr)}`;
}
if (!pr) return null;
const presentation = resolveChangeRequestPresentation(provider);
@@ -113,9 +120,12 @@ export function prStatusIndicator(
const tooltip = `${tooltipLead}: ${pr.title}`;
if (pr.state === "open") {
const isDraft = pr.isDraft === true;
return {
label: `${presentation.shortName} open`,
colorClass: "text-emerald-600 dark:text-emerald-300/90",
label: `${presentation.shortName} ${isDraft ? "draft" : "open"}`,
colorClass: isDraft
? "text-zinc-500 dark:text-zinc-400/80"
: "text-emerald-600 dark:text-emerald-300/90",
tooltip,
tooltipLead,
tooltipTitle: pr.title,
@@ -230,6 +240,7 @@ export function threadChangeRequestSnapshotsEqual(
left.pr.baseRef === right.pr.baseRef &&
left.pr.headRef === right.pr.headRef &&
left.pr.state === right.pr.state &&
left.pr.isDraft === right.pr.isDraft &&
(left.pr.updatedAt ?? null) === (right.pr.updatedAt ?? null) &&
sourceControlProvidersEqual(left.sourceControlProvider, right.sourceControlProvider) &&
linkedPullRequestsEqual(left.linkedPullRequest, right.linkedPullRequest)
@@ -625,7 +625,13 @@ export function PullRequestDetailPanel({
() =>
resolvedCoreDetail === null || sharedSummary === null || sharedSummary === resolvedCoreDetail
? resolvedCoreDetail
: { ...resolvedCoreDetail, ...sharedSummary },
: {
...resolvedCoreDetail,
...sharedSummary,
// A summary may come from an older server that does not report draft state. Keep the
// detail's required value instead of making the complete detail shape partial.
isDraft: sharedSummary.isDraft ?? resolvedCoreDetail.isDraft,
},
[resolvedCoreDetail, sharedSummary],
);
const activity = activityQuery.data;
@@ -1297,7 +1303,7 @@ export function PullRequestDetailPanel({
!conflicting &&
allowedMergeMethods.length > 1;
// The pull request number carries this state in the overview and the right-panel tab mirrors
// it. The conflict action is separate from this state: an open pull request remains green.
// it. Conflicts take the action slot while they need a person, but do not change the PR state.
const statePresentation = detail
? resolvePullRequestState({ state: detail.state, isDraft: detail.isDraft })
: null;
@@ -33,9 +33,9 @@ interface StatePresentation {
}
/**
* How a pull request's state reads on this page. Open, closed and merged use the same ink as
* the thread badge in `ThreadStatusIndicators`, so one pull request cannot look like two
* different things in two places; draft and conflicts are states that badge never shows.
* How a pull request's state reads on this page. Open, closed, merged, and draft use the same
* ink as the thread badge in `ThreadStatusIndicators`, so one pull request cannot look like two
* different things in two places.
*
* Draft outranks conflicts: a draft is not heading for a merge yet, so conflicts only surface
* once it is real work.
@@ -69,6 +69,7 @@ export function pullRequestDetailToVcsStatus(
baseRef: detail.baseBranch,
headRef: detail.headBranch,
state: detail.state,
...(detail.isDraft === true ? { isDraft: true } : {}),
updatedAt: detail.updatedAt,
};
}
+2
View File
@@ -198,6 +198,8 @@ const VcsStatusChangeRequest = Schema.Struct({
baseRef: TrimmedNonEmptyStringSchema,
headRef: TrimmedNonEmptyStringSchema,
state: VcsStatusChangeRequestState,
/** Optional for compatibility with older servers and providers. */
isDraft: Schema.optional(Schema.Boolean),
/**
* Last provider-side activity (ISO). For a merged/closed change request
* this bounds when it reached that state, so clients can tell a PR that
+2
View File
@@ -634,6 +634,8 @@ export const PullRequestSummary = Schema.Struct({
title: TrimmedNonEmptyString,
url: TrimmedNonEmptyString,
state: PullRequestState,
/** Present when the host says the open pull request is still a draft. */
isDraft: Schema.optional(Schema.Boolean),
headBranch: TrimmedNonEmptyString,
baseBranch: TrimmedNonEmptyString,
updatedAt: IsoDateTime,
+2
View File
@@ -29,6 +29,8 @@ export const ChangeRequest = Schema.Struct({
baseRefName: TrimmedNonEmptyString,
headRefName: TrimmedNonEmptyString,
state: ChangeRequestState,
/** Present when the provider can tell that an open change request is still a draft. */
isDraft: Schema.optional(Schema.Boolean),
updatedAt: Schema.Option(Schema.DateTimeUtc),
isCrossRepository: Schema.optional(Schema.Boolean),
headRepositoryNameWithOwner: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
+16 -1
View File
@@ -2863,7 +2863,7 @@ export const packWindowsServerAsar = Effect.fn("packWindowsServerAsar")(function
readonly arch: typeof BuildArch.Type;
}) {
const fs = yield* FileSystem.FileSystem;
yield* Effect.tryPromise({
const archiveStream = yield* Effect.tryPromise({
try: () =>
createPackageWithOptions(input.sourceDir, input.asarPath, {
dot: true,
@@ -2872,6 +2872,21 @@ export const packWindowsServerAsar = Effect.fn("packWindowsServerAsar")(function
}),
catch: (cause) => new WindowsServerSidecarPackError({ asarPath: input.asarPath, cause }),
});
yield* Effect.tryPromise({
try: () =>
new Promise<void>((resolve, reject) => {
const stream = archiveStream as NodeJS.WritableStream & {
readonly writableFinished?: boolean;
};
if (stream.writableFinished === true) {
resolve();
return;
}
stream.once("finish", resolve);
stream.once("error", reject);
}),
catch: (cause) => new WindowsServerSidecarPackError({ asarPath: input.asarPath, cause }),
});
const unpackedDirPath = `${input.asarPath}.unpacked`;
if (!(yield* fs.exists(unpackedDirPath))) {
return yield* new WindowsServerSidecarPackError({