Skip to content

2111 - Adjust Show inactive toggle#2112

Merged
crivetimihai merged 2 commits intomainfrom
2111-show-inactive-fix
Jan 20, 2026
Merged

2111 - Adjust Show inactive toggle#2112
crivetimihai merged 2 commits intomainfrom
2111-show-inactive-fix

Conversation

@gcgoncalves
Copy link
Copy Markdown
Collaborator

@gcgoncalves gcgoncalves commented Jan 15, 2026

🐛 Bug-fix PR

📌 Summary

Fix the Show inactive toggle behaviour on the Tools, Prompts, Resources and A2A Agents. Also, remove the toggle and deactivate button from the Roots table, as the functionality is not supported by the model.

Closes #2111

🔁 Reproduction Steps

  1. Access the Admin UI
  2. Click the Tools tab (any of: Tools, Prompts, Resources and A2A Agents)
  3. Click the Show Inactive checkbox

🐞 Root Cause

The rows are loaded on the server, so a page refresh was needed to update the table content.

💡 Fix Description

Manage which rows should be displayed from the frontend.

🧪 Verification

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

✅ Checklist

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

@gcgoncalves gcgoncalves force-pushed the 2111-show-inactive-fix branch 2 times, most recently from f44bcb8 to 5eb61f5 Compare January 15, 2026 12:18
@gcgoncalves gcgoncalves marked this pull request as ready for review January 15, 2026 13:10
@gcgoncalves gcgoncalves marked this pull request as draft January 15, 2026 16:16
@gcgoncalves gcgoncalves force-pushed the 2111-show-inactive-fix branch 3 times, most recently from 43e65c4 to 53d9766 Compare January 16, 2026 11:07
@gcgoncalves gcgoncalves marked this pull request as ready for review January 16, 2026 12:11
@crivetimihai crivetimihai self-assigned this Jan 16, 2026
@crivetimihai
Copy link
Copy Markdown
Member

crivetimihai commented Jan 16, 2026

Code Review Feedback

Thanks for working on extending the "Show Inactive" toggle! I've reviewed the changes and found some architectural issues that need to be addressed before merging.

Issues Found

1. HIGH: Pagination Mismatch (Functional Regression)

With include_inactive=true hardcoded in HTMX requests, the backend returns paginated results that include inactive items in the count. When the frontend hides inactive rows via CSS, pagination becomes inconsistent.

Example: If a user has 100 tools (80 active, 20 inactive) with "Show Inactive" unchecked:

  • Expected: Page 1 shows 20 active tools, pagination says "1-20 of 80"
  • Actual: Page 1 shows ~16 active tools (some hidden), pagination says "1-20 of 100"

The backend applies include_inactive filtering BEFORE pagination in all services (server_service.py:767-768, tool_service.py:1709-1711, resource_service.py:968-970, etc.), so when include_inactive=true, inactive items are counted in total_items and distributed across pages.

Recommendation: Restore include_inactive={{ include_inactive|default(false)|string|lower }} and use HTMX to reload when toggling.


2. MEDIUM: Filter Not Re-applied After HTMX Swaps

The inactive filter is only applied once via setTimeout at admin.js:141-149 on initial page load. When users paginate (HTMX swap), the filter is not re-applied, so inactive rows reappear.

Fix: Add htmx:afterSwap event listener to re-apply filters after pagination.


3. MEDIUM: Search and Inactive Filters Don't Compose

The PR removes the inactive check from filterServerTable(), and for tools/resources/prompts/A2A the new inactive toggle runs separately from search, so whichever runs last wins. (Note: filterGatewaysTable already composes both filters correctly.)

User experience: If you search for "api" then toggle "Show Inactive", rows that don't match "api" reappear.

Fix: Each filter function should respect both search AND inactive state.


4. LOW: ToolOps Toggle Is Non-Functional

The Tool Operations panel checkbox calls toggleInactiveItems('tools-toolops'), but:

  1. "tools-toolops" is not mapped in tbodyIdMap at admin.js:10186-10193
  2. ToolOps rows use data-status attribute instead of data-enabled at admin.js:10708

Recommended Fix Approach

Option A (Recommended): Keep server-side filtering for pagination accuracy

  • Restore include_inactive={{ include_inactive|default(false)|string|lower }} in templates
  • Add htmx:afterSwap handler to maintain toggle state
  • Coordinate search + inactive filters in each filter function

@crivetimihai crivetimihai force-pushed the 2111-show-inactive-fix branch from 53d9766 to 04a2320 Compare January 16, 2026 21:59
@gcgoncalves gcgoncalves marked this pull request as draft January 18, 2026 19:57
@gcgoncalves gcgoncalves force-pushed the 2111-show-inactive-fix branch 7 times, most recently from 630bb82 to 3c667d6 Compare January 19, 2026 11:01
@gcgoncalves gcgoncalves marked this pull request as ready for review January 19, 2026 11:17
@gcgoncalves
Copy link
Copy Markdown
Collaborator Author

@crivetimihai The search will be handled on a separate issue (#2159)

gcgoncalves and others added 2 commits January 20, 2026 01:48
Redo the "Show inactive" toggle functionality from PR #2099 to leverage
HTMX and replace the rendered content with the content rendered on the
server.

Changes:
- Implement filtering based on data-enabled attribute
- Sync toggle state with URL query parameter (?include_inactive=true)
- Remove "Show inactive" toggle from Roots table (no enabled/disabled state)
- Remove "Deactivate" button from Roots table actions
- Reorganize Roots table actions to 2x2 grid layout

Signed-off-by: Gabriel Costa <gabrielcg@proton.me>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
@crivetimihai crivetimihai force-pushed the 2111-show-inactive-fix branch from 3c667d6 to 2c0cad5 Compare January 20, 2026 01:49
@crivetimihai
Copy link
Copy Markdown
Member

Review Changes

Rebased onto main and addressed the following issues:

Bugs Fixed

  • Duplicated docstring in admin_search_tools - removed duplicate Args/Returns sections
  • Event delegation lost after HTMX swap - moved listener from #toolBody to #tool-ops-main-content-wrapper which survives swaps
  • Toggle targets incorrect - Resources/Prompts toggles now target #resources-table/#prompts-table instead of non-existent container IDs
  • Race condition - toggles are now disabled until their target element loads, enabled via htmx:afterSettle

Improvements

  • Restored 3-state status in Tool Ops - now shows Online (green), Offline (yellow), Inactive (red) based on enabled and reachable fields
  • URL state persistence - toggle state now syncs with URL via history.replaceState for bookmarkability
  • Consistent pagination - all toggles read current per_page from pagination selector, fallback to 50 (matching settings.pagination_default_page_size)
  • Reduced log noise - changed tool-ops partial logging from INFO to DEBUG, removed PII (user email, referer)

Summary

  • Reset to page 1 on toggle (standard filter UX)
  • Preserve current per_page selection
  • All tests pass (5213 passed)

@crivetimihai crivetimihai merged commit dda230b into main Jan 20, 2026
50 checks passed
@crivetimihai crivetimihai deleted the 2111-show-inactive-fix branch January 20, 2026 02:04
kcostell06 pushed a commit to kcostell06/mcp-context-forge that referenced this pull request Feb 24, 2026
* Extend "Show inactive" toggle to all entity tables

Redo the "Show inactive" toggle functionality from PR IBM#2099 to leverage
HTMX and replace the rendered content with the content rendered on the
server.

Changes:
- Implement filtering based on data-enabled attribute
- Sync toggle state with URL query parameter (?include_inactive=true)
- Remove "Show inactive" toggle from Roots table (no enabled/disabled state)
- Remove "Deactivate" button from Roots table actions
- Reorganize Roots table actions to 2x2 grid layout

Signed-off-by: Gabriel Costa <gabrielcg@proton.me>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

* Lint fixes

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

---------

Signed-off-by: Gabriel Costa <gabrielcg@proton.me>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Co-authored-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]: Show Inactive toggle doesn't update remaining tables

2 participants