merlyn/server/endpoints
Marcello Fitton 3dae8db7ae
feat: Add ability to edit existing SQL agent connections (#4848)
* Add the ability to edit existing SQL connections

* Enhance SQL connection management by adding connections prop to DBConnection and SQLConnectionModal components for improved duplicate detection and handling.

* format

* fix: prevent input defocus in SQL connection edit modal

Fixed an issue where typing in input fields would cause the field to lose
focus during editing. The useEffect dependency array was using the entire
existingConnection object, which could change reference on parent re-renders,
triggering unnecessary re-fetches and unmounting form inputs.

Changed the dependency to use the primitive database_id value instead of the
object reference, ensuring the effect only runs when the actual connection
being edited changes.

* fix: prevent duplicate SQL connections from being created

Fixed an issue where saving SQL connections multiple times would create
duplicate entries with auto-generated hash suffixes (e.g., my-db-abc7).
This occurred because the frontend maintained stale action properties on
connections after saves, causing the backend to treat already-saved
connections as new additions.

Backend changes (server/models/systemSettings.js):
- Modified mergeConnections to skip action:add items that already exist
- Reject duplicate updates instead of auto-renaming with UUID suffixes
- Check if original connection exists before applying updates

Frontend changes:
- Added hasChanges prop to SQL connector component
- Automatically refresh connections from backend after successful save
- Ensures local state has clean data without stale action properties

This prevents the creation of confusing duplicate entries and ensures
only the connections the user explicitly created are stored.

* Refactor to use existing system settings endpoint for getting agent SQL connections | Add better documentation

* Simplify handleUpdateConnection handler

* refactor mergeConnections to use map

* remove console log

* fix bug where edit SQL connection modal values werent recomputed after re-opening

* Add loading state for fetching agent SQL connections

* tooltip

* remove unused import

* Put skip conditions in switch statement

* throw error if default switch case is triggered

---------

Co-authored-by: shatfield4 <seanhatfield5@gmail.com>
Co-authored-by: Timothy Carambat <rambat1010@gmail.com>
2026-01-29 16:37:46 -08:00
..
api feat: add base64 document attachment support to API chat endpoints (#4672) 2025-11-24 15:48:44 -08:00
embed Fix prompt, model, and temperature overrides in embed chat widget (#4036) 2025-06-24 14:23:02 -07:00
experimental Remove fine-tuning flow (#2872) 2024-12-18 10:24:02 -08:00
extensions Paperless ngx data connector (#4121) 2025-11-20 11:27:38 -08:00
mobile Mobile sync support (#4173) 2025-07-31 12:28:03 -07:00
utils Docker model runner download from UI (#4884) 2026-01-19 15:08:07 -08:00
admin.js feat: Add ability to edit existing SQL agent connections (#4848) 2026-01-29 16:37:46 -08:00
agentFlows.js Implement importing of agent flows from community hub (#3867) 2025-06-05 15:08:58 -07:00
agentWebsocket.js Add LMStudio agent support (generic) support (#1246) 2024-05-07 16:35:47 -07:00
browserExtension.js AnythingLLM Chrome Extension (#2066) 2024-08-27 14:58:47 -07:00
chat.js fix: validate chat message input (#4811) 2026-01-08 17:00:15 -08:00
communityHub.js Publish system prompts to hub (#3976) 2025-06-16 09:59:38 -07:00
document.js Patch path traversal in move-files that can be used by administrator level attacker only 2024-08-27 16:19:12 -07:00
embedManagement.js Enable the ability to disable the chat history UI (#2501) 2024-10-21 13:19:19 -07:00
invite.js fix: unhelpful error message for invite link user creation (#4621) 2025-11-19 13:37:37 -08:00
mcpServers.js ModelContextProtocol (MCP) Full Compatibility (#3547) 2025-03-31 16:15:19 -05:00
system.js Manage Onboarding decision via DB flag (#4926) 2026-01-28 16:32:26 -08:00
utils.js Support PrivateModeAI Integration (#4937) 2026-01-29 12:01:11 -08:00
workspaces.js Manage Onboarding decision via DB flag (#4926) 2026-01-28 16:32:26 -08:00
workspacesParsedFiles.js Workspace Chat with documents overhaul (#4261) 2025-08-11 09:26:19 -07:00
workspaceThreads.js Prune telemetry events 2025-04-29 13:54:00 -07:00