Skip to content

fix(admin): correct HTMX event name for team list refresh#2705

Merged
crivetimihai merged 1 commit intoIBM:mainfrom
settler-av:bug/2691-team-visibility-update
Feb 6, 2026
Merged

fix(admin): correct HTMX event name for team list refresh#2705
crivetimihai merged 1 commit intoIBM:mainfrom
settler-av:bug/2691-team-visibility-update

Conversation

@settler-av
Copy link
Copy Markdown
Contributor

@settler-av settler-av commented Feb 4, 2026

🐛 Bug-fix PR

🔗 Related Issue

Closes #2691


📝 Summary

Updates the HTMX event trigger in the Team Edit modal to ensure the teams list refreshes correctly after an update. Previously, the UI would not update the table view because it was listening for a disparate event name.


🏷️ Type of Change

  • Bug fix
  • Feature / Enhancement
  • Documentation
  • Refactor
  • Chore (deps, CI, tooling)
  • Other (describe below)

🔁 Reproduction Steps

  1. Log in to the Admin UI as a user with team management permissions.
  2. Navigate to the Teams tab.
  3. Click "Edit" on an existing team.
  4. Modify the team name or description and click "Update".
  5. Observe: The modal closes, but the list behind it does not refresh to show the new values until a manual page reload.

🐞 Root Cause

The Python backend admin_update_team was sending an HTMX trigger header named refreshTeamsList, but the frontend (HTMX/Alpine.js) is listening for refreshUnifiedTeamsList. This mismatch caused the refresh event to be ignored.

💡 Fix Description

Updated admin.py to send the correct event name:

# Before
"adminTeamAction": {"closeTeamEditModal": True, "refreshTeamsList": True, ...}

# After
"adminTeamAction": {"closeTeamEditModal": True, "refreshUnifiedTeamsList": True, ...}

This aligns the backend trigger with the frontend event listener.

🧪 Verification

Check Command Status
Lint suite make lint
Unit tests make test
Coverage ≥ 80% make coverage
Manual regression no longer fails steps / screenshots

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • No secrets or credentials committed

@gcgoncalves gcgoncalves self-requested a review February 5, 2026 17:02
@@ -4597,7 +4597,7 @@ async def admin_update_team(
</div>
"""
response = HTMLResponse(content=success_html)
response.headers["HX-Trigger"] = orjson.dumps({"adminTeamAction": {"closeTeamEditModal": True, "refreshTeamsList": True, "delayMs": 1500}}).decode()
response.headers["HX-Trigger"] = orjson.dumps({"adminTeamAction": {"closeTeamEditModal": True, "refreshUnifiedTeamsList": True, "delayMs": 1500}}).decode()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this event name is used on this chunk of the admin.js file:

https://github.com/IBM/mcp-context-forge/blob/4bbb15e91bee5415edb8582382e0155ea1e6f66a/mcpgateway/static/admin.js#L21585-L21590

        if (detail.refreshTeamsList) {
            const teamsList = safeGetElement("teams-list");
            if (teamsList && window.htmx) {
                window.htmx.trigger(teamsList, "load");
            }
        }

refreshUnifiedTeamsList is used on the segment below:

https://github.com/IBM/mcp-context-forge/blob/4bbb15e91bee5415edb8582382e0155ea1e6f66a/mcpgateway/static/admin.js#L21591-L21619

        if (detail.refreshUnifiedTeamsList && window.htmx) {
            const unifiedList = document.getElementById("unified-teams-list");
            if (unifiedList) {
                // Preserve current pagination/filter state on refresh
                const params = new URLSearchParams();
                params.set("page", "1"); // Reset to first page on action
                if (typeof getTeamsPerPage === "function") {
                    params.set("per_page", getTeamsPerPage().toString());
                }
                // Preserve search query from input field
                const searchInput = document.getElementById("team-search");
                if (searchInput && searchInput.value.trim()) {
                    params.set("q", searchInput.value.trim());
                }
                // Preserve relationship filter
                if (
                    typeof currentTeamRelationshipFilter !== "undefined" &&
                    currentTeamRelationshipFilter &&
                    currentTeamRelationshipFilter !== "all"
                ) {
                    params.set("relationship", currentTeamRelationshipFilter);
                }
                const url = `${window.ROOT_PATH || ""}/admin/teams/partial?${params.toString()}`;
                window.htmx.ajax("GET", url, {
                    target: "#unified-teams-list",
                    swap: "innerHTML",
                });
            }
        }

If the refreshTeamsList event won't be needed, we can remove it from the admin.js file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gcgoncalves, let me check the dependency and I will make the change.

@crivetimihai crivetimihai force-pushed the bug/2691-team-visibility-update branch from 7eba08a to e7bc224 Compare February 6, 2026 21:08
@crivetimihai crivetimihai self-assigned this Feb 6, 2026
Updates the HX-Trigger in admin_update_team to use 'refreshUnifiedTeamsList'
instead of 'refreshTeamsList', ensuring the UI updates correctly after
editing a team.

Signed-off-by: Adnan Vahora <adnan.vahora1@motorolasolutions.com>
@crivetimihai crivetimihai force-pushed the bug/2691-team-visibility-update branch from e7bc224 to 71bcfca Compare February 6, 2026 21:13
@crivetimihai
Copy link
Copy Markdown
Member

Thanks @settler-av for the fix and @gcgoncalves for the review!

I've rebased the branch onto main and addressed the review feedback by also removing the now-unused refreshTeamsList handler from admin.js (lines 21590-21595). Since no backend code sends that event anymore and there's no #teams-list element in the codebase, it was dead code.

Changes in this PR:

  1. mcpgateway/admin.py: Changed refreshTeamsListrefreshUnifiedTeamsList in admin_update_team
  2. mcpgateway/static/admin.js: Removed the unused refreshTeamsList handler (6 lines)

All tests pass (7171 passed).

@crivetimihai crivetimihai merged commit 0d7732a into IBM:main Feb 6, 2026
51 checks passed
kcostell06 pushed a commit to kcostell06/mcp-context-forge that referenced this pull request Feb 24, 2026
Updates the HX-Trigger in admin_update_team to use 'refreshUnifiedTeamsList'
instead of 'refreshTeamsList', ensuring the UI updates correctly after
editing a team.

Signed-off-by: Adnan Vahora <adnan.vahora1@motorolasolutions.com>
Co-authored-by: Adnan Vahora <adnan.vahora1@motorolasolutions.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Teams - Team visibility updates are not reflected until the page is refreshed

3 participants