Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(web): add draft icon for PR mentions (#8340)

Jacob Beckerman46e154a00bcc
diff --git a/apps/web/src/features/block-pr/component/PrStatus.tsx b/apps/web/src/features/block-pr/component/PrStatus.tsx
index f95df125dd..7480012f67 100644
--- a/apps/web/src/features/block-pr/component/PrStatus.tsx
+++ b/apps/web/src/features/block-pr/component/PrStatus.tsx
@@ -7,12 +7,14 @@ const STATUS_ICON_CLASS: Record<string, string> = {
open: 'text-success',
merged: 'text-note',
closed: 'text-failure',
+ draft: 'text-ink-muted',
};
const STATUS_TEXT_CLASS: Record<string, string> = {
open: 'text-success',
merged: 'text-note',
closed: 'text-failure',
+ draft: 'text-ink-muted',
};
function capitalize(value: string): string {
diff --git a/apps/web/src/features/block-pr/side-panel/github-pull-request.tsx b/apps/web/src/features/block-pr/side-panel/github-pull-request.tsx
index 992451fda7..9779cde943 100644
--- a/apps/web/src/features/block-pr/side-panel/github-pull-request.tsx
+++ b/apps/web/src/features/block-pr/side-panel/github-pull-request.tsx
@@ -22,12 +22,14 @@ const STATUS_ICON_CLASS: Record<string, string> = {
open: 'text-success',
merged: 'text-note',
closed: 'text-failure',
+ draft: 'text-ink-muted',
};
const STATUS_TEXT_CLASS: Record<string, string> = {
open: 'text-success',
merged: 'text-note',
closed: 'text-failure',
+ draft: 'text-ink-muted',
};
const PR_PILL_CLASS =
diff --git a/apps/web/src/features/entity/tests/entity-icon.test.tsx b/apps/web/src/features/entity/tests/entity-icon.test.tsx
index 239b4a3fc8..06b04e9b2c 100644
--- a/apps/web/src/features/entity/tests/entity-icon.test.tsx
+++ b/apps/web/src/features/entity/tests/entity-icon.test.tsx
@@ -69,7 +69,8 @@ const foreignBase = {
} as const;
function pullRequest(
- status: GithubPullRequestEntity['metadata']['status']
+ status: GithubPullRequestEntity['metadata']['status'],
+ draft = false
): GithubPullRequestEntity {
return {
...foreignBase,
@@ -81,6 +82,7 @@ function pullRequest(
repo: 'macro',
url: 'https://github.com/macro-inc/macro/pull/42',
status,
+ draft,
additions: 1,
deletions: 1,
comments: [],
@@ -238,6 +240,16 @@ describe('Entity.Icon', () => {
expect(container.firstElementChild?.classList.contains(color)).toBe(true);
});
+ it('renders draft pull request with muted color', () => {
+ const { container } = render(() => (
+ <EntityIcon entity={pullRequest('open', true)} />
+ ));
+ expectGlyph(container, GitPullRequestIcon);
+ expect(
+ container.firstElementChild?.classList.contains('text-ink-muted')
+ ).toBe(true);
+ });
+
it('uses a generic file for unknown foreign sources even with PR-like metadata', () => {
const entity: UnknownForeignEntity = {
...foreignBase,
diff --git a/apps/web/src/features/next-soup/soup-view/views/inbox/inbox-card-layouts.tsx b/apps/web/src/features/next-soup/soup-view/views/inbox/inbox-card-layouts.tsx
index b2af2ed5c0..26818d828c 100644
--- a/apps/web/src/features/next-soup/soup-view/views/inbox/inbox-card-layouts.tsx
+++ b/apps/web/src/features/next-soup/soup-view/views/inbox/inbox-card-layouts.tsx
@@ -296,10 +296,12 @@ function ActionBubble(props: { tag: NotificationTag }) {
);
}
-function GithubStatusIcon(props: { status?: string }) {
+function GithubStatusIcon(props: { status?: string; draft?: boolean }) {
+ const isDraft = () => props.draft === true && props.status === 'open';
const statusClass = () => {
if (props.status === 'merged') return 'text-note';
if (props.status === 'closed') return 'text-failure';
+ if (isDraft()) return 'text-ink-muted';
if (props.status === 'open') return 'text-success';
return undefined;
};
@@ -1304,6 +1306,11 @@ export function GithubCardLayout(props: InboxCardLayoutProps) {
return props.item.entity.metadata.status;
});
+ const isDraft = createMemo(() => {
+ if (!isGithubPrEntity(props.item.entity)) return false;
+ return props.item.entity.metadata.draft === true;
+ });
+
const text = createMemo(() => {
const entity = props.item.entity;
@@ -1360,7 +1367,7 @@ export function GithubCardLayout(props: InboxCardLayoutProps) {
/>
}
>
- <GithubStatusIcon status={status()} />
+ <GithubStatusIcon status={status()} draft={isDraft()} />
</Show>
}
title={text().title}
diff --git a/apps/web/src/lib/core/component/EntityIcon.tsx b/apps/web/src/lib/core/component/EntityIcon.tsx
index dece8fbb0c..c0e6b564ab 100644
--- a/apps/web/src/lib/core/component/EntityIcon.tsx
+++ b/apps/web/src/lib/core/component/EntityIcon.tsx
@@ -127,6 +127,7 @@ export type EntityWithValidIcon =
| 'githubPullRequestOpen'
| 'githubPullRequestMerged'
| 'githubPullRequestClosed'
+ | 'githubPullRequestDraft'
| 'archive'
| 'files'
| 'crm_company'
@@ -421,6 +422,13 @@ export const ENTITY_ICON_CONFIGS: Record<EntityWithValidIcon, IconConfig> = {
background: 'bg-failure/20',
prettyName: 'Closed Pull Request',
},
+ githubPullRequestDraft: {
+ icon: GitPullRequest,
+ boldIcon: GitPullRequestBold,
+ foreground: 'text-ink-muted',
+ background: 'bg-ink-muted/20',
+ prettyName: 'Draft Pull Request',
+ },
pr: {
icon: GitPullRequest,
boldIcon: GitPullRequestBold,
@@ -693,7 +701,10 @@ export function getEntityIconType(entity: EntityIconData): EntityWithValidIcon {
.with({ type: 'routine' }, () => 'routine')
.with({ type: 'foreign' }, (e) => {
if (e.foreignSource !== 'github_pull_request') return 'default';
- return match<unknown, EntityWithValidIcon>(e.metadata?.status)
+ const status = e.metadata?.status;
+ const isDraft = e.metadata?.draft === true;
+ if (isDraft && status === 'open') return 'githubPullRequestDraft';
+ return match<unknown, EntityWithValidIcon>(status)
.with('open', () => 'githubPullRequestOpen')
.with('merged', () => 'githubPullRequestMerged')
.with('closed', () => 'githubPullRequestClosed')
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MagicChip/MagicChipPullRequest.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MagicChip/MagicChipPullRequest.tsx
index f067812c65..f9898f1f55 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MagicChip/MagicChipPullRequest.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MagicChip/MagicChipPullRequest.tsx
@@ -61,6 +61,8 @@ export const MagicChipPullRequest: Component<{ url: string }> = (props) => {
const value = metadata()[key];
return typeof value === 'number' ? value : undefined;
};
+ const isDraft = () =>
+ metadata().draft === true && metadata().status === 'open';
const content = () => (
<>
<Show
@@ -70,8 +72,9 @@ export const MagicChipPullRequest: Component<{ url: string }> = (props) => {
aria-hidden="true"
class="size-3.5"
classList={{
- 'text-success': metadata().status === 'open',
+ 'text-success': metadata().status === 'open' && !isDraft(),
'text-failure': metadata().status === 'closed',
+ 'text-ink-muted': isDraft(),
}}
/>
}
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/PullRequestMention.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/PullRequestMention.tsx
index 4951a41b22..c084b86381 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/PullRequestMention.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/PullRequestMention.tsx
@@ -58,6 +58,7 @@ const STATUS_ICON_CLASS: Record<string, string> = {
open: 'text-success',
merged: 'text-note',
closed: 'text-failure',
+ draft: 'text-ink-muted',
};
function metadataRecord(metadata: unknown): Record<string, unknown> {
@@ -117,7 +118,11 @@ function pullRequestStatus(entity: ForeignEntity | undefined): string {
if (!entity || entity.foreignEntitySource !== GITHUB_PULL_REQUEST_SOURCE) {
return 'open';
}
- return optionalString(metadataRecord(entity.metadata).status) ?? 'open';
+ const metadata = metadataRecord(entity.metadata);
+ const status = optionalString(metadata.status) ?? 'open';
+ const isDraft = metadata.draft === true;
+ if (isDraft && status === 'open') return 'draft';
+ return status;
}
interface PullRequestParts {
@@ -187,6 +192,7 @@ const STATUS_PILL_CLASS: Record<string, string> = {
open: 'bg-success/15 text-success',
merged: 'bg-note/15 text-note',
closed: 'bg-failure/15 text-failure',
+ draft: 'bg-ink-muted/15 text-ink-muted',
};
interface ChecksSummary {
@@ -252,11 +258,15 @@ function pullRequestPreview(
? (metadata.checks as GithubPullRequestCheckRun[])
: undefined;
+ const rawStatus = optionalString(metadata.status) ?? 'open';
+ const isDraft = metadata.draft === true;
+ const status = isDraft && rawStatus === 'open' ? 'draft' : rawStatus;
+
return {
title: title ?? displayName ?? ref ?? fallbackLabel(label),
ref,
url: optionalString(metadata.url),
- status: optionalString(metadata.status) ?? 'open',
+ status,
additions: optionalNumber(metadata.additions),
deletions: optionalNumber(metadata.deletions),
commentCount: comments?.length || undefined,