Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

AI Assistant 'Insert at Cursor' does not insert the SQL into the query editor

未关闭 适合新手
#10,690 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
88/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
javascript, postgresql
领域
database, frontend

调研方向

从 web/pgadmin/tools/sqleditor/static/js/components/sections/Query.jsx 中的 NLQ_INSERT_SQL 监听器开始检查,然后查看 CustomEditorView.js 和现有的 replaceSelection 用法。确认“Insert at Cursor”会在光标位置添加返回的 SQL,并且“Replace Query”仍能正常工作;如果有相关的查询编辑器测试,请运行这些测试。

由索引模型根据 Issue 内容生成。

描述

Bug

Describe the bug

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

  1. Open a Query Tool with an AI provider configured.
  2. Ask the AI Assistant for a query.
  3. 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.

Desktop

  • pgAdmin version: 9.19 (release candidate builds)
主要语言
Python
星标
3.9k
派生
914
平均合并
1 天 11 小时
30 天内合并 PR
37

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pgadmin-org/pgadmin4 的其他 Issue

查看 pgadmin-org/pgadmin4 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。