Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(ci): fold the MCP UI apps size report into the ci-report comment (#68036)

Paul D'Ambra4256321dbc50
diff --git a/.github/workflows/ci-mcp-ui-apps.yml b/.github/workflows/ci-mcp-ui-apps.yml
index 914e2e5a3d52..2f168faf5de5 100644
--- a/.github/workflows/ci-mcp-ui-apps.yml
+++ b/.github/workflows/ci-mcp-ui-apps.yml
@@ -41,6 +41,7 @@ jobs:
- 'services/mcp/vite.ui-apps.config.ts'
- 'services/mcp/scripts/build-ui-apps.ts'
- 'services/mcp/scripts/generate-ui-apps.ts'
+ - 'services/mcp/scripts/post-ui-apps-size-section.mjs'
- 'services/mcp/scripts/yaml-config-schema.ts'
- 'products/*/mcp/**'
- 'services/mcp/definitions/*.yaml'
@@ -107,64 +108,20 @@ jobs:
fi
echo "All UI Apps built successfully."
- - name: Post size report comment
+ # Writes the size table into the shared ci-report PR comment (one comment for
+ # all CI checks), then clears any leftover standalone size comment from before
+ # the consolidation. Guarded for unrebased branches that predate the scripts.
+ - name: Post size report to CI report comment
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
- uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
- with:
- github-token: ${{ secrets.GITHUB_TOKEN }}
- script: |
- const fs = require('fs');
- const path = require('path');
- const marker = '<!-- mcp-ui-apps-size-report -->';
-
- const distDir = 'services/mcp/public/ui-apps';
- const rows = [];
-
- // Recursively collect app dirs (those containing main.js)
- function collectApps(dir) {
- for (const entry of fs.readdirSync(dir).sort()) {
- const full = path.join(dir, entry);
- if (!fs.statSync(full).isDirectory()) continue;
- const jsPath = path.join(full, 'main.js');
- if (fs.existsSync(jsPath)) {
- const cssPath = path.join(full, 'styles.css');
- const jsSize = (fs.statSync(jsPath).size / 1024).toFixed(1);
- const cssSize = fs.existsSync(cssPath) ? (fs.statSync(cssPath).size / 1024).toFixed(1) : '—';
- rows.push(`| ${entry} | ${jsSize} KB | ${cssSize} KB |`);
- } else {
- collectApps(full);
- }
- }
- }
- collectApps(distDir);
-
- if (rows.length === 0) return;
-
- const table = `| App | JS | CSS |\n|-----|-----|-----|\n${rows.join('\n')}`;
- const body = `${marker}\n### MCP UI Apps size report\n\n${table}`;
-
- const { data: comments } = await github.rest.issues.listComments({
- owner: context.repo.owner,
- repo: context.repo.repo,
- issue_number: context.issue.number,
- });
- const existing = comments.find(c => c.body.includes(marker));
-
- if (existing) {
- await github.rest.issues.updateComment({
- owner: context.repo.owner,
- repo: context.repo.repo,
- comment_id: existing.id,
- body,
- });
- } else {
- await github.rest.issues.createComment({
- owner: context.repo.owner,
- repo: context.repo.repo,
- issue_number: context.issue.number,
- body,
- });
- }
+ env:
+ GITHUB_TOKEN: ${{ github.token }}
+ run: |
+ if [ -f services/mcp/scripts/post-ui-apps-size-section.mjs ]; then
+ node services/mcp/scripts/post-ui-apps-size-section.mjs
+ node frontend/bin/ci-report/delete-legacy-comments.mjs
+ else
+ echo "Skipping size report section — script not present on this checkout"
+ fi
ci_mcp_ui_apps:
needs: [changes, build-and-report]
diff --git a/frontend/bin/ci-report/delete-legacy-comments.mjs b/frontend/bin/ci-report/delete-legacy-comments.mjs
index 79223937f1f8..676fb9376b75 100644
--- a/frontend/bin/ci-report/delete-legacy-comments.mjs
+++ b/frontend/bin/ci-report/delete-legacy-comments.mjs
@@ -1,11 +1,15 @@
#!/usr/bin/env node
import { gh, listPrComments, resolvePrContext } from './update-ci-report.mjs'
-// The frontend checks used to each post their own PR comment. They now share one
+// The CI checks used to each post their own PR comment. They now share one
// ci-report comment, so delete any leftover standalone comments once, on the first
// consolidated run, to stop a PR from showing both. Transitional — safe to remove
// after all open PRs have re-run.
-const LEGACY_MARKERS = ['<!-- posthog-eager-graph-check -->', '<!-- posthog-bundle-size-check -->']
+const LEGACY_MARKERS = [
+ '<!-- posthog-eager-graph-check -->',
+ '<!-- posthog-bundle-size-check -->',
+ '<!-- mcp-ui-apps-size-report -->',
+]
const context = resolvePrContext('cleanup')
if (!context) {
@@ -14,8 +18,12 @@ if (!context) {
const { token, repo, prNumber } = context
try {
- const stale = (await listPrComments(context)).filter((c) =>
- LEGACY_MARKERS.some((marker) => c.body?.includes(marker))
+ // Same ownership rule as isReportComment in update-ci-report.mjs: every legacy
+ // check posted its marker as the first line under the workflow token's identity,
+ // and matching on substring alone would let a human comment that quotes or pastes
+ // a marker be deleted by CI.
+ const stale = (await listPrComments(context)).filter(
+ (c) => c.user?.login === 'github-actions[bot]' && LEGACY_MARKERS.some((marker) => c.body?.startsWith(marker))
)
for (const comment of stale) {
await gh(token, `/repos/${repo}/issues/comments/${comment.id}`, { method: 'DELETE' })
diff --git a/frontend/bin/ci-report/update-ci-report.mjs b/frontend/bin/ci-report/update-ci-report.mjs
index 1408efcbeb02..03a820a4160c 100644
--- a/frontend/bin/ci-report/update-ci-report.mjs
+++ b/frontend/bin/ci-report/update-ci-report.mjs
@@ -17,6 +17,7 @@ export const SECTIONS = [
{ id: 'bundle-size', title: 'Bundle size' },
{ id: 'eager-graph', title: 'Eager graph' },
{ id: 'dist-size', title: 'Dist folder size' },
+ { id: 'mcp-ui-apps', title: 'MCP UI apps size' },
]
export const STATUS_EMOJI = { ok: '✅', warn: '⚠️', fail: '❌', info: 'ℹ️' }
diff --git a/services/mcp/scripts/post-ui-apps-size-section.mjs b/services/mcp/scripts/post-ui-apps-size-section.mjs
new file mode 100644
index 000000000000..ad85a8e62f46
--- /dev/null
+++ b/services/mcp/scripts/post-ui-apps-size-section.mjs
@@ -0,0 +1,56 @@
+#!/usr/bin/env node
+import fs from 'node:fs'
+import path from 'node:path'
+import { fileURLToPath } from 'node:url'
+
+import { postSection } from '../../../frontend/bin/ci-report/update-ci-report.mjs'
+
+const distDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'public', 'ui-apps')
+
+// App dirs are the ones containing main.js; wrapper dirs (e.g. generated/) recurse.
+function collectApps(dir) {
+ const apps = []
+ for (const entry of fs.readdirSync(dir).sort()) {
+ const full = path.join(dir, entry)
+ if (!fs.statSync(full).isDirectory()) {
+ continue
+ }
+ const jsPath = path.join(full, 'main.js')
+ if (fs.existsSync(jsPath)) {
+ const cssPath = path.join(full, 'styles.css')
+ apps.push({
+ app: entry,
+ jsKb: fs.statSync(jsPath).size / 1024,
+ cssKb: fs.existsSync(cssPath) ? fs.statSync(cssPath).size / 1024 : null,
+ })
+ } else {
+ apps.push(...collectApps(full))
+ }
+ }
+ return apps
+}
+
+const apps = fs.existsSync(distDir) ? collectApps(distDir) : []
+if (!apps.length) {
+ console.info('No built UI apps found — nothing to post.')
+ process.exit(0)
+}
+
+const totalJsKb = apps.reduce((total, { jsKb }) => total + jsKb, 0)
+const body = [
+ 'Built size of each MCP UI app (`main.js` + `styles.css`).',
+ '',
+ '| App | JS | CSS |',
+ '| --- | --- | --- |',
+ ...apps.map(
+ ({ app, jsKb, cssKb }) =>
+ `| ${app} | ${jsKb.toFixed(1)} KB | ${cssKb === null ? '—' : `${cssKb.toFixed(1)} KB`} |`
+ ),
+].join('\n')
+
+await postSection({
+ id: 'mcp-ui-apps',
+ status: 'info',
+ summary: `${apps.length} app(s), ${totalJsKb.toFixed(1)} KB JS`,
+ body,
+})