fix: auto-inject portal logo into platform-info MCP app#210
Merged
Conversation
The platform-info app was showing the default graph icon instead of the operator's logo because registerBuiltinPlatformInfo passed through the mcpapps config verbatim — operators had to duplicate their logo as logo_svg in the mcpapps config even when portal.logo was already set. Add injectPortalLogo() which auto-populates logo_url from portal.logo when neither logo_svg nor logo_url are explicitly set. Update the platform-info HTML to support logo_url (renders with <img>) as a fallback between inline SVG and the default icon. Also extract repeated "tool" slog key to logKeyTool constant to fix a pre-existing revive lint finding.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #210 +/- ##
=======================================
Coverage 90.15% 90.15%
=======================================
Files 135 135
Lines 14032 14044 +12
=======================================
+ Hits 12650 12662 +12
Misses 1007 1007
Partials 375 375 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
registerBuiltinPlatformInfopasses the operator'smcpapps.apps.platform-info.configverbatim to the embedded HTML. The HTML rendersCFG.logo_svg || DEFAULT_LOGO, but operators typically configure their logo viaportal.logo(a URL), not by duplicating an inline SVG intomcpapps.apps.platform-info.config.logo_svg. The result: the portal, admin UI, and login page all show the correct logo, but the platform-info MCP app falls back to the default data-graph icon.Root cause
No bridging between
portal.logoand the platform-info app config. The two config paths were completely disconnected:Fix
Auto-inject portal logo (
pkg/platform/platform.go)New
injectPortalLogo()method called at the end ofregisterBuiltinPlatformInfo. When the operator hasn't explicitly setlogo_svgorlogo_urlin the app config, it auto-populateslogo_urlfromportal.logo. This means any deployment that already hasportal.logoconfigured gets the correct logo in the platform-info app with zero config changes.Precedence chain (highest to lowest):
mcpapps.apps.platform-info.config.logo_svg— inline SVG markup (explicit override)mcpapps.apps.platform-info.config.logo_url— image URL (explicit override)portal.logo— auto-injected aslogo_url(new behavior)URL logo support (
apps/platform-info/index.html)The HTML previously only supported
logo_svg(inline SVG markup). Addedlogo_urlsupport that renders with<img>tag, includingobject-fit: containstyling to handle various aspect ratios. The logo markup selection is now:Lint fix (
pkg/middleware/mcp.go)Extracted repeated
"tool"slog key string literal (4 occurrences) tologKeyToolconstant, fixing a pre-existingrevive/add-constantlint finding.Test plan
TestInjectPortalLogo/injects_logo_url_from_portal.logo— portal.logo auto-injected as logo_urlTestInjectPortalLogo/does_not_overwrite_explicit_logo_svg— explicit logo_svg preserved, no logo_url addedTestInjectPortalLogo/does_not_overwrite_explicit_logo_url— explicit logo_url preserved unchangedTestInjectPortalLogo/no-op_when_portal_logo_is_empty— no injection when portal.logo is unsetTestInjectPortalLogo/creates_map_when_config_is_nil— handles nil config (no mcpapps config block)injectPortalLogo— 100% coveragemake verify— all checks pass (fmt, test, lint, security, coverage, dead-code, mutate, release-check)<img>tag