feat(mcp-servers): resolve store icons from icon_domain via the logo.dev proxy#3585
Conversation
|
😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details. |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
|
✅ Visual changes approved by @cvolzer3 — baseline updated in 18 new, 28 removed. |
Prompt To Fix All With AIFix the following 3 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 3
packages/ui/src/features/mcp-servers/hooks/useServerIcon.ts:23
**Transient Failures Stay Visible**
When the proxy returns a temporary server or network error, `getMcpServerIconUrl` throws and this query performs no retry. An icon observed continuously remains on the generic fallback until another refetch trigger occurs, so a short proxy outage can hide branding for the rest of that view.
### Issue 2 of 3
apps/mobile/src/features/mcp/components/ServerIcon.tsx:56
**Failure Key Ignores Auth Context**
The request URL depends on the access token, cloud region, and project, but the failure key contains only the domain and theme. If the image fails during token refresh or before a project switch completes, the same component suppresses the later valid request and keeps showing the generic icon.
### Issue 3 of 3
packages/api-client/src/posthog-client.ts:4219
**Blob URLs Lack Cleanup**
Each distinct domain and theme creates a new object URL, but no owner revokes it when query data is replaced or removed. Browsing many servers in the long-lived desktop renderer retains the backing image blobs and causes memory use to grow throughout the session.
Reviews (1): Last reviewed commit: "chore(visual): update storybook baseline..." | Re-trigger Greptile |
| { | ||
| enabled: !!domain, | ||
| staleTime: Number.POSITIVE_INFINITY, | ||
| retry: false, |
There was a problem hiding this comment.
Transient Failures Stay Visible
When the proxy returns a temporary server or network error, getMcpServerIconUrl throws and this query performs no retry. An icon observed continuously remains on the generic fallback until another refetch trigger occurs, so a short proxy outage can hide branding for the rest of that view.
Rule Used: When implementing retry logic, include comprehensi... (source)
Learned From
PostHog/posthog#32651
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/ui/src/features/mcp-servers/hooks/useServerIcon.ts
Line: 23
Comment:
**Transient Failures Stay Visible**
When the proxy returns a temporary server or network error, `getMcpServerIconUrl` throws and this query performs no retry. An icon observed continuously remains on the generic fallback until another refetch trigger occurs, so a short proxy outage can hide branding for the rest of that view.
**Rule Used:** When implementing retry logic, include comprehensi... ([source](https://app.greptile.com/posthog-org-19734/-/custom-context?memory=24d1be3f-07fb-465d-b1a7-60dff301aed8))
**Learned From**
[PostHog/posthog#32651](https://github.com/PostHog/posthog/pull/32651)
How can I resolve this? If you propose a fix, please make it concise.| failedIconKey !== iconCacheKey | ||
| ? `${getCloudUrlFromRegion(cloudRegion)}/api/environments/${projectId}/mcp_servers/icon/?domain=${encodeURIComponent(domain)}&theme=${theme}` | ||
| : null; | ||
|
|
There was a problem hiding this comment.
Failure Key Ignores Auth Context
The request URL depends on the access token, cloud region, and project, but the failure key contains only the domain and theme. If the image fails during token refresh or before a project switch completes, the same component suppresses the later valid request and keeps showing the generic icon.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/mobile/src/features/mcp/components/ServerIcon.tsx
Line: 56
Comment:
**Failure Key Ignores Auth Context**
The request URL depends on the access token, cloud region, and project, but the failure key contains only the domain and theme. If the image fails during token refresh or before a project switch completes, the same component suppresses the later valid request and keeps showing the generic icon.
How can I resolve this? If you propose a fix, please make it concise.| throw error; | ||
| } | ||
| const blob = await response.blob(); | ||
| return URL.createObjectURL(blob); |
There was a problem hiding this comment.
Each distinct domain and theme creates a new object URL, but no owner revokes it when query data is replaced or removed. Browsing many servers in the long-lived desktop renderer retains the backing image blobs and causes memory use to grow throughout the session.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/api-client/src/posthog-client.ts
Line: 4219
Comment:
**Blob URLs Lack Cleanup**
Each distinct domain and theme creates a new object URL, but no owner revokes it when query data is replaced or removed. Browsing many servers in the long-lived desktop renderer retains the backing image blobs and causes memory use to grow throughout the session.
How can I resolve this? If you propose a fix, please make it concise.|
@tatoalo fastest stamp this side of the mississippi |
…dev proxy The MCP store backend is replacing bundled icon assets with an icon_domain field per template, resolved at render time through the authenticated mcp_servers/icon/ proxy (PostHog/posthog#70159). Stop reading icon_key everywhere so the backend can drop the field: - api-client: add icon_domain to the generated MCP types and a getMcpServerIconUrl method (authenticated fetch -> object URL; the endpoint's 404 means "no icon", surfaced as null). - core: iconDomainFromServerUrl derives a best-effort brand domain from a server URL (strips mcp./api./www.) so custom installs get icons too; resolveServerDetails now resolves iconDomain + serverUrl. - ui: ServerIcon fetches through the proxy with the active theme, latching failures per (domain, theme); bundled assets and BRAND_ICONS removed (claude.svg stays, used by ContinueCliSessions). - mobile: same migration on the hand-mirrored types and ServerIcon (RN Image with Authorization header); bundled assets and SERVER_LOGOS removed. Generated-By: PostHog Code Task-Id: 2f81c64d-a1c4-483e-affd-a9b355756737
c306df9 to
58ac665
Compare
|
/trunk merge |
Problem
I changed the MCP store to use a catalog-as-code approach to adding MCP servers. As part of that changed, I moved us away from bundled assets to logo.dev icons. The existing MCP store componetry uses the old model structure, so it needs to be updated.
Changes
How did you test this?
Tested the desktop version locally. Not sure how to test mobile, so I did not check that.