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

@@ -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 } : {}),