Skip to content

fix(ui): preserve visibility selection when editing entities#3402

Merged
crivetimihai merged 5 commits intoIBM:mainfrom
omorros:fix/edit-visibility-retention
Mar 8, 2026
Merged

fix(ui): preserve visibility selection when editing entities#3402
crivetimihai merged 5 commits intoIBM:mainfrom
omorros:fix/edit-visibility-retention

Conversation

@omorros
Copy link
Copy Markdown
Contributor

@omorros omorros commented Mar 2, 2026

🔗 Related Issue

Closes #3391


📝 Summary

Edit form submit handlers (handleEditServerFormSubmit, handleEditToolFormSubmit,
handleEditGatewayFormSubmit, handleEditResFormSubmit, handleEditPromptFormSubmit) were not appending
the visibility field to FormData before submission. This caused the backend to default to "private",
silently overwriting the user's original visibility selection on every edit. This PR adds
formData.append("visibility", formData.get("visibility")) to all five edit handlers, matching the pattern
already used in the corresponding create handlers.


🏷️ Type of Change

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

🧪 Verification

Check Command Status
Lint suite make lint
Unit tests make test
Coverage ≥ 80% make coverage

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • Tests added/updated for changes
  • Documentation updated (if applicable)
  • No secrets or credentials committed

📓 Notes (optional)

The change is minimal, one line added to each of the five edit form submit handlers in
mcpgateway/static/admin.js. The create handlers already had this pattern; the edit handlers were simply
missing it. The team_id field is already handled via hidden inputs injected by the respective edit*()
functions, so no changes were needed there (except for handleEditPromptFormSubmit which already appended
team_id).

@omorros omorros requested a review from crivetimihai as a code owner March 2, 2026 16:47
@msureshkumar88 msureshkumar88 self-requested a review March 4, 2026 15:21
@crivetimihai crivetimihai changed the title fix: visibility selection not retained when editing virtual servers, tools, resources, prompts, and gateways fix(ui): preserve visibility selection when editing entities Mar 5, 2026
@crivetimihai crivetimihai added bug Something isn't working ui User Interface MUST P1: Non-negotiable, critical requirements without which the product is non-functional or unsafe labels Mar 5, 2026
@crivetimihai crivetimihai added this to the Release 1.0.0-RC2 milestone Mar 5, 2026
@crivetimihai
Copy link
Copy Markdown
Member

Thanks @omorros — critical fix for #3391. Without this, every edit silently overwrites visibility to 'private'. Minimal and correct change. LGTM.

@crivetimihai crivetimihai added the release-fix Critical bugfix required for the release label Mar 7, 2026
@crivetimihai crivetimihai self-assigned this Mar 7, 2026
omorros and others added 3 commits March 8, 2026 12:53
…ss edits

Signed-off-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>
The handleEditA2AAgentFormSubmit handler was missing the
formData.append("visibility", ...) call that all other edit
and create handlers have. This ensures visibility is preserved
when editing A2A agents, matching the pattern in the other five
edit handlers.

Closes IBM#3391

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Cover all six edit form submit handlers to verify that the
visibility field selected by the user is included in the
submitted FormData: tool, prompt, gateway, server, resource,
and A2A agent.

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

Review & Rebase Summary

Rebased onto main (clean, no conflicts) and reviewed the changes thoroughly.

What's in this PR

The original fix adds formData.append("visibility", formData.get("visibility")) to 5 edit form submit handlers, matching the pattern already used in all 6 create handlers. This prevents the backend from silently defaulting visibility to "private" on every edit.

Changes added during review

  1. Fixed a gap in handleEditA2AAgentFormSubmit — this was the only edit handler missing the visibility append. Added the same one-liner for consistency with all other handlers.

  2. Added tests/js/admin-edit-visibility.test.js — 7 tests covering all 6 edit form submit handlers (tool, prompt, gateway, server, resource, A2A agent), verifying the selected visibility value reaches the submitted FormData.

Verification

  • JS unit tests: 822/822 passing (24 test files)
  • curl backend tests: Verified visibility edit round-trip for tools, servers, and gateways (public → team → private → public)
  • Playwright E2E: Logged into admin UI, edited a tool's visibility from public to team via the edit modal, confirmed the table badge updated, re-opened the edit modal and confirmed the "Team" radio was pre-selected, confirmed via API that visibility=team persisted

No security, performance, or regression issues found.

Copy link
Copy Markdown
Member

@crivetimihai crivetimihai left a comment

Choose a reason for hiding this comment

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

LGTM — verified via unit tests, curl API tests, and Playwright E2E. Added missing A2A handler fix and test coverage for all 6 edit handlers.

crivetimihai
crivetimihai previously approved these changes Mar 8, 2026
Copy link
Copy Markdown
Member

@crivetimihai crivetimihai left a comment

Choose a reason for hiding this comment

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

LGTM — verified via unit tests, curl API tests, and Playwright E2E. Added missing A2A handler fix and test coverage for all 6 edit handlers.

…visibility entries

formData.append() creates a second visibility key in the submitted
FormData. Since Starlette's ImmutableMultiDict resolves duplicate
keys to the last value, this introduces ordering-dependent behavior.

Replace all 12 append("visibility", ...) calls (6 create + 6 edit
handlers) with set(), which replaces the existing entry instead of
duplicating it. Also strengthen tests to assert exactly one
visibility entry (toEqual([value]) instead of toContain(value)),
so they now fail if duplicates are reintroduced.

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
@crivetimihai crivetimihai merged commit 89cc891 into IBM:main Mar 8, 2026
47 checks passed
MohanLaksh pushed a commit that referenced this pull request Mar 12, 2026
* fix: append visibility in edit form handlers to retain selection across edits

Signed-off-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>

* fix(ui): add visibility append to A2A edit handler for consistency

The handleEditA2AAgentFormSubmit handler was missing the
formData.append("visibility", ...) call that all other edit
and create handlers have. This ensures visibility is preserved
when editing A2A agents, matching the pattern in the other five
edit handlers.

Closes #3391

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

* test(ui): add tests for visibility preservation in edit form handlers

Cover all six edit form submit handlers to verify that the
visibility field selected by the user is included in the
submitted FormData: tool, prompt, gateway, server, resource,
and A2A agent.

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

* fix(ui): use formData.set() instead of append() to prevent duplicate visibility entries

formData.append() creates a second visibility key in the submitted
FormData. Since Starlette's ImmutableMultiDict resolves duplicate
keys to the last value, this introduces ordering-dependent behavior.

Replace all 12 append("visibility", ...) calls (6 create + 6 edit
handlers) with set(), which replaces the existing entry instead of
duplicating it. Also strengthen tests to assert exactly one
visibility entry (toEqual([value]) instead of toContain(value)),
so they now fail if duplicates are reintroduced.

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

* chore: fix trailing whitespace in sandbox.rs tests

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

---------

Signed-off-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
Yosiefeyob pushed a commit that referenced this pull request Mar 13, 2026
* fix: append visibility in edit form handlers to retain selection across edits

Signed-off-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>

* fix(ui): add visibility append to A2A edit handler for consistency

The handleEditA2AAgentFormSubmit handler was missing the
formData.append("visibility", ...) call that all other edit
and create handlers have. This ensures visibility is preserved
when editing A2A agents, matching the pattern in the other five
edit handlers.

Closes #3391

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

* test(ui): add tests for visibility preservation in edit form handlers

Cover all six edit form submit handlers to verify that the
visibility field selected by the user is included in the
submitted FormData: tool, prompt, gateway, server, resource,
and A2A agent.

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

* fix(ui): use formData.set() instead of append() to prevent duplicate visibility entries

formData.append() creates a second visibility key in the submitted
FormData. Since Starlette's ImmutableMultiDict resolves duplicate
keys to the last value, this introduces ordering-dependent behavior.

Replace all 12 append("visibility", ...) calls (6 create + 6 edit
handlers) with set(), which replaces the existing entry instead of
duplicating it. Also strengthen tests to assert exactly one
visibility entry (toEqual([value]) instead of toContain(value)),
so they now fail if duplicates are reintroduced.

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

* chore: fix trailing whitespace in sandbox.rs tests

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

---------

Signed-off-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
Signed-off-by: Yosief Eyob <yosiefogbazion@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working MUST P1: Non-negotiable, critical requirements without which the product is non-functional or unsafe release-fix Critical bugfix required for the release ui User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][UI]: Visibility selection not retained when editing virtual server

2 participants