You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AI Assistant 'Insert at Cursor' does not insert the SQL into the query editor #10690
When the AI Assistant returns a SQL block, clicking "Insert at Cursor" switches to the Query tab but does not insert the SQL. "Replace Query" works correctly.
To Reproduce
Open a Query Tool with an AI provider configured.
Ask the AI Assistant for a query.
Click "Insert at Cursor" on the returned SQL block: the Query tab is focused, but the editor content is unchanged.
Expected behavior
The SQL is inserted at the cursor position in the query editor.
Cause
The NLQ_INSERT_SQL listener at web/pgadmin/tools/sqleditor/static/js/components/sections/Query.jsx:237-242 calls editor.current?.replaceRange(sql, cursorPos), which is a CodeMirror 5 API. The editor is now a CustomEditorView (CodeMirror 6, web/pgadmin/static/js/components/ReactCodeMirror/CustomEditorView.js), which has no replaceRange method, so the call throws a TypeError and nothing is inserted. The FOCUS_PANEL event is fired separately by NLQChatPanel.jsx, which is why the tab still switches.
Using the existing editor.current?.replaceSelection(sql) (which inserts at the cursor, or replaces any selected text) should fix it.
Activity
Fix the AI Assistant's "Insert at Cursor" not inserting the generated…
dpage commentedon Nov 5, 2026
Fixed in 5c83983 (#10692).