[PR #4848] [MERGED] feat: Add ability to edit existing SQL agent connections #4786

Closed
opened 2026-02-22 18:36:32 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/4848
Author: @angelplusultra
Created: 1/9/2026
Status: Merged
Merged: 1/29/2026
Merged by: @timothycarambat

Base: masterHead: 4843-edit-sql-connections


📝 Commits (10+)

  • 7ab9da2 Add the ability to edit existing SQL connections
  • 7bd1681 Enhance SQL connection management by adding connections prop to DBConnection and SQLConnectionModal components for improved duplicate detection and handling.
  • d746abf format
  • 9c81258 fix: prevent input defocus in SQL connection edit modal
  • afb088f fix: prevent duplicate SQL connections from being created
  • c72ee32 Refactor to use existing system settings endpoint for getting agent SQL connections | Add better documentation
  • 07b736b Simplify handleUpdateConnection handler
  • cfbeab9 refactor mergeConnections to use map
  • 3033b89 remove console log
  • 89f95df fix bug where edit SQL connection modal values werent recomputed after re-opening

📊 Changes

6 files changed (+421 additions, -76 deletions)

View changed files

📝 frontend/src/pages/Admin/Agents/SQLConnectorSelection/DBConnection.jsx (+38 -9)
📝 frontend/src/pages/Admin/Agents/SQLConnectorSelection/SQLConnectionModal.jsx (+166 -9)
📝 frontend/src/pages/Admin/Agents/SQLConnectorSelection/index.jsx (+108 -15)
📝 frontend/src/pages/Admin/Agents/index.jsx (+2 -0)
📝 server/endpoints/admin.js (+1 -1)
📝 server/models/systemSettings.js (+106 -42)

📄 Description

Pull Request Type

  • feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 🔨 chore
  • 📝 docs

Relevant Issues

resolves #4843

What is in this change?

https://github.com/user-attachments/assets/29d876c8-93ec-43eb-8faa-b30fc76eff83

This PR adds the ability to edit existing SQL connections in the agent configuration UI. Previously, users could only add new SQL connections or delete existing ones, but couldn't modify connection details.

Frontend Changes:

  • Renamed and enhanced NewConnectionModal.jsx to SQLConnectionModal.jsx to support both create and edit modes
  • Added edit button (pencil icon) to each SQL connection card in DBConnection.jsx
  • Added new getSQLConnectionDetails() method in the System model to fetch connection details from the backend
  • Implemented duplicate connection name detection on the frontend using slugification that matches backend behavior
  • Added connection state refresh mechanism that reloads data from backend after save completes to ensure clean state
  • Fixed input defocus issue in edit modal by using defaultValue instead of value for form inputs

Backend Changes:

  • Added new GET /system/sql-connection/:database_id endpoint to fetch individual connection details
  • Implemented connection string parsing to extract individual fields (username, password, host, port, database, etc.)
  • Enhanced mergeConnections() function to handle action: "update" operations
  • Improved duplicate connection prevention logic to handle edge cases and concurrent updates
  • Fixed connection validation to skip already-processed updates and prevent auto-renaming conflicts

Key Features:

  • Edit existing SQL connections without recreating them
  • Prevent duplicate connection names with proper slugification
  • Maintain connection details between frontend and backend consistently
  • Proper error handling and user feedback via toast notifications

Additional Information

The implementation uses the existing connection validation flow, so all connections are validated before being saved. The edit functionality reuses most of the existing modal UI components, just switching between "create" and "edit" modes based on whether an existing connection is provided.

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated
  • I have tested my code functionality
  • Docker build succeeds locally

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Mintplex-Labs/anything-llm/pull/4848 **Author:** [@angelplusultra](https://github.com/angelplusultra) **Created:** 1/9/2026 **Status:** ✅ Merged **Merged:** 1/29/2026 **Merged by:** [@timothycarambat](https://github.com/timothycarambat) **Base:** `master` ← **Head:** `4843-edit-sql-connections` --- ### 📝 Commits (10+) - [`7ab9da2`](https://github.com/Mintplex-Labs/anything-llm/commit/7ab9da23dbe28c539fe385cda9bf168cac5aa24a) Add the ability to edit existing SQL connections - [`7bd1681`](https://github.com/Mintplex-Labs/anything-llm/commit/7bd1681ec6baa8e99762675d154d4b31a65fa7ae) Enhance SQL connection management by adding connections prop to DBConnection and SQLConnectionModal components for improved duplicate detection and handling. - [`d746abf`](https://github.com/Mintplex-Labs/anything-llm/commit/d746abf63eef24d3b7aff83a2c20ea0b6cf4caf8) format - [`9c81258`](https://github.com/Mintplex-Labs/anything-llm/commit/9c81258e895c7d4f537b00625813aa85c03f4a48) fix: prevent input defocus in SQL connection edit modal - [`afb088f`](https://github.com/Mintplex-Labs/anything-llm/commit/afb088f535b6e8b244b89896dd9f298f213d9bf0) fix: prevent duplicate SQL connections from being created - [`c72ee32`](https://github.com/Mintplex-Labs/anything-llm/commit/c72ee3288fb32fefa4668da571720e6748b1da3d) Refactor to use existing system settings endpoint for getting agent SQL connections | Add better documentation - [`07b736b`](https://github.com/Mintplex-Labs/anything-llm/commit/07b736b468e0f857571d783791710b90b45f680a) Simplify handleUpdateConnection handler - [`cfbeab9`](https://github.com/Mintplex-Labs/anything-llm/commit/cfbeab9582f36a5725f71006595a899aa65a091e) refactor mergeConnections to use map - [`3033b89`](https://github.com/Mintplex-Labs/anything-llm/commit/3033b894209a8530bc57f37fdfd91bed699a2ed0) remove console log - [`89f95df`](https://github.com/Mintplex-Labs/anything-llm/commit/89f95df011b3f01cda73d3e01a3b03c5161abc0a) fix bug where edit SQL connection modal values werent recomputed after re-opening ### 📊 Changes **6 files changed** (+421 additions, -76 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/pages/Admin/Agents/SQLConnectorSelection/DBConnection.jsx` (+38 -9) 📝 `frontend/src/pages/Admin/Agents/SQLConnectorSelection/SQLConnectionModal.jsx` (+166 -9) 📝 `frontend/src/pages/Admin/Agents/SQLConnectorSelection/index.jsx` (+108 -15) 📝 `frontend/src/pages/Admin/Agents/index.jsx` (+2 -0) 📝 `server/endpoints/admin.js` (+1 -1) 📝 `server/models/systemSettings.js` (+106 -42) </details> ### 📄 Description ### Pull Request Type <!-- For change type, change [ ] to [x]. --> - [x] ✨ feat - [ ] 🐛 fix - [ ] ♻️ refactor - [ ] 💄 style - [ ] 🔨 chore - [ ] 📝 docs ### Relevant Issues <!-- Use "resolves #xxx" to auto resolve on merge. Otherwise, please use "connect #xxx" --> resolves #4843 ### What is in this change? https://github.com/user-attachments/assets/29d876c8-93ec-43eb-8faa-b30fc76eff83 This PR adds the ability to edit existing SQL connections in the agent configuration UI. Previously, users could only add new SQL connections or delete existing ones, but couldn't modify connection details. **Frontend Changes:** - Renamed and enhanced `NewConnectionModal.jsx` to `SQLConnectionModal.jsx` to support both create and edit modes - Added edit button (pencil icon) to each SQL connection card in `DBConnection.jsx` - Added new `getSQLConnectionDetails()` method in the System model to fetch connection details from the backend - Implemented duplicate connection name detection on the frontend using slugification that matches backend behavior - Added connection state refresh mechanism that reloads data from backend after save completes to ensure clean state - Fixed input defocus issue in edit modal by using `defaultValue` instead of `value` for form inputs **Backend Changes:** - Added new `GET /system/sql-connection/:database_id` endpoint to fetch individual connection details - Implemented connection string parsing to extract individual fields (username, password, host, port, database, etc.) - Enhanced `mergeConnections()` function to handle `action: "update"` operations - Improved duplicate connection prevention logic to handle edge cases and concurrent updates - Fixed connection validation to skip already-processed updates and prevent auto-renaming conflicts **Key Features:** - Edit existing SQL connections without recreating them - Prevent duplicate connection names with proper slugification - Maintain connection details between frontend and backend consistently - Proper error handling and user feedback via toast notifications ### Additional Information The implementation uses the existing connection validation flow, so all connections are validated before being saved. The edit functionality reuses most of the existing modal UI components, just switching between "create" and "edit" modes based on whether an existing connection is provided. ### Developer Validations <!-- All of the applicable items should be checked. --> - [x] I ran `yarn lint` from the root of the repo & committed changes - [x] Relevant documentation has been updated - [x] I have tested my code functionality - [x] Docker build succeeds locally --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-22 18:36:32 -05:00
yindo closed this issue 2026-02-22 18:36:32 -05:00
yindo changed title from [PR #4848] feat: Add ability to edit existing SQL agent connections to [PR #4848] [MERGED] feat: Add ability to edit existing SQL agent connections 2026-06-05 15:20:22 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#4786