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.

fix(tasks): open a task's linked PR in Macro instead of GitHub (#8471)

Jacob Beckermanddc425273f14
diff --git a/apps/web/src/features/block-md/component/InlineTaskGithubPullRequests.test.tsx b/apps/web/src/features/block-md/component/InlineTaskGithubPullRequests.test.tsx
new file mode 100644
index 0000000000..07b928a410
--- /dev/null
+++ b/apps/web/src/features/block-md/component/InlineTaskGithubPullRequests.test.tsx
@@ -0,0 +1,71 @@
+import type { GithubPullRequest } from '@service-storage/generated/schemas';
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { afterEach, expect, it, vi } from 'vitest';
+import { InlineTaskGithubPullRequests } from './InlineTaskGithubPullRequests';
+
+const mocks = vi.hoisted(() => ({
+ openWithSplit: vi.fn(),
+ pullRequests: [] as GithubPullRequest[],
+}));
+
+vi.mock('../context/markdown-document-context', () => ({
+ useMarkdownDocument: () => ({
+ documentId: () => 'task-1',
+ kind: () => 'task',
+ }),
+}));
+vi.mock('@queries/storage/github-pull-requests', () => ({
+ useDocumentGithubPullRequestsQuery: () => ({
+ isError: false,
+ isFetching: false,
+ data: { pullRequests: mocks.pullRequests },
+ }),
+}));
+vi.mock('@components/app/split-layout/layout', () => ({
+ useSplitLayout: () => ({ openWithSplit: mocks.openWithSplit }),
+}));
+vi.mock('@components/app/side-panel', () => ({
+ GithubPullRequestStatusIcon: () => null,
+}));
+vi.mock('@core/util/branchName', () => ({
+ copyBranchNameToClipboard: vi.fn(),
+}));
+
+const pullRequest: GithubPullRequest = {
+ additions: 326,
+ deletions: 1,
+ displayName: 'macro-inc/macro#5158',
+ githubKey: 'macro-inc/macro/pull/5158',
+ name: 'fix(sync-service): strip comment highlight marks',
+ number: 5158,
+ owner: 'macro-inc',
+ repo: 'macro',
+ status: 'open',
+ url: 'https://github.com/macro-inc/macro/pull/5158',
+};
+
+afterEach(() => {
+ cleanup();
+ vi.clearAllMocks();
+});
+
+it('opens a synced pull request in a new split instead of GitHub', () => {
+ mocks.pullRequests = [{ ...pullRequest, foreignEntityId: 'pr-entity' }];
+ render(() => <InlineTaskGithubPullRequests />);
+
+ expect(screen.queryByRole('link')).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: /Open pull request/ }));
+
+ expect(mocks.openWithSplit).toHaveBeenCalledWith(
+ { type: 'pr', id: 'pr-entity' },
+ { preferNewSplit: true }
+ );
+});
+
+it('links a pull request Macro has not synced to GitHub', () => {
+ mocks.pullRequests = [pullRequest];
+ render(() => <InlineTaskGithubPullRequests />);
+
+ expect(screen.getByRole('link').getAttribute('href')).toBe(pullRequest.url);
+ expect(screen.queryByRole('button')).toBeNull();
+});
diff --git a/apps/web/src/features/block-md/component/InlineTaskGithubPullRequests.tsx b/apps/web/src/features/block-md/component/InlineTaskGithubPullRequests.tsx
index 9e6157be4e..4617417b8c 100644
--- a/apps/web/src/features/block-md/component/InlineTaskGithubPullRequests.tsx
+++ b/apps/web/src/features/block-md/component/InlineTaskGithubPullRequests.tsx
@@ -1,6 +1,10 @@
import { GithubPullRequestStatusIcon } from '@components/app/side-panel';
+import { useSplitLayout } from '@components/app/split-layout/layout';
+import { USE_MACRO_PR_SUMMARY_BLOCK } from '@core/constant/featureFlags';
import { TOKENS } from '@core/hotkey/tokens';
import { copyBranchNameToClipboard } from '@core/util/branchName';
+import { openInNewSplitForMention } from '@core/util/openInNewSplit';
+import { useSplitNavigationHandler } from '@core/util/useSplitNavigationHandler';
import GithubIcon from '@icon/mcp-github.svg';
import GitBranch from '@phosphor/git-branch.svg';
import { useDocumentGithubPullRequestsQuery } from '@queries/storage/github-pull-requests';
@@ -59,6 +63,96 @@ function InlineTaskGithubPullRequestsSkeleton(): JSX.Element {
);
}
+function PullRequestPillFace(props: { pr: GithubPullRequest }): JSX.Element {
+ return (
+ <>
+ <Show
+ when={props.pr.status}
+ fallback={<GithubIcon class="size-3 shrink-0" aria-hidden="true" />}
+ >
+ {(status) => (
+ <GithubPullRequestStatusIcon
+ status={status()}
+ class="size-3 shrink-0"
+ />
+ )}
+ </Show>
+ <Show
+ when={pullRequestName(props.pr)}
+ fallback={<span class="min-w-0 truncate">{props.pr.displayName}</span>}
+ >
+ {(title) => (
+ <>
+ <span class="min-w-0 truncate text-ink">{title()}</span>
+ <span class="shrink-0 text-ink-extra-muted">
+ {props.pr.displayName}
+ </span>
+ </>
+ )}
+ </Show>
+ <Show when={hasLineChanges(props.pr)}>
+ <span class="shrink-0 font-mono text-xs tabular-nums">
+ <span class="text-success">
+ +{formatLineCount(props.pr.additions)}
+ </span>
+ <span class="text-ink-extra-muted mx-0.5">/</span>
+ <span class="text-failure">
+ -{formatLineCount(props.pr.deletions)}
+ </span>
+ </span>
+ </Show>
+ </>
+ );
+}
+
+/**
+ * Opens the pull request's Macro block in a new split once GitHub has synced
+ * it; until then the pill links to GitHub.
+ */
+function PullRequestPill(props: { pr: GithubPullRequest }): JSX.Element {
+ const { openWithSplit } = useSplitLayout();
+ const foreignEntityId = () =>
+ USE_MACRO_PR_SUMMARY_BLOCK ? props.pr.foreignEntityId : undefined;
+ const navHandlers = useSplitNavigationHandler<HTMLButtonElement>((event) => {
+ const id = foreignEntityId();
+ if (!id) return;
+ openWithSplit(
+ { type: 'pr', id },
+ { preferNewSplit: openInNewSplitForMention(event.shiftKey, true) }
+ );
+ });
+
+ return (
+ <Layer depth={2}>
+ <Show
+ when={foreignEntityId()}
+ fallback={
+ <a
+ aria-label={`Open GitHub pull request ${pullRequestLabel(props.pr)}`}
+ class={PILL_CLASS}
+ href={props.pr.url}
+ target="_blank"
+ rel="noopener noreferrer"
+ title={pullRequestTitle(props.pr)}
+ >
+ <PullRequestPillFace pr={props.pr} />
+ </a>
+ }
+ >
+ <button
+ type="button"
+ aria-label={`Open pull request ${pullRequestLabel(props.pr)}`}
+ class={PILL_CLASS}
+ title={pullRequestTitle(props.pr)}
+ {...navHandlers}
+ >
+ <PullRequestPillFace pr={props.pr} />
+ </button>
+ </Show>
+ </Layer>
+ );
+}
+
function InlineTaskGithubPullRequestsContent(props: {
blockId: string;
}): JSX.Element {
@@ -77,63 +171,7 @@ function InlineTaskGithubPullRequestsContent(props: {
<Show when={isWaitingForPullRequests()}>
<InlineTaskGithubPullRequestsSkeleton />
</Show>
- <For each={pullRequests()}>
- {(pr) => {
- const name = pullRequestName(pr);
- return (
- <Layer depth={2}>
- <a
- aria-label={`Open GitHub pull request ${pullRequestLabel(pr)}`}
- class={PILL_CLASS}
- href={pr.url}
- target="_blank"
- rel="noopener noreferrer"
- title={pullRequestTitle(pr)}
- >
- <Show
- when={pr.status}
- fallback={
- <GithubIcon class="size-3 shrink-0" aria-hidden="true" />
- }
- >
- {(status) => (
- <GithubPullRequestStatusIcon
- status={status()}
- class="size-3 shrink-0"
- />
- )}
- </Show>
- <Show
- when={name}
- fallback={
- <span class="min-w-0 truncate">{pr.displayName}</span>
- }
- >
- {(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>
+ <For each={pullRequests()}>{(pr) => <PullRequestPill pr={pr} />}</For>
<Show when={!isWaitingForPullRequests() && pullRequests().length === 0}>
<CopyButton
variant="outline"
diff --git a/docs/agent-guide/tasks.md b/docs/agent-guide/tasks.md
index 4fa3145c28..eb04dac711 100644
--- a/docs/agent-guide/tasks.md
+++ b/docs/agent-guide/tasks.md
@@ -759,6 +759,11 @@ including properties that do not have a value yet. Click a preview pill to edit
opening the task; the property picker keeps the preview open while you make a selection.
Users with view or comment access see the same pills read-only.
+Each GitHub pull request linked to an open task shows a pill beside its property pills
+with the PR's status, title, `owner/repo#N`, and line changes. Clicking it opens the PR in
+Macro in a new split (in place on touch devices); a PR Macro has not synced yet opens on
+GitHub instead.
+
The Assignees picker offers people and available agents together. Agent rows show
their name and an `Agent` label; saved agents also show their `@handle`. Search by
name or handle to find one. Built-in session agents follow the same availability