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(settings): show the catalog logo on connected app rows (#9585)

Eric Hayesa090b9f6f5a2
diff --git a/apps/web/src/features/agents-view/views/ComposerAddMenu.test.tsx b/apps/web/src/features/agents-view/views/ComposerAddMenu.test.tsx
index 498a58ed22..9006b10758 100644
--- a/apps/web/src/features/agents-view/views/ComposerAddMenu.test.tsx
+++ b/apps/web/src/features/agents-view/views/ComposerAddMenu.test.tsx
@@ -60,6 +60,9 @@ vi.mock('../../settings/connections/integrations-view', () => ({
</p>
),
}));
+vi.mock('@core/pipedream/ConnectedAppIcon', () => ({
+ ConnectedAppIcon: () => <svg aria-hidden="true" />,
+}));
vi.mock('../../settings/connections/leftover-row', () => ({
LeftoverRow: (props: { leftover: Leftover }) => (
<p>
diff --git a/apps/web/src/features/agents-view/views/ComposerAddMenu.tsx b/apps/web/src/features/agents-view/views/ComposerAddMenu.tsx
index 64db0dd596..a111788021 100644
--- a/apps/web/src/features/agents-view/views/ComposerAddMenu.tsx
+++ b/apps/web/src/features/agents-view/views/ComposerAddMenu.tsx
@@ -6,7 +6,7 @@ import {
import { useSettingsState } from '@core/constant/SettingsState';
import { useSettingsTabAvailable } from '@core/constant/settingsTabsConfig';
import { isMobile } from '@core/mobile/isMobile';
-import { PipedreamConnectorIcon } from '@core/pipedream/ConnectorIcon';
+import { ConnectedAppIcon } from '@core/pipedream/ConnectedAppIcon';
import LightningIcon from '@icon/system/regular/lightning.svg';
import PlugsIcon from '@icon/system/regular/plugs.svg';
import PlusIcon from '@icon/system/regular/plus.svg';
@@ -111,7 +111,7 @@ export function AgentComposerAddMenu(props: {
: 'Disabled · Open settings',
icon:
connection.kind === 'pipedream' ? (
- <PipedreamConnectorIcon appSlug={connection.appSlug} />
+ <ConnectedAppIcon appSlug={connection.appSlug} />
) : (
<PlugsIcon />
),
diff --git a/apps/web/src/features/settings/Agents.test.tsx b/apps/web/src/features/settings/Agents.test.tsx
index ea102ff48c..b52d9c6a39 100644
--- a/apps/web/src/features/settings/Agents.test.tsx
+++ b/apps/web/src/features/settings/Agents.test.tsx
@@ -281,6 +281,10 @@ vi.mock('@queries/pipedream-connectors', () => ({
slugs: () => new Set(pipedreamMocks.connected),
ready: () => true,
}),
+ usePipedreamCatalogIconsQuery: () => ({
+ isPending: false,
+ data: new Map(),
+ }),
usePipedreamCatalogQuery: (search: () => string) => ({
get data() {
const term = search().trim().toLowerCase();
diff --git a/apps/web/src/features/settings/PipedreamAppPicker.tsx b/apps/web/src/features/settings/PipedreamAppPicker.tsx
index a310fc1bc1..6c193daa26 100644
--- a/apps/web/src/features/settings/PipedreamAppPicker.tsx
+++ b/apps/web/src/features/settings/PipedreamAppPicker.tsx
@@ -1,3 +1,4 @@
+import { ConnectedAppIcon } from '@core/pipedream/ConnectedAppIcon';
import { PipedreamConnectorIcon } from '@core/pipedream/ConnectorIcon';
import {
createPipedreamCatalogConnect,
@@ -219,12 +220,7 @@ function SelectedAppRow(props: {
return (
<IntegrationRow
class="px-3 py-2.5"
- icon={
- <PipedreamConnectorIcon
- appSlug={props.server.app_slug}
- class="size-5"
- />
- }
+ icon={<ConnectedAppIcon appSlug={props.server.app_slug} class="size-5" />}
title={props.server.server_name}
description={props.server.app_slug}
status={
diff --git a/apps/web/src/features/settings/connections/leftover-row.tsx b/apps/web/src/features/settings/connections/leftover-row.tsx
index 30818781fd..430f0dd843 100644
--- a/apps/web/src/features/settings/connections/leftover-row.tsx
+++ b/apps/web/src/features/settings/connections/leftover-row.tsx
@@ -1,5 +1,5 @@
import { toast } from '@core/component/Toast/Toast';
-import { PipedreamConnectorIcon } from '@core/pipedream/ConnectorIcon';
+import { ConnectedAppIcon } from '@core/pipedream/ConnectedAppIcon';
import { createPipedreamCatalogConnect } from '@core/pipedream/catalog';
import { fireAndForget } from '@core/util/fireAndForget';
import PlugIcon from '@icon/system/regular/plug.svg';
@@ -313,7 +313,7 @@ export function LeftoverRow(props: {
icon={
<Show when={props.overlaidAppSlug} fallback={<PlugIcon />}>
{(appSlug) => (
- <PipedreamConnectorIcon appSlug={appSlug()} class="size-5" />
+ <ConnectedAppIcon appSlug={appSlug()} class="size-5" />
)}
</Show>
}
@@ -336,9 +336,7 @@ export function LeftoverRow(props: {
))
.with({ kind: 'pipedream' }, (item) => (
<IntegrationListRow
- icon={
- <PipedreamConnectorIcon appSlug={item.appSlug} class="size-5" />
- }
+ icon={<ConnectedAppIcon appSlug={item.appSlug} class="size-5" />}
name={item.title}
kind="mcp"
description="Agents can use this app when you ask them to. Nothing is copied into Macro."
diff --git a/apps/web/src/lib/core/pipedream/ConnectedAppIcon.test.tsx b/apps/web/src/lib/core/pipedream/ConnectedAppIcon.test.tsx
new file mode 100644
index 0000000000..1208bc6bee
--- /dev/null
+++ b/apps/web/src/lib/core/pipedream/ConnectedAppIcon.test.tsx
@@ -0,0 +1,49 @@
+import { cleanup, render } from '@solidjs/testing-library';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { ConnectedAppIcon } from './ConnectedAppIcon';
+
+const iconUrl = 'https://connect.example/v1/catalog/airtable/icon.svg?v=abc';
+
+const catalog = vi.hoisted(() => ({ pending: false }));
+
+vi.mock('@queries/pipedream-connectors', () => ({
+ usePipedreamCatalogIconsQuery: () => ({
+ get isPending() {
+ return catalog.pending;
+ },
+ get data() {
+ if (catalog.pending) throw new Error('reading data would suspend');
+ return new Map([
+ ['airtable', iconUrl],
+ ['no_logo', null],
+ ]);
+ },
+ }),
+}));
+
+afterEach(() => {
+ cleanup();
+ catalog.pending = false;
+});
+
+describe('ConnectedAppIcon', () => {
+ it('shows the catalog logo for a connected app', () => {
+ const { container } = render(() => <ConnectedAppIcon appSlug="airtable" />);
+ expect(container.querySelector('img')?.getAttribute('src')).toContain(
+ encodeURIComponent(iconUrl)
+ );
+ });
+
+ it('keeps the fallback, without suspending, while the catalog loads', () => {
+ catalog.pending = true;
+ const { container } = render(() => <ConnectedAppIcon appSlug="airtable" />);
+ expect(container.querySelector('img')).toBeNull();
+ expect(container.querySelector('svg')).not.toBeNull();
+ });
+
+ it.each(['no_logo', 'not_in_catalog'])('falls back for %s', (appSlug) => {
+ const { container } = render(() => <ConnectedAppIcon appSlug={appSlug} />);
+ expect(container.querySelector('img')).toBeNull();
+ expect(container.querySelector('svg')).not.toBeNull();
+ });
+});
diff --git a/apps/web/src/lib/core/pipedream/ConnectedAppIcon.tsx b/apps/web/src/lib/core/pipedream/ConnectedAppIcon.tsx
new file mode 100644
index 0000000000..9a8a698482
--- /dev/null
+++ b/apps/web/src/lib/core/pipedream/ConnectedAppIcon.tsx
@@ -0,0 +1,19 @@
+import { queryReadyGate } from '@queries/gate';
+import { usePipedreamCatalogIconsQuery } from '@queries/pipedream-connectors';
+import { PipedreamConnectorIcon } from './ConnectorIcon';
+
+/**
+ * Icon for a connected app, whose record knows its slug and not its logo.
+ */
+export function ConnectedAppIcon(props: { appSlug: string; class?: string }) {
+ const icons = usePipedreamCatalogIconsQuery();
+ const iconUrl = () =>
+ queryReadyGate(icons) ? icons.data.get(props.appSlug) : undefined;
+ return (
+ <PipedreamConnectorIcon
+ appSlug={props.appSlug}
+ iconUrl={iconUrl()}
+ class={props.class}
+ />
+ );
+}
diff --git a/apps/web/src/lib/queries/pipedream-connectors.ts b/apps/web/src/lib/queries/pipedream-connectors.ts
index 6e05d81a12..3439705317 100644
--- a/apps/web/src/lib/queries/pipedream-connectors.ts
+++ b/apps/web/src/lib/queries/pipedream-connectors.ts
@@ -30,6 +30,7 @@ import type { ServerResponse } from '@service-cognition/generated/schemas';
import {
type InfiniteData,
infiniteQueryOptions,
+ queryOptions,
useInfiniteQuery,
useMutation,
useQuery,
@@ -43,6 +44,7 @@ const KEYS = {
overlays: ['pipedreamConnectors', 'overlays'] as const,
catalog: (search: string) =>
['pipedreamConnectors', 'catalog', search] as const,
+ catalogIcons: ['pipedreamConnectors', 'catalogIcons'] as const,
};
/** Stable placeholder for `neverSuspend` consumers (see below). */
@@ -226,6 +228,29 @@ export function usePipedreamCatalogQuery(search: () => string) {
return useInfiniteQuery(() => pipedreamCatalogQueryOptions(search().trim()));
}
+function pipedreamCatalogIconsQueryOptions() {
+ return queryOptions({
+ queryKey: KEYS.catalogIcons,
+ queryFn: async () =>
+ throwOnErr(
+ async () =>
+ await cognitionApiServiceClient.browsePipedreamCatalog({ limit: 50 })
+ ),
+ select: (page: PipedreamCatalogResponse) =>
+ new Map(page.servers.map((entry) => [entry.app_slug, entry.icon_url])),
+ staleTime: 5 * 60 * 1000,
+ });
+}
+
+/**
+ * App logos by slug, from one full-size catalog page. Connection records carry
+ * only a slug. That covers all of Macro Connect's catalog, and Pipedream's most
+ * popular apps; a connector outside it keeps its fallback icon.
+ */
+export function usePipedreamCatalogIconsQuery() {
+ return useQuery(pipedreamCatalogIconsQueryOptions);
+}
+
function invalidateConnections() {
return queryClient.invalidateQueries({ queryKey: KEYS.list });
}