Skip to content

[BUG][UI]: Teams list resets to page 1 after any team CRUD actionΒ #2799

@crivetimihai

Description

@crivetimihai

🐞 Bug Summary

After creating, updating, or deleting a team in the Admin UI, the teams list always resets to page 1. If a user is browsing page 5 of teams and creates a new team, they are silently jumped back to page 1, losing their pagination context.


🧩 Affected Component

  • mcpgateway - API
  • mcpgateway - UI (admin panel)
  • mcpgateway.wrapper - stdio wrapper
  • Federation or Transports
  • CLI, Makefiles, or shell scripts
  • Container setup (Docker/Podman/Compose)
  • Other (explain below)

πŸ” Steps to Reproduce

  1. Navigate to Admin β†’ Teams (/admin/#teams)
  2. Ensure there are enough teams to span multiple pages (>10)
  3. Navigate to page 3 or deeper
  4. Click Create New Team, fill in details, submit
  5. Observe: the teams list reloads showing page 1

πŸ€” Expected Behavior

After creating a team, the list should either:

  • Stay on the current page (preserving pagination context), or
  • Navigate to the page containing the newly created team

πŸ““ Logs / Error Output

No errors β€” this is a UX behavior issue, not a crash.


Root Cause

Both refresh code paths hardcode page=1:

  1. initializeTeamManagement() in mcpgateway/templates/admin.html:14721:

    let url = window.ROOT_PATH + '/admin/teams/partial?page=1&per_page=10';

    This is called after team creation via the htmx:afterRequest handler at line 14756.

  2. handleAdminTeamAction() in mcpgateway/static/admin.js:21876:

    params.set("page", "1"); // Reset to first page on action

    This is called after team update/delete via the HX-Trigger: adminTeamAction mechanism.

Both paths preserve search query and relationship filter state, but neither preserves the current page number.


Proposed Solution

Track the current page in a variable or read it from the DOM/URL, and pass it through on refresh:

// In initializeTeamManagement():
const currentPage = getCurrentTeamsPage() || 1; // Read from active pagination state
let url = window.ROOT_PATH + '/admin/teams/partial?page=' + currentPage + '&per_page=10';

For team creation specifically, resetting to page 1 may actually be desirable (so the user can see the new team sorted at the top), but for update/delete operations, preserving the current page is more intuitive.


🧩 Additional Context

Discovered during review of PR #2780. This is pre-existing behavior, not introduced by that PR. The same pattern likely affects other admin sections β€” worth auditing Servers, Tools, Gateways, and A2A Agents for the same issue.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfrontendFrontend development (HTML, CSS, JavaScript)uiUser Interface

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions