fix(ui): display CRUD changes on Users and Teams pages without full reload#3330
Open
fix(ui): display CRUD changes on Users and Teams pages without full reload#3330
Conversation
4 tasks
Member
|
Thanks @marekdano. Excellent root cause analysis and comprehensive fix. The three-layer approach (HX-Trigger headers, no-cache headers, and Edit button HTMX attributes) correctly addresses each caching layer. Test coverage is thorough — both Python and JS tests. Looks good. |
871e8d5 to
e8e6d1d
Compare
gcgoncalves
reviewed
Mar 10, 2026
gcgoncalves
reviewed
Mar 10, 2026
gcgoncalves
reviewed
Mar 10, 2026
gcgoncalves
reviewed
Mar 19, 2026
Collaborator
gcgoncalves
left a comment
There was a problem hiding this comment.
Have you considered adding the HX-Trigger header to team edit/update as well?
added 3 commits
April 2, 2026 16:46
…eload Signed-off-by: Marek Dano <Marek.Dano@ibm.com>
Signed-off-by: Marek Dano <Marek.Dano@ibm.com>
Signed-off-by: Marek Dano <Marek.Dano@ibm.com>
6ef34cb to
6a48e6d
Compare
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.
🐛 Bug-fix PR
Closes #2691 #2864
📌 Summary
Fixes stale UI data on Teams and Users admin pages when running multiple gateway replicas behind nginx. The root cause was three layers of caching preventing CRUD changes from being reflected:
HX-Triggerheaders, so the frontend never knew to refresh the lists_t=Date.now()cache-busting query parameters only after CRUD actions on Teams and Users.Editon the freshly-swapped card, which causedhtmx:targetErrorin the browser console and the edit modal never opened.🔁 Reproduction Steps
Users Page
Scenario 1:
Scenario 2:
Teams Page
🐞 Root Cause
CRUD operations on Users and Teams are cached behind the nginx 5s cache time. So when the operations are executed on the admin UI, the changes are not reflected on the UI. The whole page must be reloaded to see them.
After clicking Activate or Deactivate on a user card, the card is replaced via
hx-swap="outerHTML"using HTML generated server-side by_render_user_card_html(). TheEditbutton produced by that function was missing three HTMX attributes present in the Jinja template (users_partial.html). ClickingEditon the freshly-swapped card causedhtmx:targetErrorin the browser console and the edit modal never opened.💡 Fix Description
mcpgateway/admin.py_render_user_card_html()— addedhx-on::before-request, hx-swap, andhx-on::config-requestto the Edit button f-string to matchusers_partial.htmlexactlyadmin_get_user_edit()— addedCache-Control: no-cache, no-store, must-revalidate / Pragma: no-cache / Expires: 0response headers to prevent nginx from serving stale edit-form HTMLadmin_get_team_edit()— same no-cache headers as aboveadmin_delete_user()— addedHX-Trigger: adminUserActionresponse header so the users list refreshes automatically after deletionadmin_create_team()— addedHX-Trigger: adminTeamActionresponse header so the teams list refreshes automatically after team creationmcpgateway/static/admin.jshandleAdminTeamAction()— addedparams.set("_t", Date.now())cache-busting timestamp to the teams-list refresh URLmcpgateway/templates/admin.htmleditTeamSafe()— replaced string concatenation URL with a template literal including?_t=${Date.now()}cache-busting paramloadTeamMembersView()— same cache-busting param added to the team members modal load URLmcpgateway/templates/users_partial.htmlAdd unit tests to cover changes in
admin.pyandadmin.jsfiles🧪 Verification
make lintmake testmake coverage📐 MCP Compliance (if relevant)
✅ Checklist
make black isort pre-commit)