Skip to content

feat(core): Use interactive-only snapshots by default to improve token efficiency#28334

Draft
elsmr wants to merge 11 commits intomasterfrom
node-4778-use-interactive-only-snapshots-by-default-to-improve-token
Draft

feat(core): Use interactive-only snapshots by default to improve token efficiency#28334
elsmr wants to merge 11 commits intomasterfrom
node-4778-use-interactive-only-snapshots-by-default-to-improve-token

Conversation

@elsmr
Copy link
Copy Markdown
Member

@elsmr elsmr commented Apr 10, 2026

Summary

Switches the MCP browser tooling to use interactive-only ARIA snapshots by default, significantly reducing token usage when inspecting pages. Key changes:

  • Interactive snapshots with context refs and depth limits — new ariaSnapshot module in mcp-browser-extension that produces focused snapshots containing only interactive elements (buttons, links, inputs, etc.) with configurable depth and scoped context refs
  • Snapshot type/depth parametersinspect_page and related tools now accept snapshotType (interactive | full) and maxDepth parameters, defaulting to interactive-only
  • Extension reliability improvements — WebSocket reconnection loop, try-catch for close races, and application-level ping/pong to prevent Chrome service worker suspension
  • Comprehensive test coverage — 900+ lines of tests for ARIA snapshot generation, scope validation, and ref resolution; relay connection tests for reconnection and ping/pong

How to test

  1. Start the MCP browser server and connect via the Chrome extension
  2. Use inspect_page — verify it returns a compact interactive-only snapshot by default
  3. Use inspect_page with snapshotType: "full" — verify it returns the full ARIA tree
  4. Test maxDepth parameter to control snapshot depth
  5. Disconnect/reconnect the extension — verify automatic reconnection works

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/NODE-4778

Review / Merge checklist

  • I have seen this code, I have run this code, and I take responsibility for this code.
  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with Backport to Beta, Backport to Stable, or Backport to v1 (if the PR is an urgent fix that needs to be backported)

🤖 PR Summary generated by AI

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 10, 2026

⚠️ Ownership acknowledgement required

Please add or check the following item in your PR description before this can be merged:

- [x] I have seen this code, I have run this code, and I take responsibility for this code.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 10, 2026

Bundle Report

Changes will increase total bundle size by 79.04kB (0.17%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
editor-ui-esm 45.65MB 79.04kB (0.17%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: editor-ui-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/typescript.worker-*.js 196 bytes 10.88MB 0.0%
assets/constants-*.js 34.41kB 3.18MB 1.09%
assets/worker-*.js 724 bytes 3.16MB 0.02%
assets/src-*.js -1.87MB 556.38kB -77.06%
assets/src-*.js (New) 2.43MB 2.43MB 100.0% 🚀
assets/DataTableTable-*.js 35 bytes 1.61MB 0.0%
assets/index-*.js 31 bytes 1.31MB 0.0%
assets/ParameterInputList-*.js 6.21kB 1.28MB 0.49%
assets/users.store-*.js 32 bytes 1.05MB 0.0%
assets/expressions-*.js -1.01kB 857.51kB -0.12%
assets/NDVEmptyState-*.js 15.65kB 737.05kB 2.17%
assets/src-*.css 50 bytes 491.18kB 0.01%
assets/useCanvasMapping-*.js 35 bytes 462.73kB 0.01%
assets/sanitize-*.js 1.36kB 421.7kB 0.32%
assets/RunData-*.js 33 bytes 345.69kB 0.01%
assets/useImportCurlCommand-*.js 317 bytes 324.58kB 0.1%
assets/InstanceAiView-*.js 35 bytes 318.35kB 0.01%
assets/WorkflowDiffView-*.js 35 bytes 207.19kB 0.02%
assets/WorkflowsView-*.js -2 bytes 200.03kB -0.0%
assets/NodeView-*.js 35 bytes 137.22kB 0.03%
assets/usePostMessageHandler-*.js 34 bytes 137.01kB 0.02%
assets/WorkflowLayout-*.js 35 bytes 127.36kB 0.03%
assets/useRootStore-*.js 540 bytes 127.13kB 0.43%
assets/canvas.eventBus-*.js -2 bytes 117.47kB -0.0%
assets/router-*.js -994 bytes 116.81kB -0.84%
assets/SettingsSso-*.js 11.35kB 105.92kB 12.0% ⚠️
assets/NodeCreator-*.js 34 bytes 103.9kB 0.03%
assets/empty-*.js 76 bytes 100.55kB 0.08%
assets/useCanvasOperations-*.js 35 bytes 95.42kB 0.04%
assets/VirtualSchema-*.js 34 bytes 94.5kB 0.04%
assets/NodeSettings-*.js 34 bytes 84.63kB 0.04%
assets/CanvasRunWorkflowButton-*.js 34 bytes 77.67kB 0.04%
assets/ProjectSettings-*.js 34 bytes 74.05kB 0.05%
assets/FixedCollectionParameter-*.js 35 bytes 73.79kB 0.05%
assets/SettingsLdapView-*.js -2 bytes 71.33kB -0.0%
assets/WorkflowHistory-*.js -3 bytes 71.02kB -0.0%
assets/ChatGreetings-*.js 34 bytes 68.74kB 0.05%
assets/TriggerPanel-*.js 34 bytes 59.29kB 0.06%
assets/RunDataJsonActions-*.js -2 bytes 59.27kB -0.0%
assets/ChatView-*.js 34 bytes 57.99kB 0.06%
assets/core-*.js 57.37kB 57.59kB 25960.63% ⚠️
assets/core-*.js -613.8kB 221 bytes -99.96%
assets/CreditWarningBanner-*.js 35 bytes 53.16kB 0.07%
assets/semver-*.js 256 bytes 52.01kB 0.49%
assets/chat.store-*.js -2 bytes 49.27kB -0.0%
assets/SettingsMCPView-*.js -2 bytes 48.66kB -0.0%
assets/TemplatesSearchView-*.js -2 bytes 47.24kB -0.0%
assets/SettingsInstanceAiView-*.js -2 bytes 42.62kB -0.0%
assets/NodeDetailsView-*.js 35 bytes 42.49kB 0.08%
assets/useLogsTreeExpand-*.js 34 bytes 41.28kB 0.08%
assets/readyToRunWorkflows.store-*.js 35 bytes 40.77kB 0.09%
assets/NodeDetailsViewV2-*.js 35 bytes 38.06kB 0.09%
assets/ExecutionsView-*.js 34 bytes 36.04kB 0.09%
assets/SettingsSso-*.css 880 bytes 34.75kB 2.6%
assets/AgentEditorModal-*.js 34 bytes 34.59kB 0.1%
assets/WorkflowExecutionsView-*.js -2 bytes 33.27kB -0.01%
assets/ProjectRoleView-*.js 35 bytes 32.66kB 0.11%
assets/SettingsUsersView-*.js 34 bytes 32.57kB 0.1%
assets/AppSidebar-*.js -2 bytes 31.84kB -0.01%
assets/RunDataTable-*.js -3 bytes 31.8kB -0.01%
assets/WorkflowExecutionsPreview-*.js -2 bytes 31.24kB -0.01%
assets/usePushConnection-*.js -2 bytes 31.02kB -0.01%
assets/ExecutionsTime-*.js -4 bytes 29.45kB -0.01%
assets/ResourcesListLayout-*.js 35 bytes 29.21kB 0.12%
assets/SettingsSecretsProviders.ee-*.js -3 bytes 28.67kB -0.01%
assets/useRunWorkflow-*.js 35 bytes 27.85kB 0.13%
assets/SettingsChatHubView-*.js -2 bytes 27.8kB -0.01%
assets/WorkerView-*.js -2 bytes 27.77kB -0.01%
assets/ProjectHeader-*.js 35 bytes 25.81kB 0.14%
assets/CredentialsView-*.js -2 bytes 24.71kB -0.01%
assets/SettingsSourceControl-*.js -3 bytes 24.62kB -0.01%
assets/RecommendedTemplateCard-*.js -2 bytes 24.07kB -0.01%
assets/EvaluationsRootView-*.js 34 bytes 22.98kB 0.15%
assets/readyToRun.store-*.js 35 bytes 22.84kB 0.15%
assets/resourceCenterData-*.js -2 bytes 21.58kB -0.01%
assets/ChatLayout-*.js -2 bytes 21.47kB -0.01%
assets/useCustomAgent-*.js -2 bytes 20.8kB -0.01%
assets/InsightsDashboard-*.js -2 bytes 20.6kB -0.01%
assets/ProjectVariables-*.js 35 bytes 20.43kB 0.17%
assets/AddDataTableModal-*.js -2 bytes 20.19kB -0.01%
assets/aiTemplatesStarterCollection.store-*.js 35 bytes 20.18kB 0.17%
assets/assistant.store-*.js -2 bytes 19.37kB -0.01%
assets/ToolsManagerModal-*.js 35 bytes 19.14kB 0.18%
assets/SettingsUsageAndPlan-*.js -3 bytes 19.03kB -0.02%
assets/EvaluationsView-*.js 34 bytes 18.84kB 0.18%
assets/MainSidebarHeader-*.js 34 bytes 18.31kB 0.19%
assets/TestRunDetailView-*.js -2 bytes 17.91kB -0.01%
assets/DataTableActions-*.js -2 bytes 17.85kB -0.01%
assets/SecuritySettings-*.js 34 bytes 17.47kB 0.19%
assets/SettingsLogStreamingView-*.js -2 bytes 17.43kB -0.01%
assets/SettingsPersonalView-*.js -2 bytes 17.1kB -0.01%
assets/SettingsCommunityNodesView-*.js -2 bytes 16.41kB -0.01%
assets/ResourceCenterView-*.js -2 bytes 15.76kB -0.01%
assets/useAiGateway-*.js -2 bytes 15.66kB -0.01%
assets/DataTableView-*.js -2 bytes 14.91kB -0.01%
assets/ProviderSettingsModal-*.js -2 bytes 14.82kB -0.01%
assets/DataTableDetailsView-*.js -2 bytes 14.46kB -0.01%
assets/MigrationRules-*.js 35 bytes 14.36kB 0.24%
assets/ProjectSharing-*.js 35 bytes 14.06kB 0.25%
assets/CredentialPicker-*.js -2 bytes 13.83kB -0.01%
assets/SettingsApiView-*.js -3 bytes 13.71kB -0.02%
assets/ProjectRolesView-*.js -2 bytes 13.62kB -0.01%
assets/TemplatesCollectionView-*.js -2 bytes 13.42kB -0.01%
assets/SigninView-*.js 35 bytes 13.37kB 0.26%
assets/TemplateList-*.js -2 bytes 13.13kB -0.02%
assets/SetupTemplateFormStep-*.js -3 bytes 13.01kB -0.02%
assets/SetupWorkflowFromTemplateView-*.js -2 bytes 12.6kB -0.02%
assets/ToolSettingsContent-*.js -2 bytes 12.38kB -0.02%
assets/ToolsSelector-*.js -2 bytes 12.31kB -0.02%
assets/MigrationRuleDetail-*.js 35 bytes 12.27kB 0.29%
assets/collaboration.store-*.js -2 bytes 11.21kB -0.02%
assets/SettingsExternalSecrets-*.js -3 bytes 11.21kB -0.03%
assets/NodeCreation-*.js -2 bytes 10.85kB -0.02%
assets/MCPConnectWorkflowsModal-*.js -2 bytes 10.67kB -0.02%
assets/useActions-*.js -2 bytes 10.41kB -0.02%
assets/DependencyPill-*.js -2 bytes 10.17kB -0.02%
assets/OAuthConsentView-*.js -2 bytes 9.95kB -0.02%
assets/ProjectCardBadge-*.js -2 bytes 9.35kB -0.02%
assets/ResolversView-*.js -2 bytes 9.3kB -0.02%
assets/usePinnedData-*.js -2 bytes 9.13kB -0.02%
assets/CommunityNodeUpdateInfo-*.js -2 bytes 8.96kB -0.02%
assets/folders.store-*.js -2 bytes 8.9kB -0.02%
assets/SkeletonAgentCard-*.js 35 bytes 8.82kB 0.4%
assets/ResourceCenterSectionView-*.js -2 bytes 8.62kB -0.02%
assets/InsightsTableWorkflows-*.js -2 bytes 8.54kB -0.02%
assets/InsightsSummary-*.js -3 bytes 8.48kB -0.04%
assets/WorkflowExecutionsInfoAccordion-*.js -2 bytes 8.45kB -0.02%
assets/TagsDropdown-*.js 35 bytes 8.29kB 0.42%
assets/FolderBreadcrumbs-*.js -2 bytes 7.93kB -0.03%
assets/RunDataParsedAiContent-*.js -2 bytes 7.89kB -0.03%
assets/ChatPersonalAgentsView-*.js 35 bytes 7.75kB 0.45%
assets/WorkflowPreview-*.js -2 bytes 7.71kB -0.03%
assets/banners.store-*.js -2 bytes 7.71kB -0.03%
assets/ResourceFiltersDropdown-*.js -2 bytes 7.61kB -0.03%
assets/ExternalSecretsProviderConnectionSwitch.ee-*.js -2 bytes 7.59kB -0.03%
assets/WorkflowLocation-*.js -2 bytes 7.48kB -0.03%
assets/useCredentialResolvers-*.js -2 bytes 7.14kB -0.03%
assets/useGlobalEntityCreation-*.js -2 bytes 7.09kB -0.03%
assets/chatPanel.store-*.js -2 bytes 6.84kB -0.03%
assets/TemplatesWorkflowView-*.js -2 bytes 6.74kB -0.03%
assets/SettingsAiGatewayView-*.js -2 bytes 6.74kB -0.03%
assets/SettingsAIView-*.js -2 bytes 6.61kB -0.03%
assets/TimeAgo-*.js -2 bytes 6.57kB -0.03%
assets/insights.utils-*.js -2 bytes 6.18kB -0.03%
assets/useSettingsItems-*.js -2 bytes 5.88kB -0.03%
assets/useWorkflowActivate-*.js -2 bytes 5.85kB -0.03%
assets/ContactAdministratorToInstall-*.js -3 bytes 5.75kB -0.05%
assets/ChatWorkflowAgentsView-*.js 35 bytes 5.63kB 0.63%
assets/useExecutionDebugging-*.js -2 bytes 5.62kB -0.04%
assets/CredentialSelectorModal-*.js -2 bytes 5.6kB -0.04%
assets/RunDataSearch-*.js 35 bytes 5.55kB 0.63%
assets/LoadingView-*.js -2 bytes 5.4kB -0.04%
assets/SettingsLayout-*.js -2 bytes 5.01kB -0.04%
assets/AuthView-*.js -2 bytes 4.74kB -0.04%
assets/ModelByIdSelectorModal-*.js -2 bytes 4.64kB -0.04%
assets/ChangePasswordView-*.js -2 bytes 4.44kB -0.05%
assets/ToolSettingsModal-*.js -2 bytes 4.32kB -0.05%
assets/SetupWorkflowCredentialsButton-*.js -2 bytes 4.31kB -0.05%
assets/WorkflowExecutionsLandingPage-*.js -2 bytes 4.28kB -0.05%
assets/usePageRedirectionHelper-*.js -2 bytes 4.07kB -0.05%
assets/ProjectBreadcrumb-*.js -2 bytes 4.0kB -0.05%
assets/ChatAgentAvatar-*.js -2 bytes 3.8kB -0.05%
assets/SignupView-*.js -2 bytes 3.74kB -0.05%
assets/DemoDiffView-*.js -2 bytes 3.53kB -0.06%
assets/useExecutionHelpers-*.js -2 bytes 3.33kB -0.06%
assets/TemplatesView-*.js -2 bytes 3.29kB -0.06%
assets/CopyInput-*.js -2 bytes 3.25kB -0.06%
assets/SetupView-*.js -2 bytes 3.06kB -0.07%
assets/EntityNotFound-*.js -2 bytes 3.04kB -0.07%
assets/ForgotMyPasswordView-*.js -2 bytes 3.0kB -0.07%
assets/EntityUnAuthorised-*.js -2 bytes 2.86kB -0.07%
assets/ConnectionTracker-*.js -2 bytes 2.84kB -0.07%
assets/SelectedItemsInfo-*.js -2 bytes 2.67kB -0.07%
assets/ErrorView-*.js -2 bytes 2.66kB -0.08%
assets/utils-*.js -2 bytes 2.49kB -0.08%
assets/InsightsPaywall-*.js -2 bytes 2.4kB -0.08%
assets/InsightsChartTimeSaved-*.js -2 bytes 2.34kB -0.09%
assets/InsightsChartAverageRuntime-*.js -2 bytes 2.29kB -0.09%
assets/WorkflowOnboardingView-*.js -2 bytes 2.25kB -0.09%
assets/useFreeAiCredits-*.js -2 bytes 2.17kB -0.09%
assets/SamlOnboarding-*.js -2 bytes 2.16kB -0.09%
assets/InsightsChartFailureRate-*.js 35 bytes 2.08kB 1.71%
assets/dateFormatter-*.js -2 bytes 2.04kB -0.1%
assets/InsightsChartTotal-*.js 35 bytes 1.97kB 1.81%
assets/InsightsChartFailed-*.js 35 bytes 1.85kB 1.93%
assets/EmptySharedSectionActionBox-*.js -2 bytes 1.55kB -0.13%
assets/SignoutView-*.js -2 bytes 1.08kB -0.18%

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 10, 2026

Codecov Report

❌ Patch coverage is 3.57143% with 27 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ckages/@n8n/mcp-browser/src/adapters/playwright.ts 0.00% 21 Missing ⚠️
packages/@n8n/mcp-browser/src/cdp-relay.ts 0.00% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

@n8n-assistant n8n-assistant bot added the n8n team Authored by the n8n team label Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 10, 2026

Performance Comparison

Comparing currentlatest master14-day baseline

docker-stats

Metric Current Latest Master Baseline (avg) vs Master vs Baseline Status
docker-image-size-n8n 1249.28 MB 1269.76 MB 1269.76 MB (σ 0.00) -1.6% -1.6%
docker-image-size-runners 381.00 MB 386.00 MB 387.50 MB (σ 3.00) -1.3% -1.7% 🔴

Memory consumption baseline with starter plan resources

Metric Current Latest Master Baseline (avg) vs Master vs Baseline Status
memory-heap-used-baseline 112.97 MB 114.53 MB 113.09 MB (σ 1.15) -1.4% -0.1%
memory-rss-baseline 284.00 MB 287.07 MB 281.78 MB (σ 34.50) -1.1% +0.8%

Idle baseline with Instance AI module loaded

Metric Current Latest Master Baseline (avg) vs Master vs Baseline Status
instance-ai-heap-used-baseline 184.63 MB 186.51 MB 186.46 MB (< 3 samples) -1.0% -1.0%
instance-ai-rss-baseline 385.79 MB 394.55 MB 369.15 MB (< 3 samples) -2.2% +4.5%
How to read this table
  • Current: This PR's value (or latest master if PR perf tests haven't run)
  • Latest Master: Most recent nightly master measurement
  • Baseline: Rolling 14-day average from master
  • vs Master: PR impact (current vs latest master)
  • vs Baseline: Drift from baseline (current vs rolling avg)
  • Status: ✅ within 1σ | ⚠️ 1-2σ | 🔴 >2σ regression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

n8n team Authored by the n8n team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant