Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
style(task): update style for github pr pill and add section to sidepanel (#3552)
Seamus289427a2ada7
diff --git a/js/app/packages/app/index.css b/js/app/packages/app/index.cssindex 2db5a297fe..062a5a6d80 100644--- a/js/app/packages/app/index.css+++ b/js/app/packages/app/index.css@@ -288,6 +288,10 @@cursor: default;}+a {+ cursor: default;+}+/* utils for patterned bg images */@utility pattern-* {--pattern-color: --value(--color-*);diff --git a/js/app/packages/block-md/component/InlineTaskGithubPullRequests.tsx b/js/app/packages/block-md/component/InlineTaskGithubPullRequests.tsxindex 05891b9ca3..925984587d 100644--- a/js/app/packages/block-md/component/InlineTaskGithubPullRequests.tsx+++ b/js/app/packages/block-md/component/InlineTaskGithubPullRequests.tsx@@ -6,98 +6,41 @@ import { Layer } from '@ui';import { cn } from '@ui/utils/classname';import { createMemo, For, type JSX, Show } from 'solid-js';-const GITHUB_PULL_REQUEST_LINK_CLASS = cn(- 'inline-flex max-w-full min-w-0 items-stretch overflow-hidden rounded-lg',- 'border border-edge-muted bg-surface text-ink-muted shadow-sm',- 'leading-tight hover:bg-hover hover:text-ink',- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/20'+const PILL_CLASS = cn(+ 'inline-flex items-center gap-1.5 min-w-0 ring ring-edge-muted',+ 'px-2 py-1 leading-tight text-left rounded-full',+ 'bg-surface text-ink-muted hover:bg-hover hover:text-ink',+ 'focus-visible:outline-none focus-visible:ring-accent/20');-const GITHUB_PULL_REQUEST_SECTION_CLASS =- 'flex min-w-0 items-center gap-1.5 px-2 py-1.5';--const GITHUB_PULL_REQUEST_DIVIDER_CLASS =- 'w-px shrink-0 self-stretch bg-edge-muted';--function pullRequestName(pullRequest: GithubPullRequest): string | undefined {- return pullRequest.name?.trim() || undefined;+function pullRequestName(pr: GithubPullRequest): string | undefined {+ return pr.name?.trim() || undefined;}-function pullRequestLabel(pullRequest: GithubPullRequest): string {- const name = pullRequestName(pullRequest);- return name ? `${name} ${pullRequest.displayName}` : pullRequest.displayName;+function pullRequestLabel(pr: GithubPullRequest): string {+ const name = pullRequestName(pr);+ return name ? `${name} ${pr.displayName}` : pr.displayName;}-function hasLineChanges(pullRequest: GithubPullRequest): boolean {- return pullRequest.additions != null || pullRequest.deletions != null;+function hasLineChanges(pr: GithubPullRequest): boolean {+ return pr.additions != null || pr.deletions != null;}function formatLineCount(value: number | null | undefined): string {return (value ?? 0).toLocaleString();}-function lineChangesLabel(pullRequest: GithubPullRequest): string | undefined {- if (!hasLineChanges(pullRequest)) return undefined;-- return `+${formatLineCount(pullRequest.additions)} / -${formatLineCount(- pullRequest.deletions- )}`;+function lineChangesLabel(pr: GithubPullRequest): string | undefined {+ if (!hasLineChanges(pr)) return undefined;+ return `+${formatLineCount(pr.additions)} / -${formatLineCount(pr.deletions)}`;}-function pullRequestTitle(pullRequest: GithubPullRequest): string {- const changes = lineChangesLabel(pullRequest);- const label = pullRequestLabel(pullRequest);-+function pullRequestTitle(pr: GithubPullRequest): string {+ const changes = lineChangesLabel(pr);+ const label = pullRequestLabel(pr);return changes ? `${label} · ${changes}` : label;}-function PullRequestName(props: {- pullRequest: GithubPullRequest;-}): JSX.Element {- const name = () => pullRequestName(props.pullRequest);-- return (- <span class={GITHUB_PULL_REQUEST_SECTION_CLASS}>- <Show- when={name()}- fallback={- <span class="min-w-0 truncate">{props.pullRequest.displayName}</span>- }- >- {(title) => (- <>- <span class="min-w-0 truncate font-medium text-ink">{title()}</span>- <span class="shrink-0 text-ink-extra-muted">- {props.pullRequest.displayName}- </span>- </>- )}- </Show>- </span>- );-}--function PullRequestLineChanges(props: {- pullRequest: GithubPullRequest;-}): JSX.Element {- return (- <span- class={cn(- GITHUB_PULL_REQUEST_SECTION_CLASS,- 'shrink-0 gap-1 font-mono text-xs tabular-nums'- )}- >- <span class="text-success">- +{formatLineCount(props.pullRequest.additions)}- </span>- <span class="text-ink-extra-muted">/</span>- <span class="text-failure">- -{formatLineCount(props.pullRequest.deletions)}- </span>- </span>- );-}-export function InlineTaskGithubPullRequests(): JSX.Element {const blockId = useBlockId();const isTask = useBlockAliasedName() === 'task';@@ -110,39 +53,51 @@ export function InlineTaskGithubPullRequests(): JSX.Element {return (<Show when={pullRequests().length > 0}>- <div class="mb-6 flex flex-row flex-wrap items-center gap-2 text-sm">- <For each={pullRequests()}>- {(pullRequest) => (+ <For each={pullRequests()}>+ {(pr) => {+ const name = pullRequestName(pr);+ return (<Layer depth={2}><a- aria-label={`Open GitHub pull request ${pullRequestLabel(- pullRequest- )}`}- class={GITHUB_PULL_REQUEST_LINK_CLASS}- href={pullRequest.url}+ aria-label={`Open GitHub pull request ${pullRequestLabel(pr)}`}+ class={PILL_CLASS}+ href={pr.url}target="_blank"rel="noopener noreferrer"- title={pullRequestTitle(pullRequest)}+ title={pullRequestTitle(pr)}>- <span- class={cn(- GITHUB_PULL_REQUEST_SECTION_CLASS,- 'shrink-0 text-ink-extra-muted'- )}+ <GithubIcon class="size-3 shrink-0" aria-hidden="true" />+ <Show+ when={name}+ fallback={+ <span class="min-w-0 truncate">{pr.displayName}</span>+ }>- <GithubIcon class="size-4" aria-hidden="true" />- </span>- <span class={GITHUB_PULL_REQUEST_DIVIDER_CLASS} />- <PullRequestName pullRequest={pullRequest} />- <Show when={hasLineChanges(pullRequest)}>- <span class={GITHUB_PULL_REQUEST_DIVIDER_CLASS} />- <PullRequestLineChanges pullRequest={pullRequest} />+ {(title) => (+ <>+ <span class="min-w-0 truncate text-ink">{title()}</span>+ <span class="shrink-0 text-ink-extra-muted">+ {pr.displayName}+ </span>+ </>+ )}+ </Show>+ <Show when={hasLineChanges(pr)}>+ <span class="shrink-0 font-mono text-xs tabular-nums">+ <span class="text-success">+ +{formatLineCount(pr.additions)}+ </span>+ <span class="text-ink-extra-muted mx-0.5">/</span>+ <span class="text-failure">+ -{formatLineCount(pr.deletions)}+ </span>+ </span></Show></a></Layer>- )}- </For>- </div>+ );+ }}+ </For></Show>);}diff --git a/js/app/packages/block-md/component/InlineTaskProperties.tsx b/js/app/packages/block-md/component/InlineTaskProperties.tsxindex 3298ffd57d..186e5aa742 100644--- a/js/app/packages/block-md/component/InlineTaskProperties.tsx+++ b/js/app/packages/block-md/component/InlineTaskProperties.tsx@@ -77,11 +77,9 @@ export function InlineTaskProperties() {onPropertyDeleted={refetch}saveHandler={saveHandler}>- <div class="flex flex-row flex-wrap items-center gap-2 text-sm mb-6">- <For each={inlineProperties()}>- {(property) => <InlinePropertyValue property={property} />}- </For>- </div>+ <For each={inlineProperties()}>+ {(property) => <InlinePropertyValue property={property} />}+ </For><Modals /></PropertiesProvider></Show>diff --git a/js/app/packages/block-md/component/Notebook.tsx b/js/app/packages/block-md/component/Notebook.tsxindex cea15c6af1..87283ec956 100644--- a/js/app/packages/block-md/component/Notebook.tsx+++ b/js/app/packages/block-md/component/Notebook.tsx@@ -266,8 +266,10 @@ export function Notebook() {<div class={contentDivClasses()} ref={contentRef}><TitleEditor autoFocusOnMount={!navigatedFromJK()} /><div class="spacer h-3" />- <InlineTaskProperties />- <InlineTaskGithubPullRequests />+ <div class="mb-6 flex flex-row flex-wrap items-center gap-2 text-sm empty:hidden">+ <InlineTaskProperties />+ <InlineTaskGithubPullRequests />+ </div><ParamsProvider><MarkdownEditor autoFocusOnMount={!navigatedFromJK()} /><Show when={ENABLE_RAIL_CHAT_TASK_COMMENTS && isTask}>diff --git a/js/app/packages/block-md/component/sidepanel/MarkdownSidePanelSections.tsx b/js/app/packages/block-md/component/sidepanel/MarkdownSidePanelSections.tsxindex 472cecaa8d..0c49b3650a 100644--- a/js/app/packages/block-md/component/sidepanel/MarkdownSidePanelSections.tsx+++ b/js/app/packages/block-md/component/sidepanel/MarkdownSidePanelSections.tsx@@ -16,6 +16,7 @@ import type { Entity, EntityType } from '@core/types';import { tryMacroId, useDisplayName } from '@core/user';import { type DateValue, formatDate } from '@core/util/date';import { useSplitNavigationHandler } from '@core/util/useSplitNavigationHandler';+import GithubIcon from '@icon/mcp-github.svg';import { useNotificationsForEntity } from '@notifications';import CircleDashedEmpty from '@phosphor/circle-dashed.svg';import ClockIcon from '@phosphor/clock.svg';@@ -38,9 +39,11 @@ import type { Property, PropertyApiValues } from '@property/types';import { hasValue } from '@property/utils';import { useBulkSaveEntityPropertiesMutation } from '@queries/properties/entity';import { useDocumentMetadataQuery } from '@queries/storage/document-metadata';+import { useDocumentGithubPullRequestsQuery } from '@queries/storage/github-pull-requests';import { commsServiceClient } from '@service-comms/client';import type { EntityType as PropertiesEntityType } from '@service-properties/generated/schemas/entityType';import { blockNameToItemType } from '@service-storage/client';+import type { GithubPullRequest } from '@service-storage/generated/schemas';import { createCallback } from '@solid-primitives/rootless';import { cn } from '@ui/utils/classname';import {@@ -100,6 +103,7 @@ export function MarkdownSidePanelSections(<StatsSectionContent /></SidePanel.Section></Show>+ <GithubSectionConditional documentId={blockId} isTask={isTask()} /><NotificationsSectionConditional entity={entity()} /><ReferencesSectionConditional documentId={blockId} /></>@@ -729,3 +733,74 @@ function ReferencesSectionConditional(props: { documentId: string }) {</Show>);}++// ─────────────────────────────────────────────────────────────────────────────+// GitHub Section (conditional)+// ─────────────────────────────────────────────────────────────────────────────++function GithubSectionConditional(props: {+ documentId: string;+ isTask: boolean;+}) {+ const query = useDocumentGithubPullRequestsQuery(+ props.documentId,+ props.isTask+ );++ const pullRequests = createMemo((): GithubPullRequest[] => {+ if (!props.isTask || query.isLoading || query.isError) return [];+ return query.data?.pullRequests ?? [];+ });+ const count = createMemo(() => pullRequests().length);++ const title = () => (+ <>+ GitHub+ <Show when={count() > 0}>+ {' '}+ <span class="text-ink-extra-muted">({count()})</span>+ </Show>+ </>+ );++ return (+ <Show when={count() > 0}>+ <SidePanel.Section id="github" title={title()} order={35}>+ <div class="grid grid-cols-[var(--sidepanel-label-width,auto)_1fr] gap-x-3 items-center text-xs auto-rows-[2rem]">+ <DetailsRow label={count() === 1 ? 'PR' : 'PRs'}>+ <div class="flex min-w-0 flex-wrap items-center gap-x-1">+ <For each={pullRequests()}>+ {(pr, i) => (+ <>+ <Show when={i() > 0}>+ <span class="text-ink-extra-muted">,</span>+ </Show>+ <a+ href={pr.url}+ target="_blank"+ rel="noopener noreferrer"+ class="inline-flex min-w-0 items-center gap-1 text-ink hover:text-ink"+ title={+ pr.name?.trim()+ ? `${pr.name.trim()} ${pr.displayName}`+ : pr.displayName+ }+ >+ <GithubIcon+ class="size-3 shrink-0 text-ink-extra-muted"+ aria-hidden="true"+ />+ <span class="truncate underline decoration-current/20 decoration-[max(1px,0.1em)] underline-offset-2 hover:decoration-current">+ {pr.displayName}+ </span>+ </a>+ </>+ )}+ </For>+ </div>+ </DetailsRow>+ </div>+ </SidePanel.Section>+ </Show>+ );+}