Skip to content

Fix pagination URL parameter mixing across tables#2214

Merged
crivetimihai merged 1 commit intomainfrom
fix-page-url
Jan 21, 2026
Merged

Fix pagination URL parameter mixing across tables#2214
crivetimihai merged 1 commit intomainfrom
fix-page-url

Conversation

@madhav165
Copy link
Copy Markdown
Collaborator

@madhav165 madhav165 commented Jan 20, 2026

🐛 Bug-fix PR

Fixes #2213


Summary

Fixes pagination controls to properly namespace and clean up query parameters when navigating between different tables (tools, prompts, resources) in the admin UI.

Problem

Pagination query parameters were accumulating across different tables, resulting in URLs like:

?tools_page=3&tools_size=10&tools_inactive=false&prompts_page=2&prompts_size=10&prompts_inactive=false&resources_page=2&resources_size=10&resources_inactive=false

Each tab should only have its own table's parameters in the URL.

Changes

1. Fixed updateBrowserUrl() in pagination_controls.html

  • Changed from creating fresh URLSearchParams to preserving existing params
  • Now only updates current table's params (page, size, inactive)
  • Preserves all params from other tables

2. Fixed updateInactiveUrlState() in admin.html

  • Changed from creating fresh URLSearchParams to preserving existing params
  • Now only updates current table's inactive state and resets page to 1
  • Preserves all params from other tables

3. Enhanced showTab() in admin.js

  • Added getTableNamesForTab() function that scans DOM for pagination controls (id="*-pagination-controls")
  • Added cleanUpUrlParamsForTab() function that removes params for tables not in current tab
  • Calls cleanup function when switching tabs to remove stale params
  • Uses convention-based detection instead of hardcoded mapping

Behavior After Fix

Navigation within a table

  • Tools page 1 → Tools page 3: Only updates tools_page
  • Changing page size: Only updates tools_size, resets tools_page to 1
  • Toggling inactive: Only updates tools_inactive, resets tools_page to 1

Switching between tabs

  • On Tools tab: ?tools_page=3&tools_size=10&tools_inactive=false#tools
  • Switch to Prompts: ?prompts_page=1&prompts_size=10&prompts_inactive=false#prompts
  • Switch back to Tools: ?tools_page=3&tools_size=10&tools_inactive=false#tools

Global params preservation

  • team_id parameter is always preserved across all operations

Implementation Details

Dynamic Detection:
The solution uses convention-based DOM scanning to detect pagination tables. When switching tabs, it:

  1. Queries the panel for elements matching [id$="-pagination-controls"]
  2. Extracts table names from the ID pattern (e.g., "tools-pagination-controls""tools")
  3. Keeps only params for detected tables plus global params (team_id)

Example: Switching to Tools tab finds <div id="tools-pagination-controls">, extracts "tools", and keeps only tools_page, tools_size, tools_inactive, and team_id params.

This approach requires zero maintenance when adding new paginated tables - just follow the existing {tableName}-pagination-controls naming convention.

Notes

  • All existing functionality is preserved
  • No breaking changes to API or data handling
  • URLs are now cleaner and more bookmarkable
  • Each tab maintains its own independent pagination state

🧪 Verification

Check Command Status
Lint suite make lint pass
Unit tests make test pass

📐 MCP Compliance (if relevant)

  • Matches current MCP spec
  • No breaking change to MCP clients

✅ Checklist

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

@madhav165 madhav165 marked this pull request as draft January 20, 2026 11:55
@madhav165 madhav165 marked this pull request as ready for review January 20, 2026 12:12
Fixes pagination controls to properly namespace and clean up query
parameters when navigating between different tables (tools, prompts,
resources) in the admin UI.

Problem: Pagination parameters were accumulating across tabs, resulting
in messy URLs like ?tools_page=3&prompts_page=2&resources_page=1

Solution: Each tab now maintains its own clean URL state. When switching
tabs, URL params are cleaned to only include the current tab's params
plus global params (team_id).

Changes:
- Fixed updateBrowserUrl() in pagination_controls.html to preserve
  existing params while updating current table's params
- Fixed updateInactiveUrlState() in admin.html to preserve params
  from other tables when toggling inactive filter
- Added getTableNamesForTab() for dynamic table detection via DOM
- Added cleanUpUrlParamsForTab() to clean stale params on tab switch

Note: Tab pagination state is not preserved across tab switches.
When returning to a tab, pagination starts fresh at page 1.

Closes #2213

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
@crivetimihai
Copy link
Copy Markdown
Member

Maintainer Review & Rebase

Rebased onto main and resolved merge conflict with observability cleanup code.

Changes Made:

  1. Squashed 4 commits into 1 clean conventional commit
  2. Removed unrelated go.mod whitespace change (was only changing spaces to tabs)
  3. Resolved merge conflict in admin.js - kept both observability cleanup and URL param cleanup in showTab()
  4. Updated commit message to accurately describe behavior

Code Review Notes:

✅ Security: No issues - URL params are safely handled via URLSearchParams, DOM queries use trusted IDs

✅ Performance: Efficient - querySelectorAll scoped to panel, O(1) operations in practice

✅ Consistency: Matches existing URL manipulation patterns in codebase

Behavior Clarification:

The original PR description implied pagination state is preserved across tab switches ("Switch back to Tools restores page 3"). However, the implementation cleans URL params on tab switch, so tab state resets to page 1 when returning to a tab.

This is actually cleaner behavior - each tab has its own clean URL without param accumulation. Updated commit message to reflect this accurately.

@crivetimihai crivetimihai merged commit 56de013 into main Jan 21, 2026
51 checks passed
@crivetimihai crivetimihai deleted the fix-page-url branch January 21, 2026 00:21
kcostell06 pushed a commit to kcostell06/mcp-context-forge that referenced this pull request Feb 24, 2026
)

Fixes pagination controls to properly namespace and clean up query
parameters when navigating between different tables (tools, prompts,
resources) in the admin UI.

Problem: Pagination parameters were accumulating across tabs, resulting
in messy URLs like ?tools_page=3&prompts_page=2&resources_page=1

Solution: Each tab now maintains its own clean URL state. When switching
tabs, URL params are cleaned to only include the current tab's params
plus global params (team_id).

Changes:
- Fixed updateBrowserUrl() in pagination_controls.html to preserve
  existing params while updating current table's params
- Fixed updateInactiveUrlState() in admin.html to preserve params
  from other tables when toggling inactive filter
- Added getTableNamesForTab() for dynamic table detection via DOM
- Added cleanUpUrlParamsForTab() to clean stale params on tab switch

Note: Tab pagination state is not preserved across tab switches.
When returning to a tab, pagination starts fresh at page 1.

Closes IBM#2213

Signed-off-by: Mihai Criveti <crivetimihai@gmail.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][UI]: Pagination controls mix up query params across different tables

2 participants