Repository navigation
feat(ui): modularize admin scope into independent modules - #3137
Merged
Merged
Conversation
crivetimihai
requested review from
kevalmahajan and
madhav165
as code owners
February 24, 2026 09:18
10 tasks
gcgoncalves
force-pushed
the
admin-scope-modularised
branch
from
February 24, 2026 13:57
9b2fbe3 to
d8b8aaa
Compare
gcgoncalves
marked this pull request as draft
February 26, 2026 14:35
gcgoncalves
force-pushed
the
admin-scope-modularised
branch
from
February 28, 2026 08:38
d8b8aaa to
81c8271
Compare
gcgoncalves
marked this pull request as ready for review
February 28, 2026 08:49
gcgoncalves
marked this pull request as draft
February 28, 2026 08:50
gcgoncalves
force-pushed
the
admin-scope-modularised
branch
2 times, most recently
from
March 2, 2026 11:03
59319b4 to
0c9f317
Compare
gcgoncalves
force-pushed
the
admin-scope-modularised
branch
3 times, most recently
from
March 13, 2026 16:06
ca9317f to
53477a6
Compare
gcgoncalves
marked this pull request as ready for review
March 13, 2026 16:06
gcgoncalves
force-pushed
the
admin-scope-modularised
branch
2 times, most recently
from
March 13, 2026 23:00
4802832 to
f1e5e15
Compare
gcgoncalves
force-pushed
the
admin-scope-modularised
branch
9 times, most recently
from
March 19, 2026 14:05
c4ace4e to
9904982
Compare
gcgoncalves
force-pushed
the
admin-scope-modularised
branch
5 times, most recently
from
April 2, 2026 09:04
581bdf2 to
a114e4c
Compare
vishu-bh
previously approved these changes
Apr 2, 2026
vishu-bh
left a comment
Collaborator
There was a problem hiding this comment.
LGTM
Ran admin UI locally and all looks okay.
Collaborator
|
@vishu-bh Rebased and resolved the secrets baseline conflict. |
jonpspri
force-pushed
the
admin-scope-modularised
branch
2 times, most recently
from
April 2, 2026 13:32
3887fda to
aaa7b65
Compare
Signed-off-by: Gabriel Costa <gabrielcg@proton.me>
jonpspri
force-pushed
the
admin-scope-modularised
branch
from
April 2, 2026 14:07
aaa7b65 to
7369c61
Compare
This was referenced Apr 3, 2026
This was referenced Apr 5, 2026
This was referenced Apr 7, 2026
4 tasks
This was referenced Aug 26, 2026
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.
Admin UI Modularisation
The Problem
The original
mcpgateway/static/admin.jswas a 33,812-line monolithic file — all UI logic, state management, API calls, validation, and event handling in one place. It was untestable in isolation, slow to load, and impossible to maintain at scale.What Was Done
1. Decomposition into 44 ES Modules (
mcpgateway/admin_ui/)The monolith was split into focused, single-responsibility modules across four conceptual layers:
bootstrap.js,appState.js,utils.js,constants.js,security.jstools.js,servers.js,teams.js,gateway.js,tokens.js,llmModels.js,llmChat.js,prompts.js,resources.js,users.js,roots.js,a2aAgents.jsauth.js,filters.js,search.js,tabs.js,pagination.js,modals.js,logging.js,metrics.js,plugins.js,monitoring.js, etc.initialization.js,events.js,app.js,formSubmitHandlers.js2. Facade Pattern (
admin_ui/admin.js)A single facade aggregates all 35+ module exports and exposes them onto the
window.Adminnamespace — preserving the existing HTML contract where HTMX/Alpine templates callAdmin.editTool(...),Admin.showTab(...), etc. No template changes required.3. Vite Build Pipeline
A new Vite configuration (
vite.config.js) bundlesadmin_ui/index.jsinto an IIFE format output atmcpgateway/static/bundle-[HASH].js. The hash changes on every rebuild, providing automatic cache busting. External libraries (HTMX, Alpine, Chart.js, CodeMirror, DOMPurify) remain CDN-loaded and are declared as globals — not bundled.Python's
mcpgateway/admin.pyreads the Vite manifest at startup to resolve the hashed filename, injecting it into the admin template as{{ bundle_js }}.4. Test Suite: 20% → 70%+ Coverage
44 new Vitest unit test files in
tests/unit/js/, one per module, using:jsdomenvironment to simulate the browser DOMvi.mock()for clean module isolationAppState.reset()inafterEachto prevent test pollutionThe
vitest.config.jsinstruments onlymcpgateway/admin_ui/**/*.js(not the compiled bundle), giving accurate per-module coverage.5. Playwright Tests Maintained
End-to-end Playwright tests continue to pass at the same success rate — the public API (
window.Admin.*) is unchanged, so browser-level test contracts were not broken by the refactor.Key Design Decisions
bootstrap.jsmust initialisewindow.Adminbefore any module tries to write to it.events.js,app.js): modules that need to self-register event listeners at load time use the IIFE pattern rather than pure ES module exports.appState.jsacts as the shared hub;utils.jsandconstants.jshave zero app-level dependencies; domain modules only import from the foundation layer.emptyOutDir: falsein Vite config: preserves vendor files, images, and other static assets alongside the bundle.File Map
mcpgateway/admin_ui/*.jsmcpgateway/admin_ui/index.jsmcpgateway/admin_ui/admin.jswindow.Adminmcpgateway/admin.pyget_bundle_js_filename()— resolves hashed name at startupmcpgateway/templates/admin.html{{ bundle_js }}vite.config.jsvitest.config.jspackage.jsontests/unit/js/*.test.js