merlyn/server/models
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
..
apiKeys.js [FEAT] Automated audit logging (#667) 2024-02-06 15:21:40 -08:00
browserExtensionApiKey.js Patch path traversal in move-files that can be used by administrator level attacker only 2024-08-27 16:19:12 -07:00
cacheData.js Infinite prompt input and compression implementation (#332) 2023-11-06 13:13:53 -08:00
communityHub.js Publish slash commands to hub (#4019) 2025-06-24 16:19:50 -07:00
documents.js Prune telemetry events 2025-04-29 13:54:00 -07:00
documentSyncQueue.js fix issue with files loading with watching enabled (#3930) 2025-06-01 14:53:48 -05:00
documentSyncRun.js [BETA] Live document sync (#1719) 2024-06-21 13:38:50 -07:00
embedChats.js Add backfilling on query for chat widget to improve UX (#2482) 2024-10-15 14:37:44 -07:00
embedConfig.js Configurable message limit for embed chat widget (#4114) 2025-07-10 12:45:53 -07:00
eventLogs.js [FEAT] Automated audit logging (#667) 2024-02-06 15:21:40 -08:00
invite.js Add ability to add invitee to workspaces automatically (#975) 2024-03-26 16:38:32 -07:00
mobileDevice.js Mobile sync support (#4173) 2025-07-31 12:28:03 -07:00
passwordRecovery.js Migrate to bcryptjs (#4767) 2025-12-11 15:19:04 -08:00
promptHistory.js fix null entry on new workspace 2025-05-08 08:34:37 -07:00
slashCommandsPresets.js Community hub integration (#2555) 2024-11-26 09:59:43 -08:00
systemPromptVariables.js New Default System Prompt Variables (User ID, Workspace ID, & Workspace Name) (#4414) 2025-09-29 14:32:56 -07:00
systemSettings.js feat: Add ability to edit existing SQL agent connections (#4848) 2026-01-29 16:37:46 -08:00
telemetry.js Workspace Chat with documents overhaul (#4261) 2025-08-11 09:26:19 -07:00
temporaryAuthToken.js Add custom JWT TTL (#4234) 2025-08-01 10:39:38 -07:00
user.js Fix: Clean username already exists error (#4914) 2026-01-29 09:51:03 -08:00
vectors.js Purge cached docs and remove docs from all workspaces on vectorDB/embedder changes (#2819) 2024-12-16 12:16:20 -08:00
welcomeMessages.js [FIX] User messages not saving due to empty message check (#978) 2024-03-27 10:45:20 -07:00
workspace.js Custom Default System Prompt (#4487) 2025-11-24 13:24:10 -08:00
workspaceAgentInvocation.js patch agent invocation regression 2024-04-27 12:39:45 -07:00
workspaceChats.js Handle BigInt in message response (#4110) 2025-07-10 12:33:34 -07:00
workspaceParsedFiles.js patch paths 2025-08-14 13:40:57 -07:00
workspacesSuggestedMessages.js [FEAT] create custom prompt suggestions per workspace (#664) 2024-02-06 11:24:33 -08:00
workspaceThread.js Add ability to search workspace and threads (#4120) 2025-07-10 16:42:10 -07:00
workspaceUsers.js Add new workspace user management endpoint (#2842) 2024-12-16 11:50:34 -08:00