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
feat(connector-import): import via agent chats, connect GitHub natively (#8511)
Jacob Beckermanbea5348b6d53
diff --git a/apps/web/src/features/connector-import/browser-test/import.browser.e2e.ts b/apps/web/src/features/connector-import/browser-test/import.browser.e2e.tsindex 5c5658c180..c565c96ee6 100644--- a/apps/web/src/features/connector-import/browser-test/import.browser.e2e.ts+++ b/apps/web/src/features/connector-import/browser-test/import.browser.e2e.ts@@ -9,7 +9,9 @@ test.beforeEach(async ({ page }) => {await page.goto(fixture, { waitUntil: 'domcontentloaded' });});-test('imports selected Notion pages from the Drive card', async ({ page }) => {+test('hands a Notion import from the Drive card to the agent', async ({+ page,+}) => {const sidebar = page.getByRole('complementary', { name: 'files sidebar' });await expect(sidebar.getByRole('list', { name: /Notion, Google Drive, Dropbox/ })@@ -19,24 +21,30 @@ test('imports selected Notion pages from the Drive card', async ({ page }) => {.click();const dialog = page.getByRole('dialog');await dialog.getByRole('button', { name: 'Connect Notion' }).click();- await expect(dialog.getByText('Import from Notion')).toBeVisible();- // The title is the checkbox's label, so clicking it selects the page.- await dialog.getByText('Q4 planning', { exact: true }).click();- await expect(- dialog.getByRole('checkbox', { name: /^Select Q4 planning/ })- ).toBeChecked();- await dialog.getByRole('button', { name: 'Import 1' }).click();- await expect(- dialog.getByRole('link', { name: 'Open imported Q4 planning' })- ).toBeVisible();- await expect(- sidebar.getByRole('button', { name: 'Import files', exact: true })- ).toHaveCount(0);+ await dialog.getByRole('button', { name: 'Import from Notion' }).click();+ await expect(dialog).not.toBeVisible();+ await expect(page.getByRole('status', { name: 'Agent handoff' })).toHaveText(+ 'Import my most recent documents and files from Notion into my Macro Drive.'+ );});-test('hands a connected provider without an importer to the agent', async ({+test('connects GitHub natively, then hands its import to the agent', async ({page,}) => {+ const sidebar = page.getByRole('complementary', { name: 'tasks sidebar' });+ await sidebar+ .getByRole('button', { name: 'Import tasks', exact: true })+ .click();+ const dialog = page.getByRole('dialog');+ await dialog.getByRole('button', { name: 'Connect GitHub' }).click();+ await dialog.getByRole('button', { name: 'Import from GitHub' }).click();+ await expect(dialog).not.toBeVisible();+ await expect(page.getByRole('status', { name: 'Agent handoff' })).toHaveText(+ 'Import my most recent issues and tasks from GitHub into Macro tasks.'+ );+});++test('hands a connected Pipedream provider to the agent', async ({ page }) => {const sidebar = page.getByRole('complementary', { name: 'tasks sidebar' });await sidebar.getByRole('button', { name: 'Import tasks', exact: true })@@ -50,21 +58,23 @@ test('hands a connected provider without an importer to the agent', async ({);});-test('picks Slack channels or hands history to the archive upload', async ({+test('hands Slack channels to the agent or history to the archive upload', async ({page,}) => {const sidebar = page.getByRole('complementary', { name: 'channels sidebar' });- await sidebar- .getByRole('button', { name: 'Import from Slack', exact: true })- .click();+ const open = () =>+ sidebar+ .getByRole('button', { name: 'Import from Slack', exact: true })+ .click();+ await open();const dialog = page.getByRole('dialog');await dialog.getByRole('button', { name: 'Connect Slack' }).click();- await dialog.getByText('#general', { exact: true }).click();- await dialog.getByRole('button', { name: 'Import 1' }).click();- await expect(- dialog.getByRole('link', { name: 'Open imported #general' })- ).toBeVisible();- await dialog.getByRole('button', { name: 'Back to apps' }).click();+ await dialog.getByRole('button', { name: 'Import from Slack' }).click();+ await expect(dialog).not.toBeVisible();+ await expect(page.getByRole('status', { name: 'Agent handoff' })).toHaveText(+ 'Import my most recent channels from Slack into Macro channels.'+ );+ await open();await dialog.getByRole('button', { name: /Import with history/ }).click();await expect(dialog).not.toBeVisible();await expect(page.getByRole('status', { name: 'Agent handoff' })).toHaveText(diff --git a/apps/web/src/features/connector-import/browser-test/import.tsx b/apps/web/src/features/connector-import/browser-test/import.tsxindex 1d223121f2..5081330433 100644--- a/apps/web/src/features/connector-import/browser-test/import.tsx+++ b/apps/web/src/features/connector-import/browser-test/import.tsx@@ -5,7 +5,6 @@ import FileCsvIcon from '@phosphor/file-csv.svg';import FileZipIcon from '@phosphor/file-zip.svg';import FolderIcon from '@phosphor/folder.svg';import UploadIcon from '@phosphor/upload-simple.svg';-import type { ImportState } from '@service-cognition/import';import { createSignal, For } from 'solid-js';import { render } from 'solid-js/web';import { ConnectorImportProvider } from '../context/connector-import-context';@@ -14,98 +13,29 @@ import { IMPORT_CATEGORIES } from '../core/catalog';import type { ImportCategory } from '../core/providers';import { ConnectorImportDialog } from '../views/import-dialog';-// The real card and dialog over an in-memory pipeline: connecting succeeds-// at once, Notion discovery stages two pages, and accepted pages import.-const now = '2026-10-12T00:00:00Z';+// The real card and dialog over in-memory connections: Pipedream connects at+// once, GitHub's native authorization finishes a moment later as if in+// another tab, and every import hands off to the agent.const [connected, setConnected] = createSignal<ReadonlySet<string>>(new Set(['dropbox']));-const [state, setState] = createSignal<ImportState>({ runs: [], entities: [] });const [handoff, setHandoff] = createSignal('');-function page(id: string, title: string, summary: string) {- return {- id,- user_id: 'fixture',- source: 'notion' as const,- foreign_id: id,- status: 'staged' as const,- initiator: 'manual' as const,- metadata: { title, summary },- created_at: now,- updated_at: now,- };-}--function channel(id: string, name: string, purpose: string) {- return {- ...page(id, name, ''),- source: 'slack' as const,- metadata: { name, purpose, member_count: 12 },- };-}-const context: ConnectorImportContext = {createConnections: () => ({ connected, ready: () => true }),- createImportState: () => ({ state, ready: () => true }),connect: async (app) => {- setConnected((previous) => new Set([...previous, app.appSlug]));- return 'connected';- },- discover: async (source) => {- setState({- runs: [- { source, status: 'running', auto_import: false, updated_at: now },- ],- entities: [],- });- setTimeout(- () =>- setState({- runs: [- { source, status: 'ready', auto_import: false, updated_at: now },- ],- entities:- source === 'slack'- ? [- channel('c1', 'general', 'Company-wide announcements'),- channel('c2', 'eng', 'Engineering discussion'),- ]- : [- page('p1', 'Q4 planning', 'Goals and owners for the quarter'),- page(- 'p2',- 'Onboarding guide',- 'How new teammates get set up'- ),- ],- }),- 400- );- },- runImport: async (ids) => {- const flip = (status: 'importing' | 'imported') =>- setState((previous) => ({- ...previous,- entities: previous.entities.map((entity) =>- ids.includes(entity.id)- ? {- ...entity,- status,- ...(status === 'imported'- ? { entity_id: `doc-${entity.id}`, entity_type: 'md' }- : {}),- }- : entity- ),- }));- flip('importing');- setTimeout(() => flip('imported'), 400);+ const add = () =>+ setConnected((previous) => new Set([...previous, app.appSlug]));+ if (!app.mcpUrl) {+ add();+ return 'connected';+ }+ setTimeout(add, 400);+ return 'started';},startAgentImport: async (value) => {setHandoff(value.input);},- entityHref: (entity) => `#${entity.type}/${entity.id}`,};function Sidebar(props: { category: ImportCategory }) {@@ -134,7 +64,6 @@ function Sidebar(props: { category: ImportCategory }) {config={config}open={open()}onOpenChange={setOpen}- onImported={() => setHidden(true)}alternatives={(() => {const alternative =props.category === 'crm'diff --git a/apps/web/src/features/connector-import/components/import-item-list.tsx b/apps/web/src/features/connector-import/components/import-item-list.tsxdeleted file mode 100644index e251524917..0000000000--- a/apps/web/src/features/connector-import/components/import-item-list.tsx+++ /dev/null@@ -1,98 +0,0 @@-import ArrowUpRightIcon from '@phosphor/arrow-up-right.svg';-import SpinnerIcon from '@phosphor/spinner-gap.svg';-import { Checkbox } from '@ui';-import { For, type JSX, Match, Show, Switch } from 'solid-js';-import type { ImportItem } from '../core/import-items';--function ItemText(props: { item: ImportItem }): JSX.Element {- return (- <>- <span class="block truncate font-medium text-ink">- {props.item.title}- </span>- <Show when={props.item.detail}>- <span class="block truncate text-xs text-ink-muted">- {props.item.detail}- </span>- </Show>- <Show when={props.item.status === 'staged' && props.item.error}>- <span class="block text-xs text-failure">- Last attempt failed. Select it to try again.- </span>- </Show>- </>- );-}--/** Discovered items: staged ones are selectable, the rest show progress. */-export function ImportItemList(props: {- items: readonly ImportItem[];- selected: ReadonlySet<string>;- disabled?: boolean;- onSelect(id: string, selected: boolean): void;- href(entity: NonNullable<ImportItem['entity']>): string;-}) {- return (- <ul class="rounded-2xl bg-ink/3 px-3 py-1" aria-label="Items to import">- <For each={props.items}>- {(item) => (- <li class="flex items-start gap-3 py-2.5 text-sm">- <Switch>- <Match when={item.status === 'staged'}>- <Checkbox- class="flex min-w-0 flex-1 items-start gap-3"- checked={props.selected.has(item.id)}- disabled={props.disabled}- onChange={(checked) => props.onSelect(item.id, checked)}- >- <Checkbox.Control class="mt-0.5" />- <Checkbox.Label class="min-w-0 flex-1">- <span class="sr-only">Select </span>- <ItemText item={item} />- </Checkbox.Label>- </Checkbox>- </Match>- <Match when={item.status === 'importing'}>- <SpinnerIcon- class="mt-0.5 size-4 shrink-0 animate-spin text-ink-muted"- aria-hidden="true"- />- <span class="min-w-0 flex-1">- <ItemText item={item} />- </span>- <span class="shrink-0 text-xs text-ink-muted" role="status">- Importing…- </span>- </Match>- <Match when={item.status === 'imported'}>- <span class="size-4 shrink-0" aria-hidden="true" />- <span class="min-w-0 flex-1">- <ItemText item={item} />- </span>- <Show- when={item.entity}- fallback={- <span class="shrink-0 text-xs text-ink-muted">- Imported- </span>- }- >- {(entity) => (- <a- href={props.href(entity())}- class="inline-flex shrink-0 items-center gap-1 text-xs text-accent"- aria-label={`Open imported ${item.title}`}- >- Imported- <ArrowUpRightIcon class="size-3" aria-hidden="true" />- </a>- )}- </Show>- </Match>- </Switch>- </li>- )}- </For>- </ul>- );-}diff --git a/apps/web/src/features/connector-import/components/provider-row.tsx b/apps/web/src/features/connector-import/components/provider-row.tsxindex 3524597991..6ac37398c2 100644--- a/apps/web/src/features/connector-import/components/provider-row.tsx+++ b/apps/web/src/features/connector-import/components/provider-row.tsx@@ -9,7 +9,7 @@ export type ProviderRowState =/** Connections are still loading; no action is offered yet. */'unknown' | 'disconnected' | 'connecting' | 'connected';-/** One app in the import dialog: connect it, then import from it. */+/** One app in the import dialog: connect it, then import with the agent. */export function ProviderRow(props: {provider: ImportProvider;state: ProviderRowState;@@ -18,7 +18,6 @@ export function ProviderRow(props: {onConnect(): void;onImport(): void;}) {- const native = () => props.provider.native !== undefined;return (<li class="flex items-center gap-3 py-2.5"><span class="flex size-9 shrink-0 items-center justify-center rounded-full bg-dialog">@@ -40,7 +39,6 @@ export function ProviderRow(props: {</span><span class="block truncate text-xs text-ink-muted">{props.provider.detail}- {native() ? '' : ' · with the agent'}</span></span><Show@@ -68,9 +66,7 @@ export function ProviderRow(props: {aria-label={`Import from ${props.provider.name}`}onClick={() => props.onImport()}>- <Show when={!native()}>- <SparkleIcon aria-hidden="true" />- </Show>+ <SparkleIcon aria-hidden="true" />Import</Button></Show>diff --git a/apps/web/src/features/connector-import/connector-import-dialog.tsx b/apps/web/src/features/connector-import/connector-import-dialog.tsxindex ad792960fd..665f0e285c 100644--- a/apps/web/src/features/connector-import/connector-import-dialog.tsx+++ b/apps/web/src/features/connector-import/connector-import-dialog.tsx@@ -1,62 +1,100 @@import { openChatWithInput } from '@app/features/chat/ChatWithAgentButton';-import { buildSimpleEntityUrl } from '@core/util/url';+import { nativeToolSlug } from '@app/features/onboarding/queries/connected-tools';import {- type ImportState,- useDiscoverMutation,- useImportQuery,- useRunImportMutation,-} from '@queries/import';+ assignOauthUrl,+ reserveOauthPopup,+} from '@app/features/settings/connections/mcp-oauth';+import { Telemetry } from '@macro-inc/observability';+import {+ useMcpServersQuery,+ useStartMcpAuthMutation,+} from '@queries/mcp-servers';import {connectPipedreamApp,usePipedreamConnectedSlugs,} from '@queries/pipedream-connectors';-import type { JSX } from 'solid-js';+import { createMemo, type JSX } from 'solid-js';import { ConnectorImportProvider } from './context/connector-import-context';-import type { ConnectorImportContext } from './context/contracts';+import type {+ ConnectOutcome,+ ConnectorImportContext,+} from './context/contracts';import type { ImportCategoryConfig } from './core/providers';import {ConnectorImportDialog,type ImportAlternative,} from './views/import-dialog';-const PENDING_STATE: ImportState = { runs: [], entities: [] };-function useProductionContext(): ConnectorImportContext {- const discover = useDiscoverMutation();- const runImport = useRunImportMutation();+ const startMcpAuth = useStartMcpAuthMutation();++ // Opens the OAuth tab synchronously, inside the click, so it isn't blocked.+ function connectNative(app: {+ name: string;+ mcpUrl: string;+ }): Promise<ConnectOutcome> {+ const popup = reserveOauthPopup();+ return Telemetry.span(+ 'mcp.authorize',+ async (span): Promise<ConnectOutcome> => {+ span.setAttr('connector.server_url', app.mcpUrl);+ try {+ const { authorization_url } = await startMcpAuth.mutateAsync({+ server_url: app.mcpUrl,+ server_name: app.name,+ });+ assignOauthUrl(popup, authorization_url);+ return 'started';+ } catch (error) {+ popup?.close();+ span.error('MCP authorization failed to start');+ throw error;+ }+ }+ );+ }+return {createConnections() {- const { slugs, ready } = usePipedreamConnectedSlugs();- return { connected: slugs, ready };- },- createImportState() {- const query = useImportQuery();+ const pipedream = usePipedreamConnectedSlugs();+ // Refetches on focus, so returning from the OAuth tab shows the result.+ const native = useMcpServersQuery({ neverSuspend: true });+ const nativeSlugs = createMemo(() =>+ native.isSuccess+ ? native.data.flatMap((server) => {+ const slug =+ server.authenticated && server.enabled+ ? nativeToolSlug(server)+ : undefined;+ return slug ? [slug] : [];+ })+ : []+ );return {- // Guard resource reads so polling never suspends the dialog.- state: () => (query.isSuccess ? query.data : PENDING_STATE),- ready: () => query.isSuccess && !query.isPlaceholderData,+ connected: () => new Set([...pipedream.slugs(), ...nativeSlugs()]),+ // A failed native read leaves Pipedream's answer standing.+ ready: () =>+ pipedream.ready() &&+ (native.isError || (native.isSuccess && !native.isPlaceholderData)),};},connect: (app, container) =>- connectPipedreamApp({- appSlug: app.appSlug,- serverName: app.name,- container,- }),- discover: (source) => discover.mutateAsync(source),- runImport: async (importIds) => {- await runImport.mutateAsync({ importIds, discardIds: [] });- },+ app.mcpUrl+ ? connectNative({ name: app.name, mcpUrl: app.mcpUrl })+ : connectPipedreamApp({+ appSlug: app.appSlug,+ serverName: app.name,+ container,+ }),startAgentImport: (handoff) =>openChatWithInput(handoff.input, { instructions: handoff.instructions }),- entityHref: (entity) => buildSimpleEntityUrl(entity),};}/**- * The import dialog wired to production: the Pipedream connector stack, the- * import pipeline, and agent handoff. Loaded on demand by the sidebar card,- * so the card itself renders with its view.+ * The import dialog wired to production: native MCP and Pipedream+ * connections, and the agent chat that runs each import. Loaded on demand by+ * the sidebar card, so the card itself renders with its view.*/export function ConnectorImportDialogHost(props: {config: ImportCategoryConfig;@@ -64,7 +102,6 @@ export function ConnectorImportDialogHost(props: {onOpenChange(open: boolean): void;opener?: HTMLElement;alternatives?: readonly ImportAlternative[];- onImported(): void;}): JSX.Element {return (<ConnectorImportProvider context={useProductionContext()}>@@ -74,7 +111,6 @@ export function ConnectorImportDialogHost(props: {onOpenChange={props.onOpenChange}opener={props.opener}alternatives={props.alternatives}- onImported={props.onImported}/></ConnectorImportProvider>);diff --git a/apps/web/src/features/connector-import/connector-import.tsx b/apps/web/src/features/connector-import/connector-import.tsxindex f5b4517bba..5e0e394755 100644--- a/apps/web/src/features/connector-import/connector-import.tsx+++ b/apps/web/src/features/connector-import/connector-import.tsx@@ -6,7 +6,6 @@ import {} from '@app/features/sidebar-promotion/sidebar-promotion';import { useFeatureFlag } from '@app/lib/analytics/posthog';import { enableSidebarPromotions } from '@core/constant/featureFlags';-import { useUserId } from '@core/context/user';import {usePipedreamMcpFlag,usePipedreamMcpFlagResult,@@ -16,7 +15,7 @@ import { lazyNamed } from '@core/util/lazyNamed';import { createSignal, type JSX, Show, Suspense } from 'solid-js';import { IMPORT_CATEGORIES } from './core/catalog';import type { ImportCategory } from './core/providers';-import { hideImportPromotion, importPromotionId } from './primitives/promotion';+import { importPromotionId } from './primitives/promotion';import type { ImportAlternative } from './views/import-dialog';export type { ImportAlternative } from './views/import-dialog';@@ -65,7 +64,6 @@ export function ConnectorImportPromotion(props: {alternatives?: readonly ImportAlternative[];class?: string;}): JSX.Element {- const userId = useUserId();const pipedream = usePipedreamMcpFlag();const config = () => IMPORT_CATEGORIES[props.category];const dialogConfig = () => ({@@ -76,7 +74,6 @@ export function ConnectorImportPromotion(props: {// The dialog's code loads on first open (and is fetched ahead on hover).const [opened, setOpened] = createSignal(false);const [opener, setOpener] = createSignal<HTMLButtonElement>();- const hide = () => hideImportPromotion(userId(), props.category);// Alternatives open their own dialogs; hand them the card button for focus.const alternatives = (): ImportAlternative[] =>(props.alternatives ?? []).map((base) => ({@@ -118,7 +115,7 @@ export function ConnectorImportPromotion(props: {}}/></div>- {/* Beside the card: a finished import hides the card, not the dialog. */}+ {/* Beside the card, so the dialog outlives the card's own gates. */}<Show when={opened()}><Suspense><ConnectorImportDialogHost@@ -127,7 +124,6 @@ export function ConnectorImportPromotion(props: {onOpenChange={openDialog}opener={opener()}alternatives={alternatives()}- onImported={hide}/></Suspense></Show>diff --git a/apps/web/src/features/connector-import/context/contracts.ts b/apps/web/src/features/connector-import/context/contracts.tsindex c72b7bf289..9ae30e0452 100644--- a/apps/web/src/features/connector-import/context/contracts.ts+++ b/apps/web/src/features/connector-import/context/contracts.ts@@ -1,8 +1,11 @@-import type { ImportSource, ImportState } from '@service-cognition/import';import type { Accessor } from 'solid-js';import type { AgentImportHandoff } from '../core/agent-handoff';-export type ConnectOutcome = 'connected' | 'closed' | 'unsupported';+/**+ * `started` means authorization continues in another tab; the connection+ * shows up in `createConnections` once it finishes.+ */+export type ConnectOutcome = 'connected' | 'started' | 'closed' | 'unsupported';/** The user's connected apps; `ready` is false until the answer is known. */type ConnectionsSource = {@@ -10,26 +13,17 @@ type ConnectionsSource = {ready: Accessor<boolean>;};-/** Import pipeline state; `ready` is false while serving a placeholder. */-type ImportStateSource = {- state: Accessor<ImportState>;- ready: Accessor<boolean>;-};-export type ConnectorImportContext = {/** Called inside an open dialog so its queries live only that long. */createConnections(): ConnectionsSource;- createImportState(): ImportStateSource;- /** Connect through Pipedream; `container` keeps the iframe usable in a modal. */+ /**+ * Connect through the app's native MCP server when it has one, otherwise+ * Pipedream; `container` keeps Pipedream's iframe usable in a modal.+ */connect(- app: { appSlug: string; name: string },+ app: { appSlug: string; name: string; mcpUrl?: string },container?: HTMLElement): Promise<ConnectOutcome>;- /** Start finding items for a native source. */- discover(source: ImportSource): Promise<void>;- /** Accept staged rows; completion arrives through the import state. */- runImport(importIds: string[]): Promise<void>;- /** Hand a provider without a native importer to an agent chat. */+ /** Hand the import to an agent chat in a split beside the current view. */startAgentImport(handoff: AgentImportHandoff): Promise<void>;- entityHref(entity: { id: string; type: string }): string;};diff --git a/apps/web/src/features/connector-import/core/agent-handoff.test.ts b/apps/web/src/features/connector-import/core/agent-handoff.test.tsindex ebdb9b346f..9921dad789 100644--- a/apps/web/src/features/connector-import/core/agent-handoff.test.ts+++ b/apps/web/src/features/connector-import/core/agent-handoff.test.ts@@ -15,6 +15,22 @@ describe('agent import handoff', () => {expect(handoff.instructions).toContain('never edit or delete');});+ it("imports Notion pages through Macro's importer", () => {+ const files = IMPORT_CATEGORIES.files;+ const notion = files.providers.find((p) => p.appSlug === 'notion')!;+ const { instructions } = agentImportHandoff(files, notion);+ expect(instructions).toContain('ImportNotionPage');+ expect(instructions).not.toContain('CreateDocument, converting');+ });++ it('records ledger sources so nothing imports twice', () => {+ const tasks = IMPORT_CATEGORIES.tasks;+ const linear = tasks.providers.find((p) => p.appSlug === 'linear')!;+ const { instructions } = agentImportHandoff(tasks, linear);+ expect(instructions).toContain('ListImportEntities for source linear');+ expect(instructions).toContain('CreateImportEntity');+ });+it('creates tasks as task documents', () => {const tasks = IMPORT_CATEGORIES.tasks;const jira = tasks.providers.find((p) => p.appSlug === 'jira')!;@@ -25,12 +41,12 @@ describe('agent import handoff', () => {});describe('import catalog', () => {- it('gives every category unique providers led by a native source where one exists', () => {+ it('gives every category unique providers led by a ledger source where one exists', () => {for (const config of Object.values(IMPORT_CATEGORIES)) {const slugs = config.providers.map((p) => p.appSlug);expect(new Set(slugs).size).toBe(slugs.length);- const native = config.providers.findIndex((p) => p.native);- expect(native === -1 || native === 0).toBe(true);+ const ledger = config.providers.findIndex((p) => p.ledger);+ expect(ledger === -1 || ledger === 0).toBe(true);}});});diff --git a/apps/web/src/features/connector-import/core/agent-handoff.ts b/apps/web/src/features/connector-import/core/agent-handoff.tsindex f6fdf6fb94..16c8b8278a 100644--- a/apps/web/src/features/connector-import/core/agent-handoff.ts+++ b/apps/web/src/features/connector-import/core/agent-handoff.ts@@ -1,7 +1,7 @@import { match } from 'ts-pattern';import type { ImportCategoryConfig, ImportProvider } from './providers';-/** What an agent chat opens with when a provider has no native importer. */+/** What the agent chat that runs an import opens with. */export type AgentImportHandoff = {/** Unsent composer text the user can adjust before sending. */input: string;@@ -9,7 +9,13 @@ export type AgentImportHandoff = {instructions: string;};-function createWith(config: ImportCategoryConfig): string {+function createWith(+ config: ImportCategoryConfig,+ provider: ImportProvider+): string {+ // Macro's Notion importer converts and dedupes pages itself.+ if (provider.ledger === 'notion')+ return 'Import each chosen page with ImportNotionPage; never recreate a page with CreateDocument.';return match(config.category).with('files',@@ -34,6 +40,15 @@ function createWith(config: ImportCategoryConfig): string {.exhaustive();}+/** Ledger bookkeeping, so neither the user nor a teammate imports twice. */+function ledgerSteps(provider: ImportProvider): string[] {+ if (!provider.ledger || provider.ledger === 'notion') return [];+ return [+ `Check ListImportEntities for source ${provider.ledger} first and leave out anything already imported or declined.`,+ `After creating each item, record it with CreateImportEntity: source ${provider.ledger}, status imported, and the new entityId.`,+ ];+}+export function agentImportHandoff(config: ImportCategoryConfig,provider: ImportProvider@@ -43,8 +58,9 @@ export function agentImportHandoff(instructions: [`The user started this from Macro's import dialog and has just connected ${provider.name}.`,`Use the ${provider.name} connector tools to find their most relevant recent ${config.items}.`,+ ...ledgerSteps(provider),`Before creating anything, show a short numbered list and ask which ones to bring over.`,- createWith(config),+ createWith(config, provider),`Only read from ${provider.name}; never edit or delete anything there.`,'Finish with links to everything you created.',].join(' '),diff --git a/apps/web/src/features/connector-import/core/catalog.ts b/apps/web/src/features/connector-import/core/catalog.tsindex 78f7e6bfa5..5913bf18fd 100644--- a/apps/web/src/features/connector-import/core/catalog.ts+++ b/apps/web/src/features/connector-import/core/catalog.ts@@ -22,7 +22,7 @@ import type {} from './providers';// Order is promotion order: the sidebar card shows these left to right and-// its copy names the first few. Natively imported sources lead.+// its copy names the first few. Sources with an import ledger lead.// Each pitch fills one line and most of a second at the default sidebar width.export const IMPORT_CATEGORIES: Record<ImportCategory, ImportCategoryConfig> = {files: {@@ -32,7 +32,7 @@ export const IMPORT_CATEGORIES: Record<ImportCategory, ImportCategoryConfig> = {'Import docs and files from Notion, Google Drive, Dropbox, and more.',action: 'Import files',dialogDescription:- 'Connect an app, then pick what to bring into your Drive.',+ 'Connect an app, then pick what to bring into your Drive with the agent.',items: 'documents and files',destination: 'my Macro Drive',providers: [@@ -41,7 +41,7 @@ export const IMPORT_CATEGORIES: Record<ImportCategory, ImportCategoryConfig> = {name: 'Notion',detail: 'Pages and wikis',icon: IconNotion as ImportIcon,- native: 'notion',+ ledger: 'notion',},{appSlug: 'google_drive',@@ -81,7 +81,8 @@ export const IMPORT_CATEGORIES: Record<ImportCategory, ImportCategoryConfig> = {pitch:'Import issues and tasks from Linear, Jira, Asana, GitHub, and more.',action: 'Import tasks',- dialogDescription: 'Connect an app, then pick which tasks to bring over.',+ dialogDescription:+ 'Connect an app, then pick which tasks to bring over with the agent.',items: 'issues and tasks',destination: 'Macro tasks',providers: [@@ -90,7 +91,7 @@ export const IMPORT_CATEGORIES: Record<ImportCategory, ImportCategoryConfig> = {name: 'Linear',detail: 'Issues',icon: IconLinear as ImportIcon,- native: 'linear',+ ledger: 'linear',},{appSlug: 'jira',@@ -109,6 +110,8 @@ export const IMPORT_CATEGORIES: Record<ImportCategory, ImportCategoryConfig> = {name: 'GitHub',detail: 'Issues',icon: IconGithub as ImportIcon,+ // Macro's GitHub preset in `QUICK_CONNECT_SERVERS`.+ mcpUrl: 'https://api.githubcopilot.com/mcp',},{appSlug: 'trello',@@ -130,7 +133,7 @@ export const IMPORT_CATEGORIES: Record<ImportCategory, ImportCategoryConfig> = {pitch: 'Import companies and contacts from HubSpot, Salesforce, and more.',action: 'Import customers',dialogDescription:- 'Connect an app, then bring its companies and contacts into your CRM.',+ 'Connect an app, and the agent brings its companies and contacts into your CRM.',items: 'companies and contacts',destination: 'the Macro CRM',providers: [@@ -167,7 +170,7 @@ export const IMPORT_CATEGORIES: Record<ImportCategory, ImportCategoryConfig> = {'Import Slack channels and members, with or without message history.',action: 'Import from Slack',dialogDescription:- 'Connect Slack to pick channels, or upload an export to bring history.',+ 'Connect Slack to pick channels with the agent, or upload an export to bring history.',items: 'channels',destination: 'Macro channels',providers: [@@ -176,7 +179,7 @@ export const IMPORT_CATEGORIES: Record<ImportCategory, ImportCategoryConfig> = {name: 'Slack',detail: 'Channels',icon: IconSlack as ImportIcon,- native: 'slack',+ ledger: 'slack',},],},diff --git a/apps/web/src/features/connector-import/core/import-items.test.ts b/apps/web/src/features/connector-import/core/import-items.test.tsdeleted file mode 100644index da94507ef1..0000000000--- a/apps/web/src/features/connector-import/core/import-items.test.ts+++ /dev/null@@ -1,79 +0,0 @@-import { describe, expect, it } from 'vitest';-import { importEntity, importRunState } from '../tests/fake-context';-import { importItems, needsDiscovery, toImportItem } from './import-items';--describe('import items', () => {- it('labels Linear issues by identifier and status', () => {- expect(- toImportItem(- importEntity({- id: 'a',- source: 'linear',- metadata: { identifier: 'ENG-1', title: 'Fix it', status: 'Todo' },- })- )- ).toMatchObject({ title: 'Fix it', detail: 'ENG-1 · Todo' });- });-- it('labels Notion pages by summary and links imported entities', () => {- expect(- toImportItem(- importEntity({- id: 'b',- source: 'notion',- status: 'imported',- metadata: { title: 'Plan', summary: 'Q4 goals' },- entity_id: 'doc-1',- entity_type: 'md',- })- )- ).toMatchObject({- title: 'Plan',- detail: 'Q4 goals',- entity: { id: 'doc-1', type: 'md' },- });- });-- it('labels Slack channels with a hash, purpose, and member count', () => {- expect(- toImportItem(- importEntity({- id: 'c',- source: 'slack',- metadata: { name: 'eng', purpose: 'Builds', member_count: 4 },- })- )- ).toMatchObject({ title: '#eng', detail: 'Builds · 4 members' });- });-- it('keeps one source, drops discarded rows, and lists staged first', () => {- const items = importItems(- {- runs: [],- entities: [- importEntity({ id: 'done', source: 'notion', status: 'imported' }),- importEntity({ id: 'gone', source: 'notion', status: 'discarded' }),- importEntity({ id: 'other', source: 'linear' }),- importEntity({ id: 'new', source: 'notion' }),- ],- },- 'notion'- );- expect(items.map((item) => item.id)).toEqual(['new', 'done']);- });-- it('discovers only when nothing is staged or running', () => {- const staged = [{ id: 'a', title: 'A', status: 'staged' as const }];- expect(needsDiscovery(undefined, [])).toBe(true);- expect(needsDiscovery(undefined, staged)).toBe(false);- expect(- needsDiscovery(- importRunState({ source: 'notion', status: 'running' }),- []- )- ).toBe(false);- expect(- needsDiscovery(importRunState({ source: 'notion', status: 'failed' }), [])- ).toBe(true);- });-});diff --git a/apps/web/src/features/connector-import/core/import-items.ts b/apps/web/src/features/connector-import/core/import-items.tsdeleted file mode 100644index 32782c7943..0000000000--- a/apps/web/src/features/connector-import/core/import-items.ts+++ /dev/null@@ -1,94 +0,0 @@-import type {- ImportEntity,- ImportEntityStatus,- ImportRun,- ImportSource,- ImportState,-} from '@service-cognition/import';-import { match } from 'ts-pattern';--/** One discovered item, as the native import list shows it. */-export type ImportItem = {- id: string;- title: string;- /** A secondary line: a Linear identifier and status, a Notion summary. */- detail?: string;- status: Exclude<ImportEntityStatus, 'discarded'>;- /** The created Macro entity, once imported. */- entity?: { id: string; type: string };- error?: string;-};--function text(value: unknown): string | undefined {- return typeof value === 'string' && value.trim() ? value.trim() : undefined;-}--export function toImportItem(entity: ImportEntity): ImportItem | undefined {- if (entity.status === 'discarded') return undefined;- const meta = entity.metadata;- const title =- entity.source === 'slack'- ? `#${text(meta.name)?.replace(/^#/, '') ?? entity.foreign_id}`- : (text(meta.title) ?? text(meta.name) ?? entity.foreign_id);- const detail = match(entity.source)- .with('linear', () =>- [text(meta.identifier), text(meta.status)].filter(Boolean).join(' · ')- )- .with('notion', () => text(meta.summary))- .with('slack', () =>- [- meta.archived === true ? 'Archived' : undefined,- text(meta.purpose),- typeof meta.member_count === 'number'- ? `${meta.member_count} members`- : undefined,- ]- .filter(Boolean)- .join(' · ')- )- .exhaustive();- return {- id: entity.id,- title,- detail: detail || undefined,- status: entity.status,- entity:- entity.entity_id && entity.entity_type- ? { id: entity.entity_id, type: entity.entity_type }- : undefined,- error: entity.last_error ?? undefined,- };-}--const STATUS_ORDER: Record<ImportItem['status'], number> = {- staged: 0,- importing: 1,- imported: 2,-};--/** One source's items: staged first (selectable), then in-flight and done. */-export function importItems(- state: ImportState,- source: ImportSource-): ImportItem[] {- return state.entities- .filter((entity) => entity.source === source)- .flatMap((entity) => toImportItem(entity) ?? [])- .sort((a, b) => STATUS_ORDER[a.status] - STATUS_ORDER[b.status]);-}--export function importRun(- state: ImportState,- source: ImportSource-): ImportRun | undefined {- return state.runs.find((run) => run.source === source);-}--/** Whether opening a source should start finding items to import. */-export function needsDiscovery(- run: ImportRun | undefined,- items: readonly ImportItem[]-): boolean {- if (run?.status === 'running' || run?.status === 'importing') return false;- return !items.some((item) => item.status === 'staged');-}diff --git a/apps/web/src/features/connector-import/core/providers.ts b/apps/web/src/features/connector-import/core/providers.tsindex 9b3041a49c..66430b1e05 100644--- a/apps/web/src/features/connector-import/core/providers.ts+++ b/apps/web/src/features/connector-import/core/providers.ts@@ -7,17 +7,22 @@ export type ImportIcon = Component<JSX.SvgSVGAttributes<SVGSVGElement>>;export type ImportCategory = 'files' | 'tasks' | 'crm' | 'channels';export type ImportProvider = {- /** Pipedream app slug the provider connects through. */+ /** Pipedream app slug; also keys the provider's connection state. */appSlug: string;name: string;/** What comes over, in a few words. */detail: string;icon: ImportIcon;/**- * The import pipeline source that discovers and copies items without an- * agent. Providers without one hand off to an agent chat once connected.+ * Macro's native MCP server for the app, connected with Macro's own OAuth+ * instead of Pipedream. Agents prefer it over a Pipedream connection.*/- native?: ImportSource;+ mcpUrl?: string;+ /**+ * The import ledger source the agent records copies under, so the user+ * and teammates are never handed a duplicate.+ */+ ledger?: ImportSource;};type ImportCategoryCopy = {diff --git a/apps/web/src/features/connector-import/tests/fake-context.ts b/apps/web/src/features/connector-import/tests/fake-context.tsindex 2766485e4b..417fdf08fb 100644--- a/apps/web/src/features/connector-import/tests/fake-context.ts+++ b/apps/web/src/features/connector-import/tests/fake-context.ts@@ -1,8 +1,3 @@-import type {- ImportEntity,- ImportRun,- ImportState,-} from '@service-cognition/import';import { createSignal } from 'solid-js';import { vi } from 'vitest';import type {@@ -10,61 +5,24 @@ import type {ConnectorImportContext,} from '../context/contracts';-export function importEntity(- overrides: Partial<ImportEntity> & Pick<ImportEntity, 'id' | 'source'>-): ImportEntity {- return {- user_id: 'user',- foreign_id: overrides.id,- status: 'staged',- initiator: 'manual',- metadata: {},- created_at: '2026-10-12T00:00:00Z',- updated_at: '2026-10-12T00:00:00Z',- ...overrides,- };-}--export function importRunState(- overrides: Partial<ImportRun> & Pick<ImportRun, 'source'>-): ImportRun {- return {- status: 'ready',- auto_import: false,- updated_at: '2026-10-12T00:00:00Z',- ...overrides,- };-}--/** An in-memory context whose server state tests drive directly. */+/** An in-memory context whose connections tests drive directly. */export function fakeConnectorImport(options?: { connected?: string[] }) {const [connected, setConnected] = createSignal<ReadonlySet<string>>(new Set(options?.connected));- const [state, setState] = createSignal<ImportState>({- runs: [],- entities: [],- });- const [ready, setReady] = createSignal(true);let connectOutcome: ConnectOutcome = 'connected';const context = {createConnections: () => ({ connected, ready: () => true }),- createImportState: () => ({ state, ready }),connect: vi.fn(async (app: { appSlug: string }) => {if (connectOutcome === 'connected')setConnected((previous) => new Set([...previous, app.appSlug]));return connectOutcome;}),- discover: vi.fn(async () => {}),- runImport: vi.fn(async () => {}),startAgentImport: vi.fn(async () => {}),- entityHref: (entity: { id: string; type: string }) =>- `/app/${entity.type}/${entity.id}`,} satisfies ConnectorImportContext;return {context,- setState,- setReady,+ setConnected,setConnectOutcome(outcome: ConnectOutcome) {connectOutcome = outcome;},diff --git a/apps/web/src/features/connector-import/views/import-dialog.test.tsx b/apps/web/src/features/connector-import/views/import-dialog.test.tsxindex e82cc789c4..04a7e56a26 100644--- a/apps/web/src/features/connector-import/views/import-dialog.test.tsx+++ b/apps/web/src/features/connector-import/views/import-dialog.test.tsx@@ -10,11 +10,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { ConnectorImportProvider } from '../context/connector-import-context';import { IMPORT_CATEGORIES } from '../core/catalog';import type { ImportCategory } from '../core/providers';-import {- fakeConnectorImport,- importEntity,- importRunState,-} from '../tests/fake-context';+import { fakeConnectorImport } from '../tests/fake-context';import { ConnectorImportDialog } from './import-dialog';vi.mock('@core/mobile/isMobile', () => ({ isMobile: () => false }));@@ -47,14 +43,12 @@ function setup() {const fake = fakeConnectorImport(options);const [open, setOpen] = createSignal(true);- const onImported = vi.fn();render(() => (<ConnectorImportProvider context={fake.context}><ConnectorImportDialogconfig={IMPORT_CATEGORIES[category]}open={open()}onOpenChange={setOpen}- onImported={onImported}alternatives={options?.alternative && [{@@ -68,7 +62,7 @@ function setup(/></ConnectorImportProvider>));- return { ...fake, open, onImported };+ return { ...fake, open };}describe('connector import dialog', () => {@@ -90,7 +84,7 @@ describe('connector import dialog', () => {const { context, open } = setup('tasks');fireEvent.click(screen.getByRole('button', { name: 'Connect Jira' }));expect(context.connect).toHaveBeenCalledWith(- { appSlug: 'jira', name: 'Jira' },+ { appSlug: 'jira', name: 'Jira', mcpUrl: undefined },expect.anything());const importButton = await screen.findByRole('button', {@@ -120,100 +114,40 @@ describe('connector import dialog', () => {);});- it('discovers, imports selected native items, and reports confirmed imports', async () => {- const { context, setState, onImported } = setup('files', {- connected: ['notion'],- });+ it("hands a ledger source to the agent too, with Macro's importer", async () => {+ const { context, open } = setup('files', { connected: ['notion'] });fireEvent.click(screen.getByRole('button', { name: 'Import from Notion' }));- expect(screen.getByText('Import from Notion')).toBeTruthy();- await waitFor(() =>- expect(context.discover).toHaveBeenCalledWith('notion')+ await waitFor(() => expect(open()).toBe(false));+ expect(context.startAgentImport).toHaveBeenCalledWith(+ expect.objectContaining({+ input:+ 'Import my most recent documents and files from Notion into my Macro Drive.',+ instructions: expect.stringContaining('ImportNotionPage'),+ }));-- setState({- runs: [importRunState({ source: 'notion', status: 'running' })],- entities: [],- });- expect(- screen.getByText(/Finding your recent pages and wikis/)- ).toBeTruthy();-- setState({- runs: [importRunState({ source: 'notion' })],- entities: [- importEntity({- id: 'a',- source: 'notion',- metadata: { title: 'Plan' },- }),- importEntity({- id: 'b',- source: 'notion',- metadata: { title: 'Notes' },- }),- ],- });- fireEvent.click(screen.getByRole('checkbox', { name: 'Select Plan' }));- fireEvent.click(screen.getByRole('button', { name: 'Import 1' }));- await waitFor(() => expect(context.runImport).toHaveBeenCalledWith(['a']));- expect(onImported).not.toHaveBeenCalled();-- setState({- runs: [importRunState({ source: 'notion' })],- entities: [- importEntity({- id: 'a',- source: 'notion',- status: 'imported',- metadata: { title: 'Plan' },- entity_id: 'doc-1',- entity_type: 'md',- }),- importEntity({- id: 'b',- source: 'notion',- metadata: { title: 'Notes' },- }),- ],- });- expect(- screen- .getByRole('link', { name: 'Open imported Plan' })- .getAttribute('href')- ).toBe('/app/md/doc-1');- expect(onImported).toHaveBeenCalled();- expect(context.discover).toHaveBeenCalledTimes(1);});- it('does not rediscover when items are already staged', async () => {- const fake = fakeConnectorImport({ connected: ['linear'] });- fake.setState({- runs: [importRunState({ source: 'linear' })],- entities: [- importEntity({- id: 'x',- source: 'linear',- metadata: { identifier: 'ENG-7', title: 'Ship it' },- }),- ],- });- render(() => (- <ConnectorImportProvider context={fake.context}>- <ConnectorImportDialog- config={IMPORT_CATEGORIES.tasks}- open- onOpenChange={() => {}}- onImported={() => {}}- />- </ConnectorImportProvider>- ));- fireEvent.click(screen.getByRole('button', { name: 'Import from Linear' }));- expect(await screen.findByText('Ship it')).toBeTruthy();- expect(screen.getByText('ENG-7')).toBeTruthy();- expect(fake.context.discover).not.toHaveBeenCalled();- fireEvent.click(screen.getByRole('button', { name: 'Back to apps' }));+ it('connects GitHub through its native MCP server, not Pipedream', async () => {+ const fake = setup('tasks');+ fake.setConnectOutcome('started');+ fireEvent.click(screen.getByRole('button', { name: 'Connect GitHub' }));+ expect(fake.context.connect).toHaveBeenCalledWith(+ {+ appSlug: 'github',+ name: 'GitHub',+ mcpUrl: 'https://api.githubcopilot.com/mcp',+ },+ expect.anything()+ );+ // Authorization finishes in another tab; the row waits for the result.+ await waitFor(() =>+ expect(+ screen.getByRole('button', { name: 'Connect GitHub' })+ ).toHaveProperty('disabled', false)+ );+ fake.setConnected(new Set(['github']));expect(- screen.getByRole('button', { name: 'Import from Linear' })+ await screen.findByRole('button', { name: 'Import from GitHub' })).toBeTruthy();});diff --git a/apps/web/src/features/connector-import/views/import-dialog.tsx b/apps/web/src/features/connector-import/views/import-dialog.tsxindex dc28fa78db..e0ec615b83 100644--- a/apps/web/src/features/connector-import/views/import-dialog.tsx+++ b/apps/web/src/features/connector-import/views/import-dialog.tsx@@ -2,7 +2,6 @@ import { LogoStack } from '@app/features/sidebar-promotion/components/logo-stackimport { toast } from '@core/component/Toast/Toast';import { fireAndForget } from '@core/util/fireAndForget';import CaretRightIcon from '@phosphor/caret-right.svg';-import type { ImportSource } from '@service-cognition/import';import { ActionDialogShell, Dialog } from '@ui';import { createSignal, For, type JSX, Show } from 'solid-js';import { Dynamic } from 'solid-js/web';@@ -11,7 +10,6 @@ import { SecurityNote } from '../components/security-note';import { useConnectorImport } from '../context/connector-import-context';import { agentImportHandoff } from '../core/agent-handoff';import type { ImportCategoryConfig, ImportProvider } from '../core/providers';-import { NativeImportPane } from './native-import-pane';/** Another way in that does not go through a connector, e.g. a CSV upload. */export type ImportAlternative = {@@ -22,12 +20,6 @@ export type ImportAlternative = {onSelect(opener?: HTMLButtonElement): void;};-type NativeProvider = ImportProvider & { native: ImportSource };--function isNative(provider: ImportProvider): provider is NativeProvider {- return provider.native !== undefined;-}-export function ConnectorImportDialog(props: {config: ImportCategoryConfig;open: boolean;@@ -36,7 +28,6 @@ export function ConnectorImportDialog(props: {opener?: HTMLElement;/** Ways in that skip connectors, e.g. a CSV or local upload. */alternatives?: readonly ImportAlternative[];- onImported(): void;}): JSX.Element {let content: HTMLDivElement | undefined;return (@@ -60,7 +51,6 @@ export function ConnectorImportDialog(props: {container={() => content}alternatives={props.alternatives}onClose={() => props.onOpenChange(false)}- onImported={props.onImported}/></Show></Dialog>@@ -73,13 +63,11 @@ function ImportDialogBody(props: {/** Ways in that skip connectors, e.g. a CSV or local upload. */alternatives?: readonly ImportAlternative[];onClose(): void;- onImported(): void;}): JSX.Element {const context = useConnectorImport();const connections = context.createConnections();const [connecting, setConnecting] = createSignal<string>();const [handingOff, setHandingOff] = createSignal(false);- const [picking, setPicking] = createSignal<NativeProvider>();function rowState(provider: ImportProvider): ProviderRowState {if (connecting() === provider.appSlug) return 'connecting';@@ -94,13 +82,15 @@ function ImportDialogBody(props: {setConnecting(provider.appSlug);try {const outcome = await context.connect(- { appSlug: provider.appSlug, name: provider.name },+ {+ appSlug: provider.appSlug,+ name: provider.name,+ mcpUrl: provider.mcpUrl,+ },props.container());if (outcome === 'unsupported') {toast.failure('Connectors are not available on this deployment');- } else if (outcome === 'connected' && isNative(provider)) {- setPicking(provider);}} catch {toast.failure(`Couldn't connect ${provider.name}`);@@ -109,11 +99,8 @@ function ImportDialogBody(props: {}}+ // Every import runs in an agent chat that opens in a split beside the view.async function startImport(provider: ImportProvider) {- if (isNative(provider)) {- setPicking(provider);- return;- }if (handingOff()) return;setHandingOff(true);try {@@ -126,108 +113,90 @@ function ImportDialogBody(props: {}}- // A stable element: swapping panes at the root of Dialog content left the- // previous pane mounted beside the next one.return (+ // The `contents` wrapper hides this shell from Dialog's surface reset.<div class="contents">- <Show- when={picking()}- fallback={- // The `contents` wrapper hides this shell from Dialog's surface reset.- <ActionDialogShell- hideBorder- class="max-h-[85dvh] rounded-[24px] bg-transparent"+ <ActionDialogShell+ hideBorder+ class="max-h-[85dvh] rounded-[24px] bg-transparent"+ >+ <ActionDialogShell.Body class="space-y-4">+ <ActionDialogShell.Header>+ <LogoStack+ logos={props.config.providers}+ class="mb-3 [--logo-stack-separator:var(--color-dialog)]"+ />+ <ActionDialogShell.Title>+ {props.config.action}+ </ActionDialogShell.Title>+ <ActionDialogShell.Description>+ {props.config.dialogDescription}+ </ActionDialogShell.Description>+ </ActionDialogShell.Header>+ <ul+ class="rounded-2xl bg-ink/3 px-3 py-1"+ aria-label={`Apps to ${props.config.action.toLowerCase()} from`}>- <ActionDialogShell.Body class="space-y-4">- <ActionDialogShell.Header>- <LogoStack- logos={props.config.providers}- class="mb-3 [--logo-stack-separator:var(--color-dialog)]"+ <For each={props.config.providers}>+ {(provider) => (+ <ProviderRow+ provider={provider}+ state={rowState(provider)}+ disabled={+ handingOff() ||+ (connecting() !== undefined &&+ connecting() !== provider.appSlug)+ }+ onConnect={() =>+ fireAndForget(connect(provider), 'connector-import.connect')+ }+ onImport={() =>+ fireAndForget(+ startImport(provider),+ 'connector-import.start'+ )+ }/>- <ActionDialogShell.Title>- {props.config.action}- </ActionDialogShell.Title>- <ActionDialogShell.Description>- {props.config.dialogDescription}- </ActionDialogShell.Description>- </ActionDialogShell.Header>- <ul- class="rounded-2xl bg-ink/3 px-3 py-1"- aria-label={`Apps to ${props.config.action.toLowerCase()} from`}- >- <For each={props.config.providers}>- {(provider) => (- <ProviderRow- provider={provider}- state={rowState(provider)}- disabled={- handingOff() ||- (connecting() !== undefined &&- connecting() !== provider.appSlug)- }- onConnect={() =>- fireAndForget(- connect(provider),- 'connector-import.connect'- )- }- onImport={() =>- fireAndForget(- startImport(provider),- 'connector-import.start'- )- }+ )}+ </For>+ </ul>+ <Show when={props.alternatives?.length}>+ <div class="flex flex-col gap-2">+ <For each={props.alternatives}>+ {(alternative) => (+ <button+ type="button"+ class="flex w-full items-center gap-3 rounded-2xl bg-ink/3 px-3 py-3 text-left hover:bg-ink/5 focus-visible:outline-accent"+ onClick={() => {+ props.onClose();+ alternative.onSelect();+ }}+ >+ <Dynamic+ component={alternative.icon}+ class="size-5 shrink-0 text-ink-muted"+ aria-hidden="true"/>- )}- </For>- </ul>- <Show when={props.alternatives?.length}>- <div class="flex flex-col gap-2">- <For each={props.alternatives}>- {(alternative) => (- <button- type="button"- class="flex w-full items-center gap-3 rounded-2xl bg-ink/3 px-3 py-3 text-left hover:bg-ink/5 focus-visible:outline-accent"- onClick={() => {- props.onClose();- alternative.onSelect();- }}- >- <Dynamic- component={alternative.icon}- class="size-5 shrink-0 text-ink-muted"- aria-hidden="true"- />- <span class="min-w-0 flex-1">- <span class="block text-sm font-medium text-ink">- {alternative.label}- </span>- <span class="block text-xs text-ink-muted">- {alternative.description}- </span>- </span>- <CaretRightIcon- class="size-4 text-ink-extra-muted"- aria-hidden="true"- />- </button>- )}- </For>- </div>- </Show>- <SecurityNote />- </ActionDialogShell.Body>- </ActionDialogShell>- }- >- {(provider) => (- <NativeImportPane- provider={provider()}- onBack={() => setPicking(undefined)}- onImported={props.onImported}- />- )}- </Show>+ <span class="min-w-0 flex-1">+ <span class="block text-sm font-medium text-ink">+ {alternative.label}+ </span>+ <span class="block text-xs text-ink-muted">+ {alternative.description}+ </span>+ </span>+ <CaretRightIcon+ class="size-4 text-ink-extra-muted"+ aria-hidden="true"+ />+ </button>+ )}+ </For>+ </div>+ </Show>+ <SecurityNote />+ </ActionDialogShell.Body>+ </ActionDialogShell></div>);}diff --git a/apps/web/src/features/connector-import/views/native-import-pane.tsx b/apps/web/src/features/connector-import/views/native-import-pane.tsxdeleted file mode 100644index 88f65123ea..0000000000--- a/apps/web/src/features/connector-import/views/native-import-pane.tsx+++ /dev/null@@ -1,257 +0,0 @@-import { SearchBar } from '@app/components/view-shell';-import { toast } from '@core/component/Toast/Toast';-import { fireAndForget } from '@core/util/fireAndForget';-import ArrowLeftIcon from '@phosphor/arrow-left.svg';-import SpinnerIcon from '@phosphor/spinner-gap.svg';-import WarningIcon from '@phosphor/warning-circle.svg';-import type { ImportSource } from '@service-cognition/import';-import { ActionDialogShell, Button } from '@ui';-import {- createEffect,- createMemo,- createSignal,- type JSX,- Match,- on,- Show,- Switch,-} from 'solid-js';-import { ImportItemList } from '../components/import-item-list';-import { SecurityNote } from '../components/security-note';-import { useConnectorImport } from '../context/connector-import-context';-import { importItems, importRun, needsDiscovery } from '../core/import-items';-import type { ImportProvider } from '../core/providers';--const FILTER_THRESHOLD = 8;--/**- * Pick-and-import for a provider the import pipeline copies natively:- * discovery stages candidates, the user selects, accepted rows import live.- */-export function NativeImportPane(props: {- provider: ImportProvider & { native: ImportSource };- onBack(): void;- /** A row this pane submitted finished importing. */- onImported(): void;-}): JSX.Element {- const context = useConnectorImport();- const importState = context.createImportState();- const source = () => props.provider.native;- const run = () => importRun(importState.state(), source());- const items = createMemo(() => importItems(importState.state(), source()));- const [filter, setFilter] = createSignal('');- // Slack discovery lists every visible channel; long lists get a filter.- const filterable = () => items().length > FILTER_THRESHOLD;- const visible = createMemo(() => {- const query = filter().trim().toLowerCase();- if (!query) return items();- return items().filter((item) =>- `${item.title} ${item.detail ?? ''}`.toLowerCase().includes(query)- );- });- const staged = () => visible().filter((item) => item.status === 'staged');- const [selected, setSelected] = createSignal<ReadonlySet<string>>(new Set());- const [submitted, setSubmitted] = createSignal<ReadonlySet<string>>(- new Set()- );- const [discovering, setDiscovering] = createSignal(false);- const [importing, setImporting] = createSignal(false);- const searching = () => discovering() || run()?.status === 'running' || false;- // Status changes can make a selected row no longer importable.- // Selections stay importable while the filter hides them.- const importIds = () =>- items()- .filter((item) => item.status === 'staged' && selected().has(item.id))- .map((item) => item.id);- const allSelected = () =>- staged().length > 0 && staged().every((item) => selected().has(item.id));-- async function discover() {- if (searching()) return;- setDiscovering(true);- try {- await context.discover(source());- } catch {- toast.failure(`Couldn't search ${props.provider.name}`);- } finally {- setDiscovering(false);- }- }-- async function runImport() {- const ids = importIds();- if (!ids.length || importing()) return;- setImporting(true);- try {- await context.runImport(ids);- setSubmitted((previous) => new Set([...previous, ...ids]));- setSelected(new Set<string>());- } catch {- toast.failure(`Couldn't import from ${props.provider.name}`);- } finally {- setImporting(false);- }- }-- // Search once the real state is known, unless there is already a list.- createEffect(- on(- importState.ready,- (ready) => {- if (ready && needsDiscovery(run(), items()))- fireAndForget(discover(), 'connector-import.discover');- },- { defer: false }- )- );-- // The run mutation only queues work; wait for a server-confirmed import.- createEffect(() => {- if (- items().some(- (item) => item.status === 'imported' && submitted().has(item.id)- )- ) {- props.onImported();- }- });-- function select(id: string, checked: boolean) {- setSelected((previous) => {- const next = new Set(previous);- if (checked) next.add(id);- else next.delete(id);- return next;- });- }-- return (- // Inside the dialog's `contents` wrapper, out of reach of its surface reset.- <ActionDialogShell- hideBorder- class="max-h-[85dvh] rounded-[24px] bg-transparent"- >- <ActionDialogShell.Body class="space-y-4">- <ActionDialogShell.Header>- <div class="flex items-center gap-2">- <Button- variant="ghost"- size="icon-sm"- aria-label="Back to apps"- onClick={() => props.onBack()}- >- <ArrowLeftIcon aria-hidden="true" />- </Button>- <ActionDialogShell.Title>- Import from {props.provider.name}- </ActionDialogShell.Title>- </div>- <ActionDialogShell.Description>- Pick what to copy into Macro. Copies don't sync back to{' '}- {props.provider.name}.- </ActionDialogShell.Description>- </ActionDialogShell.Header>-- <Switch>- <Match when={run()?.status === 'failed' && !searching()}>- <div- class="flex items-start gap-2 rounded-2xl bg-ink/3 p-3 text-sm text-ink-muted"- role="alert"- >- <WarningIcon- class="mt-0.5 size-4 shrink-0 text-failure"- aria-hidden="true"- />- <span>- {run()?.error ?? `Couldn't search ${props.provider.name}.`}- </span>- </div>- </Match>- <Match when={searching() && !items().length}>- <p- class="flex items-center gap-2 py-6 text-sm text-ink-muted"- role="status"- >- <SpinnerIcon class="size-4 animate-spin" aria-hidden="true" />- Finding your recent {props.provider.detail.toLowerCase()} in{' '}- {props.provider.name}…- </p>- </Match>- <Match when={!items().length && importState.ready()}>- <p class="py-6 text-sm text-ink-muted">- Nothing new to import from {props.provider.name}.- </p>- </Match>- </Switch>-- <Show when={items().length}>- <Show when={filterable()}>- <SearchBar- label={`Filter ${props.provider.detail.toLowerCase()}`}- placeholder={`Filter ${props.provider.detail.toLowerCase()}`}- value={filter()}- onValueChange={setFilter}- />- </Show>- <Show when={staged().length > 1}>- <Button- variant="ghost"- size="xs"- disabled={importing()}- onClick={() => {- // Only the rows the filter shows; hidden selections stay.- const shown = staged().map((item) => item.id);- const clear = allSelected();- setSelected((previous) => {- const next = new Set(previous);- for (const id of shown) {- if (clear) next.delete(id);- else next.add(id);- }- return next;- });- }}- >- {allSelected() ? 'Clear selection' : 'Select all'}- </Button>- </Show>- <ImportItemList- items={visible()}- selected={selected()}- disabled={importing()}- onSelect={select}- href={context.entityHref}- />- <Show when={searching()}>- <p- class="flex items-center gap-2 text-xs text-ink-muted"- role="status"- >- <SpinnerIcon class="size-3 animate-spin" aria-hidden="true" />- Looking for more…- </p>- </Show>- </Show>- <SecurityNote />- </ActionDialogShell.Body>- <ActionDialogShell.Footer class="border-t-0">- <Button- variant="ghost"- depth={2}- disabled={searching() || importing()}- onClick={() => fireAndForget(discover(), 'connector-import.discover')}- >- Search again- </Button>- <Button- variant="strong"- depth={2}- disabled={!importIds().length || importing()}- onClick={() => fireAndForget(runImport(), 'connector-import.import')}- >- {importIds().length ? `Import ${importIds().length}` : 'Import'}- </Button>- </ActionDialogShell.Footer>- </ActionDialogShell>- );-}diff --git a/docs/agent-guide/channels.md b/docs/agent-guide/channels.mdindex 09017ada5d..dd62c6338f 100644--- a/docs/agent-guide/channels.md+++ b/docs/agent-guide/channels.md@@ -125,17 +125,17 @@ internal rollout. Model usage continues through the existing session metering.Import starts from the **Import from Slack** card at the bottom of the Chatsidebar, or **Settings → Team → Connections → Import from Slack**. The card isthe shared connector-import card (see-[Import from connected apps](surfaces.md#import-from-connected-apps)) and is+[Import from connected apps](setup-cards.md#import-from-connected-apps)) and isvisible to team admins and owners when Slack archive import is enabled. Itopens the shared import dialog: a **Slack** row connects through Pipedream,-then discovers channels for a filterable pick list (**Import N**), and-**Import with history** closes it and opens the archive upload below. Without+then **Import from Slack** hands channel picking to an agent chat in a split,+and **Import with history** closes it and opens the archive upload below. Withoutan available Slack connector (Slack's Pipedream app is dev-only), the card opensthe archive upload directly. **Dismiss import from slack** hides the card forthat user on every device (see-[Dismissing cards](surfaces.md#dismissing-cards)); successful archive imports (including partial-imports with a completed channel) and server-confirmed channel imports also-hide it. Failed or cancelled imports do not. Dismissing or completing an import+[Dismissing cards](setup-cards.md#dismissing-cards)); successful archive imports (including partial+imports with a completed channel) and Settings channel imports also hide+it. Failed or cancelled imports do not. Dismissing or completing an importkeeps the Settings entry available; completion does not close an open progressdialog. Closing the archive dialog returns focus to the card's button when itis still visible.diff --git a/docs/agent-guide/setup-cards.md b/docs/agent-guide/setup-cards.mdindex 3936e25dfc..cbeb942af1 100644--- a/docs/agent-guide/setup-cards.md+++ b/docs/agent-guide/setup-cards.md@@ -8,37 +8,31 @@ Chat sidebar's Slack card is the same component under the Slack import gates;see [channels](channels.md#imported-slack-history)):overlapping provider logos, a two-line pitch, and **Import files**, **Importtasks**, or **Import customers**. Customers shows it only to team members.-**Dismiss import files** (or tasks, customers) hides that card for good; a-server-confirmed native import also hides it. See+**Dismiss import files** (or tasks, customers) hides that card for good. See[Dismissing cards](#dismissing-cards).The button opens a dialog listing that category's apps (Files: Notion, GoogleDrive, Dropbox, OneDrive, Box, Confluence; Tasks: Linear, Jira, Asana, GitHub,Trello, monday.com; Customers: HubSpot, Salesforce, Close, Airtable). A-disconnected row offers **Connect** (`Connect <App>`), which opens Pipedream's-Connect UI inside the dialog. A connected row shows a check and **Import**-(`Import from <App>`).+disconnected row offers **Connect** (`Connect <App>`). GitHub connects through+Macro's native GitHub MCP server (`api.githubcopilot.com/mcp`): authorization+opens in a new tab, and the row flips to connected when the app regains focus.+Every other app opens Pipedream's Connect UI inside the dialog. A connected row+(native MCP or Pipedream) shows a check and **Import** (`Import from <App>`).-- **Notion**, **Linear**, and **Slack** import natively. Connecting one opens- **Import from <App>** and starts discovery- (`POST /import/runs/<source>/discover`) unless rows are already staged: a- gather agent stages recent pages or issues, and Slack discovery stages every- visible public channel. Click a title to select it, then **Import N**. Lists- longer than eight rows get a filter; selections hidden by the filter still- import. Rows spin while importing and then link to the created document,- task, or channel. **Search again** rediscovers; **Back to apps** returns to- the list.-- Every other app is labelled "with the agent". **Import** closes the dialog- and opens an agent chat with an unsent prompt such as "Import my most recent+- Every **Import** closes the dialog and opens an agent chat in a split beside+ the current view, with an unsent prompt such as "Import my most recentissues and tasks from Jira into Macro tasks.". Private instructions tell theagent to list candidates and ask before creating anything, and never to- write to the source.+ write to the source. Notion pages import through `ImportNotionPage`; Linear+ and Slack items are checked against and recorded in the import ledger+ (`ListImportEntities`, `CreateImportEntity`) so nothing imports twice.- Files also offers **Upload files** and **Upload a folder** (Drive's ownuploads), and Customers offers **Upload a CSV** (the existing CSV import).Each closes the dialog first.-`src/features/connector-import/browser-test/` exercises both paths without a-backend.+`src/features/connector-import/browser-test/` exercises the connect and+handoff paths without a backend.## Sidebar setup cardsdiff --git a/docs/agent-guide/tasks.md b/docs/agent-guide/tasks.mdindex 7fa63cab2c..1ed9c18c4d 100644--- a/docs/agent-guide/tasks.md+++ b/docs/agent-guide/tasks.md@@ -552,7 +552,7 @@ also show up in Files/`All` and in AI-chat document listings.To bring tasks over from Linear, Jira, Asana, and other apps, use the **Importtasks** card at the bottom of the Tasks sidebar; see-[Import from connected apps](surfaces.md#import-from-connected-apps).+[Import from connected apps](setup-cards.md#import-from-connected-apps).## Projectsdiff --git a/docs/runbooks/media/connector-import/README.md b/docs/runbooks/media/connector-import/README.mdindex 12b454ae6d..f50f8a7c26 100644--- a/docs/runbooks/media/connector-import/README.md+++ b/docs/runbooks/media/connector-import/README.md@@ -1,17 +1,17 @@# Connector import review mediaCaptured from `apps/web/src/features/connector-import/browser-test/import.html`,-which renders the real card and dialog over an in-memory import pipeline.+which renders the real card and dialog over in-memory connections.- [Sidebar cards, light](cards-light.jpg) and [dark](cards-dark.jpg): Drive,Tasks, Customers, and Chat (Slack) cards with overlapping provider logos.-- [Import files dialog](dialog-light.jpg): Notion imports natively; the other- apps connect through Pipedream and import with the agent. Dropbox is connected.-- [Notion pick list](notion-dark.jpg): discovered pages after connecting Notion.+- [Import files dialog](dialog-light.jpg): Dropbox is connected. Captured+ before every app imported with the agent, so Notion's row still reads as a+ native import.Live Pipedream authorization and agent imports are not shown: the hosted devconnection requires a signed-in account.- [Trailer](trailer.mp4): a 21-second walkthrough of the import cards, the Files- dialog, a Notion import, and the Home, Calendar, and Pull request setup cards.+ dialog, the retired in-dialog Notion pick list, and the Home, Calendar, and Pull request setup cards.Rendered from the same fixture captures.diff --git a/docs/runbooks/media/connector-import/notion-dark.jpg b/docs/runbooks/media/connector-import/notion-dark.jpgdeleted file mode 100644index 7f3013c90b..0000000000Binary files a/docs/runbooks/media/connector-import/notion-dark.jpg and /dev/null differ