This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch sql-query-tui
in repository https://gitbox.apache.org/repos/asf/camel.git

commit a3246b1284443389a2f6360c488d96f11c323c8b
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Jun 28 11:59:51 2026 +0200

    chore: camel-jbang - Enrich SQL query tab MCP response with input state
    
    Include current SQL text, datasource name, selected row index, primary
    keys, and executing flag in the tui_get_table JSON response for the
    SQL Query tab, so AI agents have full context about the query state.
    
    Co-Authored-By: Claude <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../dsl/jbang/core/commands/tui/SqlQueryTab.java   | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SqlQueryTab.java
 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SqlQueryTab.java
index 7a9faa2e5ef1..8ea690948765 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SqlQueryTab.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SqlQueryTab.java
@@ -856,6 +856,16 @@ class SqlQueryTab implements MonitorTab {
     @Override
     public JsonObject getTableDataAsJson() {
         JsonObject root = new JsonObject();
+
+        // current input state
+        String sql = sqlInput.text().trim();
+        if (!sql.isEmpty()) {
+            root.put("sql", sql);
+        }
+        if (!dsNames.isEmpty()) {
+            root.put("datasource", dsNames.get(selectedDs));
+        }
+
         if (columnNames != null && resultRows != null) {
             JsonArray cols = new JsonArray();
             for (String col : columnNames) {
@@ -866,9 +876,20 @@ class SqlQueryTab implements MonitorTab {
             root.put("rowCount", rowCount);
             root.put("truncated", truncated);
             root.put("elapsed", elapsed);
+            Integer sel = tableState.selected();
+            if (sel != null && sel >= 0 && sel < resultRows.size()) {
+                root.put("selectedIndex", sel);
+            }
             if (tableName != null) {
                 root.put("tableName", tableName);
                 root.put("editable", true);
+                if (primaryKeys != null) {
+                    JsonArray pkArr = new JsonArray();
+                    for (String pk : primaryKeys) {
+                        pkArr.add(pk);
+                    }
+                    root.put("primaryKeys", pkArr);
+                }
             }
         }
         if (errorMessage != null) {
@@ -877,6 +898,9 @@ class SqlQueryTab implements MonitorTab {
         if (updateCount != null) {
             root.put("updateCount", updateCount);
         }
+        if (executing.get()) {
+            root.put("executing", true);
+        }
         return root;
     }
 

Reply via email to